Skip to content

Commit

Permalink
allow stand alone cout/cerr
Browse files Browse the repository at this point in the history
  • Loading branch information
VinInn committed Feb 5, 2014
1 parent 9941e28 commit 27bbeb8
Showing 1 changed file with 70 additions and 60 deletions.
130 changes: 70 additions & 60 deletions EventFilter/CSCRawToDigi/src/CSCDCCExaminer.cc
Expand Up @@ -2,9 +2,19 @@
#include <cstring>
#include <iomanip>

#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include <cassert>

#ifdef CSC_DEBUG
#include<iostream>
#define COUT std::cout
#define CERR std::cerr
#else
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#define COUT LogTrace("CSCDCCExaminer")
#define CERR edm::LogWarning("CSCDCCExaminer")
#endif



using namespace std;

Expand Down Expand Up @@ -301,8 +311,8 @@ int32_t CSCDCCExaminer::check(const uint16_t* &buffer, int32_t length){
bERROR|=0x2000000;
fERROR[0]=true;
bERROR|=0x1;
edm::LogWarning("CSCDCCExaminer")<<"\n\nDCC Header Occurrence ";
edm::LogWarning("CSCDCCExaminer")<<" ERROR 25 "<<sERROR[25]<<endl;
CERR<<"\n\nDCC Header Occurrence ";
CERR<<" ERROR 25 "<<sERROR[25]<<endl;
fDDU_Header = false;

// go backward for 3 DDU words ( buf2, buf1, and buf0 )
Expand Down Expand Up @@ -331,8 +341,8 @@ int32_t CSCDCCExaminer::check(const uint16_t* &buffer, int32_t length){
bERROR |= 0x100000;
// fCHAMB_ERR[20].insert(currentChamber);
// bCHAMB_ERR[currentChamber] |= 0x100000;
edm::LogWarning("CSCDCCExaminer")<<"\nDDU Header Occurrence = "<<cntDDU_Headers;
edm::LogWarning("CSCDCCExaminer")<<" ERROR 20 "<<sERROR[20]<<endl;
CERR<<"\nDDU Header Occurrence = "<<cntDDU_Headers;
CERR<<" ERROR 20 "<<sERROR[20]<<endl;
}

// == DDU Header found
Expand All @@ -349,8 +359,8 @@ int32_t CSCDCCExaminer::check(const uint16_t* &buffer, int32_t length){
bERROR|=0x2;
fERROR[0] = true;
bERROR|=0x1;
edm::LogWarning("CSCDCCExaminer")<<"\n\nDDU Header Occurrence = "<<cntDDU_Headers;
edm::LogWarning("CSCDCCExaminer")<<" ERROR 1 "<<sERROR[1]<<endl;
CERR<<"\n\nDDU Header Occurrence = "<<cntDDU_Headers;
CERR<<" ERROR 1 "<<sERROR[1]<<endl;
fDDU_Header = false;

// Part of work for chambers that hasn't been done in absent trailer
Expand All @@ -363,8 +373,8 @@ int32_t CSCDCCExaminer::check(const uint16_t* &buffer, int32_t length){
bCHAMB_ERR[currentChamber] |= 0x20;
fCHAMB_ERR[0].insert(currentChamber);
bCHAMB_ERR[currentChamber] |= 0x1;
edm::LogWarning("CSCDCCExaminer")<<"\n\nDDU Header Occurrence = "<<cntDDU_Headers;
edm::LogWarning("CSCDCCExaminer")<<" ERROR 5 "<<sERROR[5]<<endl;
CERR<<"\n\nDDU Header Occurrence = "<<cntDDU_Headers;
CERR<<" ERROR 5 "<<sERROR[5]<<endl;
} // One of DMB Trailers is missing ( or both )
fDMB_Header = false;
fDMB_Trailer = false;
Expand Down Expand Up @@ -405,8 +415,8 @@ int32_t CSCDCCExaminer::check(const uint16_t* &buffer, int32_t length){
// == Counted extraneous words between last DDU Trailer and this DDU Header
fWARNING[0]=true;
bWARNING|=0x1;
edm::LogWarning("CSCDCCExaminer")<<"\nDDU Header Occurrence = "<<cntDDU_Headers;
edm::LogWarning("CSCDCCExaminer")<<" WARNING 0 "<<sWARNING[0]<<" "<<DDU_WordsSinceLastTrailer<<" extra 64-bit words"<<endl;
CERR<<"\nDDU Header Occurrence = "<<cntDDU_Headers;
CERR<<" WARNING 0 "<<sWARNING[0]<<" "<<DDU_WordsSinceLastTrailer<<" extra 64-bit words"<<endl;
}

sourceID = ((buf_1[1]&0xF)<<8) | ((buf_1[0]&0xFF00)>>8);
Expand Down Expand Up @@ -457,14 +467,14 @@ int32_t CSCDCCExaminer::check(const uint16_t* &buffer, int32_t length){
if( (buf_1[3]&0xF000)!=0x5000 ){
fWARNING[1]=true;
bWARNING|=0x2;
edm::LogWarning("CSCDCCExaminer")<<"\nDDU Header Occurrence = "<<cntDDU_Headers;
edm::LogWarning("CSCDCCExaminer")<<" WARNING 1 "<<sWARNING[1]<<". What must have been Header 1: 0x"<<std::hex<<buf_1[0]<<" 0x"<<buf_1[1]<<" 0x"<<buf_1[2]<<" 0x"<<buf_1[3]<<std::dec<<endl;
CERR<<"\nDDU Header Occurrence = "<<cntDDU_Headers;
CERR<<" WARNING 1 "<<sWARNING[1]<<". What must have been Header 1: 0x"<<std::hex<<buf_1[0]<<" 0x"<<buf_1[1]<<" 0x"<<buf_1[2]<<" 0x"<<buf_1[3]<<std::dec<<endl;
}

++cntDDU_Headers;
DDU_WordsSinceLastHeader=0; // Reset counter of DDU Words since last DDU Header
LogTrace("CSCDCCExaminer")<<"\n----------------------------------------------------------"<<endl;
LogTrace("CSCDCCExaminer")<<"DDU Header Occurrence "<<cntDDU_Headers<< " L1A = " << ( ((buf_1[2]&0xFFFF) + ((buf_1[3]&0x00FF) << 16)) ) <<endl;
COUT<<"\n----------------------------------------------------------"<<endl;
COUT<<"DDU Header Occurrence "<<cntDDU_Headers<< " L1A = " << ( ((buf_1[2]&0xFFFF) + ((buf_1[3]&0x00FF) << 16)) ) <<endl;
}

// == DMB Header found
Expand Down Expand Up @@ -541,14 +551,14 @@ int32_t CSCDCCExaminer::check(const uint16_t* &buffer, int32_t length){
dmbSize [sourceID][currentChamber] = 4;

// Print DMB_ID from DMB Header
LogTrace("CSCDCCExaminer")<< "Crate=" << setw(3) << setfill('0') << ((buf0[1]>>4)&0x00FF) << " DMB="<<setw(2)<<setfill('0')<<(buf0[1]&0x000F)<<" ";
COUT<< "Crate=" << setw(3) << setfill('0') << ((buf0[1]>>4)&0x00FF) << " DMB="<<setw(2)<<setfill('0')<<(buf0[1]&0x000F)<<" ";
// Print ALCT_DAV and TMB_DAV from DMB Header
//LogTrace("CSCDCCExaminer")<<setw(1)<<((buf0[0]&0x0020)>>5)<<" "<<((buf0[0]&0x0040)>>6)<<" ";
LogTrace("CSCDCCExaminer")<<setw(1)<<((buf0[0]&0x0200)>>9)<<" "<<((buf0[0]&0x0800)>>11)<<" "; //change of format 16.09.05
//COUT<<setw(1)<<((buf0[0]&0x0020)>>5)<<" "<<((buf0[0]&0x0040)>>6)<<" ";
COUT<<setw(1)<<((buf0[0]&0x0200)>>9)<<" "<<((buf0[0]&0x0800)>>11)<<" "; //change of format 16.09.05
// Print CFEB_DAV from DMB Header
LogTrace("CSCDCCExaminer")<<setw(1)<<((buf0[0]&0x0010)>>4)<<((buf0[0]&0x0008)>>3)<<((buf0[0]&0x0004)>>2)<<((buf0[0]&0x0002)>>1)<<(buf0[0]&0x0001);
COUT<<setw(1)<<((buf0[0]&0x0010)>>4)<<((buf0[0]&0x0008)>>3)<<((buf0[0]&0x0004)>>2)<<((buf0[0]&0x0002)>>1)<<(buf0[0]&0x0001);
// Print DMB Header Tag
LogTrace("CSCDCCExaminer") << " {";
COUT << " {";

// Set variables if we are waiting ALCT, TMB and CFEB records to be present in event
DAV_ALCT = (buf0[0]&0x0200)>>9;
Expand Down Expand Up @@ -607,10 +617,10 @@ int32_t CSCDCCExaminer::check(const uint16_t* &buffer, int32_t length){
}
}

// LogTrace("CSCDCCExaminer") << " Number of Wire Groups: " << nWG_round_up << std::endl;
/// LogTrace("CSCDCCExaminer") << " ALCT_ZSE: " << ALCT_ZSE << std::endl;
// LogTrace("CSCDCCExaminer") << " raw_tbins: " << std::dec << raw_tbins << std::endl;
// LogTrace("CSCDCCExaminer") << " LCT Tbins: " << lct_tbins << std::endl;
// COUT << " Number of Wire Groups: " << nWG_round_up << std::endl;
/// COUT << " ALCT_ZSE: " << ALCT_ZSE << std::endl;
// COUT << " raw_tbins: " << std::dec << raw_tbins << std::endl;
// COUT << " LCT Tbins: " << lct_tbins << std::endl;

// Data block sizes:
// 3 words of Vertex ID register + 5 words of config. register bits:
Expand All @@ -624,11 +634,11 @@ int32_t CSCDCCExaminer::check(const uint16_t* &buffer, int32_t length){
// raw hit dump size:
int raw_hit_dump_size=(!raw_overflow ? nWG_round_up*6*raw_tbins : 0 );

//LogTrace("CSCDCCExaminer") << " Raw Hit Dump: " << std::dec << raw_hit_dump_size << std::endl;
//COUT << " Raw Hit Dump: " << std::dec << raw_hit_dump_size << std::endl;

ALCT_WordsExpected += config_size + colreg_size + hot_ch_size + alct_0_1_size + raw_hit_dump_size;

LogTrace("CSCDCCExaminer")<<" <A";
COUT<<" <A";
} else {
// Old ALCT data format

Expand All @@ -653,10 +663,10 @@ int32_t CSCDCCExaminer::check(const uint16_t* &buffer, int32_t length){
((buf0[3]&0x0010)>>4)+((buf0[3]&0x0020)>>5)+
((buf0[3]&0x0040)>>6) ) * 12 + 12;
}
LogTrace("CSCDCCExaminer")<<" <A";
COUT<<" <A";
}
}
//LogTrace("CSCDCCExaminer") << " ALCT Word Expected: " << ALCT_WordsExpected << std::endl;
//COUT << " ALCT Word Expected: " << ALCT_WordsExpected << std::endl;

if( (buf0[0]&0xFFFF)==0xDB0C ){
fTMB_Header = true;
Expand All @@ -669,7 +679,7 @@ int32_t CSCDCCExaminer::check(const uint16_t* &buffer, int32_t length){
if ( (buf1[1]&0x3000) == 0x3000) { TMB_WordsExpected = 12; } // Short Header Only
if ( (buf1[1]&0x3000) == 0x0000) { TMB_WordsExpected = 48; } // Long Header Only

LogTrace("CSCDCCExaminer") << " <T";
COUT << " <T";
} else {
// == TMB Header found right after DMB Header or right after ALCT Trailer
if( (buf0 [0]&0xFFFF)==0x6B0C && (
Expand All @@ -696,7 +706,7 @@ int32_t CSCDCCExaminer::check(const uint16_t* &buffer, int32_t length){
TMB_WordsExpected = 28 + TMB_Tbins * ((buf1[0]&0x00E0)>>5) * 6;
}

LogTrace("CSCDCCExaminer") << " <T";
COUT << " <T";
}
}
// New TMB format => very long header Find Firmware revision
Expand Down Expand Up @@ -745,9 +755,9 @@ int32_t CSCDCCExaminer::check(const uint16_t* &buffer, int32_t length){

/// Print Out ALCT word counting
/*
LogTrace("CSCDCCExaminer") << " ALCT Word Since Last Header: " << ALCT_WordsSinceLastHeader << std::endl;
LogTrace("CSCDCCExaminer") << " ALCT Word Expected: " << ALCT_WordsExpected << std::endl;
LogTrace("CSCDCCExaminer") << " ALCT Word Since Last Header Zero Supressed: " << ALCT_WordsSinceLastHeaderZeroSuppressed <<
COUT << " ALCT Word Since Last Header: " << ALCT_WordsSinceLastHeader << std::endl;
COUT << " ALCT Word Expected: " << ALCT_WordsExpected << std::endl;
COUT << " ALCT Word Since Last Header Zero Supressed: " << ALCT_WordsSinceLastHeaderZeroSuppressed <<
std::endl;
*/
/// Check calculated CRC sum against reported
Expand All @@ -771,7 +781,7 @@ int32_t CSCDCCExaminer::check(const uint16_t* &buffer, int32_t length){
ALCT_WordCount = (buf0[3]&0x07FF);
//ALCT_WordCount = (buf0[3]&0x0FFF);
CFEB_SampleWordCount = 0;
LogTrace("CSCDCCExaminer") << "A> ";
COUT << "A> ";
}

// Calculation of CRC sum ( algorithm is written by Madorsky )
Expand Down Expand Up @@ -937,7 +947,7 @@ int32_t CSCDCCExaminer::check(const uint16_t* &buffer, int32_t length){
TMB_WordsExpected += 22;

CFEB_SampleWordCount = 0;
LogTrace("CSCDCCExaminer") << "T> ";
COUT << "T> ";
}

if( fTMB_Header && checkCrcTMB ){
Expand All @@ -964,9 +974,9 @@ int32_t CSCDCCExaminer::check(const uint16_t* &buffer, int32_t length){
( (buf0[3]&buf0[0])==0x0000 && (buf0[3]+buf0[0])==0x7FFF ) // 2007 format
) ){

if((CFEB_SampleCount%8) == 0 ){ LogTrace("CSCDCCExaminer")<<" <"; }
if( CFEB_SampleWordCount == 100 ){ LogTrace("CSCDCCExaminer")<<"+"; }
if( CFEB_SampleWordCount != 100 ){ LogTrace("CSCDCCExaminer")<<"-";
if((CFEB_SampleCount%8) == 0 ){ COUT<<" <"; }
if( CFEB_SampleWordCount == 100 ){ COUT<<"+"; }
if( CFEB_SampleWordCount != 100 ){ COUT<<"-";
fERROR[16] = true;
bERROR |= 0x10000;
fCHAMB_ERR[16].insert(currentChamber);
Expand All @@ -978,7 +988,7 @@ int32_t CSCDCCExaminer::check(const uint16_t* &buffer, int32_t length){
++CFEB_SampleCount;

if( (CFEB_SampleCount%8)==0 ){
LogTrace("CSCDCCExaminer")<<">";
COUT<<">";
CFEB_BSampleCount=0;
// Count CFEBs
DAV_CFEB--;
Expand All @@ -1003,14 +1013,14 @@ int32_t CSCDCCExaminer::check(const uint16_t* &buffer, int32_t length){
if( (buf0[0]&0xF000)==0xB000 && (buf0[1]&0xF000)==0xB000 && (buf0[2]&0xF000)==0xB000 && (buf0[3]&0xF000)==0xB000 ){
bCHAMB_STATUS[currentChamber] |= 0x400000;

if( (CFEB_SampleCount%8)==0 ){ LogTrace("CSCDCCExaminer")<<" <"; }
LogTrace("CSCDCCExaminer")<<"B";
if( (CFEB_SampleCount%8)==0 ){ COUT<<" <"; }
COUT<<"B";

++CFEB_SampleCount;
++CFEB_BSampleCount;

if( (CFEB_SampleCount%8)==0 ){
LogTrace("CSCDCCExaminer") << ">";
COUT << ">";
CFEB_BSampleCount=0;
DAV_CFEB--;
}
Expand Down Expand Up @@ -1071,7 +1081,7 @@ int32_t CSCDCCExaminer::check(const uint16_t* &buffer, int32_t length){
}

// Print DMB F-Trailer marker
LogTrace("CSCDCCExaminer") << " }";
COUT << " }";
}

// == DMB E-Trailer found
Expand Down Expand Up @@ -1124,8 +1134,8 @@ int32_t CSCDCCExaminer::check(const uint16_t* &buffer, int32_t length){
fDMB_Trailer = false;

// Print DMB E-Trailer marker
LogTrace("CSCDCCExaminer")<<" DMB="<<(buf0[1]&0x000F);
LogTrace("CSCDCCExaminer") << "; "
COUT<<" DMB="<<(buf0[1]&0x000F);
COUT << "; "
<< ALCT_WordsSinceLastHeader << "-"
<< ALCT_WordCount << "-"
<< ALCT_WordsExpected
Expand Down Expand Up @@ -1160,8 +1170,8 @@ int32_t CSCDCCExaminer::check(const uint16_t* &buffer, int32_t length){
currentChamber=-1;
/*
// Print DMB E-Trailer marker
LogTrace("CSCDCCExaminer")<<" DMB="<<(buf0[1]&0x000F);
LogTrace("CSCDCCExaminer") << "; "
COUT<<" DMB="<<(buf0[1]&0x000F);
COUT << "; "
<< ALCT_WordsSinceLastHeader << "-"
<< ALCT_WordCount << "-"
<< ALCT_WordsExpected
Expand All @@ -1181,7 +1191,7 @@ int32_t CSCDCCExaminer::check(const uint16_t* &buffer, int32_t length){
// fERROR[0] = true;
// fERROR[21] = true;
// bERROR|=0x200000;
// //edm::LogWarning("CSCDCCExaminer")<<" ERROR 21 "<<sERROR[21]<<endl;
// //CERR<<" ERROR 21 "<<sERROR[21]<<endl;
// }
// headerDAV_Active = -1;
/////////////////////////////////////////////////////////
Expand All @@ -1204,7 +1214,7 @@ int32_t CSCDCCExaminer::check(const uint16_t* &buffer, int32_t length){
fDDU_Header=false;

if( fDMB_Header || fDMB_Trailer ){
// LogTrace("CSCDCCExaminer") << " Ex-Err: DMB (Header, Trailer) " << std::endl;
// COUT << " Ex-Err: DMB (Header, Trailer) " << std::endl;
fERROR[5] = true;
bERROR |= 0x20;
fCHAMB_ERR[5].insert(currentChamber);
Expand Down Expand Up @@ -1252,23 +1262,23 @@ int32_t CSCDCCExaminer::check(const uint16_t* &buffer, int32_t length){
bERROR |= 0x1000000;
}

LogTrace("CSCDCCExaminer")<<"DDU Trailer Occurrence "<<cntDDU_Trailers<<endl;
LogTrace("CSCDCCExaminer")<<"----------------------------------------------------------"<<endl;
LogTrace("CSCDCCExaminer")<<"DDU 64-bit words = Actual - DDUcounted ="<<DDU_WordsSinceLastHeader+4<<"-"<<DDU_WordCount<<endl;
COUT<<"DDU Trailer Occurrence "<<cntDDU_Trailers<<endl;
COUT<<"----------------------------------------------------------"<<endl;
COUT<<"DDU 64-bit words = Actual - DDUcounted ="<<DDU_WordsSinceLastHeader+4<<"-"<<DDU_WordCount<<endl;

// increment statistics Errors and Warnings (i=0 case is handled in DDU Header)
for(int err=1; err<nERRORS; ++err){
if( fERROR[err] ){
fERROR[0] = true;
bERROR |= 0x1;
edm::LogWarning("CSCDCCExaminer")<<"\nDDU Header Occurrence = "<<cntDDU_Headers;
edm::LogWarning("CSCDCCExaminer")<<" ERROR "<<err<<" " <<sERROR[err]<<endl;
CERR<<"\nDDU Header Occurrence = "<<cntDDU_Headers;
CERR<<" ERROR "<<err<<" " <<sERROR[err]<<endl;
}
}
for(int wrn=1; wrn<nWARNINGS; ++wrn){
if( fWARNING[wrn] ){
LogTrace("CSCDCCExaminer")<<"\nDDU Header Occurrence = "<<cntDDU_Headers;
LogTrace("CSCDCCExaminer")<<" WARNING "<<wrn<<" "<<sWARNING[wrn]<<endl;
COUT<<"\nDDU Header Occurrence = "<<cntDDU_Headers;
COUT<<" WARNING "<<wrn<<" "<<sWARNING[wrn]<<endl;
}
}

Expand Down Expand Up @@ -1424,10 +1434,10 @@ void CSCDCCExaminer::checkDAVs()

void CSCDCCExaminer::checkTriggerHeadersAndTrailers()
{ /*
LogTrace("CSCDCCExaminer") << " Ex-ALCT-Word-count " << std::endl;
LogTrace("CSCDCCExaminer") << " ALCT Words Since Last Header: " << ALCT_WordsSinceLastHeader << std::endl;
LogTrace("CSCDCCExaminer") << " ALCT Word Count: " << ALCT_WordCount << std::endl;
LogTrace("CSCDCCExaminer") << " ALCT Words Expected: " << ALCT_WordsExpected << std::endl;
COUT << " Ex-ALCT-Word-count " << std::endl;
COUT << " ALCT Words Since Last Header: " << ALCT_WordsSinceLastHeader << std::endl;
COUT << " ALCT Word Count: " << ALCT_WordCount << std::endl;
COUT << " ALCT Words Expected: " << ALCT_WordsExpected << std::endl;
*/
if( !fALCT_Header && ( ALCT_WordsSinceLastHeader!=ALCT_WordCount || ALCT_WordsSinceLastHeader!=ALCT_WordsExpected )
&& ALCT_ZSE==0 ){
Expand Down

0 comments on commit 27bbeb8

Please sign in to comment.