CMS 3D CMS Logo

L1Comparator Class Reference

#include <L1Trigger/HardwareValidation/interface/L1Comparator.h>

Inheritance diagram for L1Comparator:

edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

 L1Comparator (const edm::ParameterSet &)
 ~L1Comparator ()

Private Member Functions

virtual void beginJob (const edm::EventSetup &)
template<class T>
bool CompareCollections (edm::Handle< T > data, edm::Handle< T > emul)
bool compareCollections (edm::Handle< L1GlobalTriggerObjectMapRecord > data, edm::Handle< L1GlobalTriggerObjectMapRecord > emul)
bool compareCollections (edm::Handle< L1GlobalTriggerEvmReadoutRecord >data, edm::Handle< L1GlobalTriggerEvmReadoutRecord >emul)
bool compareCollections (edm::Handle< L1GlobalTriggerReadoutRecord > data, edm::Handle< L1GlobalTriggerReadoutRecord > emul)
bool compareFedRawCollections (edm::Handle< FEDRawDataCollection > data, edm::Handle< FEDRawDataCollection > emul, int fedid)
template<class T>
bool dumpCandidate (const T &dt, const T &em, std::ostream &s)
virtual void endJob ()
template<class T>
void process (const edm::Handle< T > data, const edm::Handle< T > emul, const int sys, const int cid)
template<class T>
void process (T const *, T const *, const int, const int)
virtual void produce (edm::Event &, const edm::EventSetup &)
int verbose ()

Private Attributes

bool DEmatchEvt [dedefs::DEnsys]
int DEncand [dedefs::DEnsys][2]
bool dumpEvent_
int evtNum_
L1DEDigiCollection m_dedigis
edm::InputTag m_DEsource [dedefs::DEnsys][4]
bool m_doSys [dedefs::DEnsys]
std::ofstream m_dumpFile
std::string m_dumpFileName
int m_dumpMode
int m_fedId
edm::InputTag m_FEDsource [2]
bool m_match
int nevt_
int runNum_
int verbose_


Detailed Description

Definition at line 37 of file L1Comparator.h.


Constructor & Destructor Documentation

L1Comparator::L1Comparator ( const edm::ParameterSet iConfig  )  [explicit]

assertions/temporary

dump level: -1(all),0(none),1(disagree),2(loc.disagree),3(loc.agree)

create d|e record product

Definition at line 5 of file L1Comparator.cc.

References GenMuonPlsPt100GeV_cfg::cout, dedefs::CTF, dedefs::CTP, DEmatchEvt, DEncand, dedefs::DEnsys, dedefs::DTF, dedefs::DTP, dumpEvent_, lat::endl(), dedefs::ETP, Exception, flush(), dedefs::GCT, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), dedefs::GLT, GMT, dedefs::HTP, i, j, dedefs::LTC, m_dedigis, m_DEsource, m_doSys, m_dumpFile, m_dumpFileName, m_dumpMode, m_fedId, m_FEDsource, m_match, nevt_, out, dedefs::RCT, dedefs::RPC, dedefs::SystLabel, verbose(), and verbose_.

00005                                                          {
00006 
00007   verbose_ = iConfig.getUntrackedParameter<int>("VerboseFlag",0);
00008 
00009   if(verbose())
00010     std::cout << "\nL1COMPARATOR constructor...\n" << std::flush;
00011 
00012   std::vector<unsigned int> dosys(0,DEnsys); 
00013   dosys = 
00014     iConfig.getUntrackedParameter<std::vector<unsigned int> >("COMPARE_COLLS", dosys);
00015   
00016   if((int)dosys.size()!=DEnsys)
00017     edm::LogError("L1Comparator") 
00018       << "wrong selection of systems to be compared\n"
00019       << "\t the size of the mask COMPARE_COLLS (" << dosys.size() 
00020       << ") is not " << DEnsys << std::endl;
00021   assert((int)dosys.size()==DEnsys);
00022   
00023   for(int isys=0; isys<DEnsys; isys++)
00024     if( dosys[isys]!=0 && dosys[isys]!=1 ) 
00025       throw cms::Exception("Invalid configuration") 
00026         << "L1Comparator: comparison flag for system " << isys 
00027         << " is non boolean: " << dosys[isys] << ". Exiting.\n";
00028     
00029   for(int i=0; i<DEnsys; i++)
00030     m_doSys[i] = dosys[i];
00031   
00032   if(verbose()) {
00033     std::cout << "[L1Comparator] do sys? ";
00034     for(int i=0; i<DEnsys; i++)
00035       std::cout << m_doSys[i] << " ";
00036     std::cout << std::endl;
00037 
00038     std::cout << "[L1Comparator] list of systems to process: ";
00039     for(int i=0; i<DEnsys; i++) 
00040       if(m_doSys[i]) 
00041         std::cout << SystLabel[i] << " ";
00042     std::cout << std::endl;
00043   }
00044 
00046   assert(ETP==0); assert(HTP==1); assert(RCT== 2); assert(GCT== 3);
00047   assert(DTP==4); assert(DTF==5); assert(CTP== 6); assert(CTF== 7);
00048   assert(RPC==8); assert(LTC==9); assert(GMT==10); assert(GLT==11);
00049 
00050   if(verbose())
00051     std::cout << "[L1Comparator] debug print collection labels\n";
00052 
00053   m_DEsource[ETP][0] = iConfig.getParameter<edm::InputTag>("ETPsourceData");
00054   m_DEsource[ETP][1] = iConfig.getParameter<edm::InputTag>("ETPsourceEmul");
00055   m_DEsource[HTP][0] = iConfig.getParameter<edm::InputTag>("HTPsourceData");
00056   m_DEsource[HTP][1] = iConfig.getParameter<edm::InputTag>("HTPsourceEmul");
00057   m_DEsource[RCT][0] = iConfig.getParameter<edm::InputTag>("RCTsourceData");
00058   m_DEsource[RCT][1] = iConfig.getParameter<edm::InputTag>("RCTsourceEmul");
00059   m_DEsource[GCT][0] = iConfig.getParameter<edm::InputTag>("GCTsourceData");
00060   m_DEsource[GCT][1] = iConfig.getParameter<edm::InputTag>("GCTsourceEmul");
00061   m_DEsource[DTP][0] = iConfig.getParameter<edm::InputTag>("DTPsourceData");
00062   m_DEsource[DTP][1] = iConfig.getParameter<edm::InputTag>("DTPsourceEmul");
00063   m_DEsource[DTF][0] = iConfig.getParameter<edm::InputTag>("DTFsourceData");
00064   m_DEsource[DTF][1] = iConfig.getParameter<edm::InputTag>("DTFsourceEmul");
00065   m_DEsource[CTP][0] = iConfig.getParameter<edm::InputTag>("CTPsourceData");
00066   m_DEsource[CTP][1] = iConfig.getParameter<edm::InputTag>("CTPsourceEmul");
00067   m_DEsource[CTF][0] = iConfig.getParameter<edm::InputTag>("CTFsourceData");
00068   m_DEsource[CTF][1] = iConfig.getParameter<edm::InputTag>("CTFsourceEmul");
00069   m_DEsource[CTF][2] = iConfig.getParameter<edm::InputTag>("CTTsourceData");
00070   m_DEsource[CTF][3] = iConfig.getParameter<edm::InputTag>("CTTsourceEmul");
00071   m_DEsource[RPC][0] = iConfig.getParameter<edm::InputTag>("RPCsourceData");
00072   m_DEsource[RPC][1] = iConfig.getParameter<edm::InputTag>("RPCsourceEmul");
00073   m_DEsource[LTC][0] = iConfig.getParameter<edm::InputTag>("LTCsourceData");
00074   m_DEsource[LTC][1] = iConfig.getParameter<edm::InputTag>("LTCsourceEmul");
00075   m_DEsource[GMT][0] = iConfig.getParameter<edm::InputTag>("GMTsourceData");
00076   m_DEsource[GMT][1] = iConfig.getParameter<edm::InputTag>("GMTsourceEmul");
00077   m_DEsource[GLT][0] = iConfig.getParameter<edm::InputTag>("GLTsourceData");
00078   m_DEsource[GLT][1] = iConfig.getParameter<edm::InputTag>("GLTsourceEmul");
00079 
00080   for(int sys=0; sys<DEnsys; sys++) {
00081     std::string data_label = SystLabel[sys] + "sourceData";
00082     std::string emul_label = SystLabel[sys] + "sourceEmul";
00083     //m_DEsource[sys][0] = iConfig.getParameter<edm::InputTag>(data_label);
00084     //m_DEsource[sys][1] = iConfig.getParameter<edm::InputTag>(emul_label);
00085     //if(sys==CTF) {
00086     //  std::string data_label(""); data_label+="CTTsourceData";
00087     //  std::string emul_label(""); emul_label+="CTTsourceEmul";
00088     //  m_DEsource[sys][2] = iConfig.getParameter<edm::InputTag>(data_label);
00089     //  m_DEsource[sys][3] = iConfig.getParameter<edm::InputTag>(emul_label);
00090     //}
00091     if(m_doSys[sys] && verbose()) {
00092       std::cout << " sys:"   << sys << " label:" << SystLabel[sys]  
00093                 << "\n\tdt:" << data_label << " : " <<m_DEsource[sys][0]
00094                 << "\n\tem:" << emul_label << " : " <<m_DEsource[sys][1]
00095                 << std::endl;
00096       if(sys==CTF) {
00097         std::cout << "\tdt:"     << data_label << " : " <<m_DEsource[sys][2]
00098                   << "\n\tem:" << emul_label << " : " <<m_DEsource[sys][3]
00099                   << std::endl;
00100       }
00101     }
00102   }
00103 
00104   
00105   m_fedId = iConfig.getUntrackedParameter<int>("FEDid", 0);
00106   m_FEDsource[0] = 
00107     iConfig.getUntrackedParameter<edm::InputTag>("FEDsourceData",edm::InputTag());
00108   m_FEDsource[1] = 
00109     iConfig.getUntrackedParameter<edm::InputTag>("FEDsourceEmul",edm::InputTag());
00110 
00111 
00113   m_dumpMode = iConfig.getUntrackedParameter<int>("DumpMode",0);  
00114   m_dumpFileName = iConfig.getUntrackedParameter<std::string>("DumpFile","");
00115   if(m_dumpMode) {
00116     m_dumpFile.open(m_dumpFileName.c_str(), std::ios::out);
00117     if(!m_dumpFile.good())
00118       edm::LogInfo("L1ComparatorDumpFileOpenError")
00119         << " L1Comparator::L1Comparator() : "
00120         << " couldn't open dump file " << m_dumpFileName.c_str() << std::endl;
00121   }
00122 
00123   m_match = true;
00124   dumpEvent_ = true;
00125   nevt_=-1;
00126 
00127   for(int i=0; i<DEnsys; i++) {
00128     for(int j=0; j<2; j++) 
00129       DEncand[i][j] = 0;
00130     DEmatchEvt[i] = true;
00131   }
00132 
00133   m_dedigis.clear();
00135   produces<L1DataEmulRecord>().setBranchAlias("L1DataEmulRecord");  
00136 
00137   if(verbose())
00138     std::cout << "\nL1Comparator constructor...done.\n" << std::flush;
00139 }

L1Comparator::~L1Comparator (  ) 

Definition at line 142 of file L1Comparator.cc.

00142 {}


Member Function Documentation

void L1Comparator::beginJob ( const edm::EventSetup  )  [private, virtual]

Reimplemented from edm::EDProducer.

Definition at line 144 of file L1Comparator.cc.

00144 {}

template<class myCol>
bool L1Comparator::CompareCollections ( edm::Handle< myCol >  data,
edm::Handle< myCol >  emul 
) [inline, private]

Definition at line 1430 of file L1Comparator.cc.

References begin, dumpCandidate(), lat::endl(), i, itd, m_dumpFile, and edm::match().

01430                                                                                    {
01431   bool match = true;
01432   typedef typename myCol::size_type col_sz;
01433   typedef typename myCol::iterator col_it;
01434   col_sz ndata = data->size();
01435   col_sz nemul = emul->size();
01436   if(ndata!=nemul) {
01437     match &= false;
01438     m_dumpFile << " #cand mismatch!"
01439                << "\tdata: " << ndata
01440                << "\temul: " << nemul
01441                << std::endl;
01442   }
01443   col_it itd = data -> begin();
01444   col_it itm = emul -> begin();
01445   for (col_sz i=0; i<ndata; i++) {
01446     match &= dumpCandidate(*itd++,*itm++, m_dumpFile);
01447   }  
01448   return match; 
01449 }

bool L1Comparator::compareCollections ( edm::Handle< L1GlobalTriggerObjectMapRecord data,
edm::Handle< L1GlobalTriggerObjectMapRecord emul 
) [private]

Definition at line 1333 of file L1Comparator.cc.

References lat::endl(), i, m_dumpFile, m_dumpMode, and edm::match().

01334                                                                                  {
01335 
01336   m_dumpFile << "\n  L1GlobalTriggerObjectMapRecord candidates...\n";
01337 
01338   bool match = true;
01339   //match &= (*data==*emul);
01340 
01341   const std::vector<L1GlobalTriggerObjectMap>& data_ovec = data->gtObjectMap();
01342   const std::vector<L1GlobalTriggerObjectMap>& emul_ovec = emul->gtObjectMap();
01343 
01344   for(std::vector<L1GtLogicParser::OperandToken>::size_type idx=0; idx<data_ovec.size(); idx++) {
01345     match &= ( data_ovec.at(idx).algoName()               == emul_ovec.at(idx).algoName()               );
01346     match &= ( data_ovec.at(idx).algoBitNumber()          == emul_ovec.at(idx).algoBitNumber()          );
01347     match &= ( data_ovec.at(idx).algoGtlResult()          == emul_ovec.at(idx).algoGtlResult()          );
01348     match &= ( data_ovec.at(idx).combinationVector()      == emul_ovec.at(idx).combinationVector()      );
01349     match &= ( data_ovec.at(idx).operandTokenVector().size()==emul_ovec.at(idx).operandTokenVector().size());
01350     if(match) {
01351       for(std::vector<L1GtLogicParser::OperandToken>::size_type i=0; i<data_ovec.at(idx).operandTokenVector().size(); i++) {
01352         match &= ( data_ovec.at(idx).operandTokenVector().at(i).tokenName ==
01353                    emul_ovec.at(idx).operandTokenVector().at(i).tokenName );
01354         match &= ( data_ovec.at(idx).operandTokenVector().at(i).tokenNumber ==
01355                    emul_ovec.at(idx).operandTokenVector().at(i).tokenNumber );
01356         match &= ( data_ovec.at(idx).operandTokenVector().at(i).tokenResult ==
01357                    emul_ovec.at(idx).operandTokenVector().at(i).tokenResult );
01358       }
01359     }
01360   }
01361 
01362   if(m_dumpMode==0 && match)
01363     return match;
01364   
01365   // dump
01366   int idx = 0;
01367   m_dumpFile << "\n\tL1GlobalTriggerObjectMap";
01368   m_dumpFile << "\n\tdata: "
01369              << " algorithmName:"         << data_ovec.at(idx).algoName()
01370              << " Bitnumber:"             << data_ovec.at(idx).algoBitNumber()
01371              << " GTLresult:"             << data_ovec.at(idx).algoGtlResult()
01372              << " combinationVectorSize:" << data_ovec.at(idx).combinationVector().size()
01373              << " operandTokenVector:"    << data_ovec.at(idx).operandTokenVector().size(); 
01374   m_dumpFile << "\n\temul: "
01375              << " algorithmName:"         << emul_ovec.at(idx).algoName()
01376              << " Bitnumber:"             << emul_ovec.at(idx).algoBitNumber()
01377              << " GTLresult:"             << emul_ovec.at(idx).algoGtlResult()
01378              << " combinationVectorSize:" << emul_ovec.at(idx).combinationVector().size()
01379              << " operandTokenVector:"    << emul_ovec.at(idx).operandTokenVector().size() 
01380              << "\n" << std::endl;
01381 
01382   char ok[10];
01383   if(match) sprintf(ok,"successful");
01384   else      sprintf(ok,"failed");
01385   m_dumpFile << " ...L1GlobalTriggerObjectMapRecord data and emulator comparison: " 
01386              << ok << std::endl;
01387   
01388   return match;
01389 }

bool L1Comparator::compareCollections ( edm::Handle< L1GlobalTriggerEvmReadoutRecord data,
edm::Handle< L1GlobalTriggerEvmReadoutRecord emul 
) [private]

Definition at line 1187 of file L1Comparator.cc.

References lat::endl(), i, m_dumpFile, m_dumpMode, and edm::match().

01188                                                                                   {
01189 
01190   m_dumpFile << "\n  L1GlobalTriggerEvmReadoutRecord candidates...\n";
01191   
01192   bool match = true;
01193   match &= (*data==*emul);
01194   
01195   if(m_dumpMode==0 && match)
01196     return match;
01197   
01198   // gt decision
01199   m_dumpFile << "\n\tGlobal decision: "
01200              << data->decision() << " (data) "
01201              << emul->decision() << " (emul) "
01202              << std::endl;
01203 
01204   // gt decision word
01205   m_dumpFile << "\n\tDecisionWord  (bits: 0:63, 127:64)";
01206   int nbitword = 64; 
01207   std::vector<bool> data_gtword = data->decisionWord();
01208   std::vector<bool> emul_gtword = emul->decisionWord();
01209   m_dumpFile << "\n\tdata: ";
01210   for(int i=0; i<nbitword; i++) {
01211     if (i%16==0) m_dumpFile << " ";
01212     m_dumpFile << (data_gtword.at(nbitword-1-i)  ? '1' : '0');
01213   }
01214   m_dumpFile << "\n\t      ";
01215   for(int i=0; i<nbitword; i++) {
01216     if (i%16==0) m_dumpFile << " ";
01217     m_dumpFile << (data_gtword.at(nbitword*2-1-i)  ? '1' : '0');
01218   }
01219   m_dumpFile << "\n\temul: ";
01220   for(int i=0; i<nbitword; i++) {
01221     if (i%16==0) m_dumpFile << " ";
01222     m_dumpFile << (emul_gtword.at(nbitword-1-i)  ? '1' : '0');
01223   }
01224   m_dumpFile << "\n\t      ";
01225   for(int i=0; i<nbitword; i++) {
01226     if (i%16==0) m_dumpFile << " ";
01227     m_dumpFile << (emul_gtword.at(nbitword*2-1-i)  ? '1' : '0');
01228   }
01229   m_dumpFile << std::endl;
01230 
01231   m_dumpFile << "\n\tDecisionWordExtended  (bits: 0:63)";
01232   std::vector<bool> data_decwext = data->gtFdlWord().gtDecisionWordExtended();
01233   std::vector<bool> emul_decwext = emul->gtFdlWord().gtDecisionWordExtended();
01234   m_dumpFile << "\n\tdata: ";
01235   for(int i=0; i<nbitword; i++) {
01236     if (i%16==0) m_dumpFile << " ";
01237     m_dumpFile << (data_decwext.at(nbitword-1-i)  ? '1' : '0');
01238   }
01239   m_dumpFile << "\n\temul: ";
01240   for(int i=0; i<nbitword; i++) {
01241     if (i%16==0) m_dumpFile << " ";
01242     m_dumpFile << (emul_decwext.at(nbitword-1-i)  ? '1' : '0');
01243   }
01244   m_dumpFile << std::endl;
01245 
01246   m_dumpFile << "\n\tTechnical triggers (bits: 0:63)";
01247   std::vector<bool> data_fdlttw = data->gtFdlWord().gtTechnicalTriggerWord();
01248   std::vector<bool> emul_fdlttw = emul->gtFdlWord().gtTechnicalTriggerWord();
01249   assert((int)data_fdlttw.size()==nbitword); 
01250   m_dumpFile << "\n\tdata: ";
01251   for(int i=0; i<nbitword; i++) {
01252     if (i%16==0) m_dumpFile << " ";
01253     m_dumpFile << (data_fdlttw.at(nbitword-1-i)  ? '1' : '0');
01254   }
01255   m_dumpFile << "\n\temul: ";
01256   for(int i=0; i<nbitword; i++) {
01257     if (i%16==0) m_dumpFile << " ";
01258     m_dumpFile << (emul_fdlttw.at(nbitword-1-i)  ? '1' : '0');
01259   }
01260   m_dumpFile << std::endl;
01261 
01262   m_dumpFile << "\n\tL1GtFdlWord";
01263   m_dumpFile << "\n\tdata: "
01264              << " BoardId:"   << data->gtFdlWord().boardId()
01265              << " BxInEvent:" << data->gtFdlWord().bxInEvent()
01266              << " BxNr:"      << data->gtFdlWord().bxNr()
01267              << " EventNr:"   << data->gtFdlWord().eventNr()
01268              << " NoAlgo:"    << data->gtFdlWord().noAlgo()
01269              << " FinalOR:"   << data->gtFdlWord().finalOR()
01270              << " LocalBxNr:" << data->gtFdlWord().localBxNr();
01271   m_dumpFile << "\n\temul: "
01272              << " BoardId:"   << emul->gtFdlWord().boardId()
01273              << " BxInEvent:" << emul->gtFdlWord().bxInEvent()
01274              << " BxNr:"      << emul->gtFdlWord().bxNr()
01275              << " EventNr:"   << emul->gtFdlWord().eventNr()
01276              << " NoAlgo:"    << emul->gtFdlWord().noAlgo()
01277              << " FinalOR:"   << emul->gtFdlWord().finalOR()
01278              << " LocalBxNr:" << emul->gtFdlWord().localBxNr()
01279              << std::endl;
01280 
01281   m_dumpFile << "\n\tL1GtfeWord";
01282   m_dumpFile << "\n\tdata: " 
01283              << " BoardId:"        << data->gtfeWord().boardId()
01284              << " RecordLength:"   << data->gtfeWord().recordLength()
01285              << " BxNr:"           << data->gtfeWord().bxNr() 
01286              << " SetupVersion:"   << data->gtfeWord().setupVersion()
01287              << " ActiveBoards:"   << data->gtfeWord().activeBoards()
01288              << " TotalTriggerNr:" << data->gtfeWord().totalTriggerNr();
01289   m_dumpFile << "\n\temul: " 
01290              << " BoardId:"        << emul->gtfeWord().boardId()
01291              << " RecordLength:"   << emul->gtfeWord().recordLength()
01292              << " BxNr:"           << emul->gtfeWord().bxNr() 
01293              << " SetupVersion:"   << emul->gtfeWord().setupVersion()
01294              << " ActiveBoards:"   << emul->gtfeWord().activeBoards()
01295              << " TotalTriggerNr:" << emul->gtfeWord().totalTriggerNr()
01296              << std::endl;
01297 
01298   // -- tcs 
01299   m_dumpFile << "\n\ttcsWord";
01300   m_dumpFile << "\n\tdata:"
01301              << " DaqNr:"              << data->tcsWord().daqNr()
01302              << " TriggerType:"        << data->tcsWord().triggerType()
01303              << " Status:"             << data->tcsWord().status()
01304              << " BxNr:"               << data->tcsWord().bxNr()
01305              << " PartTrigNr:"         << data->tcsWord().partTrigNr()
01306              << " EventNr:"            << data->tcsWord().eventNr() << "\n\t"
01307              << " AssignedPartitions:" << data->tcsWord().assignedPartitions()
01308              << " PartRunNr:"          << data->tcsWord().partTrigNr()
01309              << " OrbitNr:"            << data->tcsWord().orbitNr();
01310   m_dumpFile << "\n\temul:"                                                  
01311              << " DaqNr:"              << emul->tcsWord().daqNr()
01312              << " TriggerType:"        << emul->tcsWord().triggerType()
01313              << " Status:"             << emul->tcsWord().status()
01314              << " BxNr:"               << emul->tcsWord().bxNr()
01315              << " PartTrigNr:"         << emul->tcsWord().partTrigNr()
01316              << " EventNr:"            << emul->tcsWord().eventNr() << "\n\t"       
01317              << " AssignedPartitions:" << emul->tcsWord().assignedPartitions()
01318              << " PartRunNr:"          << emul->tcsWord().partTrigNr()
01319              << " OrbitNr:"            << emul->tcsWord().orbitNr()
01320              << "\n" << std::endl;
01321 
01322   char ok[10];
01323   if(match) sprintf(ok,"successful");
01324   else      sprintf(ok,"failed");
01325   m_dumpFile << " ...L1GlobalTriggerEvmReadoutRecord data and emulator comparison: " 
01326              << ok << std::endl;
01327 
01328   return match;
01329 }

bool L1Comparator::compareCollections ( edm::Handle< L1GlobalTriggerReadoutRecord data,
edm::Handle< L1GlobalTriggerReadoutRecord emul 
) [private]

todo: skip empty events

todo printL1Objects!

debug: print it all ()

Definition at line 970 of file L1Comparator.cc.

References lat::endl(), i, int, m_dumpFile, m_dumpMode, edm::match(), and edm::Handle< T >::product().

Referenced by produce().

00971                                                                                {
00972 
00973   m_dumpFile << "\n L1GlobalTriggerReadoutRecord candidates...\n";
00974 
00975   bool thematch = true;
00976   
00977   thematch &= (*data==*emul);
00978   
00979   bool match = thematch;
00980 
00981   if(m_dumpMode==0 && match)
00982     return match;    
00983   
00984   //expand to check mismatching  stage
00985 
00986   //need to create new objects due to lack of suitable accessors
00987   // needed only for accessing gtPsbVector()
00988   std::auto_ptr<L1GlobalTriggerReadoutRecord> 
00989     data_( new L1GlobalTriggerReadoutRecord(*(data.product())));
00990   std::auto_ptr<L1GlobalTriggerReadoutRecord> 
00991     emul_( new L1GlobalTriggerReadoutRecord(*(emul.product())));
00992 
00993   match = true;
00994   m_dumpFile << "\tmatch stage: ";
00995   match &= (data->gtfeWord()            == emul->gtfeWord()     );
00996   m_dumpFile << " gtfeWord:" << match;          
00997   match &= (data->gtFdlWord()           == emul->gtFdlWord()    );
00998   m_dumpFile << " gtFdlWord:" << match;                 
00999   match &= (data->muCollectionRefProd() == emul->muCollectionRefProd());
01000   m_dumpFile << " muCollectionRefProd:" << match << "\n"; 
01001   boost::uint16_t dt_psb_bid=0, em_psb_bid=0;    
01002   size_t npsbw = (data_->gtPsbVector().size()>emul_->gtPsbVector().size())?
01003     emul_->gtPsbVector().size():data_->gtPsbVector().size();
01004   for(int idx=0; idx<(int)npsbw; idx++) {
01005     if(data_->gtPsbVector().at(idx) != emul_->gtPsbVector().at(idx) ) {
01006       //match &= false;
01007       dt_psb_bid = data_->gtPsbVector().at(idx).boardId();
01008       em_psb_bid = emul_->gtPsbVector().at(idx).boardId();
01009       break;
01010     }
01011   }
01012   match &= (data->gtPsbWord(dt_psb_bid) == emul->gtPsbWord(em_psb_bid) );
01013   //if(!match) {
01014   //  m_dumpFile << "  data"; data_->gtPsbWord(dt_psb_bid).print(m_dumpFile);
01015   //  m_dumpFile << "\nemul"; emul_->gtPsbWord(em_psb_bid).print(m_dumpFile);
01016   //}
01017   //problem: vector not accessible from handle (only reference non-const)
01018   //std::vector<L1GtPsbWord>& data_psbVec = data_->gtPsbVector();
01019   //std::vector<L1GtPsbWord>& emul_psbVec = emul_->gtPsbVector();
01020   m_dumpFile << " gtPsbWord("<<dt_psb_bid<<","<<em_psb_bid<<"):" << match << "\n"; 
01021 
01023 
01024   // gt decision
01025   m_dumpFile << "\n\tGlobal decision: "
01026            << data->decision() << " (data) "
01027            << emul->decision() << " (emul) "
01028            << std::endl;
01029 
01030   // gt decision word
01031   m_dumpFile << "\n\tDecisionWord  (bits: 63:0, 127:64)";
01032   int nbitword = 64; 
01033   std::vector<bool> data_gtword = data->decisionWord();
01034   std::vector<bool> emul_gtword = emul->decisionWord();
01035   m_dumpFile << "\n\tdata: ";
01036   for(int i=0; i<nbitword; i++) {
01037     if (i%16==0) m_dumpFile << " ";
01038     m_dumpFile << (data_gtword.at(nbitword-1-i)  ? '1' : '0');
01039   }
01040   m_dumpFile << "\n\t      ";
01041   for(int i=0; i<nbitword; i++) {
01042     if (i%16==0) m_dumpFile << " ";
01043     m_dumpFile << (data_gtword.at(nbitword*2-1-i)  ? '1' : '0');
01044   }
01045   m_dumpFile << "\n\temul: ";
01046   for(int i=0; i<nbitword; i++) {
01047     if (i%16==0) m_dumpFile << " ";
01048     m_dumpFile << (emul_gtword.at(nbitword-1-i)  ? '1' : '0');
01049   }
01050   m_dumpFile << "\n\t      ";
01051   for(int i=0; i<nbitword; i++) {
01052     if (i%16==0) m_dumpFile << " ";
01053     m_dumpFile << (emul_gtword.at(nbitword*2-1-i)  ? '1' : '0');
01054   }
01055   m_dumpFile << std::endl;
01056  
01057   m_dumpFile << "\n\tDecisionWordExtended  (bits: 0:63)";
01058   std::vector<bool> data_decwext = data->gtFdlWord().gtDecisionWordExtended();
01059   std::vector<bool> emul_decwext = emul->gtFdlWord().gtDecisionWordExtended();
01060   m_dumpFile << "\n\tdata: ";
01061   for(int i=0; i<nbitword; i++) {
01062     if (i%16==0) m_dumpFile << " ";
01063     m_dumpFile << (data_decwext.at(nbitword-1-i)  ? '1' : '0');
01064   }
01065   m_dumpFile << "\n\temul: ";
01066   for(int i=0; i<nbitword; i++) {
01067     if (i%16==0) m_dumpFile << " ";
01068     m_dumpFile << (emul_decwext.at(nbitword-1-i)  ? '1' : '0');
01069   }
01070   m_dumpFile << std::endl;
01071 
01072   m_dumpFile << "\n\tTechnical triggers (bits: 0:63)";
01073   std::vector<bool> data_fdlttw = data->gtFdlWord().gtTechnicalTriggerWord();
01074   std::vector<bool> emul_fdlttw = emul->gtFdlWord().gtTechnicalTriggerWord();
01075   assert((int)data_fdlttw.size()==nbitword); 
01076   m_dumpFile << "\n\tdata: ";
01077   for(int i=0; i<nbitword; i++) {
01078     if (i%16==0) m_dumpFile << " ";
01079     m_dumpFile << (data_fdlttw.at(nbitword-1-i)  ? '1' : '0');
01080   }
01081   m_dumpFile << "\n\temul: ";
01082   for(int i=0; i<nbitword; i++) {
01083     if (i%16==0) m_dumpFile << " ";
01084     m_dumpFile << (emul_fdlttw.at(nbitword-1-i)  ? '1' : '0');
01085   }
01086   m_dumpFile << std::endl;
01087 
01088   m_dumpFile << "\n\tL1GtFdlWord";
01089   m_dumpFile << "\n\tdata: "
01090            << " BoardId:"   << data->gtFdlWord().boardId()
01091            << " BxInEvent:" << data->gtFdlWord().bxInEvent()
01092            << " BxNr:"      << data->gtFdlWord().bxNr()
01093            << " EventNr:"   << data->gtFdlWord().eventNr()
01094            << " NoAlgo:"    << data->gtFdlWord().noAlgo()
01095            << " FinalOR:"   << data->gtFdlWord().finalOR()
01096            << " LocalBxNr:" << data->gtFdlWord().localBxNr();
01097   m_dumpFile << "\n\temul: "
01098            << " BoardId:"   << emul->gtFdlWord().boardId()
01099            << " BxInEvent:" << emul->gtFdlWord().bxInEvent()
01100            << " BxNr:"      << emul->gtFdlWord().bxNr()
01101            << " EventNr:"   << emul->gtFdlWord().eventNr()
01102            << " NoAlgo:"    << emul->gtFdlWord().noAlgo()
01103            << " FinalOR:"   << emul->gtFdlWord().finalOR()
01104            << " LocalBxNr:" << emul->gtFdlWord().localBxNr()
01105            << std::endl;
01106 
01107   m_dumpFile << "\n\tL1GtfeWord";
01108   m_dumpFile << "\n\tdata: " 
01109            << " BoardId:"        << data->gtfeWord().boardId()
01110            << " RecordLength:"   << data->gtfeWord().recordLength()
01111            << " BxNr:"           << data->gtfeWord().bxNr() 
01112            << " SetupVersion:"   << data->gtfeWord().setupVersion()
01113            << " ActiveBoards:"   << data->gtfeWord().activeBoards()
01114            << " TotalTriggerNr:" << data->gtfeWord().totalTriggerNr();
01115   m_dumpFile << "\n\temul: " 
01116            << " BoardId:"        << emul->gtfeWord().boardId()
01117            << " RecordLength:"   << emul->gtfeWord().recordLength()
01118            << " BxNr:"           << emul->gtfeWord().bxNr() 
01119            << " SetupVersion:"   << emul->gtfeWord().setupVersion()
01120            << " ActiveBoards:"   << emul->gtfeWord().activeBoards()
01121            << " TotalTriggerNr:" << emul->gtfeWord().totalTriggerNr()
01122            << std::endl;
01123 
01124   //uint16_t psb_bid = (uint16_t)idx; //need to find relevant board-id to dump
01125   m_dumpFile << "\n\tgtPsbWord";
01126   m_dumpFile << "\n\tdata: "
01127            << " Board Id:"  << data->gtPsbWord(dt_psb_bid).boardId()
01128            << " BxInEvent:" << data->gtPsbWord(dt_psb_bid).bxInEvent()
01129            << " BxNr:"      << data->gtPsbWord(dt_psb_bid).bxNr()
01130            << " LocalBxNr:" << data->gtPsbWord(dt_psb_bid).localBxNr()
01131            << " EventNr:"   << data->gtPsbWord(dt_psb_bid).eventNr();
01132   m_dumpFile << "\n\temul: "
01133            << " Board Id:"  << emul->gtPsbWord(em_psb_bid).boardId()
01134            << " BxInEvent:" << emul->gtPsbWord(em_psb_bid).bxInEvent()
01135            << " BxNr:"      << emul->gtPsbWord(em_psb_bid).bxNr()
01136            << " LocalBxNr:" << emul->gtPsbWord(em_psb_bid).localBxNr()
01137            << " EventNr:"   << emul->gtPsbWord(em_psb_bid).eventNr()
01138            << std::endl;
01139   
01140   // m_dumpFile << "\n\tA,B_Data_CH7:0"
01141   //       << " ...waiting for data accessors in dataformats!\n\n";
01142   //#include "DataFormats/L1GlobalTrigger/src/L1GtPsbWord.cc"
01143   
01144   m_dumpFile << "\n\tA_Data_CH7:0";
01145   m_dumpFile << "\n\tdata: ";
01146   for (int i=0; i<8; ++i)
01147     m_dumpFile << data->gtPsbWord(dt_psb_bid).aData(7-i) << " ";
01148   m_dumpFile << "\n\temul: ";
01149   for (int i=0; i<8; ++i)
01150     m_dumpFile << emul->gtPsbWord(em_psb_bid).aData(7-i) << " ";
01151   m_dumpFile << std::endl;
01152   
01153   m_dumpFile << "\n\tA_Data_CH7:0";
01154   m_dumpFile << "\n\tdata: ";
01155   for (int i=0; i<8; ++i)
01156     m_dumpFile << data->gtPsbWord(dt_psb_bid).bData(7-i) << " ";
01157   m_dumpFile << "\n\temul: ";
01158   for (int i=0; i<8; ++i)
01159     m_dumpFile << emul->gtPsbWord(em_psb_bid).bData(7-i) << " ";
01160   m_dumpFile << "\n" << std::endl;
01161 
01162 
01164 
01166   if(false) {
01167     m_dumpFile << "---debug: print full gt record---";
01168     m_dumpFile << "\n\tdata: ";   
01169     data->print(m_dumpFile);
01170     m_dumpFile << "\n\temul: ";   
01171     emul->print(m_dumpFile);
01172     m_dumpFile << "\n"; 
01173     m_dumpFile << "---debug: print full gt record Done.---\n\n";
01174   }
01175 
01176   char ok[10];
01177   if(match) sprintf(ok,"successful");
01178   else      sprintf(ok,"failed");
01179   m_dumpFile << " ...L1GlobalTriggerReadoutRecord data and emulator comparison: " 
01180            << ok << std::endl;
01181 
01182   return thematch;
01183 }

bool L1Comparator::compareFedRawCollections ( edm::Handle< FEDRawDataCollection data,
edm::Handle< FEDRawDataCollection emul,
int  fedid 
) [private]

Definition at line 1393 of file L1Comparator.cc.

References GenMuonPlsPt100GeV_cfg::cout, FEDRawData::data(), dd, dumpEvent_, lat::endl(), flush(), i, int, j, m_dumpFile, m_dumpMode, nevt_, FEDRawData::size(), and verbose().

Referenced by produce().

01394                                                                                         {
01395   if(verbose())
01396     std::cout << "[L1Comparator]  fedraw start processing :" << std::endl << std::flush;
01397   if(dumpEvent_) {
01398     m_dumpFile << "\nEvent: " << nevt_ << std::endl;
01399     dumpEvent_=false;
01400   }
01401   m_dumpFile << "\n  FEDRawData candidates...\n";
01402   const FEDRawData& raw_fed_data = data->FEDData(fedId);
01403   const FEDRawData& raw_fed_emul = emul->FEDData(fedId);
01404   bool raw_match=true;
01405   for(int i=0; i!=(int)raw_fed_data.size();i++) {
01406     raw_match &= ( raw_fed_data.data()[i] == raw_fed_emul.data()[i] );
01407   }
01408   unsigned long dd = 0, de = 0;
01409   for(int i=0; i<(int)raw_fed_data.size()/4;i++) {
01410     dd=0; de=0;
01411     for(int j=0; j<4; j++)
01412       dd += ((raw_fed_data.data()[i*4+j]&0xff)<<(8*j));
01413     for(int j=0; j<4; j++) 
01414       de += ((raw_fed_emul.data()[i*4+j]&0xff)<<(8*j));
01415     if(m_dumpMode==-1 || (m_dumpMode==1 && dd!=de) ) {
01416       m_dumpFile << "\n\tdata: " << std::setw(8) << std::setfill('0') << std::hex << dd;
01417       m_dumpFile << "\n\temul: " << std::setw(8) << std::setfill('0') << std::hex << de;
01418     }
01419     m_dumpFile << std::endl;
01420   }
01421   char ok[10];
01422   if(raw_match) sprintf(ok,"successful");
01423   else          sprintf(ok,"failed");
01424   m_dumpFile << " ...FEDRawData data and emulator comparison: " 
01425              << ok << std::endl;
01426   return raw_match;
01427 }

template<class T>
bool L1Comparator::dumpCandidate ( const T &  dt,
const T &  em,
std::ostream &  s 
) [inline, private]

Definition at line 1452 of file L1Comparator.cc.

References lat::endl().

Referenced by CompareCollections().

01452                                                                          {
01453   if(dt==em)
01454     return true;
01455   s<<dt<<std::endl; 
01456   s<<em<<std::endl<<std::endl;
01457   return false;
01458 }

void L1Comparator::endJob ( void   )  [private, virtual]

Reimplemented from edm::EDProducer.

Definition at line 146 of file L1Comparator.cc.

References lat::endl(), m_dumpFile, m_dumpMode, and m_match.

00146                           {
00147   if(m_dumpMode)
00148     m_dumpFile << "\n\n-------\n"
00149                << "Global data|emulator agreement: " 
00150                << m_match << std::endl;
00151   m_dumpFile.close();
00152 }

template<class T>
void L1Comparator::process ( const edm::Handle< T >  data,
const edm::Handle< T >  emul,
const int  sys,
const int  cid 
) [inline, private]

Definition at line 53 of file L1Comparator.h.

References edm::Handle< T >::isValid(), process(), and edm::Handle< T >::product().

00054                                                {
00055     if(data.isValid()&&emul.isValid())
00056       process(data.product(),emul.product(),sys, cid);
00057   }

template<class T>
void L1Comparator::process ( T const *  data,
T const *  emul,
const   int,
const   int 
) [inline, private]

tmp: for getting a clean dump (avoid empty entries)

perform comparison

gather results

over-write system-id: needed eg for GMT input, CSC tf reg cand, CTP&CTF

over-write data type: needed eg for GCT jet types, regional muon sources

append d|e digis to the record's collection

Definition at line 858 of file L1Comparator.cc.

References GenMuonPlsPt100GeV_cfg::cout, DEcompare< T >::de_type(), DEmatchEvt, DEncand, DEcompare< T >::do_compare(), dumpEvent_, lat::endl(), evtNum_, flush(), DEcompare< T >::get_ncand(), DEcompare< T >::getDEDigis(), DEcompare< T >::GetName(), i, it, m_dedigis, m_dumpFile, m_dumpMode, nevt_, DEcompare< T >::print(), runNum_, dedefs::SystLabel, tmp, and verbose().

Referenced by process().

00858                                                                                      {
00859 
00860   if(verbose())
00861     std::cout << "L1Comparator::process -ing system:" << sys 
00862               << " (" << SystLabel[sys] << "), data type " << cid 
00863               << "...\n" << std::flush;
00864   if(verbose())
00865   std::cout << "L1Comparator::process debug "
00866             << " (size "  << data->size() << "," <<emul->size() << ")"   
00867             << ".\n" << std::flush;
00868 
00870   bool prt = false; 
00871   if(!m_dumpMode)
00872     prt = false;
00873   else if(m_dumpMode==-1)
00874     prt=true;
00875   else if(m_dumpMode>0) {
00876     DEcompare<T> tmp(data,emul);
00877     if(tmp.get_ncand(0)==0 && tmp.get_ncand(1)==0)
00878       prt=false;
00879     else
00880     prt = !tmp.do_compare(m_dumpFile,0);
00881   }
00882 
00883   //declare de compare object
00884   DEcompare<T> cmp(data,emul);
00885 
00886   int ndata = cmp.get_ncand(0);
00887   int nemul = cmp.get_ncand(1);
00888   
00889   if(verbose())
00890     std::cout << "L1Comparator::process " 
00891               << " system:" << SystLabel[sys] << "(id " << sys << ")" 
00892               << " type:"   << cmp.GetName(0) << "(" << cmp.de_type() << ")"
00893               << " ndata:"  << ndata
00894               << " nemul:"  << nemul
00895               << " (size "  << data->size() << "," <<emul->size() << ")"   
00896               << ".\n" << std::flush;
00897   
00898   if(ndata==0&&nemul==0) {
00899     if(verbose())
00900       std::cout << "L1Comparator::process " 
00901                 << "empty collections -- exiting!\n" << std::flush;
00902     return;
00903   }
00904   
00905   m_dumpFile << std::setiosflags(std::ios::showpoint | std::ios::fixed 
00906                                  | std::ios::right | std::ios::adjustfield);
00907   std::cout  << std::setiosflags(std::ios::showpoint | std::ios::fixed 
00908                                  | std::ios::right | std::ios::adjustfield);
00909   
00910   if(dumpEvent_ &&  prt ) {
00911     m_dumpFile << "\nEntry: " << nevt_ 
00912                << " (event:"  << evtNum_
00913                << " | run:"   << runNum_ 
00914                << ")\n"       << std::flush;
00915     dumpEvent_=false;
00916   }
00917   
00918   if(prt)
00919     m_dumpFile << "\n  sys:" << SystLabel[sys] 
00920                << " (" << sys << "), type:" << cid //cmp.GetName() 
00921                << " ...\n";
00922   
00923   if(verbose())
00924     std::cout << "L1Comparator::process print:\n" << std::flush
00925               << cmp.print()
00926               << std::flush;
00927   
00929   DEmatchEvt[sys] &= cmp.do_compare(m_dumpFile,m_dumpMode);
00930   
00932   L1DEDigiCollection dg = cmp.getDEDigis();
00933 
00934   if(verbose())
00935     for(L1DEDigiCollection::iterator it=dg.begin(); it!=dg.end();it++)
00936       std::cout << *it << "\n";
00937 
00939   for(L1DEDigiCollection::iterator it=dg.begin(); it!=dg.end();it++)
00940     it->setSid(sys);
00942   for(L1DEDigiCollection::iterator it=dg.begin(); it!=dg.end();it++)
00943     it->setCid(cid);
00944 
00946   m_dedigis.insert(m_dedigis.end(), dg.begin(), dg.end()); 
00947   for(int i=0; i<2; i++)
00948     DEncand[sys][i] += cmp.get_ncand(i);
00949 
00950   if(verbose())
00951     std::cout << "L1Comparator::process " 
00952               << " system:" << SystLabel[sys] 
00953               << " type:"   << cmp.GetName(0) 
00954               << " ndata:"  << DEncand[sys][0]
00955               << " nemul:"  << DEncand[sys][1]
00956               << " (size "  << data->size() << "," <<emul->size() << ")"   
00957               << " ndigis:" << dg.size()
00958               << " agree? " << DEmatchEvt[sys]
00959               << std::endl;
00960 
00961   if(verbose())
00962     std::cout << "L1Comparator::process -ing system:" 
00963               << sys << " (" << SystLabel[sys] << ")...done.\n" 
00964               << std::flush;
00965 }

void L1Comparator::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
) [private, virtual]

-- Get the data and emulated collections -----------------------------

place candidates into vectors

--- done getting collections. ---

processing : compare the pairs of collections

tmp: for getting a clean dump (avoid empty entries)

further analysis

Implements edm::EDProducer.

Definition at line 156 of file L1Comparator.cc.

References compareCollections(), compareFedRawCollections(), GenMuonPlsPt100GeV_cfg::cout, dedefs::CSCtf, dedefs::CSCtfsta, dedefs::CSCtftrc, dedefs::CSCtftrk, dedefs::CSCtpa, dedefs::CSCtpc, dedefs::CSCtpl, dedefs::CTF, dedefs::CTP, DEmatchEvt, DEncand, dedefs::DEnsys, dedefs::DTF, dedefs::DTP, dedefs::DTtf, dedefs::DTtftrk, dedefs::DTtpPh, dedefs::DTtpTh, dumpEvent_, dedefs::ECALtp, lat::endl(), dedefs::ETP, evtNum_, find(), flush(), dedefs::GCT, dedefs::GCTcenjets, dedefs::GCTforjets, dedefs::GCTisolaem, dedefs::GCTnoisoem, dedefs::GCTtaujets, edm::Event::getByLabel(), dedefs::GLT, GMT, dedefs::GMTcnd, dedefs::GMTmain, dedefs::GMTrdt, dedefs::HCALtp, dedefs::HTP, i, edm::Event::id(), edm::Handle< T >::isValid(), it, j, label, dedefs::LTC, dedefs::LTCi, m_dedigis, m_DEsource, m_doSys, m_dumpFile, m_dumpMode, m_fedId, m_FEDsource, m_match, nevt_, edm::Event::put(), dedefs::RCT, dedefs::RCTem, dedefs::RCTrgn, ecalRecalibSequence_cff::record, dedefs::RPC, dedefs::RPCcen, dedefs::RPCfor, runNum_, and verbose().

00156                                                                    {
00157  
00158   nevt_++;
00159   evtNum_ = iEvent.id().event();
00160   runNum_ = iEvent.id().run();
00161 
00162   if(verbose())
00163     std::cout << "\nL1COMPARATOR entry:" << nevt_ << " | evt:" << evtNum_ 
00164               << " | run:" << runNum_ << "\n" << std::flush;
00165 
00166   //flag whether event id has already been written to dumpFile
00167   dumpEvent_ = true;
00168 
00169   //reset event holder quantities
00170   for(int i=0; i<DEnsys; i++) {
00171     for(int j=0; j<2; j++) 
00172       DEncand[i][j] = 0;
00173     DEmatchEvt[i] = true;
00174   }
00175   m_dedigis.clear();
00176 
00177 
00179 
00180   // -- ETP [electromagnetic calorimeter trigger primitives]
00181   edm::Handle<EcalTrigPrimDigiCollection> ecal_tp_data;
00182   edm::Handle<EcalTrigPrimDigiCollection> ecal_tp_emul;
00183   if(m_doSys[ETP]) {
00184     iEvent.getByLabel(m_DEsource[ETP][0], ecal_tp_data);
00185     iEvent.getByLabel(m_DEsource[ETP][1], ecal_tp_emul);
00186   }
00187 
00188   // -- HTP [hadronic calorimeter trigger primitives]
00189   edm::Handle<HcalTrigPrimDigiCollection> hcal_tp_data;
00190   edm::Handle<HcalTrigPrimDigiCollection> hcal_tp_emul;
00191   if(m_doSys[HTP]) {
00192     iEvent.getByLabel(m_DEsource[HTP][0], hcal_tp_data);
00193     iEvent.getByLabel(m_DEsource[HTP][1], hcal_tp_emul);
00194   }
00195 
00196   // -- RCT [regional calorimeter trigger]
00197   edm::Handle<L1CaloEmCollection> rct_em_data;
00198   edm::Handle<L1CaloEmCollection> rct_em_emul;
00199   edm::Handle<L1CaloRegionCollection> rct_rgn_data;
00200   edm::Handle<L1CaloRegionCollection> rct_rgn_emul;
00201   if(m_doSys[RCT]) {
00202     iEvent.getByLabel(m_DEsource[RCT][0], rct_em_data);
00203     iEvent.getByLabel(m_DEsource[RCT][1], rct_em_emul);
00204     iEvent.getByLabel(m_DEsource[RCT][0], rct_rgn_data);
00205     iEvent.getByLabel(m_DEsource[RCT][1], rct_rgn_emul);
00206   }
00207 
00208   // -- GCT [global calorimeter trigger]
00209   edm::Handle<L1GctEmCandCollection>  gct_isolaem_data;
00210   edm::Handle<L1GctEmCandCollection>  gct_isolaem_emul;
00211   edm::Handle<L1GctEmCandCollection>  gct_noisoem_data;
00212   edm::Handle<L1GctEmCandCollection>  gct_noisoem_emul;
00213   edm::Handle<L1GctJetCandCollection> gct_cenjets_data;
00214   edm::Handle<L1GctJetCandCollection> gct_cenjets_emul;
00215   edm::Handle<L1GctJetCandCollection> gct_forjets_data;
00216   edm::Handle<L1GctJetCandCollection> gct_forjets_emul;
00217   edm::Handle<L1GctJetCandCollection> gct_taujets_data;
00218   edm::Handle<L1GctJetCandCollection> gct_taujets_emul;
00219   if(m_doSys[GCT]) {
00220    iEvent.getByLabel(m_DEsource[GCT][0].label(),"isoEm",   gct_isolaem_data);
00221    iEvent.getByLabel(m_DEsource[GCT][1].label(),"isoEm",   gct_isolaem_emul);
00222    iEvent.getByLabel(m_DEsource[GCT][0].label(),"nonIsoEm",gct_noisoem_data);
00223    iEvent.getByLabel(m_DEsource[GCT][1].label(),"nonIsoEm",gct_noisoem_emul);
00224    iEvent.getByLabel(m_DEsource[GCT][0].label(),"cenJets", gct_cenjets_data);
00225    iEvent.getByLabel(m_DEsource[GCT][1].label(),"cenJets", gct_cenjets_emul);
00226    iEvent.getByLabel(m_DEsource[GCT][0].label(),"forJets", gct_forjets_data);
00227    iEvent.getByLabel(m_DEsource[GCT][1].label(),"forJets", gct_forjets_emul);
00228    iEvent.getByLabel(m_DEsource[GCT][0].label(),"tauJets", gct_taujets_data);
00229    iEvent.getByLabel(m_DEsource[GCT][1].label(),"tauJets", gct_taujets_emul);
00230   }
00231 
00232   // -- DTP [drift tube trigger primitive]
00233   edm::Handle<L1MuDTChambPhContainer> dtp_ph_data_;
00234   edm::Handle<L1MuDTChambPhContainer> dtp_ph_emul_;
00235   edm::Handle<L1MuDTChambThContainer> dtp_th_data_;
00236   edm::Handle<L1MuDTChambThContainer> dtp_th_emul_;
00237   if(m_doSys[DTP]) {
00238     iEvent.getByLabel(m_DEsource[DTP][0],dtp_ph_data_);
00239     iEvent.getByLabel(m_DEsource[DTP][1],dtp_ph_emul_);
00240     iEvent.getByLabel(m_DEsource[DTP][0],dtp_th_data_);
00241     iEvent.getByLabel(m_DEsource[DTP][1],dtp_th_emul_);
00242   }
00243   L1MuDTChambPhDigiCollection const* dtp_ph_data = 0; 
00244   L1MuDTChambPhDigiCollection const* dtp_ph_emul = 0; 
00245   L1MuDTChambThDigiCollection const* dtp_th_data = 0; 
00246   L1MuDTChambThDigiCollection const* dtp_th_emul = 0; 
00247 
00248   if(dtp_ph_data_.isValid()) dtp_ph_data = dtp_ph_data_->getContainer();
00249   if(dtp_ph_emul_.isValid()) dtp_ph_emul = dtp_ph_emul_->getContainer();
00250   if(dtp_th_data_.isValid()) dtp_th_data = dtp_th_data_->getContainer();
00251   if(dtp_th_emul_.isValid()) dtp_th_emul = dtp_th_emul_->getContainer();
00252 
00253   // -- DTF [drift tube track finder]
00254   edm::Handle<L1MuRegionalCandCollection> dtf_data;
00255   edm::Handle<L1MuRegionalCandCollection> dtf_emul;
00256   edm::Handle<L1MuDTTrackContainer>       dtf_trk_data_;
00257   edm::Handle<L1MuDTTrackContainer>       dtf_trk_emul_;
00258   L1MuRegionalCandCollection const* dtf_trk_data = 0;
00259   L1MuRegionalCandCollection const* dtf_trk_emul = 0;
00260   if(m_doSys[DTF]) {
00261     iEvent.getByLabel(m_DEsource[DTF][0].label(),"DT",dtf_data);
00262     iEvent.getByLabel(m_DEsource[DTF][1].label(),"DT",dtf_emul);
00263     iEvent.getByLabel(m_DEsource[DTF][0].label(),"DTTF",dtf_trk_data_);
00264     iEvent.getByLabel(m_DEsource[DTF][1].label(),"DTTF",dtf_trk_emul_);
00265   } 
00266   //extract the regional cands
00267   typedef std::vector<L1MuDTTrackCand> L1MuDTTrackCandCollection;
00268   L1MuRegionalCandCollection dtf_trk_data_v, dtf_trk_emul_v;
00269   dtf_trk_data_v.clear(); dtf_trk_emul_v.clear();
00270   if(dtf_trk_data_.isValid()) {
00271     L1MuDTTrackCandCollection *dttc = dtf_trk_data_->getContainer();
00272     for(L1MuDTTrackCandCollection::const_iterator  it=dttc->begin(); 
00273         it!=dttc->end(); it++)
00274       dtf_trk_data_v.push_back(L1MuRegionalCand(*it)); 
00275   }
00276   if(dtf_trk_emul_.isValid()) {
00277     L1MuDTTrackCandCollection *dttc = dtf_trk_emul_->getContainer();
00278     for(L1MuDTTrackCandCollection::const_iterator  it=dttc->begin(); 
00279         it!=dttc->end(); it++)
00280       dtf_trk_emul_v.push_back(L1MuRegionalCand(*it)); 
00281   }  
00282   dtf_trk_data =&dtf_trk_data_v;
00283   dtf_trk_emul =&dtf_trk_emul_v;
00284   
00285   // -- CTP [cathode strip chamber trigger primitive]
00286   edm::Handle<CSCALCTDigiCollection>          ctp_ano_data_;
00287   edm::Handle<CSCALCTDigiCollection>          ctp_ano_emul_;
00288   edm::Handle<CSCCLCTDigiCollection>          ctp_cat_data_;
00289   edm::Handle<CSCCLCTDigiCollection>          ctp_cat_emul_;
00290   edm::Handle<CSCCorrelatedLCTDigiCollection> ctp_lct_data_;
00291   edm::Handle<CSCCorrelatedLCTDigiCollection> ctp_lct_emul_;
00292   CSCALCTDigiCollection_          const* ctp_ano_data = 0;
00293   CSCALCTDigiCollection_          const* ctp_ano_emul = 0;
00294   CSCCLCTDigiCollection_          const* ctp_cat_data = 0;
00295   CSCCLCTDigiCollection_          const* ctp_cat_emul = 0;
00296   CSCCorrelatedLCTDigiCollection_ const* ctp_lct_data = 0;
00297   CSCCorrelatedLCTDigiCollection_ const* ctp_lct_emul = 0;
00298   if(m_doSys[CTP]) {
00299     if(m_DEsource[CTP][0].label().find("tf")!=std::string::npos) {
00300       //if correlated LCTs from TF, read needed info from TP data digis
00301       iEvent.getByLabel("muonCSCDigis", "MuonCSCALCTDigi"     ,ctp_ano_data_);
00302       iEvent.getByLabel("muonCSCDigis", "MuonCSCCLCTDigi"     ,ctp_cat_data_);
00303       iEvent.getByLabel(m_DEsource[CTP][0]                    ,ctp_lct_data_);
00304     } else {
00305       iEvent.getByLabel(m_DEsource[CTP][0].label(),"MuonCSCALCTDigi",ctp_ano_data_);
00306       iEvent.getByLabel(m_DEsource[CTP][0].label(),"MuonCSCCLCTDigi",ctp_cat_data_);
00307       iEvent.getByLabel(m_DEsource[CTP][0].label(),"MuonCSCCorrelatedLCTDigi",ctp_lct_data_);
00308     }
00309     iEvent.getByLabel(m_DEsource[CTP][1]                    ,ctp_ano_emul_);
00310     iEvent.getByLabel(m_DEsource[CTP][1]                    ,ctp_cat_emul_);
00311     iEvent.getByLabel(m_DEsource[CTP][1]                    ,ctp_lct_emul_);
00312   }
00313 
00315   //Anode LCT
00316   CSCALCTDigiCollection_ ctp_ano_data_v, ctp_ano_emul_v;
00317   ctp_ano_data_v.clear(); ctp_ano_emul_v.clear();
00318   if(ctp_ano_data_.isValid() && ctp_ano_emul_.isValid()) {
00319     // The following numbers should come from config. database eventually...
00320     int fifo_pretrig     = 10;
00321     int fpga_latency     =  6;
00322     int l1a_window_width =  7;
00323     // Time offset of raw hits w.r.t. the full 12-bit BXN.
00324     int rawhit_tbin_offset =
00325       (fifo_pretrig - fpga_latency) + (l1a_window_width-1)/2;
00326     // Extra difference due to additional register stages; determined
00327     // empirically.
00328     int register_delay =  2;
00329     typedef CSCALCTDigiCollection::DigiRangeIterator mapIt;
00330     typedef CSCALCTDigiCollection::const_iterator    vecIt;
00331     for (mapIt mit = ctp_ano_data_->begin(); mit != ctp_ano_data_->end(); mit++)
00332       for (vecIt vit = ctp_ano_data_->get((*mit).first).first; 
00333            vit != ctp_ano_data_->get((*mit).first).second; vit++) 
00334         ctp_ano_data_v.push_back(*vit);
00335     for (mapIt mit = ctp_ano_emul_->begin(); mit != ctp_ano_emul_->end(); mit++)
00336       for (vecIt vit = ctp_ano_emul_->get((*mit).first).first; 
00337            vit != ctp_ano_emul_->get((*mit).first).second; vit++) {
00338         int emul_bx_corr =
00339           (*vit).getBX() - rawhit_tbin_offset + register_delay;
00340         CSCALCTDigi alct((*vit).isValid(),        (*vit).getQuality(),
00341                          (*vit).getAccelerator(), (*vit).getCollisionB(),
00342                          (*vit).getKeyWG(),       emul_bx_corr,
00343                          (*vit).getTrknmb()); 
00344         ctp_ano_emul_v.push_back(alct);
00345       }
00346   }
00347   ctp_ano_data =&ctp_ano_data_v;
00348   ctp_ano_emul =&ctp_ano_emul_v;
00349   //Cathode LCT
00350   CSCCLCTDigiCollection_ ctp_cat_data_v, ctp_cat_emul_v;
00351   ctp_cat_data_v.clear(); ctp_cat_emul_v.clear();
00352   if(ctp_cat_data_.isValid() && ctp_cat_emul_.isValid()) {
00353     int tbin_cathode_offset = 7, emul_bx_corr;
00354     typedef CSCCLCTDigiCollection::DigiRangeIterator mapIt;
00355     typedef CSCCLCTDigiCollection::const_iterator    vecIt;
00356     for (mapIt mit = ctp_cat_data_->begin(); mit != ctp_cat_data_->end(); mit++)
00357       for (vecIt vit = ctp_cat_data_->get((*mit).first).first; 
00358            vit != ctp_cat_data_->get((*mit).first).second; vit++) 
00359         ctp_cat_data_v.push_back(*vit);
00360     for (mapIt mit = ctp_cat_emul_->begin(); mit != ctp_cat_emul_->end(); mit++) {
00361       const CSCDetId& detid = (*mit).first;
00362 
00363       // Extract full 12-bit BX word from CLCT data collections.
00364       int full_cathode_bx = -999;
00365       const CSCCLCTDigiCollection::Range& crange = ctp_cat_data_->get(detid);
00366       for (vecIt digiIt = crange.first; digiIt != crange.second; digiIt++) {
00367         if ((*digiIt).isValid()) {
00368           full_cathode_bx = (*digiIt).getFullBX();
00369           break;
00370         }
00371       }
00372 
00373       for (vecIt vit = ctp_cat_emul_->get(detid).first; 
00374            vit != ctp_cat_emul_->get(detid).second; vit++) {
00375         int emul_bx = (*vit).getBX();
00376         if (full_cathode_bx != -999)
00377           emul_bx_corr =
00378             (full_cathode_bx + emul_bx - tbin_cathode_offset) & 0x03;
00379         else
00380           emul_bx_corr = emul_bx & 0x03;
00381         CSCCLCTDigi clct((*vit).isValid(),    (*vit).getQuality(),
00382                          (*vit).getPattern(), (*vit).getStripType(),
00383                          (*vit).getBend(),    (*vit).getStrip(),
00384                          (*vit).getCFEB(),    emul_bx_corr,
00385                          (*vit).getTrknmb());
00386         ctp_cat_emul_v.push_back(clct);
00387       }
00388     }
00389   }
00390   ctp_cat_data =&ctp_cat_data_v;
00391   ctp_cat_emul =&ctp_cat_emul_v;
00392   //Correlated (anode+cathode) LCTs
00393   CSCCorrelatedLCTDigiCollection_ ctp_lct_data_v, ctp_lct_emul_v;
00394   ctp_lct_data_v.clear(); ctp_lct_emul_v.clear();
00395   if(ctp_lct_data_.isValid() && ctp_lct_emul_.isValid()) {
00396     int tbin_anode_offset = 5, emul_bx_corr;
00397     typedef CSCCorrelatedLCTDigiCollection::DigiRangeIterator mapIt;//map iterator
00398     typedef CSCCorrelatedLCTDigiCollection::const_iterator    vecIt;//vec iterator
00399     //loop over data (map<idx,vec_digi>)
00400     for (mapIt mit = ctp_lct_data_->begin(); mit != ctp_lct_data_->end(); mit++)
00401       //get vec_digi range(pair)  corresponding to idx of map
00402       //loop over digi vector (ie between begin and end pointers in range)
00403       //CSCCorrelatedLCTDigiCollection::Range ctpRange = ctp_lct_data_->get((*mit).first)
00404       //for (vecIt vit = ctpRange.first; vit != ctpRange.second; vit++) {
00405       for (vecIt vit = ctp_lct_data_->get((*mit).first).first; 
00406            vit != ctp_lct_data_->get((*mit).first).second; vit++) 
00407         ctp_lct_data_v.push_back(*vit);
00408     for (mapIt mit = ctp_lct_emul_->begin(); mit != ctp_lct_emul_->end(); mit++) {
00409       const CSCDetId& detid = (*mit).first;
00410 
00411       // Extract full 12-bit BX word from ALCT data collections.
00412       int full_anode_bx = -999;
00413       if(ctp_ano_data_.isValid()) {
00414         const CSCALCTDigiCollection::Range& arange = ctp_ano_data_->get(detid);
00415         for (CSCALCTDigiCollection::const_iterator digiIt = arange.first;
00416              digiIt != arange.second; digiIt++) {
00417           if ((*digiIt).isValid()) {
00418             full_anode_bx = (*digiIt).getFullBX();
00419             break;
00420           }
00421         }
00422       }
00423 
00424       for (vecIt vit = ctp_lct_emul_->get(detid).first; 
00425            vit != ctp_lct_emul_->get(detid).second; vit++) {
00426         int emul_bx = (*vit).getBX();
00427         if (full_anode_bx != -999) {
00428           emul_bx_corr = (full_anode_bx + emul_bx - tbin_anode_offset) & 0x01;
00429         }
00430         else { // This should never happen for default config. settings.
00431           emul_bx_corr = emul_bx & 0x01;
00432         }
00433 
00434         // If one compares correlated LCTs after the muon port card, an
00435         // additional offset is needed.
00436         if (m_DEsource[CTP][1].instance() == "MPCSORTED") emul_bx_corr += 5;
00437 
00438         CSCCorrelatedLCTDigi lct((*vit).getTrknmb(),  (*vit).isValid(),
00439                                  (*vit).getQuality(), (*vit).getKeyWG(),
00440                                  (*vit).getStrip(),   (*vit).getPattern(),
00441                                  (*vit).getBend(),    emul_bx_corr,
00442                                  (*vit).getMPCLink(), (*vit).getBX0(),
00443                                  (*vit).getSyncErr(), (*vit).getCSCID());
00444         ctp_lct_emul_v.push_back(lct);
00445       }
00446     }
00447   }
00448   ctp_lct_data =&ctp_lct_data_v;
00449   ctp_lct_emul =&ctp_lct_emul_v;
00450 
00451 
00452   // -- CTF [cathode strip chamber track finder]
00453   edm::Handle<L1MuRegionalCandCollection> ctf_data, ctf_emul;
00454   edm::Handle<L1CSCTrackCollection> ctf_trk_data_, ctf_trk_emul_; 
00455   CSCCorrelatedLCTDigiCollection_ const* ctf_trk_data(new CSCCorrelatedLCTDigiCollection_);
00456   CSCCorrelatedLCTDigiCollection_ const* ctf_trk_emul(new CSCCorrelatedLCTDigiCollection_);
00457   L1MuRegionalCandCollection      const* ctf_trc_data(new L1MuRegionalCandCollection);
00458   L1MuRegionalCandCollection      const* ctf_trc_emul(new L1MuRegionalCandCollection);
00459   edm::Handle<L1CSCStatusDigiCollection> ctf_sta_data_;
00460   edm::Handle<L1CSCStatusDigiCollection> ctf_sta_emul_;
00461   L1CSCSPStatusDigiCollection_    const* ctf_sta_data(new L1CSCSPStatusDigiCollection_);
00462   L1CSCSPStatusDigiCollection_    const* ctf_sta_emul(new L1CSCSPStatusDigiCollection_);
00463   if(m_doSys[CTF]) {
00464     iEvent.getByLabel(m_DEsource[CTF][2],ctf_trk_data_);
00465     iEvent.getByLabel(m_DEsource[CTF][3],ctf_trk_emul_);
00466     //note: unpacker different label: MounL1CSCTrackCollection
00467     iEvent.getByLabel(m_DEsource[CTF][0],ctf_data);
00468     iEvent.getByLabel(m_DEsource[CTF][1],ctf_emul);
00469     //note: unpacker only
00470     iEvent.getByLabel(m_DEsource[CTF][0].label(),"MuonL1CSCStatusDigiCollection",ctf_sta_data_);
00471     iEvent.getByLabel(m_DEsource[CTF][1].label(),"MuonL1CSCStatusDigiCollection",ctf_sta_emul_);
00472   }
00473   if(ctf_sta_data_.isValid())
00474     ctf_sta_data = &(ctf_sta_data_->second);
00475   if(ctf_sta_emul_.isValid())
00476     ctf_sta_emul = &(ctf_sta_emul_->second);
00477   if(ctf_trk_data_.isValid() && ctf_trk_emul_.isValid()) {
00478     typedef CSCCorrelatedLCTDigiCollection::DigiRangeIterator mapIt;//map iterator
00479     typedef CSCCorrelatedLCTDigiCollection::const_iterator    vecIt;//vec iterator
00480     CSCCorrelatedLCTDigiCollection_ ctf_trk_data_v, ctf_trk_emul_v; //vector
00481     L1MuRegionalCandCollection      ctf_trc_data_v, ctf_trc_emul_v; //vector
00482     typedef L1CSCTrackCollection::const_iterator ctcIt;
00483     //loop over csc-tracks (ie pairs<l1track,digi_vec>)
00484     for(ctcIt tcit=ctf_trk_data_->begin(); tcit!=ctf_trk_data_->end(); tcit++) {
00485       //store the muon candidate
00486       //csc::L1Track ttr = tcit->first;
00487       //L1MuRegionalCand cand(ttr);    
00488       //ctf_trc_data_v.push_back(tcit->first);
00489       ctf_trc_data_v.push_back(L1MuRegionalCand(tcit->first.getDataWord(), tcit->first.bx()));
00490       CSCCorrelatedLCTDigiCollection ldc = tcit->second; //muondigicollection=map
00491       //get the lct-digi-collection (ie muon-digi-collection)
00492       //loop over data (map<idx,vec_digi>)
00493       for (mapIt mit = ldc.begin(); mit != ldc.end(); mit++)
00494         //get vec_digi range(pair)  corresponding to idx of map
00495         //loop over digi vector (ie between begin and end pointers in range)
00496         //CSCCorrelatedLCTDigiCollection::Range ctpRange = ctp_lct_data_->get((*mit).first)
00497         //for (vecIt vit = ctpRange.first; vit != ctpRange.second; vit++) {
00498         for (vecIt vit = ldc.get((*mit).first).first; 
00499              vit != ldc.get((*mit).first).second; vit++) 
00500           ctf_trk_data_v.push_back(*vit);
00501     }
00502     ctf_trk_data = &ctf_trk_data_v;
00503     ctf_trc_data = &ctf_trc_data_v;
00504     //same for emulator collection
00505     for(ctcIt tcit=ctf_trk_emul_->begin();tcit!=ctf_trk_emul_->end(); tcit++) {
00506       ctf_trc_emul_v.push_back(L1MuRegionalCand(tcit->first.getDataWord(), tcit->first.bx()));
00507       CSCCorrelatedLCTDigiCollection ldc = tcit->second;
00508       for (mapIt mit = ldc.begin(); mit != ldc.end(); mit++)
00509         for (vecIt vit = ldc.get((*mit).first).first; 
00510              vit != ldc.get((*mit).first).second; vit++) 
00511           ctf_trk_emul_v.push_back(*vit);
00512     }
00513     ctf_trk_emul = &ctf_trk_emul_v;
00514     ctf_trc_emul = &ctf_trc_emul_v;
00515   }
00516   
00517   // -- RPC [resistive plate chambers regional trigger] 
00518   edm::Handle<L1MuRegionalCandCollection> rpc_cen_data;
00519   edm::Handle<L1MuRegionalCandCollection> rpc_cen_emul;
00520   edm::Handle<L1MuRegionalCandCollection> rpc_for_data;
00521   edm::Handle<L1MuRegionalCandCollection> rpc_for_emul;
00522   if(m_doSys[RPC]) {
00523     iEvent.getByLabel(m_DEsource[RPC][0].label(),"RPCb",rpc_cen_data);
00524     iEvent.getByLabel(m_DEsource[RPC][1].label(),"RPCb",rpc_cen_emul);
00525     iEvent.getByLabel(m_DEsource[RPC][0].label(),"RPCf",rpc_for_data);
00526     iEvent.getByLabel(m_DEsource[RPC][1].label(),"RPCf",rpc_for_emul);
00527   } 
00528 
00529   // -- LTC [local trigger controller]
00530   edm::Handle<LTCDigiCollection> ltc_data;
00531   edm::Handle<LTCDigiCollection> ltc_emul;
00532   if(m_doSys[LTC]) {
00533     iEvent.getByLabel(m_DEsource[LTC][0],ltc_data);
00534     iEvent.getByLabel(m_DEsource[LTC][1],ltc_emul);
00535   }
00536 
00537   // -- GMT [global muon trigger]
00538   edm::Handle<L1MuGMTCandCollection> gmt_data;
00539   edm::Handle<L1MuGMTCandCollection> gmt_emul;
00540   edm::Handle<L1MuGMTReadoutCollection> gmt_rdt_data_;
00541   edm::Handle<L1MuGMTReadoutCollection> gmt_rdt_emul_;
00542   L1MuRegionalCandCollection const* gmt_rdt_data(new L1MuRegionalCandCollection);
00543   L1MuRegionalCandCollection const* gmt_rdt_emul(new L1MuRegionalCandCollection);
00544   //tbd: may compare extended candidates
00545   L1MuGMTCandCollection const *gmt_can_data(new L1MuGMTCandCollection);
00546   L1MuGMTCandCollection const *gmt_can_emul(new L1MuGMTCandCollection);
00547   if(m_doSys[GMT]) {
00548     iEvent.getByLabel(m_DEsource[GMT][0], gmt_data);
00549     iEvent.getByLabel(m_DEsource[GMT][1], gmt_emul);
00550     iEvent.getByLabel(m_DEsource[GMT][0], gmt_rdt_data_);
00551     iEvent.getByLabel(m_DEsource[GMT][1], gmt_rdt_emul_);
00552   }  
00553   L1MuGMTCandCollection      gmt_can_data_vec, gmt_can_emul_vec;
00554   L1MuRegionalCandCollection gmt_rdt_data_vec, gmt_rdt_emul_vec;
00555   gmt_can_data_vec.clear();  gmt_can_emul_vec.clear();
00556   gmt_rdt_data_vec.clear();  gmt_rdt_emul_vec.clear();
00557   if( gmt_rdt_data_.isValid() && gmt_rdt_emul_.isValid() ) {
00558     typedef std::vector<L1MuGMTReadoutRecord>::const_iterator GmtRrIt;
00559     //get record vector for data 
00560     std::vector<L1MuGMTReadoutRecord> gmt_rdt_data_bx = gmt_rdt_data_->getRecords();
00561     for(GmtRrIt igmtrr=gmt_rdt_data_bx.begin(); igmtrr!=gmt_rdt_data_bx.end(); igmtrr++) {
00562       //get gmt cands
00563       typedef std::vector<L1MuGMTExtendedCand>::const_iterator GmtECIt;
00564       std::vector<L1MuGMTExtendedCand> gmc;
00565       gmc = igmtrr->getGMTCands();
00566       for(GmtECIt iter1=gmc.begin(); iter1!=gmc.end(); iter1++) {
00567         L1MuGMTCand cand(iter1->getDataWord(),iter1->bx());
00568         cand.setPhiValue(iter1->phiValue());
00569         cand.setEtaValue(iter1->etaValue());
00570         cand.setPtValue (iter1->ptValue ());
00571         gmt_can_data_vec.push_back(cand);
00572       }
00573       //get reg cands
00574       typedef L1MuRegionalCandCollection::const_iterator GmtRCIt;
00575       L1MuRegionalCandCollection rmc;
00576       rmc.clear();
00577       rmc = igmtrr->getDTBXCands();
00578       gmt_rdt_data_vec.insert(gmt_rdt_data_vec.end(),rmc.begin(),rmc.end());
00579       rmc.clear();
00580       rmc = igmtrr->getCSCCands();
00581       gmt_rdt_data_vec.insert(gmt_rdt_data_vec.end(),rmc.begin(),rmc.end());
00582       rmc.clear();
00583       rmc = igmtrr->getBrlRPCCands();
00584       gmt_rdt_data_vec.insert(gmt_rdt_data_vec.end(),rmc.begin(),rmc.end());
00585       rmc.clear();
00586       rmc = igmtrr->getFwdRPCCands();
00587       gmt_rdt_data_vec.insert(gmt_rdt_data_vec.end(),rmc.begin(),rmc.end());
00588     }
00589     //get record vector for emul 
00590     std::vector<L1MuGMTReadoutRecord> gmt_rdt_emul_bx = gmt_rdt_emul_->getRecords();
00591     for(GmtRrIt igmtrr=gmt_rdt_emul_bx.begin(); igmtrr!=gmt_rdt_emul_bx.end(); igmtrr++) {
00592       //get gmt cands
00593       typedef std::vector<L1MuGMTExtendedCand>::const_iterator GmtECIt;
00594       std::vector<L1MuGMTExtendedCand> gmc;
00595       gmc = igmtrr->getGMTCands();
00596       for(GmtECIt iter1=gmc.begin(); iter1!=gmc.end(); iter1++) {
00597         gmt_can_emul_vec.push_back(L1MuGMTCand(iter1->getDataWord(),iter1->bx()));
00598       }
00599       //get reg cands
00600       typedef L1MuRegionalCandCollection::const_iterator GmtRCIt;
00601       L1MuRegionalCandCollection rmc;
00602       rmc.clear();
00603       rmc = igmtrr->getDTBXCands();
00604       gmt_rdt_emul_vec.insert(gmt_rdt_emul_vec.end(),rmc.begin(),rmc.end());
00605       rmc.clear();
00606       rmc = igmtrr->getCSCCands();
00607       gmt_rdt_emul_vec.insert(gmt_rdt_emul_vec.end(),rmc.begin(),rmc.end());
00608       rmc.clear();
00609       rmc = igmtrr->getBrlRPCCands();
00610       gmt_rdt_emul_vec.insert(gmt_rdt_emul_vec.end(),rmc.begin(),rmc.end());
00611       rmc.clear();
00612       rmc = igmtrr->getFwdRPCCands();
00613       gmt_rdt_emul_vec.insert(gmt_rdt_emul_vec.end(),rmc.begin(),rmc.end());
00614     }
00615   }
00616   gmt_rdt_data = &gmt_rdt_data_vec;
00617   gmt_rdt_emul = &gmt_rdt_emul_vec;
00618   gmt_can_data = &gmt_can_data_vec;
00619   gmt_can_emul = &gmt_can_emul_vec;
00620 
00621   // -- GLT [global trigger]
00622   edm::Handle<L1GlobalTriggerReadoutRecord>    glt_rdt_data;
00623   edm::Handle<L1GlobalTriggerReadoutRecord>    glt_rdt_emul;
00624   edm::Handle<L1GlobalTriggerEvmReadoutRecord> glt_evm_data;
00625   edm::Handle<L1GlobalTriggerEvmReadoutRecord> glt_evm_emul;
00626   edm::Handle<L1GlobalTriggerObjectMapRecord>  glt_obj_data;
00627   edm::Handle<L1GlobalTriggerObjectMapRecord>  glt_obj_emul;
00628   if(m_doSys[GLT]) {
00629     iEvent.getByLabel(m_DEsource[GLT][0], glt_rdt_data);
00630     iEvent.getByLabel(m_DEsource[GLT][1], glt_rdt_emul);
00631     iEvent.getByLabel(m_DEsource[GLT][0], glt_evm_data);
00632     iEvent.getByLabel(m_DEsource[GLT][1], glt_evm_emul);
00633     iEvent.getByLabel(m_DEsource[GLT][0], glt_obj_data);
00634     iEvent.getByLabel(m_DEsource[GLT][1], glt_obj_emul);
00635   }
00636   
00638 
00639   //check collections validity
00640   bool isValidDE[DEnsys][2];// = {false};
00641   for(int i=0; i<DEnsys; i++) for(int j=0; j<2; j++) isValidDE[i][j]=false;
00642 
00643   isValidDE[ETP][0] =     ecal_tp_data .isValid(); isValidDE[ETP][1] =    ecal_tp_emul .isValid();
00644   isValidDE[HTP][0] =     hcal_tp_data .isValid(); isValidDE[HTP][1] =    hcal_tp_emul .isValid();
00645   isValidDE[RCT][0] =      rct_em_data .isValid(); isValidDE[RCT][1] =     rct_em_emul .isValid();
00646   isValidDE[RCT][0]&=     rct_rgn_data .isValid(); isValidDE[RCT][1] =    rct_rgn_emul .isValid();
00647   isValidDE[GCT][0] = gct_isolaem_data .isValid(); isValidDE[GCT][1] =gct_isolaem_emul .isValid();
00648   isValidDE[GCT][0]&= gct_noisoem_data .isValid(); isValidDE[GCT][1]&=gct_noisoem_emul .isValid();
00649   isValidDE[GCT][0]&= gct_cenjets_data .isValid(); isValidDE[GCT][1]&=gct_cenjets_emul .isValid();
00650   isValidDE[GCT][0]&= gct_forjets_data .isValid(); isValidDE[GCT][1]&=gct_forjets_emul .isValid();
00651   isValidDE[GCT][0]&= gct_taujets_data .isValid(); isValidDE[GCT][1]&=gct_taujets_emul .isValid();
00652   isValidDE[DTP][0] =      dtp_ph_data_.isValid(); isValidDE[DTP][1] =     dtp_ph_emul_.isValid();
00653   isValidDE[DTP][0]&=      dtp_th_data_.isValid(); isValidDE[DTP][1]&=     dtp_th_emul_.isValid();
00654   isValidDE[DTF][0] =         dtf_data .isValid(); isValidDE[DTF][1] =        dtf_emul .isValid();
00655 //isValidDE[DTF][0]&=     dtf_trk_data_.isValid(); isValidDE[DTF][1]&=    dtf_trk_emul_.isValid();
00656   isValidDE[CTP][0] =     ctp_lct_data_.isValid(); isValidDE[CTP][1] =    ctp_lct_emul_.isValid();
00657   if (m_DEsource[CTP][0].label().find("tf") == std::string::npos) {
00658     isValidDE[CTP][0]&=   ctp_ano_data_.isValid(); isValidDE[CTP][1]&=    ctp_ano_emul_.isValid();
00659     isValidDE[CTP][0]&=   ctp_cat_data_.isValid(); isValidDE[CTP][1]&=    ctp_cat_emul_.isValid();
00660   }
00661   isValidDE[CTF][0] =         ctf_data .isValid(); isValidDE[CTF][1] =        ctf_emul .isValid();
00662 //isValidDE[CTF][0]&=    ctf_trk_data_ .isValid(); isValidDE[CTF][1]&=   ctf_trk_emul_ .isValid();
00663 //isValidDE[CTF][0]&=    ctf_sta_data_ .isValid(); isValidDE[CTF][1]&=   ctf_sta_emul_ .isValid();
00664   isValidDE[RPC][0] =     rpc_cen_data .isValid(); isValidDE[RPC][1] =    rpc_cen_emul .isValid();
00665   isValidDE[RPC][0]&=     rpc_for_data .isValid(); isValidDE[RPC][1]&=    rpc_for_emul .isValid();
00666   isValidDE[LTC][0] =         ltc_data .isValid(); isValidDE[LTC][1] =        ltc_emul .isValid();
00667   isValidDE[GMT][0] =         gmt_data .isValid(); isValidDE[GMT][1] =        gmt_emul .isValid();
00668 //isValidDE[GMT][0]&=     gmt_rdt_data_.isValid(); isValidDE[GMT][1]&=    gmt_rdt_emul_.isValid();
00669   isValidDE[GLT][0] =     glt_rdt_data .isValid(); isValidDE[GLT][1] =    glt_rdt_emul .isValid();
00670 //isValidDE[GLT][0]&=     glt_evm_data .isValid(); isValidDE[GLT][1]&=    glt_evm_emul .isValid();
00671 //isValidDE[GLT][0]&=     glt_obj_data .isValid(); isValidDE[GLT][1]&=    glt_obj_emul .isValid();
00672 
00673   bool isValid[DEnsys];
00674   for(int i=0; i<DEnsys; i++) {
00675     isValid[i]=true;
00676     for(int j=0; j<2; j++) {
00677       isValid[i] &= isValidDE[i][j];
00678     }
00679   }
00680 
00681   if(verbose()) {
00682     std::cout << "L1Comparator sys isValid?  (evt:" << nevt_ << ") ";
00683     std::cout << "\n\t&: ";
00684     for(int i=0; i<DEnsys; i++)
00685       std::cout << isValid[i] << " ";
00686     std::cout << "\n\td: ";
00687     for(int i=0; i<DEnsys; i++)
00688       std::cout << isValidDE[i][0] << " ";
00689     std::cout << "\n\te: ";
00690     for(int i=0; i<DEnsys; i++)
00691       std::cout << isValidDE[i][1] << " ";
00692     std::cout << std::endl;
00693   }
00694   
00695   //reset flags...
00696   //for(int i=0; i<DEnsys; i++) isValid[i]=true;
00697 
00698   if(verbose())
00699     std::cout << "L1Comparator start processing the collections.\n" << std::flush;
00700 
00702   if(m_doSys[ETP]&&isValid[ETP]) process<EcalTrigPrimDigiCollection>     (    ecal_tp_data,     ecal_tp_emul, ETP,ECALtp);
00703   if(m_doSys[HTP]&&isValid[HTP]) process<HcalTrigPrimDigiCollection>     (    hcal_tp_data,     hcal_tp_emul, HTP,HCALtp);
00704   if(m_doSys[RCT]&&isValid[RCT]) process<L1CaloEmCollection>             (     rct_em_data,      rct_em_emul, RCT,RCTem);
00705   if(m_doSys[RCT]&&isValid[RCT]) process<L1CaloRegionCollection>         (    rct_rgn_data,     rct_rgn_emul, RCT,RCTrgn);
00706   if(m_doSys[GCT]&&isValid[GCT]) process<L1GctEmCandCollection>          (gct_isolaem_data, gct_isolaem_emul, GCT,GCTisolaem);
00707   if(m_doSys[GCT]&&isValid[GCT]) process<L1GctEmCandCollection>          (gct_noisoem_data, gct_noisoem_emul, GCT,GCTnoisoem);
00708   if(m_doSys[GCT]&&isValid[GCT]) process<L1GctJetCandCollection>         (gct_cenjets_data, gct_cenjets_emul, GCT,GCTcenjets);
00709   if(m_doSys[GCT]&&isValid[GCT]) process<L1GctJetCandCollection>         (gct_forjets_data, gct_forjets_emul, GCT,GCTforjets);
00710   if(m_doSys[GCT]&&isValid[GCT]) process<L1GctJetCandCollection>         (gct_taujets_data, gct_taujets_emul, GCT,GCTtaujets);
00711   if(m_doSys[DTP]&&isValid[DTP]) process<L1MuDTChambPhDigiCollection>    (     dtp_ph_data,      dtp_ph_emul, DTP,DTtpPh);
00712   if(m_doSys[DTP]&&isValid[DTP]) process<L1MuDTChambThDigiCollection>    (     dtp_th_data,      dtp_th_emul, DTP,DTtpTh);
00713   if(m_doSys[DTF]&&isValid[DTF]) process<L1MuRegionalCandCollection>     (        dtf_data,         dtf_emul, DTF,DTtf);
00714   if(m_doSys[DTF]&&isValid[DTF]) process<L1MuRegionalCandCollection>     (    dtf_trk_data,     dtf_trk_emul, DTF,DTtftrk);
00715   if(m_DEsource[CTP][0].label().find("tf") == std::string::npos) {
00716   if(m_doSys[CTP]&&isValid[CTP]) process<CSCALCTDigiCollection_>         (    ctp_ano_data,     ctp_ano_emul, CTP,CSCtpa);
00717   if(m_doSys[CTP]&&isValid[CTP]) process<CSCCLCTDigiCollection_>         (    ctp_cat_data,     ctp_cat_emul, CTP,CSCtpc);
00718   }
00719   if(m_doSys[CTP]&&isValid[CTP]) process<CSCCorrelatedLCTDigiCollection_>(    ctp_lct_data,     ctp_lct_emul, CTP,CSCtpl);
00720   if(m_doSys[CTF]&&isValid[CTF]) process<L1MuRegionalCandCollection>     (        ctf_data,         ctf_emul, CTF,CSCtf);
00721   if(m_doSys[CTF]&&isValid[CTF]) process<CSCCorrelatedLCTDigiCollection_>(    ctf_trk_data,     ctf_trk_emul, CTF,CSCtftrk);
00722   if(m_doSys[CTF]&&isValid[CTF]) process<L1MuRegionalCandCollection>     (    ctf_trc_data,     ctf_trc_emul, CTF,CSCtftrc);
00723   if(m_doSys[CTF]&&isValid[CTF]) process<L1CSCSPStatusDigiCollection_>   (    ctf_sta_data,     ctf_sta_emul, CTF,CSCtfsta);
00724   if(m_doSys[RPC]&&isValid[RPC]) process<L1MuRegionalCandCollection>     (    rpc_cen_data,     rpc_cen_emul, RPC,RPCcen);
00725   if(m_doSys[RPC]&&isValid[RPC]) process<L1MuRegionalCandCollection>     (    rpc_for_data,     rpc_for_emul, RPC,RPCfor);
00726   if(m_doSys[LTC]&&isValid[LTC]) process<LTCDigiCollection>              (        ltc_data,         ltc_emul, LTC,LTCi);
00727   if(m_doSys[GMT]&&isValid[GMT]) process<L1MuGMTCandCollection>          (        gmt_data,         gmt_emul, GMT,GMTmain);
00728   if(m_doSys[GMT]&&isValid[GMT]) process<L1MuRegionalCandCollection>     (    gmt_rdt_data,     gmt_rdt_emul, GMT,GMTrdt);
00729   if(m_doSys[GMT]&&isValid[GMT]) process<L1MuGMTCandCollection>          (    gmt_can_data,     gmt_can_emul, GMT,GMTcnd);
00730 
00731   // >>---- GLT ---- <<  
00732   GltDEDigi gltdigimon;
00733   
00734   if(m_doSys[GLT] && isValid[GLT] ) {
00735 
00737     bool prt = false; 
00738     if(!m_dumpMode)
00739       prt = false;
00740     else if(m_dumpMode==-1)
00741       prt=true;
00742 
00743     if(dumpEvent_ && prt) {
00744       m_dumpFile << "\nEntry: " << nevt_ 
00745                  << " (event:"  << evtNum_
00746                  << " | run:"   << runNum_ 
00747                  << ")\n"       << std::flush;
00748       dumpEvent_=false;
00749     }
00750 
00751     m_dumpFile << "\n  GT...\n";
00752 
00753     if(glt_rdt_data.isValid() && glt_rdt_emul.isValid()) {
00754       
00755       //fill gt mon info
00756       bool globalDBit[2];
00757       std::vector<bool> gltDecBits[2], gltTchBits[2];
00758       globalDBit[0] = glt_rdt_data->decision();
00759       globalDBit[1] = glt_rdt_emul->decision();
00760       gltDecBits[0] = glt_rdt_data->decisionWord();
00761       gltDecBits[1] = glt_rdt_emul->decisionWord();
00762       //gltTchBits[0] = glt_rdt_data->gtFdlWord().gtTechnicalTriggerWord();
00763       //gltTchBits[1] = glt_rdt_emul->gtFdlWord().gtTechnicalTriggerWord();
00764       gltTchBits[0] = glt_rdt_data->technicalTriggerWord();
00765       gltTchBits[1] = glt_rdt_emul->technicalTriggerWord();
00766       gltdigimon.set(globalDBit, gltDecBits, gltTchBits);
00767 
00768       DEncand[GLT][0]=1; DEncand[GLT][1]=1;
00769       DEmatchEvt[GLT]  = compareCollections(glt_rdt_data, glt_rdt_emul);  
00770     }
00771 
00772     if(glt_evm_data.isValid() && glt_evm_emul.isValid())
00773       DEmatchEvt[GLT] &= compareCollections(glt_evm_data, glt_evm_emul);  
00774     if(glt_obj_data.isValid() && glt_obj_emul.isValid())
00775       DEmatchEvt[GLT] &= compareCollections(glt_obj_data, glt_obj_emul);  
00776 
00777     char ok[10];
00778     char dumptofile[1000];
00779     if(DEmatchEvt[GLT]) sprintf(ok,"successful");
00780     else         sprintf(ok,"failed");
00781     sprintf(dumptofile,"  ...GT data and emulator comparison: %s\n", ok); 
00782     m_dumpFile<<dumptofile;
00783   }
00784 
00785   if(verbose())
00786     std::cout << "L1Comparator done processing all collections.\n" << std::flush;
00787 
00788   if(verbose()) {
00789     std::cout << "[L1Comparator] sys match? << evt." << nevt_ << ": ";
00790     for(int i=0; i<DEnsys; i++)
00791       std::cout << DEmatchEvt[i] << " ";
00792     std::cout << std::endl;
00793   }
00794 
00795 
00796   // >>---- Event match? ---- <<  
00797 
00798   bool evt_match  = true;
00799   for(int i=0; i<DEnsys; i++)
00800     evt_match &= DEmatchEvt[i];
00801 
00802   
00803   /* char ok[10];
00804      if(evt_match) sprintf(ok,"GOOD :]");
00805      else      sprintf(ok,"BAD !!!"); 
00806      char dumptofile[1000];
00807      sprintf(dumptofile,"\n -> event data and emulator match... %s\n", ok);
00808      m_dumpFile<<dumptofile;
00809   */
00810 
00811   // >>---- Global match? ---- <<  
00812   m_match &= evt_match;
00813   m_dumpFile << std::flush;
00814 
00815   //if collection is empty, add empty digi
00816   if(m_dedigis.size()==0) {
00817     if(verbose())
00818       std::cout << "\n [L1Comparator] adding empty collection to DErecord\n";
00819     m_dedigis.push_back(L1DataEmulDigi());
00820   }
00821   
00822   // >>---- d|e record ---- <<  
00823   std::auto_ptr<L1DataEmulRecord> record
00824     (new L1DataEmulRecord(evt_match,m_doSys,DEmatchEvt,DEncand,m_dedigis, gltdigimon));
00825   if(verbose()) {
00826     std::cout << "\n [L1Comparator] printing DErecord" 
00827               << "(entry:"<< nevt_ 
00828               << "|evt:"  << evtNum_
00829               << "|run:"  << runNum_ 
00830               << "):\n"    << std::flush;
00831     std::cout << *record 
00832               << "\n" << std::flush;
00833   }
00834 
00835   iEvent.put(record);
00836 
00838   bool dorawdata = false;
00839   if(dorawdata) {
00840     edm::Handle<FEDRawDataCollection> raw_fedcoll_data;
00841     edm::Handle<FEDRawDataCollection> raw_fedcoll_emul;
00842     iEvent.getByLabel(m_FEDsource[0], raw_fedcoll_data);
00843     iEvent.getByLabel(m_FEDsource[1], raw_fedcoll_emul);
00844     bool rawval=true;
00845     rawval &= raw_fedcoll_data.isValid();
00846     rawval &= raw_fedcoll_emul.isValid();
00847     if(rawval) 
00848       compareFedRawCollections(raw_fedcoll_data,raw_fedcoll_emul, m_fedId);
00849   }
00850   
00851   if(verbose())
00852     std::cout << "L1comparator::analize() end. " << nevt_ << std::endl;
00853   
00854 }

int L1Comparator::verbose ( void   )  [inline, private]

Definition at line 71 of file L1Comparator.h.

References verbose_.

Referenced by compareFedRawCollections(), L1Comparator(), process(), and produce().

00071 {return verbose_;}


Member Data Documentation

bool L1Comparator::DEmatchEvt[dedefs::DEnsys] [private]

Definition at line 87 of file L1Comparator.h.

Referenced by L1Comparator(), process(), and produce().

int L1Comparator::DEncand[dedefs::DEnsys][2] [private]

Definition at line 88 of file L1Comparator.h.

Referenced by L1Comparator(), process(), and produce().

bool L1Comparator::dumpEvent_ [private]

Definition at line 79 of file L1Comparator.h.

Referenced by compareFedRawCollections(), L1Comparator(), process(), and produce().

int L1Comparator::evtNum_ [private]

Definition at line 76 of file L1Comparator.h.

Referenced by process(), and produce().

L1DEDigiCollection L1Comparator::m_dedigis [private]

Definition at line 89 of file L1Comparator.h.

Referenced by L1Comparator(), process(), and produce().

edm::InputTag L1Comparator::m_DEsource[dedefs::DEnsys][4] [private]

Definition at line 81 of file L1Comparator.h.

Referenced by L1Comparator(), and produce().

bool L1Comparator::m_doSys[dedefs::DEnsys] [private]

Definition at line 82 of file L1Comparator.h.

Referenced by L1Comparator(), and produce().

std::ofstream L1Comparator::m_dumpFile [private]

Definition at line 84 of file L1Comparator.h.

Referenced by compareCollections(), CompareCollections(), compareFedRawCollections(), endJob(), L1Comparator(), process(), and produce().

std::string L1Comparator::m_dumpFileName [private]

Definition at line 83 of file L1Comparator.h.

Referenced by L1Comparator().

int L1Comparator::m_dumpMode [private]

Definition at line 85 of file L1Comparator.h.

Referenced by compareCollections(), compareFedRawCollections(), endJob(), L1Comparator(), process(), and produce().

int L1Comparator::m_fedId [private]

Definition at line 91 of file L1Comparator.h.

Referenced by L1Comparator(), and produce().

edm::InputTag L1Comparator::m_FEDsource[2] [private]

Definition at line 92 of file L1Comparator.h.

Referenced by L1Comparator(), and produce().

bool L1Comparator::m_match [private]

Definition at line 86 of file L1Comparator.h.

Referenced by endJob(), L1Comparator(), and produce().

int L1Comparator::nevt_ [private]

Definition at line 75 of file L1Comparator.h.

Referenced by compareFedRawCollections(), L1Comparator(), process(), and produce().

int L1Comparator::runNum_ [private]

Definition at line 77 of file L1Comparator.h.

Referenced by process(), and produce().

int L1Comparator::verbose_ [private]

Definition at line 78 of file L1Comparator.h.

Referenced by L1Comparator(), and verbose().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:26:24 2009 for CMSSW by  doxygen 1.5.4