00001 #include "L1Trigger/HardwareValidation/interface/L1Comparator.h"
00002 #include "FWCore/Framework/interface/ESHandle.h"
00003
00004 using namespace dedefs;
00005
00006 L1Comparator::L1Comparator(const edm::ParameterSet& iConfig) {
00007
00008 verbose_ = iConfig.getUntrackedParameter<int>("VerboseFlag",0);
00009
00010 if(verbose())
00011 std::cout << "\nL1COMPARATOR constructor...\n" << std::flush;
00012
00013 std::vector<unsigned int> dosys(0,DEnsys);
00014 dosys =
00015 iConfig.getUntrackedParameter<std::vector<unsigned int> >("COMPARE_COLLS", dosys);
00016
00017 if((int)dosys.size()!=DEnsys)
00018 edm::LogError("L1Comparator")
00019 << "wrong selection of systems to be compared\n"
00020 << "\t the size of the mask COMPARE_COLLS (" << dosys.size()
00021 << ") is not " << DEnsys << std::endl;
00022 assert((int)dosys.size()==DEnsys);
00023
00024 for(int isys=0; isys<DEnsys; isys++)
00025 if( dosys[isys]!=0 && dosys[isys]!=1 )
00026 throw cms::Exception("Invalid configuration")
00027 << "L1Comparator: comparison flag for system " << isys
00028 << " is non boolean: " << dosys[isys] << ". Exiting.\n";
00029
00030 for(int i=0; i<DEnsys; i++)
00031 m_doSys[i] = dosys[i];
00032
00033 if(verbose()) {
00034 std::cout << "[L1Comparator] do sys? ";
00035 for(int i=0; i<DEnsys; i++)
00036 std::cout << m_doSys[i] << " ";
00037 std::cout << std::endl;
00038
00039 std::cout << "[L1Comparator] list of systems to process: ";
00040 for(int i=0; i<DEnsys; i++)
00041 if(m_doSys[i])
00042 std::cout << SystLabel[i] << " ";
00043 std::cout << std::endl;
00044 }
00045
00047 assert(ETP==0); assert(HTP==1); assert(RCT== 2); assert(GCT== 3);
00048 assert(DTP==4); assert(DTF==5); assert(CTP== 6); assert(CTF== 7);
00049 assert(RPC==8); assert(LTC==9); assert(GMT==10); assert(GLT==11);
00050
00051 if(verbose())
00052 std::cout << "[L1Comparator] debug print collection labels\n";
00053
00054 m_DEsource[ETP][0] = iConfig.getParameter<edm::InputTag>("ETPsourceData");
00055 m_DEsource[ETP][1] = iConfig.getParameter<edm::InputTag>("ETPsourceEmul");
00056 m_DEsource[HTP][0] = iConfig.getParameter<edm::InputTag>("HTPsourceData");
00057 m_DEsource[HTP][1] = iConfig.getParameter<edm::InputTag>("HTPsourceEmul");
00058 m_DEsource[RCT][0] = iConfig.getParameter<edm::InputTag>("RCTsourceData");
00059 m_DEsource[RCT][1] = iConfig.getParameter<edm::InputTag>("RCTsourceEmul");
00060 m_DEsource[GCT][0] = iConfig.getParameter<edm::InputTag>("GCTsourceData");
00061 m_DEsource[GCT][1] = iConfig.getParameter<edm::InputTag>("GCTsourceEmul");
00062 m_DEsource[DTP][0] = iConfig.getParameter<edm::InputTag>("DTPsourceData");
00063 m_DEsource[DTP][1] = iConfig.getParameter<edm::InputTag>("DTPsourceEmul");
00064 m_DEsource[DTF][0] = iConfig.getParameter<edm::InputTag>("DTFsourceData");
00065 m_DEsource[DTF][1] = iConfig.getParameter<edm::InputTag>("DTFsourceEmul");
00066 m_DEsource[CTP][0] = iConfig.getParameter<edm::InputTag>("CTPsourceData");
00067 m_DEsource[CTP][1] = iConfig.getParameter<edm::InputTag>("CTPsourceEmul");
00068 m_DEsource[CTF][0] = iConfig.getParameter<edm::InputTag>("CTFsourceData");
00069 m_DEsource[CTF][1] = iConfig.getParameter<edm::InputTag>("CTFsourceEmul");
00070 m_DEsource[CTF][2] = iConfig.getParameter<edm::InputTag>("CTTsourceData");
00071 m_DEsource[CTF][3] = iConfig.getParameter<edm::InputTag>("CTTsourceEmul");
00072 m_DEsource[RPC][0] = iConfig.getParameter<edm::InputTag>("RPCsourceData");
00073 m_DEsource[RPC][1] = iConfig.getParameter<edm::InputTag>("RPCsourceEmul");
00074 m_DEsource[LTC][0] = iConfig.getParameter<edm::InputTag>("LTCsourceData");
00075 m_DEsource[LTC][1] = iConfig.getParameter<edm::InputTag>("LTCsourceEmul");
00076 m_DEsource[GMT][0] = iConfig.getParameter<edm::InputTag>("GMTsourceData");
00077 m_DEsource[GMT][1] = iConfig.getParameter<edm::InputTag>("GMTsourceEmul");
00078 m_DEsource[GLT][0] = iConfig.getParameter<edm::InputTag>("GLTsourceData");
00079 m_DEsource[GLT][1] = iConfig.getParameter<edm::InputTag>("GLTsourceEmul");
00080
00081 for(int sys=0; sys<DEnsys; sys++) {
00082 std::string data_label = SystLabel[sys] + "sourceData";
00083 std::string emul_label = SystLabel[sys] + "sourceEmul";
00084
00085
00086
00087
00088
00089
00090
00091
00092 if(m_doSys[sys] && verbose()) {
00093 std::cout << " sys:" << sys << " label:" << SystLabel[sys]
00094 << "\n\tdt:" << data_label << " : " <<m_DEsource[sys][0]
00095 << "\n\tem:" << emul_label << " : " <<m_DEsource[sys][1]
00096 << std::endl;
00097 if(sys==CTF) {
00098 std::cout << "\tdt:" << data_label << " : " <<m_DEsource[sys][2]
00099 << "\n\tem:" << emul_label << " : " <<m_DEsource[sys][3]
00100 << std::endl;
00101 }
00102 }
00103 }
00104
00105
00106 m_fedId = iConfig.getUntrackedParameter<int>("FEDid", 0);
00107 m_FEDsource[0] =
00108 iConfig.getUntrackedParameter<edm::InputTag>("FEDsourceData",edm::InputTag());
00109 m_FEDsource[1] =
00110 iConfig.getUntrackedParameter<edm::InputTag>("FEDsourceEmul",edm::InputTag());
00111
00112
00114 m_dumpMode = iConfig.getUntrackedParameter<int>("DumpMode",0);
00115 m_dumpFileName = iConfig.getUntrackedParameter<std::string>("DumpFile","");
00116 if(m_dumpMode) {
00117 m_dumpFile.open(m_dumpFileName.c_str(), std::ios::out);
00118 if(!m_dumpFile.good())
00119 edm::LogInfo("L1ComparatorDumpFileOpenError")
00120 << " L1Comparator::L1Comparator() : "
00121 << " couldn't open dump file " << m_dumpFileName.c_str() << std::endl;
00122 }
00123
00124 m_match = true;
00125 dumpEvent_ = true;
00126 nevt_=-1;
00127
00128 for(int i=0; i<DEnsys; i++) {
00129 for(int j=0; j<2; j++)
00130 DEncand[i][j] = 0;
00131 DEmatchEvt[i] = true;
00132 }
00133
00134 m_dedigis.clear();
00136 produces<L1DataEmulRecord>().setBranchAlias("L1DataEmulRecord");
00137
00138 if(verbose())
00139 std::cout << "\nL1Comparator constructor...done.\n" << std::flush;
00140 }
00141
00142
00143 L1Comparator::~L1Comparator(){}
00144
00145 void L1Comparator::beginJob(void) {}
00146
00147 void L1Comparator::beginRun(edm::Run& iRun, const edm::EventSetup& iSetup) {
00148
00149 if(verbose())
00150 std::cout << "\nL1COMPARATOR beginRun...\n" << std::flush;
00151
00152
00153
00154 try
00155 {
00156 edm::ESHandle< L1TriggerKey > pKey ;
00157 iSetup.get< L1TriggerKeyRcd >().get( pKey ) ;
00158
00159 m_doSys[RCT] &= (!(pKey->subsystemKey( L1TriggerKey::kRCT) .empty()));
00160 m_doSys[GCT] &= (!(pKey->subsystemKey( L1TriggerKey::kGCT) .empty()));
00161 m_doSys[DTF] &= (!(pKey->subsystemKey( L1TriggerKey::kDTTF) .empty()));
00162 m_doSys[CTF] &= (!(pKey->subsystemKey( L1TriggerKey::kCSCTF).empty()));
00163 m_doSys[RPC] &= (!(pKey->subsystemKey( L1TriggerKey::kRPC) .empty()));
00164 m_doSys[GMT] &= (!(pKey->subsystemKey( L1TriggerKey::kGMT) .empty()));
00165 m_doSys[GLT] &= (!(pKey->subsystemKey( L1TriggerKey::kGT) .empty()));
00166
00167 if(verbose()) {
00168 if ( pKey->subsystemKey( L1TriggerKey::kRCT ).empty() )
00169 std::cout << "RCT key is empty. Sub-systems is disabled ("<<m_doSys[RCT]<<")\n";
00170 if ( pKey->subsystemKey( L1TriggerKey::kGCT ).empty() )
00171 std::cout << "GCT key is empty. Sub-systems is disabled ("<<m_doSys[GCT]<<")\n";
00172 if ( pKey->subsystemKey( L1TriggerKey::kDTTF ).empty() )
00173 std::cout << "DTTF key is empty. Sub-systems is disabled ("<<m_doSys[DTF]<<")\n";
00174 if ( pKey->subsystemKey( L1TriggerKey::kCSCTF).empty() )
00175 std::cout << "CSCTF key is empty. Sub-systems is disabled ("<<m_doSys[CTF]<<")\n";
00176 if ( pKey->subsystemKey( L1TriggerKey::kRPC ).empty() )
00177 std::cout << "RPC key is empty. Sub-systems is disabled ("<<m_doSys[RPC]<<")\n";
00178 if ( pKey->subsystemKey( L1TriggerKey::kGMT ).empty() )
00179 std::cout << "GMT key is empty. Sub-systems is disabled ("<<m_doSys[GMT]<<")\n";
00180 if ( pKey->subsystemKey( L1TriggerKey::kGT ).empty() )
00181 std::cout << "GT key is empty. Sub-systems is disabled ("<<m_doSys[GLT]<<")\n";
00182 std::cout << "TSC key = " << pKey->tscKey() << std::endl;
00183 }
00184
00185
00186
00187 }
00188 catch( cms::Exception& ex )
00189 {
00190 edm::LogWarning("L1Comparator")
00191 << "No L1TriggerKey found."
00192 << std::endl;
00193 }
00194
00195 if(verbose())
00196 std::cout << "L1COMPARATOR beginRun... done\n" << std::flush;
00197
00198 }
00199
00200 void L1Comparator::endJob() {
00201 if(m_dumpMode)
00202 m_dumpFile << "\n\n-------\n"
00203 << "Global data|emulator agreement: "
00204 << m_match << std::endl;
00205 m_dumpFile.close();
00206 }
00207
00208 void
00209 L1Comparator::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
00210
00211 nevt_++;
00212 evtNum_ = iEvent.id().event();
00213 runNum_ = iEvent.id().run();
00214
00215 if(verbose())
00216 std::cout << "\nL1COMPARATOR entry:" << nevt_ << " | evt:" << evtNum_
00217 << " | run:" << runNum_ << "\n" << std::flush;
00218
00219
00220 dumpEvent_ = true;
00221
00222
00223 for(int i=0; i<DEnsys; i++) {
00224 for(int j=0; j<2; j++)
00225 DEncand[i][j] = 0;
00226 DEmatchEvt[i] = true;
00227 }
00228 m_dedigis.clear();
00229
00230
00232
00233
00234 edm::Handle<EcalTrigPrimDigiCollection> ecal_tp_data;
00235 edm::Handle<EcalTrigPrimDigiCollection> ecal_tp_emul;
00236 if(m_doSys[ETP]) {
00237 iEvent.getByLabel(m_DEsource[ETP][0], ecal_tp_data);
00238 iEvent.getByLabel(m_DEsource[ETP][1], ecal_tp_emul);
00239 }
00240
00241
00242 edm::Handle<HcalTrigPrimDigiCollection> hcal_tp_data;
00243 edm::Handle<HcalTrigPrimDigiCollection> hcal_tp_emul;
00244 if(m_doSys[HTP]) {
00245 iEvent.getByLabel(m_DEsource[HTP][0], hcal_tp_data);
00246 iEvent.getByLabel(m_DEsource[HTP][1], hcal_tp_emul);
00247 }
00248
00249
00250 edm::Handle<L1CaloEmCollection> rct_em_data;
00251 edm::Handle<L1CaloEmCollection> rct_em_emul;
00252 edm::Handle<L1CaloRegionCollection> rct_rgn_data;
00253 edm::Handle<L1CaloRegionCollection> rct_rgn_emul;
00254 if(m_doSys[RCT]) {
00255 iEvent.getByLabel(m_DEsource[RCT][0], rct_em_data);
00256 iEvent.getByLabel(m_DEsource[RCT][1], rct_em_emul);
00257 iEvent.getByLabel(m_DEsource[RCT][0], rct_rgn_data);
00258 iEvent.getByLabel(m_DEsource[RCT][1], rct_rgn_emul);
00259 }
00260
00261
00262 edm::Handle<L1GctEmCandCollection> gct_isolaem_data;
00263 edm::Handle<L1GctEmCandCollection> gct_isolaem_emul;
00264 edm::Handle<L1GctEmCandCollection> gct_noisoem_data;
00265 edm::Handle<L1GctEmCandCollection> gct_noisoem_emul;
00266 edm::Handle<L1GctJetCandCollection> gct_cenjets_data;
00267 edm::Handle<L1GctJetCandCollection> gct_cenjets_emul;
00268 edm::Handle<L1GctJetCandCollection> gct_forjets_data;
00269 edm::Handle<L1GctJetCandCollection> gct_forjets_emul;
00270 edm::Handle<L1GctJetCandCollection> gct_taujets_data;
00271 edm::Handle<L1GctJetCandCollection> gct_taujets_emul;
00272
00273 edm::Handle<L1GctEtHadCollection> gct_ht_data;
00274 edm::Handle<L1GctEtHadCollection> gct_ht_emul;
00275 edm::Handle<L1GctEtMissCollection> gct_etmiss_data;
00276 edm::Handle<L1GctEtMissCollection> gct_etmiss_emul;
00277 edm::Handle<L1GctEtTotalCollection> gct_ettota_data;
00278 edm::Handle<L1GctEtTotalCollection> gct_ettota_emul;
00279 edm::Handle<L1GctHtMissCollection> gct_htmiss_data;
00280 edm::Handle<L1GctHtMissCollection> gct_htmiss_emul;
00281 edm::Handle<L1GctHFRingEtSumsCollection>gct_hfring_data;
00282 edm::Handle<L1GctHFRingEtSumsCollection>gct_hfring_emul;
00283 edm::Handle<L1GctHFBitCountsCollection> gct_hfbcnt_data;
00284 edm::Handle<L1GctHFBitCountsCollection> gct_hfbcnt_emul;
00285 edm::Handle<L1GctJetCountsCollection> gct_jetcnt_data;
00286 edm::Handle<L1GctJetCountsCollection> gct_jetcnt_emul;
00287
00288 if(m_doSys[GCT]) {
00289 iEvent.getByLabel(m_DEsource[GCT][0].label(),"isoEm", gct_isolaem_data);
00290 iEvent.getByLabel(m_DEsource[GCT][1].label(),"isoEm", gct_isolaem_emul);
00291 iEvent.getByLabel(m_DEsource[GCT][0].label(),"nonIsoEm",gct_noisoem_data);
00292 iEvent.getByLabel(m_DEsource[GCT][1].label(),"nonIsoEm",gct_noisoem_emul);
00293 iEvent.getByLabel(m_DEsource[GCT][0].label(),"cenJets", gct_cenjets_data);
00294 iEvent.getByLabel(m_DEsource[GCT][1].label(),"cenJets", gct_cenjets_emul);
00295 iEvent.getByLabel(m_DEsource[GCT][0].label(),"forJets", gct_forjets_data);
00296 iEvent.getByLabel(m_DEsource[GCT][1].label(),"forJets", gct_forjets_emul);
00297 iEvent.getByLabel(m_DEsource[GCT][0].label(),"tauJets", gct_taujets_data);
00298 iEvent.getByLabel(m_DEsource[GCT][1].label(),"tauJets", gct_taujets_emul);
00299
00300 iEvent.getByLabel(m_DEsource[GCT][0],gct_ht_data);
00301 iEvent.getByLabel(m_DEsource[GCT][1],gct_ht_emul);
00302 iEvent.getByLabel(m_DEsource[GCT][0],gct_etmiss_data);
00303 iEvent.getByLabel(m_DEsource[GCT][1],gct_etmiss_emul);
00304 iEvent.getByLabel(m_DEsource[GCT][0],gct_ettota_data);
00305 iEvent.getByLabel(m_DEsource[GCT][1],gct_ettota_emul);
00306 iEvent.getByLabel(m_DEsource[GCT][0],gct_htmiss_data);
00307 iEvent.getByLabel(m_DEsource[GCT][1],gct_htmiss_emul);
00308 iEvent.getByLabel(m_DEsource[GCT][0],gct_hfring_data);
00309 iEvent.getByLabel(m_DEsource[GCT][1],gct_hfring_emul);
00310 iEvent.getByLabel(m_DEsource[GCT][0],gct_hfbcnt_data);
00311 iEvent.getByLabel(m_DEsource[GCT][1],gct_hfbcnt_emul);
00312 iEvent.getByLabel(m_DEsource[GCT][0],gct_jetcnt_data);
00313 iEvent.getByLabel(m_DEsource[GCT][1],gct_jetcnt_emul);
00314 }
00315
00316
00317 edm::Handle<L1MuDTChambPhContainer> dtp_ph_data_;
00318 edm::Handle<L1MuDTChambPhContainer> dtp_ph_emul_;
00319 edm::Handle<L1MuDTChambThContainer> dtp_th_data_;
00320 edm::Handle<L1MuDTChambThContainer> dtp_th_emul_;
00321 if(m_doSys[DTP]) {
00322 iEvent.getByLabel(m_DEsource[DTP][0],dtp_ph_data_);
00323 iEvent.getByLabel(m_DEsource[DTP][1],dtp_ph_emul_);
00324 iEvent.getByLabel(m_DEsource[DTP][0],dtp_th_data_);
00325 iEvent.getByLabel(m_DEsource[DTP][1],dtp_th_emul_);
00326 }
00327 L1MuDTChambPhDigiCollection const* dtp_ph_data = 0;
00328 L1MuDTChambPhDigiCollection const* dtp_ph_emul = 0;
00329 L1MuDTChambThDigiCollection const* dtp_th_data = 0;
00330 L1MuDTChambThDigiCollection const* dtp_th_emul = 0;
00331
00332 if(dtp_ph_data_.isValid()) dtp_ph_data = dtp_ph_data_->getContainer();
00333 if(dtp_ph_emul_.isValid()) dtp_ph_emul = dtp_ph_emul_->getContainer();
00334 if(dtp_th_data_.isValid()) dtp_th_data = dtp_th_data_->getContainer();
00335 if(dtp_th_emul_.isValid()) dtp_th_emul = dtp_th_emul_->getContainer();
00336
00337
00338 edm::Handle<L1MuRegionalCandCollection> dtf_data;
00339 edm::Handle<L1MuRegionalCandCollection> dtf_emul;
00340 edm::Handle<L1MuDTTrackContainer> dtf_trk_data_;
00341 edm::Handle<L1MuDTTrackContainer> dtf_trk_emul_;
00342 L1MuRegionalCandCollection const* dtf_trk_data = 0;
00343 L1MuRegionalCandCollection const* dtf_trk_emul = 0;
00344 if(m_doSys[DTF]) {
00345 iEvent.getByLabel(m_DEsource[DTF][0].label(),"DT",dtf_data);
00346 iEvent.getByLabel(m_DEsource[DTF][1].label(),"DT",dtf_emul);
00347
00348 iEvent.getByLabel(m_DEsource[DTF][0].label(),"DATA",dtf_trk_data_);
00349 iEvent.getByLabel(m_DEsource[DTF][1].label(),"DTTF",dtf_trk_emul_);
00350 }
00351
00352 typedef std::vector<L1MuDTTrackCand> L1MuDTTrackCandCollection;
00353 L1MuRegionalCandCollection dtf_trk_data_v, dtf_trk_emul_v;
00354 dtf_trk_data_v.clear(); dtf_trk_emul_v.clear();
00355 if(dtf_trk_data_.isValid()) {
00356 L1MuDTTrackCandCollection *dttc = dtf_trk_data_->getContainer();
00357 for(L1MuDTTrackCandCollection::const_iterator it=dttc->begin();
00358 it!=dttc->end(); it++)
00359 dtf_trk_data_v.push_back(L1MuRegionalCand(*it));
00360 }
00361 if(dtf_trk_emul_.isValid()) {
00362 L1MuDTTrackCandCollection *dttc = dtf_trk_emul_->getContainer();
00363 for(L1MuDTTrackCandCollection::const_iterator it=dttc->begin();
00364 it!=dttc->end(); it++)
00365 dtf_trk_emul_v.push_back(L1MuRegionalCand(*it));
00366 }
00367 dtf_trk_data =&dtf_trk_data_v;
00368 dtf_trk_emul =&dtf_trk_emul_v;
00369
00370
00371 edm::Handle<CSCALCTDigiCollection> ctp_ano_data_;
00372 edm::Handle<CSCALCTDigiCollection> ctp_ano_emul_;
00373 edm::Handle<CSCCLCTDigiCollection> ctp_cat_data_;
00374 edm::Handle<CSCCLCTDigiCollection> ctp_cat_emul_;
00375 edm::Handle<CSCCorrelatedLCTDigiCollection> ctp_lct_data_;
00376 edm::Handle<CSCCorrelatedLCTDigiCollection> ctp_lct_emul_;
00377 CSCALCTDigiCollection_ const* ctp_ano_data = 0;
00378 CSCALCTDigiCollection_ const* ctp_ano_emul = 0;
00379 CSCCLCTDigiCollection_ const* ctp_cat_data = 0;
00380 CSCCLCTDigiCollection_ const* ctp_cat_emul = 0;
00381 CSCCorrelatedLCTDigiCollection_ const* ctp_lct_data = 0;
00382 CSCCorrelatedLCTDigiCollection_ const* ctp_lct_emul = 0;
00383 if(m_doSys[CTP]) {
00384 if(m_DEsource[CTP][0].label().find("tf")!=std::string::npos) {
00385
00386 iEvent.getByLabel("muonCSCDigis", "MuonCSCALCTDigi" ,ctp_ano_data_);
00387 iEvent.getByLabel("muonCSCDigis", "MuonCSCCLCTDigi" ,ctp_cat_data_);
00388 iEvent.getByLabel(m_DEsource[CTP][0] ,ctp_lct_data_);
00389 } else {
00390 iEvent.getByLabel(m_DEsource[CTP][0].label(),"MuonCSCALCTDigi",ctp_ano_data_);
00391 iEvent.getByLabel(m_DEsource[CTP][0].label(),"MuonCSCCLCTDigi",ctp_cat_data_);
00392 iEvent.getByLabel(m_DEsource[CTP][0].label(),"MuonCSCCorrelatedLCTDigi",ctp_lct_data_);
00393 }
00394 iEvent.getByLabel(m_DEsource[CTP][1] ,ctp_ano_emul_);
00395 iEvent.getByLabel(m_DEsource[CTP][1] ,ctp_cat_emul_);
00396 iEvent.getByLabel(m_DEsource[CTP][1] ,ctp_lct_emul_);
00397 }
00398
00400
00401 CSCALCTDigiCollection_ ctp_ano_data_v, ctp_ano_emul_v;
00402 ctp_ano_data_v.clear(); ctp_ano_emul_v.clear();
00403 if(ctp_ano_data_.isValid() && ctp_ano_emul_.isValid()) {
00404
00405 int fifo_pretrig = 10;
00406 int fpga_latency = 6;
00407 int l1a_window_width = 7;
00408
00409 int rawhit_tbin_offset =
00410 (fifo_pretrig - fpga_latency) + (l1a_window_width-1)/2;
00411
00412
00413 int register_delay = 2;
00414 typedef CSCALCTDigiCollection::DigiRangeIterator mapIt;
00415 typedef CSCALCTDigiCollection::const_iterator vecIt;
00416 for (mapIt mit = ctp_ano_data_->begin(); mit != ctp_ano_data_->end(); mit++)
00417 for (vecIt vit = ctp_ano_data_->get((*mit).first).first;
00418 vit != ctp_ano_data_->get((*mit).first).second; vit++)
00419 ctp_ano_data_v.push_back(*vit);
00420 for (mapIt mit = ctp_ano_emul_->begin(); mit != ctp_ano_emul_->end(); mit++)
00421 for (vecIt vit = ctp_ano_emul_->get((*mit).first).first;
00422 vit != ctp_ano_emul_->get((*mit).first).second; vit++) {
00423 int emul_bx_corr =
00424 (*vit).getBX() - rawhit_tbin_offset + register_delay;
00425 CSCALCTDigi alct((*vit).isValid(), (*vit).getQuality(),
00426 (*vit).getAccelerator(), (*vit).getCollisionB(),
00427 (*vit).getKeyWG(), emul_bx_corr,
00428 (*vit).getTrknmb());
00429 ctp_ano_emul_v.push_back(alct);
00430 }
00431 }
00432 ctp_ano_data =&ctp_ano_data_v;
00433 ctp_ano_emul =&ctp_ano_emul_v;
00434
00435 CSCCLCTDigiCollection_ ctp_cat_data_v, ctp_cat_emul_v;
00436 ctp_cat_data_v.clear(); ctp_cat_emul_v.clear();
00437 if(ctp_cat_data_.isValid() && ctp_cat_emul_.isValid()) {
00438 int tbin_cathode_offset = 7, emul_bx_corr;
00439 typedef CSCCLCTDigiCollection::DigiRangeIterator mapIt;
00440 typedef CSCCLCTDigiCollection::const_iterator vecIt;
00441 for (mapIt mit = ctp_cat_data_->begin(); mit != ctp_cat_data_->end(); mit++)
00442 for (vecIt vit = ctp_cat_data_->get((*mit).first).first;
00443 vit != ctp_cat_data_->get((*mit).first).second; vit++)
00444 ctp_cat_data_v.push_back(*vit);
00445 for (mapIt mit = ctp_cat_emul_->begin(); mit != ctp_cat_emul_->end(); mit++) {
00446 const CSCDetId& detid = (*mit).first;
00447
00448
00449 int full_cathode_bx = -999;
00450 const CSCCLCTDigiCollection::Range& crange = ctp_cat_data_->get(detid);
00451 for (vecIt digiIt = crange.first; digiIt != crange.second; digiIt++) {
00452 if ((*digiIt).isValid()) {
00453 full_cathode_bx = (*digiIt).getFullBX();
00454 break;
00455 }
00456 }
00457
00458 for (vecIt vit = ctp_cat_emul_->get(detid).first;
00459 vit != ctp_cat_emul_->get(detid).second; vit++) {
00460 int emul_bx = (*vit).getBX();
00461 if (full_cathode_bx != -999)
00462 emul_bx_corr =
00463 (full_cathode_bx + emul_bx - tbin_cathode_offset) & 0x03;
00464 else
00465 emul_bx_corr = emul_bx & 0x03;
00466 CSCCLCTDigi clct((*vit).isValid(), (*vit).getQuality(),
00467 (*vit).getPattern(), (*vit).getStripType(),
00468 (*vit).getBend(), (*vit).getStrip(),
00469 (*vit).getCFEB(), emul_bx_corr,
00470 (*vit).getTrknmb());
00471 ctp_cat_emul_v.push_back(clct);
00472 }
00473 }
00474 }
00475 ctp_cat_data =&ctp_cat_data_v;
00476 ctp_cat_emul =&ctp_cat_emul_v;
00477
00478 CSCCorrelatedLCTDigiCollection_ ctp_lct_data_v, ctp_lct_emul_v;
00479 ctp_lct_data_v.clear(); ctp_lct_emul_v.clear();
00480 if(ctp_lct_data_.isValid() && ctp_lct_emul_.isValid()) {
00481 int tbin_anode_offset = 5, emul_bx_corr;
00482 typedef CSCCorrelatedLCTDigiCollection::DigiRangeIterator mapIt;
00483 typedef CSCCorrelatedLCTDigiCollection::const_iterator vecIt;
00484
00485 for (mapIt mit = ctp_lct_data_->begin(); mit != ctp_lct_data_->end(); mit++)
00486
00487
00488
00489
00490 for (vecIt vit = ctp_lct_data_->get((*mit).first).first;
00491 vit != ctp_lct_data_->get((*mit).first).second; vit++)
00492 ctp_lct_data_v.push_back(*vit);
00493 for (mapIt mit = ctp_lct_emul_->begin(); mit != ctp_lct_emul_->end(); mit++) {
00494 const CSCDetId& detid = (*mit).first;
00495
00496
00497 int full_anode_bx = -999;
00498 if(ctp_ano_data_.isValid()) {
00499 const CSCALCTDigiCollection::Range& arange = ctp_ano_data_->get(detid);
00500 for (CSCALCTDigiCollection::const_iterator digiIt = arange.first;
00501 digiIt != arange.second; digiIt++) {
00502 if ((*digiIt).isValid()) {
00503 full_anode_bx = (*digiIt).getFullBX();
00504 break;
00505 }
00506 }
00507 }
00508
00509 for (vecIt vit = ctp_lct_emul_->get(detid).first;
00510 vit != ctp_lct_emul_->get(detid).second; vit++) {
00511 int emul_bx = (*vit).getBX();
00512 if (full_anode_bx != -999) {
00513 emul_bx_corr = (full_anode_bx + emul_bx - tbin_anode_offset) & 0x01;
00514 }
00515 else {
00516 emul_bx_corr = emul_bx & 0x01;
00517 }
00518
00519
00520
00521 if (m_DEsource[CTP][1].instance() == "MPCSORTED") emul_bx_corr += 5;
00522
00523 CSCCorrelatedLCTDigi lct((*vit).getTrknmb(), (*vit).isValid(),
00524 (*vit).getQuality(), (*vit).getKeyWG(),
00525 (*vit).getStrip(), (*vit).getPattern(),
00526 (*vit).getBend(), emul_bx_corr,
00527 (*vit).getMPCLink(), (*vit).getBX0(),
00528 (*vit).getSyncErr(), (*vit).getCSCID());
00529 ctp_lct_emul_v.push_back(lct);
00530 }
00531 }
00532 }
00533 ctp_lct_data =&ctp_lct_data_v;
00534 ctp_lct_emul =&ctp_lct_emul_v;
00535
00536
00537
00538 edm::Handle<L1MuRegionalCandCollection> ctf_data, ctf_emul;
00539 edm::Handle<L1CSCTrackCollection> ctf_trk_data_, ctf_trk_emul_;
00540 CSCCorrelatedLCTDigiCollection_ const* ctf_trk_data(new CSCCorrelatedLCTDigiCollection_);
00541 CSCCorrelatedLCTDigiCollection_ const* ctf_trk_emul(new CSCCorrelatedLCTDigiCollection_);
00542 L1MuRegionalCandCollection const* ctf_trc_data(new L1MuRegionalCandCollection);
00543 L1MuRegionalCandCollection const* ctf_trc_emul(new L1MuRegionalCandCollection);
00544 edm::Handle<L1CSCStatusDigiCollection> ctf_sta_data_;
00545 edm::Handle<L1CSCStatusDigiCollection> ctf_sta_emul_;
00546 L1CSCSPStatusDigiCollection_ const* ctf_sta_data(new L1CSCSPStatusDigiCollection_);
00547 L1CSCSPStatusDigiCollection_ const* ctf_sta_emul(new L1CSCSPStatusDigiCollection_);
00548 if(m_doSys[CTF]) {
00549 iEvent.getByLabel(m_DEsource[CTF][2],ctf_trk_data_);
00550 iEvent.getByLabel(m_DEsource[CTF][3],ctf_trk_emul_);
00551
00552 iEvent.getByLabel(m_DEsource[CTF][0],ctf_data);
00553 iEvent.getByLabel(m_DEsource[CTF][1],ctf_emul);
00554
00555 iEvent.getByLabel(m_DEsource[CTF][0].label(),"MuonL1CSCStatusDigiCollection",ctf_sta_data_);
00556 iEvent.getByLabel(m_DEsource[CTF][1].label(),"MuonL1CSCStatusDigiCollection",ctf_sta_emul_);
00557 }
00558 if(ctf_sta_data_.isValid())
00559 ctf_sta_data = &(ctf_sta_data_->second);
00560 if(ctf_sta_emul_.isValid())
00561 ctf_sta_emul = &(ctf_sta_emul_->second);
00562 if(ctf_trk_data_.isValid() && ctf_trk_emul_.isValid()) {
00563 typedef CSCCorrelatedLCTDigiCollection::DigiRangeIterator mapIt;
00564 typedef CSCCorrelatedLCTDigiCollection::const_iterator vecIt;
00565 CSCCorrelatedLCTDigiCollection_ ctf_trk_data_v, ctf_trk_emul_v;
00566 L1MuRegionalCandCollection ctf_trc_data_v, ctf_trc_emul_v;
00567 typedef L1CSCTrackCollection::const_iterator ctcIt;
00568
00569 for(ctcIt tcit=ctf_trk_data_->begin(); tcit!=ctf_trk_data_->end(); tcit++) {
00571 if((tcit->first.bx() < -1) || (tcit->first.bx() > 1))
00572 continue;
00573
00574
00575
00576
00577 ctf_trc_data_v.push_back(L1MuRegionalCand(tcit->first.getDataWord(), tcit->first.bx()));
00578 CSCCorrelatedLCTDigiCollection ldc = tcit->second;
00579
00580
00581 for (mapIt mit = ldc.begin(); mit != ldc.end(); mit++)
00582
00583
00584
00585
00586 for (vecIt vit = ldc.get((*mit).first).first;
00587 vit != ldc.get((*mit).first).second; vit++)
00588 ctf_trk_data_v.push_back(*vit);
00589 }
00590 ctf_trk_data = &ctf_trk_data_v;
00591 ctf_trc_data = &ctf_trc_data_v;
00592
00593 for(ctcIt tcit=ctf_trk_emul_->begin();tcit!=ctf_trk_emul_->end(); tcit++) {
00594 if((tcit->first.bx() < -1) || (tcit->first.bx() > 1))
00595 continue;
00596 ctf_trc_emul_v.push_back(L1MuRegionalCand(tcit->first.getDataWord(), tcit->first.bx()));
00597 CSCCorrelatedLCTDigiCollection ldc = tcit->second;
00598 for (mapIt mit = ldc.begin(); mit != ldc.end(); mit++)
00599 for (vecIt vit = ldc.get((*mit).first).first;
00600 vit != ldc.get((*mit).first).second; vit++)
00601 ctf_trk_emul_v.push_back(*vit);
00602 }
00603 ctf_trk_emul = &ctf_trk_emul_v;
00604 ctf_trc_emul = &ctf_trc_emul_v;
00605 }
00606
00607
00608 edm::Handle<L1MuRegionalCandCollection> rpc_cen_data;
00609 edm::Handle<L1MuRegionalCandCollection> rpc_cen_emul;
00610 edm::Handle<L1MuRegionalCandCollection> rpc_for_data;
00611 edm::Handle<L1MuRegionalCandCollection> rpc_for_emul;
00612 if(m_doSys[RPC]) {
00613 iEvent.getByLabel(m_DEsource[RPC][0].label(),"RPCb",rpc_cen_data);
00614 iEvent.getByLabel(m_DEsource[RPC][1].label(),"RPCb",rpc_cen_emul);
00615 iEvent.getByLabel(m_DEsource[RPC][0].label(),"RPCf",rpc_for_data);
00616 iEvent.getByLabel(m_DEsource[RPC][1].label(),"RPCf",rpc_for_emul);
00617 }
00618
00619
00620 edm::Handle<LTCDigiCollection> ltc_data;
00621 edm::Handle<LTCDigiCollection> ltc_emul;
00622 if(m_doSys[LTC]) {
00623 iEvent.getByLabel(m_DEsource[LTC][0],ltc_data);
00624 iEvent.getByLabel(m_DEsource[LTC][1],ltc_emul);
00625 }
00626
00627
00628 edm::Handle<L1MuGMTCandCollection> gmt_data;
00629 edm::Handle<L1MuGMTCandCollection> gmt_emul;
00630 edm::Handle<L1MuGMTReadoutCollection> gmt_rdt_data_;
00631 edm::Handle<L1MuGMTReadoutCollection> gmt_rdt_emul_;
00632 L1MuRegionalCandCollection const* gmt_rdt_data(new L1MuRegionalCandCollection);
00633 L1MuRegionalCandCollection const* gmt_rdt_emul(new L1MuRegionalCandCollection);
00634
00635 L1MuGMTCandCollection const *gmt_can_data(new L1MuGMTCandCollection);
00636 L1MuGMTCandCollection const *gmt_can_emul(new L1MuGMTCandCollection);
00637 if(m_doSys[GMT]) {
00638 iEvent.getByLabel(m_DEsource[GMT][0], gmt_data);
00639 iEvent.getByLabel(m_DEsource[GMT][1], gmt_emul);
00640 iEvent.getByLabel(m_DEsource[GMT][0], gmt_rdt_data_);
00641 iEvent.getByLabel(m_DEsource[GMT][1], gmt_rdt_emul_);
00642 }
00643 L1MuGMTCandCollection gmt_can_data_vec, gmt_can_emul_vec;
00644 L1MuRegionalCandCollection gmt_rdt_data_vec, gmt_rdt_emul_vec;
00645 gmt_can_data_vec.clear(); gmt_can_emul_vec.clear();
00646 gmt_rdt_data_vec.clear(); gmt_rdt_emul_vec.clear();
00647 if( gmt_rdt_data_.isValid() && gmt_rdt_emul_.isValid() ) {
00648 typedef std::vector<L1MuGMTReadoutRecord>::const_iterator GmtRrIt;
00649
00650 std::vector<L1MuGMTReadoutRecord> gmt_rdt_data_bx = gmt_rdt_data_->getRecords();
00651 for(GmtRrIt igmtrr=gmt_rdt_data_bx.begin(); igmtrr!=gmt_rdt_data_bx.end(); igmtrr++) {
00652
00653 typedef std::vector<L1MuGMTExtendedCand>::const_iterator GmtECIt;
00654 std::vector<L1MuGMTExtendedCand> gmc;
00655 gmc = igmtrr->getGMTCands();
00656 for(GmtECIt iter1=gmc.begin(); iter1!=gmc.end(); iter1++) {
00657 L1MuGMTCand cand(iter1->getDataWord(),iter1->bx());
00658 cand.setPhiValue(iter1->phiValue());
00659 cand.setEtaValue(iter1->etaValue());
00660 cand.setPtValue (iter1->ptValue ());
00661 gmt_can_data_vec.push_back(cand);
00662 }
00663
00664 typedef L1MuRegionalCandCollection::const_iterator GmtRCIt;
00665 L1MuRegionalCandCollection rmc;
00666 rmc.clear();
00667 rmc = igmtrr->getDTBXCands();
00668 gmt_rdt_data_vec.insert(gmt_rdt_data_vec.end(),rmc.begin(),rmc.end());
00669 rmc.clear();
00670 rmc = igmtrr->getCSCCands();
00671 gmt_rdt_data_vec.insert(gmt_rdt_data_vec.end(),rmc.begin(),rmc.end());
00672 rmc.clear();
00673 rmc = igmtrr->getBrlRPCCands();
00674 gmt_rdt_data_vec.insert(gmt_rdt_data_vec.end(),rmc.begin(),rmc.end());
00675 rmc.clear();
00676 rmc = igmtrr->getFwdRPCCands();
00677 gmt_rdt_data_vec.insert(gmt_rdt_data_vec.end(),rmc.begin(),rmc.end());
00678 }
00679
00680 std::vector<L1MuGMTReadoutRecord> gmt_rdt_emul_bx = gmt_rdt_emul_->getRecords();
00681 for(GmtRrIt igmtrr=gmt_rdt_emul_bx.begin(); igmtrr!=gmt_rdt_emul_bx.end(); igmtrr++) {
00682
00683 typedef std::vector<L1MuGMTExtendedCand>::const_iterator GmtECIt;
00684 std::vector<L1MuGMTExtendedCand> gmc;
00685 gmc = igmtrr->getGMTCands();
00686 for(GmtECIt iter1=gmc.begin(); iter1!=gmc.end(); iter1++) {
00687 gmt_can_emul_vec.push_back(L1MuGMTCand(iter1->getDataWord(),iter1->bx()));
00688 }
00689
00690 typedef L1MuRegionalCandCollection::const_iterator GmtRCIt;
00691 L1MuRegionalCandCollection rmc;
00692 rmc.clear();
00693 rmc = igmtrr->getDTBXCands();
00694 gmt_rdt_emul_vec.insert(gmt_rdt_emul_vec.end(),rmc.begin(),rmc.end());
00695 rmc.clear();
00696 rmc = igmtrr->getCSCCands();
00697 gmt_rdt_emul_vec.insert(gmt_rdt_emul_vec.end(),rmc.begin(),rmc.end());
00698 rmc.clear();
00699 rmc = igmtrr->getBrlRPCCands();
00700 gmt_rdt_emul_vec.insert(gmt_rdt_emul_vec.end(),rmc.begin(),rmc.end());
00701 rmc.clear();
00702 rmc = igmtrr->getFwdRPCCands();
00703 gmt_rdt_emul_vec.insert(gmt_rdt_emul_vec.end(),rmc.begin(),rmc.end());
00704 }
00705 }
00706 gmt_rdt_data = &gmt_rdt_data_vec;
00707 gmt_rdt_emul = &gmt_rdt_emul_vec;
00708 gmt_can_data = &gmt_can_data_vec;
00709 gmt_can_emul = &gmt_can_emul_vec;
00710
00711
00712 edm::Handle<L1GlobalTriggerReadoutRecord> glt_rdt_data;
00713 edm::Handle<L1GlobalTriggerReadoutRecord> glt_rdt_emul;
00714 edm::Handle<L1GlobalTriggerEvmReadoutRecord> glt_evm_data;
00715 edm::Handle<L1GlobalTriggerEvmReadoutRecord> glt_evm_emul;
00716 edm::Handle<L1GlobalTriggerObjectMapRecord> glt_obj_data;
00717 edm::Handle<L1GlobalTriggerObjectMapRecord> glt_obj_emul;
00718 if(m_doSys[GLT]) {
00719 iEvent.getByLabel(m_DEsource[GLT][0], glt_rdt_data);
00720 iEvent.getByLabel(m_DEsource[GLT][1], glt_rdt_emul);
00721 iEvent.getByLabel(m_DEsource[GLT][0], glt_evm_data);
00722 iEvent.getByLabel(m_DEsource[GLT][1], glt_evm_emul);
00723 iEvent.getByLabel(m_DEsource[GLT][0], glt_obj_data);
00724 iEvent.getByLabel(m_DEsource[GLT][1], glt_obj_emul);
00725 }
00726
00728
00729
00730 bool isValidDE[DEnsys][2];
00731 for(int i=0; i<DEnsys; i++) for(int j=0; j<2; j++) isValidDE[i][j]=false;
00732
00733 isValidDE[ETP][0] = ecal_tp_data .isValid(); isValidDE[ETP][1] = ecal_tp_emul .isValid();
00734 isValidDE[HTP][0] = hcal_tp_data .isValid(); isValidDE[HTP][1] = hcal_tp_emul .isValid();
00735 isValidDE[RCT][0] = rct_em_data .isValid(); isValidDE[RCT][1] = rct_em_emul .isValid();
00736 isValidDE[RCT][0]&= rct_rgn_data .isValid(); isValidDE[RCT][1] = rct_rgn_emul .isValid();
00737 isValidDE[GCT][0] = gct_isolaem_data .isValid(); isValidDE[GCT][1] =gct_isolaem_emul .isValid();
00738 isValidDE[GCT][0]&= gct_noisoem_data .isValid(); isValidDE[GCT][1]&=gct_noisoem_emul .isValid();
00739 isValidDE[GCT][0]&= gct_cenjets_data .isValid(); isValidDE[GCT][1]&=gct_cenjets_emul .isValid();
00740 isValidDE[GCT][0]&= gct_forjets_data .isValid(); isValidDE[GCT][1]&=gct_forjets_emul .isValid();
00741 isValidDE[GCT][0]&= gct_taujets_data .isValid(); isValidDE[GCT][1]&=gct_taujets_emul .isValid();
00742 isValidDE[GCT][0]&= gct_etmiss_data .isValid(); isValidDE[GCT][1]&= gct_etmiss_emul .isValid();
00743 isValidDE[GCT][0]&= gct_ettota_data .isValid(); isValidDE[GCT][1]&= gct_ettota_emul .isValid();
00744 isValidDE[GCT][0]&= gct_htmiss_data .isValid(); isValidDE[GCT][1]&= gct_htmiss_emul .isValid();
00745 isValidDE[GCT][0]&= gct_hfring_data .isValid(); isValidDE[GCT][1]&= gct_hfring_emul .isValid();
00746 isValidDE[GCT][0]&= gct_hfbcnt_data .isValid(); isValidDE[GCT][1]&= gct_hfbcnt_emul .isValid();
00747
00748 isValidDE[DTP][0] = dtp_ph_data_.isValid(); isValidDE[DTP][1] = dtp_ph_emul_.isValid();
00749 isValidDE[DTP][0]&= dtp_th_data_.isValid(); isValidDE[DTP][1]&= dtp_th_emul_.isValid();
00750 isValidDE[DTF][0] = dtf_trk_data_.isValid(); isValidDE[DTF][1] = dtf_trk_emul_.isValid();
00751
00752 isValidDE[CTP][0] = ctp_lct_data_.isValid(); isValidDE[CTP][1] = ctp_lct_emul_.isValid();
00753 if (m_DEsource[CTP][0].label().find("tf") == std::string::npos) {
00754 isValidDE[CTP][0]&= ctp_ano_data_.isValid(); isValidDE[CTP][1]&= ctp_ano_emul_.isValid();
00755 isValidDE[CTP][0]&= ctp_cat_data_.isValid(); isValidDE[CTP][1]&= ctp_cat_emul_.isValid();
00756 }
00757 isValidDE[CTF][0] = ctf_data .isValid(); isValidDE[CTF][1] = ctf_emul .isValid();
00758 isValidDE[CTF][0]&= ctf_trk_data_ .isValid(); isValidDE[CTF][1]&= ctf_trk_emul_ .isValid();
00759
00760 isValidDE[RPC][0] = rpc_cen_data .isValid(); isValidDE[RPC][1] = rpc_cen_emul .isValid();
00761 isValidDE[RPC][0]&= rpc_for_data .isValid(); isValidDE[RPC][1]&= rpc_for_emul .isValid();
00762 isValidDE[LTC][0] = ltc_data .isValid(); isValidDE[LTC][1] = ltc_emul .isValid();
00763 isValidDE[GMT][0] = gmt_data .isValid(); isValidDE[GMT][1] = gmt_emul .isValid();
00764
00765 isValidDE[GLT][0] = glt_rdt_data .isValid(); isValidDE[GLT][1] = glt_rdt_emul .isValid();
00766
00767
00768
00769 bool isValid[DEnsys];
00770 for(int i=0; i<DEnsys; i++) {
00771 isValid[i]=true;
00772 for(int j=0; j<2; j++) {
00773 isValid[i] &= isValidDE[i][j];
00774 }
00775 }
00776
00777 if(verbose()) {
00778 std::cout << "L1Comparator sys isValid? (evt:" << nevt_ << ") ";
00779 std::cout << "\n\t&: ";
00780 for(int i=0; i<DEnsys; i++)
00781 std::cout << isValid[i] << " ";
00782 std::cout << "\n\td: ";
00783 for(int i=0; i<DEnsys; i++)
00784 std::cout << isValidDE[i][0] << " ";
00785 std::cout << "\n\te: ";
00786 for(int i=0; i<DEnsys; i++)
00787 std::cout << isValidDE[i][1] << " ";
00788 std::cout << std::endl;
00789 }
00790
00791
00792
00793
00794 if(verbose())
00795 std::cout << "L1Comparator start processing the collections.\n" << std::flush;
00796
00798 if(m_doSys[ETP]&&isValid[ETP]) process<EcalTrigPrimDigiCollection> ( ecal_tp_data, ecal_tp_emul, ETP,ECALtp);
00799 if(m_doSys[HTP]&&isValid[HTP]) process<HcalTrigPrimDigiCollection> ( hcal_tp_data, hcal_tp_emul, HTP,HCALtp);
00800 if(m_doSys[RCT]&&isValid[RCT]) process<L1CaloEmCollection> ( rct_em_data, rct_em_emul, RCT,RCTem);
00801 if(m_doSys[RCT]&&isValid[RCT]) process<L1CaloRegionCollection> ( rct_rgn_data, rct_rgn_emul, RCT,RCTrgn);
00802 if(m_doSys[GCT]&&isValid[GCT]) process<L1GctEmCandCollection> (gct_isolaem_data, gct_isolaem_emul, GCT,GCTisolaem);
00803 if(m_doSys[GCT]&&isValid[GCT]) process<L1GctEmCandCollection> (gct_noisoem_data, gct_noisoem_emul, GCT,GCTnoisoem);
00804 if(m_doSys[GCT]&&isValid[GCT]) process<L1GctJetCandCollection> (gct_cenjets_data, gct_cenjets_emul, GCT,GCTcenjets);
00805 if(m_doSys[GCT]&&isValid[GCT]) process<L1GctJetCandCollection> (gct_forjets_data, gct_forjets_emul, GCT,GCTforjets);
00806 if(m_doSys[GCT]&&isValid[GCT]) process<L1GctJetCandCollection> (gct_taujets_data, gct_taujets_emul, GCT,GCTtaujets);
00807 if(m_doSys[GCT]&&isValid[GCT]) process<L1GctEtHadCollection> ( gct_ht_data, gct_ht_emul, GCT,GCTethad);
00808 if(m_doSys[GCT]&&isValid[GCT]) process<L1GctEtMissCollection> ( gct_etmiss_data, gct_etmiss_emul, GCT,GCTetmiss);
00809 if(m_doSys[GCT]&&isValid[GCT]) process<L1GctEtTotalCollection> ( gct_ettota_data , gct_ettota_emul, GCT,GCTettot);
00810 if(m_doSys[GCT]&&isValid[GCT]) process<L1GctHtMissCollection> ( gct_htmiss_data, gct_htmiss_emul, GCT,GCThtmiss);
00811 if(m_doSys[GCT]&&isValid[GCT]) process<L1GctHFRingEtSumsCollection> ( gct_hfring_data, gct_hfring_emul, GCT,GCThfring);
00812 if(m_doSys[GCT]&&isValid[GCT]) process<L1GctHFBitCountsCollection> ( gct_hfbcnt_data, gct_hfbcnt_emul, GCT,GCThfbit);
00813
00814 if(m_doSys[DTP]&&isValid[DTP]) process<L1MuDTChambPhDigiCollection> ( dtp_ph_data, dtp_ph_emul, DTP,DTtpPh);
00815 if(m_doSys[DTP]&&isValid[DTP]) process<L1MuDTChambThDigiCollection> ( dtp_th_data, dtp_th_emul, DTP,DTtpTh);
00816 if(m_doSys[DTF]&&isValid[DTF]) process<L1MuRegionalCandCollection> ( dtf_data, dtf_emul, DTF,DTtf);
00817 if(m_doSys[DTF]&&isValid[DTF]) process<L1MuRegionalCandCollection> ( dtf_trk_data, dtf_trk_emul, DTF,DTtftrk);
00818 if(m_DEsource[CTP][0].label().find("tf") == std::string::npos) {
00819 if(m_doSys[CTP]&&isValid[CTP]) process<CSCALCTDigiCollection_> ( ctp_ano_data, ctp_ano_emul, CTP,CSCtpa);
00820 if(m_doSys[CTP]&&isValid[CTP]) process<CSCCLCTDigiCollection_> ( ctp_cat_data, ctp_cat_emul, CTP,CSCtpc);
00821 }
00822 if(m_doSys[CTP]&&isValid[CTP]) process<CSCCorrelatedLCTDigiCollection_>( ctp_lct_data, ctp_lct_emul, CTP,CSCtpl);
00823 if(m_doSys[CTF]&&isValid[CTF]) process<L1MuRegionalCandCollection> ( ctf_data, ctf_emul, CTF,CSCtf);
00824 if(m_doSys[CTF]&&isValid[CTF]) process<CSCCorrelatedLCTDigiCollection_>( ctf_trk_data, ctf_trk_emul, CTF,CSCtftrk);
00825
00826 if(m_doSys[CTF]&&isValid[CTF]) process<L1CSCSPStatusDigiCollection_> ( ctf_sta_data, ctf_sta_emul, CTF,CSCtfsta);
00827 if(m_doSys[RPC]&&isValid[RPC]) process<L1MuRegionalCandCollection> ( rpc_cen_data, rpc_cen_emul, RPC,RPCcen);
00828 if(m_doSys[RPC]&&isValid[RPC]) process<L1MuRegionalCandCollection> ( rpc_for_data, rpc_for_emul, RPC,RPCfor);
00829 if(m_doSys[LTC]&&isValid[LTC]) process<LTCDigiCollection> ( ltc_data, ltc_emul, LTC,LTCi);
00830 if(m_doSys[GMT]&&isValid[GMT]) process<L1MuGMTCandCollection> ( gmt_data, gmt_emul, GMT,GMTmain);
00831 if(m_doSys[GMT]&&isValid[GMT]) process<L1MuRegionalCandCollection> ( gmt_rdt_data, gmt_rdt_emul, GMT,GMTrdt);
00832 if(m_doSys[GMT]&&isValid[GMT]) process<L1MuGMTCandCollection> ( gmt_can_data, gmt_can_emul, GMT,GMTcnd);
00833
00834
00835 GltDEDigi gltdigimon;
00836
00837 if(m_doSys[GLT] && isValid[GLT] ) {
00838
00840 bool prt = false;
00841 if(!m_dumpMode)
00842 prt = false;
00843 else if(m_dumpMode==-1)
00844 prt=true;
00845
00846 if(dumpEvent_ && prt) {
00847 m_dumpFile << "\nEntry: " << nevt_
00848 << " (event:" << evtNum_
00849 << " | run:" << runNum_
00850 << ")\n" << std::flush;
00851 dumpEvent_=false;
00852 }
00853
00854 m_dumpFile << "\n GT...\n";
00855
00856 if(glt_rdt_data.isValid() && glt_rdt_emul.isValid()) {
00857
00858
00859 bool globalDBit[2];
00860 std::vector<bool> gltDecBits[2], gltTchBits[2];
00861 globalDBit[0] = glt_rdt_data->decision();
00862 globalDBit[1] = glt_rdt_emul->decision();
00863 gltDecBits[0] = glt_rdt_data->decisionWord();
00864 gltDecBits[1] = glt_rdt_emul->decisionWord();
00865
00866
00867 gltTchBits[0] = glt_rdt_data->technicalTriggerWord();
00868 gltTchBits[1] = glt_rdt_emul->technicalTriggerWord();
00869 gltdigimon.set(globalDBit, gltDecBits, gltTchBits);
00870
00871 DEncand[GLT][0]=1; DEncand[GLT][1]=1;
00872 DEmatchEvt[GLT] = compareCollections(glt_rdt_data, glt_rdt_emul);
00873 }
00874
00876 if(glt_evm_data.isValid() && glt_evm_emul.isValid())
00877 DEmatchEvt[GLT] &= compareCollections(glt_evm_data, glt_evm_emul);
00878 if(glt_obj_data.isValid() && glt_obj_emul.isValid())
00879 DEmatchEvt[GLT] &= compareCollections(glt_obj_data, glt_obj_emul);
00880
00881 char ok[10];
00882 char dumptofile[1000];
00883 if(DEmatchEvt[GLT]) sprintf(ok,"successful");
00884 else sprintf(ok,"failed");
00885 sprintf(dumptofile," ...GT data and emulator comparison: %s\n", ok);
00886 m_dumpFile<<dumptofile;
00887 }
00888
00889 if(verbose())
00890 std::cout << "L1Comparator done processing all collections.\n" << std::flush;
00891
00892 if(verbose()) {
00893 std::cout << "[L1Comparator] sys match? << evt." << nevt_ << ": ";
00894 for(int i=0; i<DEnsys; i++)
00895 std::cout << DEmatchEvt[i] << " ";
00896 std::cout << std::endl;
00897 }
00898
00899
00900
00901
00902 bool evt_match = true;
00903 for(int i=0; i<DEnsys; i++)
00904 evt_match &= DEmatchEvt[i];
00905
00906
00907
00908
00909
00910
00911
00912
00913
00914
00915
00916 m_match &= evt_match;
00917 m_dumpFile << std::flush;
00918
00919
00920 if(m_dedigis.size()==0) {
00921 if(verbose())
00922 std::cout << "\n [L1Comparator] adding empty collection to DErecord\n";
00923 m_dedigis.push_back(L1DataEmulDigi());
00924 }
00925
00926
00927 std::auto_ptr<L1DataEmulRecord> record
00928 (new L1DataEmulRecord(evt_match,m_doSys,DEmatchEvt,DEncand,m_dedigis, gltdigimon));
00929 if(verbose()) {
00930 std::cout << "\n [L1Comparator] printing DErecord"
00931 << "(entry:"<< nevt_
00932 << "|evt:" << evtNum_
00933 << "|run:" << runNum_
00934 << "):\n" << std::flush;
00935 std::cout << *record
00936 << "\n" << std::flush;
00937 }
00938
00939 iEvent.put(record);
00940
00942 bool dorawdata = false;
00943 if(dorawdata) {
00944 edm::Handle<FEDRawDataCollection> raw_fedcoll_data;
00945 edm::Handle<FEDRawDataCollection> raw_fedcoll_emul;
00946 iEvent.getByLabel(m_FEDsource[0], raw_fedcoll_data);
00947 iEvent.getByLabel(m_FEDsource[1], raw_fedcoll_emul);
00948 bool rawval=true;
00949 rawval &= raw_fedcoll_data.isValid();
00950 rawval &= raw_fedcoll_emul.isValid();
00951 if(rawval)
00952 compareFedRawCollections(raw_fedcoll_data,raw_fedcoll_emul, m_fedId);
00953 }
00954
00955 if(verbose())
00956 std::cout << "L1comparator::analize() end. " << nevt_ << std::endl;
00957
00958 }
00959
00960
00961 template <class T>
00962 void L1Comparator::process(T const* data, T const* emul, const int sys, const int cid) {
00963
00964 if(verbose())
00965 std::cout << "L1Comparator::process -ing system:" << sys
00966 << " (" << SystLabel[sys] << "), data type " << cid
00967 << "...\n" << std::flush;
00968 if(verbose())
00969 std::cout << "L1Comparator::process debug "
00970 << " (size " << data->size() << "," <<emul->size() << ")"
00971 << ".\n" << std::flush;
00972
00974 bool prt = false;
00975 if(!m_dumpMode)
00976 prt = false;
00977 else if(m_dumpMode==-1)
00978 prt=true;
00979 else if(m_dumpMode>0) {
00980 DEcompare<T> tmp(data,emul);
00981 if(tmp.get_ncand(0)==0 && tmp.get_ncand(1)==0)
00982 prt=false;
00983 else
00984 prt = !tmp.do_compare(m_dumpFile,0);
00985 }
00986
00987
00988 DEcompare<T> cmp(data,emul);
00989
00990 int ndata = cmp.get_ncand(0);
00991 int nemul = cmp.get_ncand(1);
00992
00993 if(verbose())
00994 std::cout << "L1Comparator::process "
00995 << " system:" << SystLabel[sys] << "(id " << sys << ")"
00996 << " type:" << cmp.GetName(0) << "(" << cmp.de_type() << ")"
00997 << " ndata:" << ndata
00998 << " nemul:" << nemul
00999 << " (size " << data->size() << "," <<emul->size() << ")"
01000 << ".\n" << std::flush;
01001
01002 if(ndata==0&&nemul==0) {
01003 if(verbose())
01004 std::cout << "L1Comparator::process "
01005 << "empty collections -- exiting!\n" << std::flush;
01006 return;
01007 }
01008
01009 m_dumpFile << std::setiosflags(std::ios::showpoint | std::ios::fixed
01010 | std::ios::right | std::ios::adjustfield);
01011 std::cout << std::setiosflags(std::ios::showpoint | std::ios::fixed
01012 | std::ios::right | std::ios::adjustfield);
01013
01014 if(dumpEvent_ && prt ) {
01015 m_dumpFile << "\nEntry: " << nevt_
01016 << " (event:" << evtNum_
01017 << " | run:" << runNum_
01018 << ")\n" << std::flush;
01019 dumpEvent_=false;
01020 }
01021
01022 if(prt)
01023 m_dumpFile << "\n sys:" << SystLabel[sys]
01024 << " (" << sys << "), type:" << cid
01025 << " ...\n";
01026
01027 if(verbose())
01028 std::cout << "L1Comparator::process print:\n" << std::flush
01029 << cmp.print()
01030 << std::flush;
01031
01033 DEmatchEvt[sys] &= cmp.do_compare(m_dumpFile,m_dumpMode);
01034
01036 L1DEDigiCollection dg = cmp.getDEDigis();
01037
01038 if(verbose())
01039 for(L1DEDigiCollection::iterator it=dg.begin(); it!=dg.end();it++)
01040 std::cout << *it << "\n";
01041
01043 for(L1DEDigiCollection::iterator it=dg.begin(); it!=dg.end();it++)
01044 it->setSid(sys);
01046 for(L1DEDigiCollection::iterator it=dg.begin(); it!=dg.end();it++)
01047 it->setCid(cid);
01048
01050 m_dedigis.insert(m_dedigis.end(), dg.begin(), dg.end());
01051 for(int i=0; i<2; i++)
01052 DEncand[sys][i] += cmp.get_ncand(i);
01053
01054 if(verbose())
01055 std::cout << "L1Comparator::process "
01056 << " system:" << SystLabel[sys]
01057 << " type:" << cmp.GetName(0)
01058 << " ndata:" << DEncand[sys][0]
01059 << " nemul:" << DEncand[sys][1]
01060 << " (size " << data->size() << "," <<emul->size() << ")"
01061 << " ndigis:" << dg.size()
01062 << " agree? " << DEmatchEvt[sys]
01063 << std::endl;
01064
01065 if(verbose())
01066 std::cout << "L1Comparator::process -ing system:"
01067 << sys << " (" << SystLabel[sys] << ")...done.\n"
01068 << std::flush;
01069 }
01070
01071
01072
01073 bool
01074 L1Comparator::compareCollections(edm::Handle<L1GlobalTriggerReadoutRecord> data,
01075 edm::Handle<L1GlobalTriggerReadoutRecord> emul) {
01076
01077 if(verbose())
01078 std::cout << "L1Comparator -- result of GT embedded comparison.\n"
01079 << "L1GlobalTriggerReadoutRecord:: data and emulator agree? "
01080 << ((*data==*emul)?"yes":"no")
01081 << std::endl;
01082
01083 m_dumpFile << "\n L1GlobalTriggerReadoutRecord candidates...\n";
01084
01085 bool thematch = true;
01086
01087 thematch &= (*data==*emul);
01088
01089 bool match = thematch;
01090
01091 if(m_dumpMode==0 && match)
01092 return match;
01093
01094
01095
01096
01097
01098 std::auto_ptr<L1GlobalTriggerReadoutRecord>
01099 data_( new L1GlobalTriggerReadoutRecord(*(data.product())));
01100 std::auto_ptr<L1GlobalTriggerReadoutRecord>
01101 emul_( new L1GlobalTriggerReadoutRecord(*(emul.product())));
01102
01103 match = true;
01104 m_dumpFile << "\tmatch stage: ";
01105 match &= (data->gtfeWord() == emul->gtfeWord() );
01106 m_dumpFile << " gtfeWord:" << match;
01107 match &= (data->gtFdlWord() == emul->gtFdlWord() );
01108 m_dumpFile << " gtFdlWord:" << match;
01109 match &= (data->muCollectionRefProd() == emul->muCollectionRefProd());
01110 m_dumpFile << " muCollectionRefProd:" << match << "\n";
01111 boost::uint16_t dt_psb_bid=0, em_psb_bid=0;
01112 size_t npsbw = (data_->gtPsbVector().size()>emul_->gtPsbVector().size())?
01113 emul_->gtPsbVector().size():data_->gtPsbVector().size();
01114 for(int idx=0; idx<(int)npsbw; idx++) {
01115 if(data_->gtPsbVector().at(idx) != emul_->gtPsbVector().at(idx) ) {
01116
01117 dt_psb_bid = data_->gtPsbVector().at(idx).boardId();
01118 em_psb_bid = emul_->gtPsbVector().at(idx).boardId();
01119 break;
01120 }
01121 }
01122 match &= (data->gtPsbWord(dt_psb_bid) == emul->gtPsbWord(em_psb_bid) );
01123
01124
01125
01126
01127
01128
01129
01130 m_dumpFile << " gtPsbWord("<<dt_psb_bid<<","<<em_psb_bid<<"):" << match << "\n";
01131
01133
01134
01135 m_dumpFile << "\n\tGlobal decision: "
01136 << data->decision() << " (data) "
01137 << emul->decision() << " (emul) "
01138 << std::endl;
01139
01140
01141 m_dumpFile << "\n\tDecisionWord (bits: 63:0, 127:64)";
01142 int nbitword = 64;
01143 std::vector<bool> data_gtword = data->decisionWord();
01144 std::vector<bool> emul_gtword = emul->decisionWord();
01145 m_dumpFile << "\n\tdata: ";
01146 for(int i=0; i<nbitword; i++) {
01147 if (i%16==0) m_dumpFile << " ";
01148 m_dumpFile << (data_gtword.at(nbitword-1-i) ? '1' : '0');
01149 }
01150 m_dumpFile << "\n\t ";
01151 for(int i=0; i<nbitword; i++) {
01152 if (i%16==0) m_dumpFile << " ";
01153 m_dumpFile << (data_gtword.at(nbitword*2-1-i) ? '1' : '0');
01154 }
01155 m_dumpFile << "\n\temul: ";
01156 for(int i=0; i<nbitword; i++) {
01157 if (i%16==0) m_dumpFile << " ";
01158 m_dumpFile << (emul_gtword.at(nbitword-1-i) ? '1' : '0');
01159 }
01160 m_dumpFile << "\n\t ";
01161 for(int i=0; i<nbitword; i++) {
01162 if (i%16==0) m_dumpFile << " ";
01163 m_dumpFile << (emul_gtword.at(nbitword*2-1-i) ? '1' : '0');
01164 }
01165 m_dumpFile << std::endl;
01166
01167 m_dumpFile << "\n\tDecisionWordExtended (bits: 0:63)";
01168 std::vector<bool> data_decwext = data->gtFdlWord().gtDecisionWordExtended();
01169 std::vector<bool> emul_decwext = emul->gtFdlWord().gtDecisionWordExtended();
01170 m_dumpFile << "\n\tdata: ";
01171 for(int i=0; i<nbitword; i++) {
01172 if (i%16==0) m_dumpFile << " ";
01173 m_dumpFile << (data_decwext.at(nbitword-1-i) ? '1' : '0');
01174 }
01175 m_dumpFile << "\n\temul: ";
01176 for(int i=0; i<nbitword; i++) {
01177 if (i%16==0) m_dumpFile << " ";
01178 m_dumpFile << (emul_decwext.at(nbitword-1-i) ? '1' : '0');
01179 }
01180 m_dumpFile << std::endl;
01181
01182 m_dumpFile << "\n\tTechnical triggers (bits: 0:63)";
01183 std::vector<bool> data_fdlttw = data->gtFdlWord().gtTechnicalTriggerWord();
01184 std::vector<bool> emul_fdlttw = emul->gtFdlWord().gtTechnicalTriggerWord();
01185 assert((int)data_fdlttw.size()==nbitword);
01186 m_dumpFile << "\n\tdata: ";
01187 for(int i=0; i<nbitword; i++) {
01188 if (i%16==0) m_dumpFile << " ";
01189 m_dumpFile << (data_fdlttw.at(nbitword-1-i) ? '1' : '0');
01190 }
01191 m_dumpFile << "\n\temul: ";
01192 for(int i=0; i<nbitword; i++) {
01193 if (i%16==0) m_dumpFile << " ";
01194 m_dumpFile << (emul_fdlttw.at(nbitword-1-i) ? '1' : '0');
01195 }
01196 m_dumpFile << std::endl;
01197
01198 m_dumpFile << "\n\tL1GtFdlWord";
01199 m_dumpFile << "\n\tdata: "
01200 << " BoardId:" << data->gtFdlWord().boardId()
01201 << " BxInEvent:" << data->gtFdlWord().bxInEvent()
01202 << " BxNr:" << data->gtFdlWord().bxNr()
01203 << " EventNr:" << data->gtFdlWord().eventNr()
01204 << " NoAlgo:" << data->gtFdlWord().noAlgo()
01205 << " FinalOR:" << data->gtFdlWord().finalOR()
01206 << " LocalBxNr:" << data->gtFdlWord().localBxNr();
01207 m_dumpFile << "\n\temul: "
01208 << " BoardId:" << emul->gtFdlWord().boardId()
01209 << " BxInEvent:" << emul->gtFdlWord().bxInEvent()
01210 << " BxNr:" << emul->gtFdlWord().bxNr()
01211 << " EventNr:" << emul->gtFdlWord().eventNr()
01212 << " NoAlgo:" << emul->gtFdlWord().noAlgo()
01213 << " FinalOR:" << emul->gtFdlWord().finalOR()
01214 << " LocalBxNr:" << emul->gtFdlWord().localBxNr()
01215 << std::endl;
01216
01217 m_dumpFile << "\n\tL1GtfeWord";
01218 m_dumpFile << "\n\tdata: "
01219 << " BoardId:" << data->gtfeWord().boardId()
01220 << " RecordLength:" << data->gtfeWord().recordLength()
01221 << " BxNr:" << data->gtfeWord().bxNr()
01222 << " SetupVersion:" << data->gtfeWord().setupVersion()
01223 << " ActiveBoards:" << data->gtfeWord().activeBoards()
01224 << " TotalTriggerNr:" << data->gtfeWord().totalTriggerNr();
01225 m_dumpFile << "\n\temul: "
01226 << " BoardId:" << emul->gtfeWord().boardId()
01227 << " RecordLength:" << emul->gtfeWord().recordLength()
01228 << " BxNr:" << emul->gtfeWord().bxNr()
01229 << " SetupVersion:" << emul->gtfeWord().setupVersion()
01230 << " ActiveBoards:" << emul->gtfeWord().activeBoards()
01231 << " TotalTriggerNr:" << emul->gtfeWord().totalTriggerNr()
01232 << std::endl;
01233
01234
01235 m_dumpFile << "\n\tgtPsbWord";
01236 m_dumpFile << "\n\tdata: "
01237 << " Board Id:" << data->gtPsbWord(dt_psb_bid).boardId()
01238 << " BxInEvent:" << data->gtPsbWord(dt_psb_bid).bxInEvent()
01239 << " BxNr:" << data->gtPsbWord(dt_psb_bid).bxNr()
01240 << " LocalBxNr:" << data->gtPsbWord(dt_psb_bid).localBxNr()
01241 << " EventNr:" << data->gtPsbWord(dt_psb_bid).eventNr();
01242 m_dumpFile << "\n\temul: "
01243 << " Board Id:" << emul->gtPsbWord(em_psb_bid).boardId()
01244 << " BxInEvent:" << emul->gtPsbWord(em_psb_bid).bxInEvent()
01245 << " BxNr:" << emul->gtPsbWord(em_psb_bid).bxNr()
01246 << " LocalBxNr:" << emul->gtPsbWord(em_psb_bid).localBxNr()
01247 << " EventNr:" << emul->gtPsbWord(em_psb_bid).eventNr()
01248 << std::endl;
01249
01250
01251
01252
01253
01254 m_dumpFile << "\n\tA_Data_CH7:0";
01255 m_dumpFile << "\n\tdata: ";
01256 for (int i=0; i<8; ++i)
01257 m_dumpFile << data->gtPsbWord(dt_psb_bid).aData(7-i) << " ";
01258 m_dumpFile << "\n\temul: ";
01259 for (int i=0; i<8; ++i)
01260 m_dumpFile << emul->gtPsbWord(em_psb_bid).aData(7-i) << " ";
01261 m_dumpFile << std::endl;
01262
01263 m_dumpFile << "\n\tA_Data_CH7:0";
01264 m_dumpFile << "\n\tdata: ";
01265 for (int i=0; i<8; ++i)
01266 m_dumpFile << data->gtPsbWord(dt_psb_bid).bData(7-i) << " ";
01267 m_dumpFile << "\n\temul: ";
01268 for (int i=0; i<8; ++i)
01269 m_dumpFile << emul->gtPsbWord(em_psb_bid).bData(7-i) << " ";
01270 m_dumpFile << "\n" << std::endl;
01271
01272
01274
01276 if(false) {
01277 m_dumpFile << "---debug: print full gt record---";
01278 m_dumpFile << "\n\tdata: ";
01279 data->print(m_dumpFile);
01280 m_dumpFile << "\n\temul: ";
01281 emul->print(m_dumpFile);
01282 m_dumpFile << "\n";
01283 m_dumpFile << "---debug: print full gt record Done.---\n\n";
01284 }
01285
01286 char ok[10];
01287 if(match) sprintf(ok,"successful");
01288 else sprintf(ok,"failed");
01289 m_dumpFile << " ...L1GlobalTriggerReadoutRecord data and emulator comparison: "
01290 << ok << std::endl;
01291
01292 return thematch;
01293 }
01294
01295
01296 bool
01297 L1Comparator::compareCollections(edm::Handle<L1GlobalTriggerEvmReadoutRecord> data,
01298 edm::Handle<L1GlobalTriggerEvmReadoutRecord> emul) {
01299
01300 if(verbose())
01301 std::cout << "L1Comparator -- result of GT embedded comparison.\n"
01302 << "L1GlobalTriggerEvmReadoutRecord data and emulator agree? "
01303 << ((*data==*emul)?"yes":"no")
01304 << std::endl;
01305
01306 m_dumpFile << "\n L1GlobalTriggerEvmReadoutRecord candidates...\n";
01307
01308 bool match = true;
01309 match &= (*data==*emul);
01310
01311 if(m_dumpMode==0 && match)
01312 return match;
01313
01314
01315 m_dumpFile << "\n\tGlobal decision: "
01316 << data->decision() << " (data) "
01317 << emul->decision() << " (emul) "
01318 << std::endl;
01319
01320
01321 m_dumpFile << "\n\tDecisionWord (bits: 0:63, 127:64)";
01322 int nbitword = 64;
01323 std::vector<bool> data_gtword = data->decisionWord();
01324 std::vector<bool> emul_gtword = emul->decisionWord();
01325 m_dumpFile << "\n\tdata: ";
01326 for(int i=0; i<nbitword; i++) {
01327 if (i%16==0) m_dumpFile << " ";
01328 m_dumpFile << (data_gtword.at(nbitword-1-i) ? '1' : '0');
01329 }
01330 m_dumpFile << "\n\t ";
01331 for(int i=0; i<nbitword; i++) {
01332 if (i%16==0) m_dumpFile << " ";
01333 m_dumpFile << (data_gtword.at(nbitword*2-1-i) ? '1' : '0');
01334 }
01335 m_dumpFile << "\n\temul: ";
01336 for(int i=0; i<nbitword; i++) {
01337 if (i%16==0) m_dumpFile << " ";
01338 m_dumpFile << (emul_gtword.at(nbitword-1-i) ? '1' : '0');
01339 }
01340 m_dumpFile << "\n\t ";
01341 for(int i=0; i<nbitword; i++) {
01342 if (i%16==0) m_dumpFile << " ";
01343 m_dumpFile << (emul_gtword.at(nbitword*2-1-i) ? '1' : '0');
01344 }
01345 m_dumpFile << std::endl;
01346
01347 m_dumpFile << "\n\tDecisionWordExtended (bits: 0:63)";
01348 std::vector<bool> data_decwext = data->gtFdlWord().gtDecisionWordExtended();
01349 std::vector<bool> emul_decwext = emul->gtFdlWord().gtDecisionWordExtended();
01350 m_dumpFile << "\n\tdata: ";
01351 for(int i=0; i<nbitword; i++) {
01352 if (i%16==0) m_dumpFile << " ";
01353 m_dumpFile << (data_decwext.at(nbitword-1-i) ? '1' : '0');
01354 }
01355 m_dumpFile << "\n\temul: ";
01356 for(int i=0; i<nbitword; i++) {
01357 if (i%16==0) m_dumpFile << " ";
01358 m_dumpFile << (emul_decwext.at(nbitword-1-i) ? '1' : '0');
01359 }
01360 m_dumpFile << std::endl;
01361
01362 m_dumpFile << "\n\tTechnical triggers (bits: 0:63)";
01363 std::vector<bool> data_fdlttw = data->gtFdlWord().gtTechnicalTriggerWord();
01364 std::vector<bool> emul_fdlttw = emul->gtFdlWord().gtTechnicalTriggerWord();
01365 assert((int)data_fdlttw.size()==nbitword);
01366 m_dumpFile << "\n\tdata: ";
01367 for(int i=0; i<nbitword; i++) {
01368 if (i%16==0) m_dumpFile << " ";
01369 m_dumpFile << (data_fdlttw.at(nbitword-1-i) ? '1' : '0');
01370 }
01371 m_dumpFile << "\n\temul: ";
01372 for(int i=0; i<nbitword; i++) {
01373 if (i%16==0) m_dumpFile << " ";
01374 m_dumpFile << (emul_fdlttw.at(nbitword-1-i) ? '1' : '0');
01375 }
01376 m_dumpFile << std::endl;
01377
01378 m_dumpFile << "\n\tL1GtFdlWord";
01379 m_dumpFile << "\n\tdata: "
01380 << " BoardId:" << data->gtFdlWord().boardId()
01381 << " BxInEvent:" << data->gtFdlWord().bxInEvent()
01382 << " BxNr:" << data->gtFdlWord().bxNr()
01383 << " EventNr:" << data->gtFdlWord().eventNr()
01384 << " NoAlgo:" << data->gtFdlWord().noAlgo()
01385 << " FinalOR:" << data->gtFdlWord().finalOR()
01386 << " LocalBxNr:" << data->gtFdlWord().localBxNr();
01387 m_dumpFile << "\n\temul: "
01388 << " BoardId:" << emul->gtFdlWord().boardId()
01389 << " BxInEvent:" << emul->gtFdlWord().bxInEvent()
01390 << " BxNr:" << emul->gtFdlWord().bxNr()
01391 << " EventNr:" << emul->gtFdlWord().eventNr()
01392 << " NoAlgo:" << emul->gtFdlWord().noAlgo()
01393 << " FinalOR:" << emul->gtFdlWord().finalOR()
01394 << " LocalBxNr:" << emul->gtFdlWord().localBxNr()
01395 << std::endl;
01396
01397 m_dumpFile << "\n\tL1GtfeWord";
01398 m_dumpFile << "\n\tdata: "
01399 << " BoardId:" << data->gtfeWord().boardId()
01400 << " RecordLength:" << data->gtfeWord().recordLength()
01401 << " BxNr:" << data->gtfeWord().bxNr()
01402 << " SetupVersion:" << data->gtfeWord().setupVersion()
01403 << " ActiveBoards:" << data->gtfeWord().activeBoards()
01404 << " TotalTriggerNr:" << data->gtfeWord().totalTriggerNr();
01405 m_dumpFile << "\n\temul: "
01406 << " BoardId:" << emul->gtfeWord().boardId()
01407 << " RecordLength:" << emul->gtfeWord().recordLength()
01408 << " BxNr:" << emul->gtfeWord().bxNr()
01409 << " SetupVersion:" << emul->gtfeWord().setupVersion()
01410 << " ActiveBoards:" << emul->gtfeWord().activeBoards()
01411 << " TotalTriggerNr:" << emul->gtfeWord().totalTriggerNr()
01412 << std::endl;
01413
01414
01415 m_dumpFile << "\n\ttcsWord";
01416 m_dumpFile << "\n\tdata:"
01417 << " DaqNr:" << data->tcsWord().daqNr()
01418 << " TriggerType:" << data->tcsWord().triggerType()
01419 << " Status:" << data->tcsWord().status()
01420 << " BxNr:" << data->tcsWord().bxNr()
01421 << " PartTrigNr:" << data->tcsWord().partTrigNr()
01422 << " EventNr:" << data->tcsWord().eventNr() << "\n\t"
01423 << " AssignedPartitions:" << data->tcsWord().assignedPartitions()
01424 << " PartRunNr:" << data->tcsWord().partTrigNr()
01425 << " OrbitNr:" << data->tcsWord().orbitNr();
01426 m_dumpFile << "\n\temul:"
01427 << " DaqNr:" << emul->tcsWord().daqNr()
01428 << " TriggerType:" << emul->tcsWord().triggerType()
01429 << " Status:" << emul->tcsWord().status()
01430 << " BxNr:" << emul->tcsWord().bxNr()
01431 << " PartTrigNr:" << emul->tcsWord().partTrigNr()
01432 << " EventNr:" << emul->tcsWord().eventNr() << "\n\t"
01433 << " AssignedPartitions:" << emul->tcsWord().assignedPartitions()
01434 << " PartRunNr:" << emul->tcsWord().partTrigNr()
01435 << " OrbitNr:" << emul->tcsWord().orbitNr()
01436 << "\n" << std::endl;
01437
01438 char ok[10];
01439 if(match) sprintf(ok,"successful");
01440 else sprintf(ok,"failed");
01441 m_dumpFile << " ...L1GlobalTriggerEvmReadoutRecord data and emulator comparison: "
01442 << ok << std::endl;
01443
01444 return match;
01445 }
01446
01447
01448 bool
01449 L1Comparator::compareCollections(edm::Handle<L1GlobalTriggerObjectMapRecord> data,
01450 edm::Handle<L1GlobalTriggerObjectMapRecord> emul) {
01451
01452 m_dumpFile << "\n L1GlobalTriggerObjectMapRecord candidates...\n";
01453
01454 bool match = true;
01455
01456
01457 const std::vector<L1GlobalTriggerObjectMap>& data_ovec = data->gtObjectMap();
01458 const std::vector<L1GlobalTriggerObjectMap>& emul_ovec = emul->gtObjectMap();
01459
01460 for(std::vector<L1GtLogicParser::OperandToken>::size_type idx=0; idx<data_ovec.size(); idx++) {
01461 match &= ( data_ovec.at(idx).algoName() == emul_ovec.at(idx).algoName() );
01462 match &= ( data_ovec.at(idx).algoBitNumber() == emul_ovec.at(idx).algoBitNumber() );
01463 match &= ( data_ovec.at(idx).algoGtlResult() == emul_ovec.at(idx).algoGtlResult() );
01464 match &= ( data_ovec.at(idx).combinationVector() == emul_ovec.at(idx).combinationVector() );
01465 match &= ( data_ovec.at(idx).operandTokenVector().size()==emul_ovec.at(idx).operandTokenVector().size());
01466 if(match) {
01467 for(std::vector<L1GtLogicParser::OperandToken>::size_type i=0; i<data_ovec.at(idx).operandTokenVector().size(); i++) {
01468 match &= ( data_ovec.at(idx).operandTokenVector().at(i).tokenName ==
01469 emul_ovec.at(idx).operandTokenVector().at(i).tokenName );
01470 match &= ( data_ovec.at(idx).operandTokenVector().at(i).tokenNumber ==
01471 emul_ovec.at(idx).operandTokenVector().at(i).tokenNumber );
01472 match &= ( data_ovec.at(idx).operandTokenVector().at(i).tokenResult ==
01473 emul_ovec.at(idx).operandTokenVector().at(i).tokenResult );
01474 }
01475 }
01476 }
01477
01478 if(m_dumpMode==0 && match)
01479 return match;
01480
01481
01482 int idx = 0;
01483 m_dumpFile << "\n\tL1GlobalTriggerObjectMap";
01484 m_dumpFile << "\n\tdata: "
01485 << " algorithmName:" << data_ovec.at(idx).algoName()
01486 << " Bitnumber:" << data_ovec.at(idx).algoBitNumber()
01487 << " GTLresult:" << data_ovec.at(idx).algoGtlResult()
01488 << " combinationVectorSize:" << data_ovec.at(idx).combinationVector().size()
01489 << " operandTokenVector:" << data_ovec.at(idx).operandTokenVector().size();
01490 m_dumpFile << "\n\temul: "
01491 << " algorithmName:" << emul_ovec.at(idx).algoName()
01492 << " Bitnumber:" << emul_ovec.at(idx).algoBitNumber()
01493 << " GTLresult:" << emul_ovec.at(idx).algoGtlResult()
01494 << " combinationVectorSize:" << emul_ovec.at(idx).combinationVector().size()
01495 << " operandTokenVector:" << emul_ovec.at(idx).operandTokenVector().size()
01496 << "\n" << std::endl;
01497
01498 char ok[10];
01499 if(match) sprintf(ok,"successful");
01500 else sprintf(ok,"failed");
01501 m_dumpFile << " ...L1GlobalTriggerObjectMapRecord data and emulator comparison: "
01502 << ok << std::endl;
01503
01504 return match;
01505 }
01506
01507
01508 bool
01509 L1Comparator::compareFedRawCollections(edm::Handle<FEDRawDataCollection> data,
01510 edm::Handle<FEDRawDataCollection> emul, int fedId) {
01511 if(verbose())
01512 std::cout << "[L1Comparator] fedraw start processing :" << std::endl << std::flush;
01513 if(dumpEvent_) {
01514 m_dumpFile << "\nEvent: " << nevt_ << std::endl;
01515 dumpEvent_=false;
01516 }
01517 m_dumpFile << "\n FEDRawData candidates...\n";
01518 const FEDRawData& raw_fed_data = data->FEDData(fedId);
01519 const FEDRawData& raw_fed_emul = emul->FEDData(fedId);
01520 bool raw_match=true;
01521 for(int i=0; i!=(int)raw_fed_data.size();i++) {
01522 raw_match &= ( raw_fed_data.data()[i] == raw_fed_emul.data()[i] );
01523 }
01524 unsigned long dd = 0, de = 0;
01525 for(int i=0; i<(int)raw_fed_data.size()/4;i++) {
01526 dd=0; de=0;
01527 for(int j=0; j<4; j++)
01528 dd += ((raw_fed_data.data()[i*4+j]&0xff)<<(8*j));
01529 for(int j=0; j<4; j++)
01530 de += ((raw_fed_emul.data()[i*4+j]&0xff)<<(8*j));
01531 if(m_dumpMode==-1 || (m_dumpMode==1 && dd!=de) ) {
01532 m_dumpFile << "\n\tdata: " << std::setw(8) << std::setfill('0') << std::hex << dd;
01533 m_dumpFile << "\n\temul: " << std::setw(8) << std::setfill('0') << std::hex << de;
01534 }
01535 m_dumpFile << std::endl;
01536 }
01537 char ok[10];
01538 if(raw_match) sprintf(ok,"successful");
01539 else sprintf(ok,"failed");
01540 m_dumpFile << " ...FEDRawData data and emulator comparison: "
01541 << ok << std::endl;
01542 return raw_match;
01543 }
01544
01545 template <class myCol>
01546 bool L1Comparator::CompareCollections( edm::Handle<myCol> data, edm::Handle<myCol> emul) {
01547 bool match = true;
01548 typedef typename myCol::size_type col_sz;
01549 typedef typename myCol::iterator col_it;
01550 col_sz ndata = data->size();
01551 col_sz nemul = emul->size();
01552 if(ndata!=nemul) {
01553 match &= false;
01554 m_dumpFile << " #cand mismatch!"
01555 << "\tdata: " << ndata
01556 << "\temul: " << nemul
01557 << std::endl;
01558 }
01559 col_it itd = data -> begin();
01560 col_it itm = emul -> begin();
01561 for (col_sz i=0; i<ndata; i++) {
01562 match &= dumpCandidate(*itd++,*itm++, m_dumpFile);
01563 }
01564 return match;
01565 }
01566
01567 template <class T>
01568 bool L1Comparator::dumpCandidate( const T& dt, const T& em, std::ostream& s) {
01569 if(dt==em)
01570 return true;
01571 s<<dt<<std::endl;
01572 s<<em<<std::endl<<std::endl;
01573 return false;
01574 }