Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-07-24 02:52:17

0001 #include "L1Trigger/HardwareValidation/interface/L1Comparator.h"
0002 #include "FWCore/Framework/interface/ESHandle.h"
0003 
0004 using namespace dedefs;
0005 
0006 namespace {
0007   std::array<bool, dedefs::DEnsys> fillDoSys(edm::ParameterSet const& iConfig) {
0008     std::vector<unsigned int> dosys = iConfig.getUntrackedParameter<std::vector<unsigned int> >(
0009         "COMPARE_COLLS", std::vector<unsigned int>(0, DEnsys));
0010 
0011     if ((int)dosys.size() != DEnsys)
0012       edm::LogError("L1Comparator") << "wrong selection of systems to be compared\n"
0013                                     << "\t the size of the mask COPARE_COLLS (" << dosys.size() << ") is not " << DEnsys
0014                                     << std::endl;
0015     assert((int)dosys.size() == DEnsys);
0016 
0017     for (int isys = 0; isys < DEnsys; isys++)
0018       if (dosys[isys] != 0 && dosys[isys] != 1)
0019         throw cms::Exception("Invalid configuration") << "L1Comparator: comparison flag for system " << isys
0020                                                       << " is non boolean: " << dosys[isys] << ". Exiting.\n";
0021 
0022     std::array<bool, dedefs::DEnsys> ret;
0023     for (int i = 0; i < DEnsys; i++)
0024       ret[i] = dosys[i];
0025     return ret;
0026   }
0027 }  // namespace
0028 
0029 L1Comparator::L1Comparator(const edm::ParameterSet& iConfig)
0030     : m_stage1_layer2_{iConfig.getParameter<bool>("stage1_layer2_")},
0031       verbose_{iConfig.getUntrackedParameter<int>("VerboseFlag", 0)},
0032       tokenTriggerKey_{esConsumes<edm::Transition::BeginRun>()},
0033       m_doSys{fillDoSys(iConfig)},
0034       m_dumpFileName{iConfig.getUntrackedParameter<std::string>("DumpFile", "")},
0035       m_dumpMode{iConfig.getUntrackedParameter<int>("DumpMode", 0)},
0036       m_fileGuard{} {
0037   if (verbose())
0038     std::cout << "\nL1COMPARATOR constructor...\n" << std::flush;
0039 
0040   if (verbose()) {
0041     std::cout << "[L1Comparator] do sys? ";
0042     for (int i = 0; i < DEnsys; i++)
0043       std::cout << m_doSys[i] << " ";
0044     std::cout << std::endl;
0045 
0046     std::cout << "[L1Comparator] list of systems to process: ";
0047     for (int i = 0; i < DEnsys; i++)
0048       if (m_doSys[i])
0049         std::cout << SystLabel[i] << " ";
0050     std::cout << std::endl;
0051   }
0052 
0053   ///assertions/temporary
0054   assert(ETP == 0);
0055   assert(HTP == 1);
0056   assert(RCT == 2);
0057   assert(GCT == 3);
0058   assert(DTP == 4);
0059   assert(DTF == 5);
0060   assert(CTP == 6);
0061   assert(CTF == 7);
0062   assert(RPC == 8);
0063   assert(LTC == 9);
0064   assert(GMT == 10);
0065   assert(GLT == 11);
0066 
0067   /// dump level:  -1(all),0(none),1(disagree),2(loc.disagree),3(loc.agree)
0068   if (m_dumpMode) {
0069     m_dumpFile.open(m_dumpFileName.c_str(), std::ios::out);
0070     if (!m_dumpFile.good())
0071       edm::LogInfo("L1ComparatorDumpFileOpenError")
0072           << " L1Comparator::L1Comparator() : "
0073           << " couldn't open dump file " << m_dumpFileName.c_str() << std::endl;
0074   }
0075 
0076   m_match = true;
0077   nevt_ = -1;
0078 
0079   /// create d|e record product
0080   produces<L1DataEmulRecord>().setBranchAlias("L1DataEmulRecord");
0081 
0082   // -- RCT [regional calorimeter trigger]
0083   if (m_doSys[RCT]) {
0084     edm::InputTag tag0 = iConfig.getParameter<edm::InputTag>("RCTsourceData");
0085     edm::InputTag tag1 = iConfig.getParameter<edm::InputTag>("RCTsourceEmul");
0086 
0087     tokenCaloEm_[0] = consumes<L1CaloEmCollection>(tag0);
0088     tokenCaloEm_[1] = consumes<L1CaloEmCollection>(tag1);
0089     tokenCaloRegion_[0] = consumes<L1CaloRegionCollection>(tag0);
0090     tokenCaloRegion_[1] = consumes<L1CaloRegionCollection>(tag1);
0091   }
0092 
0093   // -- GCT [global calorimeter trigger]
0094   if (m_doSys[GCT]) {
0095     edm::InputTag tags[2];
0096     tags[0] = iConfig.getParameter<edm::InputTag>("GCTsourceData");
0097     tags[1] = iConfig.getParameter<edm::InputTag>("GCTsourceEmul");
0098 
0099     if (m_stage1_layer2_ == false) {
0100       for (int i = 0; i < 2; ++i) {
0101         edm::InputTag const& tag = tags[i];
0102         std::string const& label = tag.label();
0103         tokenGctEmCand_isoEm_[i] = consumes<L1GctEmCandCollection>(edm::InputTag(label, "isoEm"));
0104         tokenGctEmCand_nonIsoEm_[i] = consumes<L1GctEmCandCollection>(edm::InputTag(label, "nonIsoEm"));
0105         tokenGctJetCand_cenJets_[i] = consumes<L1GctJetCandCollection>(edm::InputTag(label, "cenJets"));
0106         tokenGctJetCand_forJets_[i] = consumes<L1GctJetCandCollection>(edm::InputTag(label, "forJets"));
0107         tokenGctJetCand_tauJets_[i] = consumes<L1GctJetCandCollection>(edm::InputTag(label, "tauJets"));
0108         tokenGctEtTotal_[i] = consumes<L1GctEtTotalCollection>(tag);
0109         tokenGctEtHad_[i] = consumes<L1GctEtHadCollection>(tag);
0110         tokenGctEtMiss_[i] = consumes<L1GctEtMissCollection>(tag);
0111         tokenGctHFRingEtSums_[i] = consumes<L1GctHFRingEtSumsCollection>(tag);
0112         tokenGctHFBitCounts_[i] = consumes<L1GctHFBitCountsCollection>(tag);
0113         tokenGctHtMiss_[i] = consumes<L1GctHtMissCollection>(tag);
0114         tokenGctJetCounts_[i] = consumes<L1GctJetCountsCollection>(tag);
0115       }
0116     }
0117     if (m_stage1_layer2_ == true) {
0118       for (int i = 0; i < 2; ++i) {
0119         edm::InputTag const& tag = tags[i];
0120         std::string const& label = tag.label();
0121         tokenGctEmCand_isoEm_[i] = consumes<L1GctEmCandCollection>(edm::InputTag(label, "isoEm"));
0122         tokenGctEmCand_nonIsoEm_[i] = consumes<L1GctEmCandCollection>(edm::InputTag(label, "nonIsoEm"));
0123         tokenGctJetCand_cenJets_[i] = consumes<L1GctJetCandCollection>(edm::InputTag(label, "cenJets"));
0124         tokenGctJetCand_forJets_[i] = consumes<L1GctJetCandCollection>(edm::InputTag(label, "forJets"));
0125         tokenGctJetCand_tauJets_[i] = consumes<L1GctJetCandCollection>(edm::InputTag(label, "tauJets"));
0126         tokenGctJetCand_isoTauJets_[i] = consumes<L1GctJetCandCollection>(edm::InputTag(label, "isoTauJets"));
0127         tokenGctEtTotal_[i] = consumes<L1GctEtTotalCollection>(tag);
0128         tokenGctEtHad_[i] = consumes<L1GctEtHadCollection>(tag);
0129         tokenGctEtMiss_[i] = consumes<L1GctEtMissCollection>(tag);
0130         tokenGctHFRingEtSums_[i] = consumes<L1GctHFRingEtSumsCollection>(tag);
0131         tokenGctHFBitCounts_[i] = consumes<L1GctHFBitCountsCollection>(tag);
0132         tokenGctHtMiss_[i] = consumes<L1GctHtMissCollection>(tag);
0133         tokenGctJetCounts_[i] = consumes<L1GctJetCountsCollection>(tag);
0134       }
0135     }
0136   }
0137 
0138   // -- DTP [drift tube trigger primitive]
0139   if (m_doSys[DTP]) {
0140     edm::InputTag tag0 = iConfig.getParameter<edm::InputTag>("DTPsourceData");
0141     edm::InputTag tag1 = iConfig.getParameter<edm::InputTag>("DTPsourceEmul");
0142 
0143     tokenMuDTChambPh_[0] = consumes<L1MuDTChambPhContainer>(tag0);
0144     tokenMuDTChambPh_[1] = consumes<L1MuDTChambPhContainer>(tag1);
0145     tokenMuDTChambTh_[0] = consumes<L1MuDTChambThContainer>(tag0);
0146     tokenMuDTChambTh_[1] = consumes<L1MuDTChambThContainer>(tag1);
0147   }
0148 
0149   // -- DTF [drift tube track finder]
0150   if (m_doSys[DTF]) {
0151     edm::InputTag tag0 = iConfig.getParameter<edm::InputTag>("DTFsourceData");
0152     edm::InputTag tag1 = iConfig.getParameter<edm::InputTag>("DTFsourceEmul");
0153 
0154     tokenMuDTTrack_[0] = consumes<L1MuDTTrackContainer>(edm::InputTag(tag0.label(), "DATA"));
0155     tokenMuDTTrack_[1] = consumes<L1MuDTTrackContainer>(edm::InputTag(tag1.label(), "DTTF"));
0156   }
0157 
0158   // -- RPC [resistive plate chambers regional trigger]
0159   if (m_doSys[RPC]) {
0160     edm::InputTag tag0 = iConfig.getParameter<edm::InputTag>("RPCsourceData");
0161     edm::InputTag tag1 = iConfig.getParameter<edm::InputTag>("RPCsourceEmul");
0162 
0163     tokenMuRegionalCandRPCb_[0] = consumes<L1MuRegionalCandCollection>(edm::InputTag(tag0.label(), "RPCb"));
0164     tokenMuRegionalCandRPCb_[1] = consumes<L1MuRegionalCandCollection>(edm::InputTag(tag1.label(), "RPCb"));
0165     tokenMuRegionalCandRPCf_[0] = consumes<L1MuRegionalCandCollection>(edm::InputTag(tag0.label(), "RPCf"));
0166     tokenMuRegionalCandRPCf_[1] = consumes<L1MuRegionalCandCollection>(edm::InputTag(tag1.label(), "RPCf"));
0167   }
0168 
0169   // -- LTC [local trigger controller]
0170   if (m_doSys[LTC]) {
0171     // FIXME
0172     // There should be a real input tag here, but there was none in the original code.
0173     edm::InputTag dummyTag;
0174     tokenLTCDigi_[0] = consumes<LTCDigiCollection>(dummyTag);
0175     tokenLTCDigi_[1] = consumes<LTCDigiCollection>(dummyTag);
0176   }
0177 
0178   // -- GMT [global muon trigger]
0179   if (m_doSys[GMT]) {
0180     edm::InputTag tag0 = iConfig.getParameter<edm::InputTag>("GMTsourceData");
0181     edm::InputTag tag1 = iConfig.getParameter<edm::InputTag>("GMTsourceEmul");
0182 
0183     tokenMuGMTCand_[0] = consumes<L1MuGMTCandCollection>(tag0);
0184     tokenMuGMTCand_[1] = consumes<L1MuGMTCandCollection>(tag1);
0185     tokenMuReadoutCand_[0] = consumes<L1MuGMTReadoutCollection>(tag0);
0186     tokenMuReadoutCand_[1] = consumes<L1MuGMTReadoutCollection>(tag1);
0187   }
0188 
0189   if (verbose())
0190     std::cout << "\nL1Comparator constructor...done.\n" << std::flush;
0191 }
0192 
0193 std::shared_ptr<L1Comparator::RunCache> L1Comparator::globalBeginRun(edm::Run const& iRun,
0194                                                                      const edm::EventSetup& iSetup) const {
0195   if (verbose())
0196     std::cout << "\nL1COMPARATOR beginRun...\n" << std::flush;
0197 
0198   auto runDoSys = std::make_shared<RunCache>();
0199   // disable subsystem if not included in current run configuration
0200   try {
0201     auto const& pKey = iSetup.getData(tokenTriggerKey_);
0202     *runDoSys = m_doSys;
0203 
0204     (*runDoSys)[RCT] &= (!(pKey.subsystemKey(L1TriggerKey::kRCT).empty()));
0205     (*runDoSys)[GCT] &= (!(pKey.subsystemKey(L1TriggerKey::kGCT).empty()));
0206     (*runDoSys)[DTF] &= (!(pKey.subsystemKey(L1TriggerKey::kDTTF).empty()));
0207     (*runDoSys)[CTF] &= (!(pKey.subsystemKey(L1TriggerKey::kCSCTF).empty()));
0208     (*runDoSys)[RPC] &= (!(pKey.subsystemKey(L1TriggerKey::kRPC).empty()));
0209     (*runDoSys)[GMT] &= (!(pKey.subsystemKey(L1TriggerKey::kGMT).empty()));
0210     (*runDoSys)[GLT] &= (!(pKey.subsystemKey(L1TriggerKey::kGT).empty()));
0211 
0212     if (verbose()) {
0213       if (pKey.subsystemKey(L1TriggerKey::kRCT).empty())
0214         std::cout << "RCT   key is empty. Sub-systems is disabled (" << (*runDoSys)[RCT] << ")\n";
0215       if (pKey.subsystemKey(L1TriggerKey::kGCT).empty())
0216         std::cout << "GCT   key is empty. Sub-systems is disabled (" << (*runDoSys)[GCT] << ")\n";
0217       if (pKey.subsystemKey(L1TriggerKey::kDTTF).empty())
0218         std::cout << "DTTF  key is empty. Sub-systems is disabled (" << (*runDoSys)[DTF] << ")\n";
0219       if (pKey.subsystemKey(L1TriggerKey::kCSCTF).empty())
0220         std::cout << "CSCTF key is empty. Sub-systems is disabled (" << (*runDoSys)[CTF] << ")\n";
0221       if (pKey.subsystemKey(L1TriggerKey::kRPC).empty())
0222         std::cout << "RPC   key is empty. Sub-systems is disabled (" << (*runDoSys)[RPC] << ")\n";
0223       if (pKey.subsystemKey(L1TriggerKey::kGMT).empty())
0224         std::cout << "GMT   key is empty. Sub-systems is disabled (" << (*runDoSys)[GMT] << ")\n";
0225       if (pKey.subsystemKey(L1TriggerKey::kGT).empty())
0226         std::cout << "GT    key is empty. Sub-systems is disabled (" << (*runDoSys)[GLT] << ")\n";
0227       std::cout << "TSC key = " << pKey.tscKey() << std::endl;
0228     }
0229 
0230     //access subsystem key if needed, eg:
0231     //std::cout << "RCT key:" << pKey->subsystemKey( L1TriggerKey::kRCT ) << std::endl;
0232   } catch (cms::Exception& ex) {
0233     edm::LogWarning("L1Comparator") << "No L1TriggerKey found." << std::endl;
0234   }
0235 
0236   if (verbose())
0237     std::cout << "L1COMPARATOR beginRun... done\n" << std::flush;
0238   return runDoSys;
0239 }
0240 
0241 void L1Comparator::endJob() {
0242   if (m_dumpMode)
0243     m_dumpFile << "\n\n-------\n"
0244                << "Global data|emulator agreement: " << m_match << std::endl;
0245   m_dumpFile.close();
0246 }
0247 
0248 void L1Comparator::produce(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const {
0249   EventInfo eventInfo;
0250   eventInfo.nevt_ = ++nevt_;
0251   eventInfo.evtNum_ = iEvent.id().event();
0252   eventInfo.runNum_ = iEvent.id().run();
0253 
0254   if (verbose())
0255     std::cout << "\nL1COMPARATOR entry:" << eventInfo.nevt_ << " | evt:" << eventInfo.evtNum_
0256               << " | run:" << eventInfo.runNum_ << "\n"
0257               << std::flush;
0258 
0259   /// --  Get the data and emulated collections -----------------------------
0260 
0261   // -- RCT [regional calorimeter trigger]
0262   edm::Handle<L1CaloEmCollection> rct_em_data;
0263   edm::Handle<L1CaloEmCollection> rct_em_emul;
0264   edm::Handle<L1CaloRegionCollection> rct_rgn_data;
0265   edm::Handle<L1CaloRegionCollection> rct_rgn_emul;
0266   auto const runIndex = iEvent.getRun().index();
0267   auto& runDoSys = *runCache(runIndex);
0268 
0269   if (runDoSys[RCT]) {
0270     iEvent.getByToken(tokenCaloEm_[0], rct_em_data);
0271     iEvent.getByToken(tokenCaloEm_[1], rct_em_emul);
0272     iEvent.getByToken(tokenCaloRegion_[0], rct_rgn_data);
0273     iEvent.getByToken(tokenCaloRegion_[1], rct_rgn_emul);
0274   }
0275 
0276   // -- GCT [global calorimeter trigger]
0277   edm::Handle<L1GctEmCandCollection> gct_isolaem_data;
0278   edm::Handle<L1GctEmCandCollection> gct_isolaem_emul;
0279   edm::Handle<L1GctEmCandCollection> gct_noisoem_data;
0280   edm::Handle<L1GctEmCandCollection> gct_noisoem_emul;
0281   edm::Handle<L1GctJetCandCollection> gct_cenjets_data;
0282   edm::Handle<L1GctJetCandCollection> gct_cenjets_emul;
0283   edm::Handle<L1GctJetCandCollection> gct_forjets_data;
0284   edm::Handle<L1GctJetCandCollection> gct_forjets_emul;
0285   edm::Handle<L1GctJetCandCollection> gct_taujets_data;
0286   edm::Handle<L1GctJetCandCollection> gct_taujets_emul;
0287   edm::Handle<L1GctJetCandCollection> gct_isotaujets_data;
0288   edm::Handle<L1GctJetCandCollection> gct_isotaujets_emul;
0289 
0290   edm::Handle<L1GctEtHadCollection> gct_ht_data;
0291   edm::Handle<L1GctEtHadCollection> gct_ht_emul;
0292   edm::Handle<L1GctEtMissCollection> gct_etmiss_data;
0293   edm::Handle<L1GctEtMissCollection> gct_etmiss_emul;
0294   edm::Handle<L1GctEtTotalCollection> gct_ettota_data;
0295   edm::Handle<L1GctEtTotalCollection> gct_ettota_emul;
0296   edm::Handle<L1GctHtMissCollection> gct_htmiss_data;
0297   edm::Handle<L1GctHtMissCollection> gct_htmiss_emul;
0298   edm::Handle<L1GctHFRingEtSumsCollection> gct_hfring_data;
0299   edm::Handle<L1GctHFRingEtSumsCollection> gct_hfring_emul;
0300   edm::Handle<L1GctHFBitCountsCollection> gct_hfbcnt_data;
0301   edm::Handle<L1GctHFBitCountsCollection> gct_hfbcnt_emul;
0302   edm::Handle<L1GctJetCountsCollection> gct_jetcnt_data;
0303   edm::Handle<L1GctJetCountsCollection> gct_jetcnt_emul;
0304 
0305   if (runDoSys[GCT]) {
0306     if (m_stage1_layer2_ == false) {
0307       iEvent.getByToken(tokenGctEmCand_isoEm_[0], gct_isolaem_data);
0308       iEvent.getByToken(tokenGctEmCand_isoEm_[1], gct_isolaem_emul);
0309       iEvent.getByToken(tokenGctEmCand_nonIsoEm_[0], gct_noisoem_data);
0310       iEvent.getByToken(tokenGctEmCand_nonIsoEm_[1], gct_noisoem_emul);
0311       iEvent.getByToken(tokenGctJetCand_cenJets_[0], gct_cenjets_data);
0312       iEvent.getByToken(tokenGctJetCand_cenJets_[1], gct_cenjets_emul);
0313       iEvent.getByToken(tokenGctJetCand_forJets_[0], gct_forjets_data);
0314       iEvent.getByToken(tokenGctJetCand_forJets_[1], gct_forjets_emul);
0315       iEvent.getByToken(tokenGctJetCand_tauJets_[0], gct_taujets_data);
0316       iEvent.getByToken(tokenGctJetCand_tauJets_[1], gct_taujets_emul);
0317       iEvent.getByToken(tokenGctEtHad_[0], gct_ht_data);
0318       iEvent.getByToken(tokenGctEtHad_[1], gct_ht_emul);
0319       iEvent.getByToken(tokenGctEtMiss_[0], gct_etmiss_data);
0320       iEvent.getByToken(tokenGctEtMiss_[1], gct_etmiss_emul);
0321       iEvent.getByToken(tokenGctEtTotal_[0], gct_ettota_data);
0322       iEvent.getByToken(tokenGctEtTotal_[1], gct_ettota_emul);
0323       iEvent.getByToken(tokenGctHtMiss_[0], gct_htmiss_data);
0324       iEvent.getByToken(tokenGctHtMiss_[1], gct_htmiss_emul);
0325       iEvent.getByToken(tokenGctHFRingEtSums_[0], gct_hfring_data);
0326       iEvent.getByToken(tokenGctHFRingEtSums_[1], gct_hfring_emul);
0327       iEvent.getByToken(tokenGctHFBitCounts_[0], gct_hfbcnt_data);
0328       iEvent.getByToken(tokenGctHFBitCounts_[1], gct_hfbcnt_emul);
0329       iEvent.getByToken(tokenGctJetCounts_[0], gct_jetcnt_data);
0330       iEvent.getByToken(tokenGctJetCounts_[1], gct_jetcnt_emul);
0331     }
0332     if (m_stage1_layer2_ == true) {
0333       iEvent.getByToken(tokenGctEmCand_isoEm_[0], gct_isolaem_data);
0334       iEvent.getByToken(tokenGctEmCand_isoEm_[1], gct_isolaem_emul);
0335       iEvent.getByToken(tokenGctEmCand_nonIsoEm_[0], gct_noisoem_data);
0336       iEvent.getByToken(tokenGctEmCand_nonIsoEm_[1], gct_noisoem_emul);
0337       iEvent.getByToken(tokenGctJetCand_cenJets_[0], gct_cenjets_data);
0338       iEvent.getByToken(tokenGctJetCand_cenJets_[1], gct_cenjets_emul);
0339       iEvent.getByToken(tokenGctJetCand_forJets_[0], gct_forjets_data);
0340       iEvent.getByToken(tokenGctJetCand_forJets_[1], gct_forjets_emul);
0341       iEvent.getByToken(tokenGctJetCand_tauJets_[0], gct_taujets_data);
0342       iEvent.getByToken(tokenGctJetCand_tauJets_[1], gct_taujets_emul);
0343       iEvent.getByToken(tokenGctJetCand_isoTauJets_[0], gct_isotaujets_data);
0344       iEvent.getByToken(tokenGctJetCand_isoTauJets_[1], gct_isotaujets_emul);
0345       iEvent.getByToken(tokenGctEtHad_[0], gct_ht_data);
0346       iEvent.getByToken(tokenGctEtHad_[1], gct_ht_emul);
0347       iEvent.getByToken(tokenGctEtMiss_[0], gct_etmiss_data);
0348       iEvent.getByToken(tokenGctEtMiss_[1], gct_etmiss_emul);
0349       iEvent.getByToken(tokenGctEtTotal_[0], gct_ettota_data);
0350       iEvent.getByToken(tokenGctEtTotal_[1], gct_ettota_emul);
0351       iEvent.getByToken(tokenGctHtMiss_[0], gct_htmiss_data);
0352       iEvent.getByToken(tokenGctHtMiss_[1], gct_htmiss_emul);
0353       iEvent.getByToken(tokenGctHFRingEtSums_[0], gct_hfring_data);
0354       iEvent.getByToken(tokenGctHFRingEtSums_[1], gct_hfring_emul);
0355       iEvent.getByToken(tokenGctHFBitCounts_[0], gct_hfbcnt_data);
0356       iEvent.getByToken(tokenGctHFBitCounts_[1], gct_hfbcnt_emul);
0357       iEvent.getByToken(tokenGctJetCounts_[0], gct_jetcnt_data);
0358       iEvent.getByToken(tokenGctJetCounts_[1], gct_jetcnt_emul);
0359     }
0360   }
0361 
0362   // -- DTP [drift tube trigger primitive]
0363   edm::Handle<L1MuDTChambPhContainer> dtp_ph_data_;
0364   edm::Handle<L1MuDTChambPhContainer> dtp_ph_emul_;
0365   edm::Handle<L1MuDTChambThContainer> dtp_th_data_;
0366   edm::Handle<L1MuDTChambThContainer> dtp_th_emul_;
0367   if (runDoSys[DTP]) {
0368     iEvent.getByToken(tokenMuDTChambPh_[0], dtp_ph_data_);
0369     iEvent.getByToken(tokenMuDTChambPh_[1], dtp_ph_emul_);
0370     iEvent.getByToken(tokenMuDTChambTh_[0], dtp_th_data_);
0371     iEvent.getByToken(tokenMuDTChambTh_[1], dtp_th_emul_);
0372   }
0373   L1MuDTChambPhDigiCollection const* dtp_ph_data = nullptr;
0374   L1MuDTChambPhDigiCollection const* dtp_ph_emul = nullptr;
0375   L1MuDTChambThDigiCollection const* dtp_th_data = nullptr;
0376   L1MuDTChambThDigiCollection const* dtp_th_emul = nullptr;
0377 
0378   if (dtp_ph_data_.isValid())
0379     dtp_ph_data = dtp_ph_data_->getContainer();
0380   if (dtp_ph_emul_.isValid())
0381     dtp_ph_emul = dtp_ph_emul_->getContainer();
0382   if (dtp_th_data_.isValid())
0383     dtp_th_data = dtp_th_data_->getContainer();
0384   if (dtp_th_emul_.isValid())
0385     dtp_th_emul = dtp_th_emul_->getContainer();
0386 
0387   // -- DTF [drift tube track finder]
0388   edm::Handle<L1MuDTTrackContainer> dtf_trk_data_;
0389   edm::Handle<L1MuDTTrackContainer> dtf_trk_emul_;
0390   L1MuRegionalCandCollection const* dtf_trk_data = nullptr;
0391   L1MuRegionalCandCollection const* dtf_trk_emul = nullptr;
0392   if (runDoSys[DTF]) {
0393     iEvent.getByToken(tokenMuDTTrack_[0], dtf_trk_data_);
0394     iEvent.getByToken(tokenMuDTTrack_[1], dtf_trk_emul_);
0395   }
0396   //extract the regional cands
0397   typedef std::vector<L1MuDTTrackCand> L1MuDTTrackCandCollection;
0398   L1MuRegionalCandCollection dtf_trk_data_v, dtf_trk_emul_v;
0399   dtf_trk_data_v.clear();
0400   dtf_trk_emul_v.clear();
0401   if (dtf_trk_data_.isValid()) {
0402     L1MuDTTrackCandCollection const* dttc = dtf_trk_data_->getContainer();
0403     for (L1MuDTTrackCandCollection::const_iterator it = dttc->begin(); it != dttc->end(); it++)
0404       dtf_trk_data_v.push_back(L1MuRegionalCand(*it));
0405   }
0406   if (dtf_trk_emul_.isValid()) {
0407     L1MuDTTrackCandCollection const* dttc = dtf_trk_emul_->getContainer();
0408     for (L1MuDTTrackCandCollection::const_iterator it = dttc->begin(); it != dttc->end(); it++)
0409       dtf_trk_emul_v.push_back(L1MuRegionalCand(*it));
0410   }
0411   dtf_trk_data = &dtf_trk_data_v;
0412   dtf_trk_emul = &dtf_trk_emul_v;
0413 
0414   // -- RPC [resistive plate chambers regional trigger]
0415   edm::Handle<L1MuRegionalCandCollection> rpc_cen_data;
0416   edm::Handle<L1MuRegionalCandCollection> rpc_cen_emul;
0417   edm::Handle<L1MuRegionalCandCollection> rpc_for_data;
0418   edm::Handle<L1MuRegionalCandCollection> rpc_for_emul;
0419   if (runDoSys[RPC]) {
0420     iEvent.getByToken(tokenMuRegionalCandRPCb_[0], rpc_cen_data);
0421     iEvent.getByToken(tokenMuRegionalCandRPCb_[1], rpc_cen_emul);
0422     iEvent.getByToken(tokenMuRegionalCandRPCf_[0], rpc_for_data);
0423     iEvent.getByToken(tokenMuRegionalCandRPCf_[1], rpc_for_emul);
0424   }
0425 
0426   // -- LTC [local trigger controller]
0427   edm::Handle<LTCDigiCollection> ltc_data;
0428   edm::Handle<LTCDigiCollection> ltc_emul;
0429   if (runDoSys[LTC]) {
0430     iEvent.getByToken(tokenLTCDigi_[0], ltc_data);
0431     iEvent.getByToken(tokenLTCDigi_[1], ltc_emul);
0432   }
0433 
0434   // -- GMT [global muon trigger]
0435   edm::Handle<L1MuGMTCandCollection> gmt_data;
0436   edm::Handle<L1MuGMTCandCollection> gmt_emul;
0437   edm::Handle<L1MuGMTReadoutCollection> gmt_rdt_data_;
0438   edm::Handle<L1MuGMTReadoutCollection> gmt_rdt_emul_;
0439   L1MuRegionalCandCollection const* gmt_rdt_data(new L1MuRegionalCandCollection);
0440   L1MuRegionalCandCollection const* gmt_rdt_emul(new L1MuRegionalCandCollection);
0441   //tbd: may compare extended candidates
0442   L1MuGMTCandCollection const* gmt_can_data(new L1MuGMTCandCollection);
0443   L1MuGMTCandCollection const* gmt_can_emul(new L1MuGMTCandCollection);
0444   if (runDoSys[GMT]) {
0445     iEvent.getByToken(tokenMuGMTCand_[0], gmt_data);
0446     iEvent.getByToken(tokenMuGMTCand_[1], gmt_emul);
0447     iEvent.getByToken(tokenMuReadoutCand_[0], gmt_rdt_data_);
0448     iEvent.getByToken(tokenMuReadoutCand_[1], gmt_rdt_emul_);
0449   }
0450   L1MuGMTCandCollection gmt_can_data_vec, gmt_can_emul_vec;
0451   L1MuRegionalCandCollection gmt_rdt_data_vec, gmt_rdt_emul_vec;
0452   gmt_can_data_vec.clear();
0453   gmt_can_emul_vec.clear();
0454   gmt_rdt_data_vec.clear();
0455   gmt_rdt_emul_vec.clear();
0456   if (gmt_rdt_data_.isValid() && gmt_rdt_emul_.isValid()) {
0457     typedef std::vector<L1MuGMTReadoutRecord>::const_iterator GmtRrIt;
0458     //get record vector for data
0459     std::vector<L1MuGMTReadoutRecord> gmt_rdt_data_bx = gmt_rdt_data_->getRecords();
0460     for (GmtRrIt igmtrr = gmt_rdt_data_bx.begin(); igmtrr != gmt_rdt_data_bx.end(); igmtrr++) {
0461       //get gmt cands
0462       typedef std::vector<L1MuGMTExtendedCand>::const_iterator GmtECIt;
0463       std::vector<L1MuGMTExtendedCand> gmc;
0464       gmc = igmtrr->getGMTCands();
0465       for (GmtECIt iter1 = gmc.begin(); iter1 != gmc.end(); iter1++) {
0466         L1MuGMTCand cand(iter1->getDataWord(), iter1->bx());
0467         cand.setPhiValue(iter1->phiValue());
0468         cand.setEtaValue(iter1->etaValue());
0469         cand.setPtValue(iter1->ptValue());
0470         gmt_can_data_vec.push_back(cand);
0471       }
0472       //get reg cands
0473       typedef L1MuRegionalCandCollection::const_iterator GmtRCIt;
0474       L1MuRegionalCandCollection rmc;
0475       rmc.clear();
0476       rmc = igmtrr->getDTBXCands();
0477       gmt_rdt_data_vec.insert(gmt_rdt_data_vec.end(), rmc.begin(), rmc.end());
0478       rmc.clear();
0479       rmc = igmtrr->getCSCCands();
0480       gmt_rdt_data_vec.insert(gmt_rdt_data_vec.end(), rmc.begin(), rmc.end());
0481       rmc.clear();
0482       rmc = igmtrr->getBrlRPCCands();
0483       gmt_rdt_data_vec.insert(gmt_rdt_data_vec.end(), rmc.begin(), rmc.end());
0484       rmc.clear();
0485       rmc = igmtrr->getFwdRPCCands();
0486       gmt_rdt_data_vec.insert(gmt_rdt_data_vec.end(), rmc.begin(), rmc.end());
0487     }
0488     //get record vector for emul
0489     std::vector<L1MuGMTReadoutRecord> gmt_rdt_emul_bx = gmt_rdt_emul_->getRecords();
0490     for (GmtRrIt igmtrr = gmt_rdt_emul_bx.begin(); igmtrr != gmt_rdt_emul_bx.end(); igmtrr++) {
0491       //get gmt cands
0492       typedef std::vector<L1MuGMTExtendedCand>::const_iterator GmtECIt;
0493       std::vector<L1MuGMTExtendedCand> gmc;
0494       gmc = igmtrr->getGMTCands();
0495       for (GmtECIt iter1 = gmc.begin(); iter1 != gmc.end(); iter1++) {
0496         gmt_can_emul_vec.push_back(L1MuGMTCand(iter1->getDataWord(), iter1->bx()));
0497       }
0498       //get reg cands
0499       typedef L1MuRegionalCandCollection::const_iterator GmtRCIt;
0500       L1MuRegionalCandCollection rmc;
0501       rmc.clear();
0502       rmc = igmtrr->getDTBXCands();
0503       gmt_rdt_emul_vec.insert(gmt_rdt_emul_vec.end(), rmc.begin(), rmc.end());
0504       rmc.clear();
0505       rmc = igmtrr->getCSCCands();
0506       gmt_rdt_emul_vec.insert(gmt_rdt_emul_vec.end(), rmc.begin(), rmc.end());
0507       rmc.clear();
0508       rmc = igmtrr->getBrlRPCCands();
0509       gmt_rdt_emul_vec.insert(gmt_rdt_emul_vec.end(), rmc.begin(), rmc.end());
0510       rmc.clear();
0511       rmc = igmtrr->getFwdRPCCands();
0512       gmt_rdt_emul_vec.insert(gmt_rdt_emul_vec.end(), rmc.begin(), rmc.end());
0513     }
0514   }
0515   gmt_rdt_data = &gmt_rdt_data_vec;
0516   gmt_rdt_emul = &gmt_rdt_emul_vec;
0517   gmt_can_data = &gmt_can_data_vec;
0518   gmt_can_emul = &gmt_can_emul_vec;
0519 
0520   ///--- done getting collections. ---
0521 
0522   //check collections validity
0523   bool isValidDE[DEnsys][2];  // = {false};
0524   for (int i = 0; i < DEnsys; i++)
0525     for (int j = 0; j < 2; j++)
0526       isValidDE[i][j] = false;
0527 
0528   isValidDE[RCT][0] = rct_em_data.isValid();
0529   isValidDE[RCT][1] = rct_em_emul.isValid();
0530   isValidDE[RCT][0] &= rct_rgn_data.isValid();
0531   isValidDE[RCT][1] = rct_rgn_emul.isValid();
0532 
0533   if (m_stage1_layer2_ == false) {
0534     isValidDE[GCT][0] = gct_isolaem_data.isValid();
0535     isValidDE[GCT][1] = gct_isolaem_emul.isValid();
0536     isValidDE[GCT][0] &= gct_noisoem_data.isValid();
0537     isValidDE[GCT][1] &= gct_noisoem_emul.isValid();
0538     isValidDE[GCT][0] &= gct_cenjets_data.isValid();
0539     isValidDE[GCT][1] &= gct_cenjets_emul.isValid();
0540     isValidDE[GCT][0] &= gct_forjets_data.isValid();
0541     isValidDE[GCT][1] &= gct_forjets_emul.isValid();
0542     isValidDE[GCT][0] &= gct_taujets_data.isValid();
0543     isValidDE[GCT][1] &= gct_taujets_emul.isValid();
0544     isValidDE[GCT][0] &= gct_etmiss_data.isValid();
0545     isValidDE[GCT][1] &= gct_etmiss_emul.isValid();
0546     isValidDE[GCT][0] &= gct_ettota_data.isValid();
0547     isValidDE[GCT][1] &= gct_ettota_emul.isValid();
0548     isValidDE[GCT][0] &= gct_htmiss_data.isValid();
0549     isValidDE[GCT][1] &= gct_htmiss_emul.isValid();
0550     isValidDE[GCT][0] &= gct_hfring_data.isValid();
0551     isValidDE[GCT][1] &= gct_hfring_emul.isValid();
0552     isValidDE[GCT][0] &= gct_hfbcnt_data.isValid();
0553     isValidDE[GCT][1] &= gct_hfbcnt_emul.isValid();
0554     //isValidDE[GCT][0]&=  gct_jetcnt_data .isValid(); isValidDE[GCT][1]&= gct_jetcnt_emul .isValid(); #temporary
0555   }
0556   if (m_stage1_layer2_ == true) {
0557     isValidDE[GCT][0] = gct_isolaem_data.isValid();
0558     isValidDE[GCT][1] = gct_isolaem_emul.isValid();
0559     isValidDE[GCT][0] &= gct_noisoem_data.isValid();
0560     isValidDE[GCT][1] &= gct_noisoem_emul.isValid();
0561     isValidDE[GCT][0] &= gct_cenjets_data.isValid();
0562     isValidDE[GCT][1] &= gct_cenjets_emul.isValid();
0563     isValidDE[GCT][0] &= gct_forjets_data.isValid();
0564     isValidDE[GCT][1] &= gct_forjets_emul.isValid();
0565     isValidDE[GCT][0] &= gct_taujets_data.isValid();
0566     isValidDE[GCT][1] &= gct_taujets_emul.isValid();
0567     isValidDE[GCT][0] &= gct_isotaujets_data.isValid();
0568     isValidDE[GCT][1] &= gct_isotaujets_emul.isValid();
0569     isValidDE[GCT][0] &= gct_etmiss_data.isValid();
0570     isValidDE[GCT][1] &= gct_etmiss_emul.isValid();
0571     isValidDE[GCT][0] &= gct_ettota_data.isValid();
0572     isValidDE[GCT][1] &= gct_ettota_emul.isValid();
0573     isValidDE[GCT][0] &= gct_htmiss_data.isValid();
0574     isValidDE[GCT][1] &= gct_htmiss_emul.isValid();
0575     isValidDE[GCT][0] &= gct_hfring_data.isValid();
0576     isValidDE[GCT][1] &= gct_hfring_emul.isValid();
0577     isValidDE[GCT][0] &= gct_hfbcnt_data.isValid();
0578     isValidDE[GCT][1] &= gct_hfbcnt_emul.isValid();
0579   }
0580   isValidDE[DTP][0] = dtp_ph_data_.isValid();
0581   isValidDE[DTP][1] = dtp_ph_emul_.isValid();
0582   isValidDE[DTP][0] &= dtp_th_data_.isValid();
0583   isValidDE[DTP][1] &= dtp_th_emul_.isValid();
0584 
0585   isValidDE[DTF][0] = dtf_trk_data_.isValid();
0586   isValidDE[DTF][1] = dtf_trk_emul_.isValid();
0587 
0588   isValidDE[RPC][0] = rpc_cen_data.isValid();
0589   isValidDE[RPC][1] = rpc_cen_emul.isValid();
0590   isValidDE[RPC][0] &= rpc_for_data.isValid();
0591   isValidDE[RPC][1] &= rpc_for_emul.isValid();
0592 
0593   isValidDE[LTC][0] = ltc_data.isValid();
0594   isValidDE[LTC][1] = ltc_emul.isValid();
0595 
0596   isValidDE[GMT][0] = gmt_data.isValid();
0597   isValidDE[GMT][1] = gmt_emul.isValid();
0598   //isValidDE[GMT][0]&=     gmt_rdt_data_.isValid(); isValidDE[GMT][1]&=    gmt_rdt_emul_.isValid();
0599 
0600   bool isValid[DEnsys];
0601   for (int i = 0; i < DEnsys; i++) {
0602     isValid[i] = true;
0603     for (int j = 0; j < 2; j++) {
0604       isValid[i] &= isValidDE[i][j];
0605     }
0606   }
0607 
0608   if (verbose()) {
0609     std::cout << "L1Comparator sys isValid?  (evt:" << eventInfo.nevt_ << ") ";
0610     std::cout << "\n\t&: ";
0611     for (int i = 0; i < DEnsys; i++)
0612       std::cout << isValid[i] << " ";
0613     std::cout << "\n\td: ";
0614     for (int i = 0; i < DEnsys; i++)
0615       std::cout << isValidDE[i][0] << " ";
0616     std::cout << "\n\te: ";
0617     for (int i = 0; i < DEnsys; i++)
0618       std::cout << isValidDE[i][1] << " ";
0619     std::cout << std::endl;
0620   }
0621 
0622   //reset flags...
0623   //for(int i=0; i<DEnsys; i++) isValid[i]=true;
0624 
0625   if (verbose())
0626     std::cout << "L1Comparator start processing the collections.\n" << std::flush;
0627 
0628   ///processing : compare the pairs of collections
0629   if (runDoSys[RCT] && isValid[RCT])
0630     process<L1CaloEmCollection>(rct_em_data, rct_em_emul, RCT, RCTem, eventInfo);
0631   if (runDoSys[RCT] && isValid[RCT])
0632     process<L1CaloRegionCollection>(rct_rgn_data, rct_rgn_emul, RCT, RCTrgn, eventInfo);
0633 
0634   if (m_stage1_layer2_ == false) {
0635     if (runDoSys[GCT] && isValid[GCT])
0636       process<L1GctEmCandCollection>(gct_isolaem_data, gct_isolaem_emul, GCT, GCTisolaem, eventInfo);
0637     if (runDoSys[GCT] && isValid[GCT])
0638       process<L1GctEmCandCollection>(gct_noisoem_data, gct_noisoem_emul, GCT, GCTnoisoem, eventInfo);
0639     if (runDoSys[GCT] && isValid[GCT])
0640       process<L1GctJetCandCollection>(gct_cenjets_data, gct_cenjets_emul, GCT, GCTcenjets, eventInfo);
0641     if (runDoSys[GCT] && isValid[GCT])
0642       process<L1GctJetCandCollection>(gct_forjets_data, gct_forjets_emul, GCT, GCTforjets, eventInfo);
0643     if (runDoSys[GCT] && isValid[GCT])
0644       process<L1GctJetCandCollection>(gct_taujets_data, gct_taujets_emul, GCT, GCTtaujets, eventInfo);
0645     if (runDoSys[GCT] && isValid[GCT])
0646       process<L1GctEtHadCollection>(gct_ht_data, gct_ht_emul, GCT, GCTethad, eventInfo);
0647     if (runDoSys[GCT] && isValid[GCT])
0648       process<L1GctEtMissCollection>(gct_etmiss_data, gct_etmiss_emul, GCT, GCTetmiss, eventInfo);
0649     if (runDoSys[GCT] && isValid[GCT])
0650       process<L1GctEtTotalCollection>(gct_ettota_data, gct_ettota_emul, GCT, GCTettot, eventInfo);
0651     if (runDoSys[GCT] && isValid[GCT])
0652       process<L1GctHtMissCollection>(gct_htmiss_data, gct_htmiss_emul, GCT, GCThtmiss, eventInfo);
0653     if (runDoSys[GCT] && isValid[GCT])
0654       process<L1GctHFRingEtSumsCollection>(gct_hfring_data, gct_hfring_emul, GCT, GCThfring, eventInfo);
0655     if (runDoSys[GCT] && isValid[GCT])
0656       process<L1GctHFBitCountsCollection>(gct_hfbcnt_data, gct_hfbcnt_emul, GCT, GCThfbit, eventInfo);
0657     //if(runDoSys[GCT]&&isValid[GCT]) process<L1GctJetCountsCollection>  ( gct_jetcnt_data,  gct_jetcnt_emul, GCT,GCTjetcnt);#missing in emulator
0658   }
0659   if (m_stage1_layer2_ == true) {
0660     if (runDoSys[GCT] && isValid[GCT])
0661       process<L1GctEmCandCollection>(gct_isolaem_data, gct_isolaem_emul, GCT, GCTisolaem, eventInfo);
0662     if (runDoSys[GCT] && isValid[GCT])
0663       process<L1GctEmCandCollection>(gct_noisoem_data, gct_noisoem_emul, GCT, GCTnoisoem, eventInfo);
0664     if (runDoSys[GCT] && isValid[GCT])
0665       process<L1GctJetCandCollection>(gct_cenjets_data, gct_cenjets_emul, GCT, GCTcenjets, eventInfo);
0666     if (runDoSys[GCT] && isValid[GCT])
0667       process<L1GctJetCandCollection>(gct_forjets_data, gct_forjets_emul, GCT, GCTforjets, eventInfo);
0668     if (runDoSys[GCT] && isValid[GCT])
0669       process<L1GctJetCandCollection>(gct_taujets_data, gct_taujets_emul, GCT, GCTtaujets, eventInfo);
0670     if (runDoSys[GCT] && isValid[GCT])
0671       process<L1GctJetCandCollection>(gct_isotaujets_data, gct_isotaujets_emul, GCT, GCTisotaujets, eventInfo);
0672     if (runDoSys[GCT] && isValid[GCT])
0673       process<L1GctEtHadCollection>(gct_ht_data, gct_ht_emul, GCT, GCTethad, eventInfo);
0674     if (runDoSys[GCT] && isValid[GCT])
0675       process<L1GctEtMissCollection>(gct_etmiss_data, gct_etmiss_emul, GCT, GCTetmiss, eventInfo);
0676     if (runDoSys[GCT] && isValid[GCT])
0677       process<L1GctEtTotalCollection>(gct_ettota_data, gct_ettota_emul, GCT, GCTettot, eventInfo);
0678     if (runDoSys[GCT] && isValid[GCT])
0679       process<L1GctHtMissCollection>(gct_htmiss_data, gct_htmiss_emul, GCT, GCThtmiss, eventInfo);
0680     if (runDoSys[GCT] && isValid[GCT])
0681       process<L1GctHFRingEtSumsCollection>(gct_hfring_data, gct_hfring_emul, GCT, GCThfring, eventInfo);
0682     if (runDoSys[GCT] && isValid[GCT])
0683       process<L1GctHFBitCountsCollection>(gct_hfbcnt_data, gct_hfbcnt_emul, GCT, GCThfbit, eventInfo);
0684     //if(runDoSys[GCT]&&isValid[GCT]) process<L1GctJetCountsCollection>  ( gct_jetcnt_data,  gct_jetcnt_emul, GCT,GCTjetcnt);#missing in emulator
0685   }
0686 
0687   if (runDoSys[DTP] && isValid[DTP])
0688     process<L1MuDTChambPhDigiCollection>(dtp_ph_data, dtp_ph_emul, DTP, DTtpPh, eventInfo);
0689   if (runDoSys[DTP] && isValid[DTP])
0690     process<L1MuDTChambThDigiCollection>(dtp_th_data, dtp_th_emul, DTP, DTtpTh, eventInfo);
0691 
0692   if (runDoSys[DTF] && isValid[DTF])
0693     process<L1MuRegionalCandCollection>(dtf_trk_data, dtf_trk_emul, DTF, DTtftrk, eventInfo);
0694 
0695   if (runDoSys[RPC] && isValid[RPC])
0696     process<L1MuRegionalCandCollection>(rpc_cen_data, rpc_cen_emul, RPC, RPCcen, eventInfo);
0697   if (runDoSys[RPC] && isValid[RPC])
0698     process<L1MuRegionalCandCollection>(rpc_for_data, rpc_for_emul, RPC, RPCfor, eventInfo);
0699 
0700   if (runDoSys[GMT] && isValid[GMT])
0701     process<L1MuGMTCandCollection>(gmt_data, gmt_emul, GMT, GMTmain, eventInfo);
0702   if (runDoSys[GMT] && isValid[GMT])
0703     process<L1MuRegionalCandCollection>(gmt_rdt_data, gmt_rdt_emul, GMT, GMTrdt, eventInfo);
0704   if (runDoSys[GMT] && isValid[GMT])
0705     process<L1MuGMTCandCollection>(gmt_can_data, gmt_can_emul, GMT, GMTcnd, eventInfo);
0706 
0707   // >>---- GLT ---- <<
0708   GltDEDigi gltdigimon;
0709 
0710   if (verbose())
0711     std::cout << "L1Comparator done processing all collections.\n" << std::flush;
0712 
0713   if (verbose()) {
0714     std::cout << "[L1Comparator] sys match? << evt." << eventInfo.nevt_ << ": ";
0715     for (int i = 0; i < DEnsys; i++)
0716       std::cout << eventInfo.DEmatchEvt[i] << " ";
0717     std::cout << std::endl;
0718   }
0719 
0720   // >>---- Event match? ---- <<
0721 
0722   bool evt_match = true;
0723   for (int i = 0; i < DEnsys; i++)
0724     evt_match &= eventInfo.DEmatchEvt[i];
0725 
0726   /* char ok[10];
0727      if(evt_match) sprintf(ok,"GOOD :]");
0728      else      sprintf(ok,"BAD !!!"); 
0729      char dumptofile[1000];
0730      sprintf(dumptofile,"\n -> event data and emulator match... %s\n", ok);
0731      m_dumpFile<<dumptofile;
0732   */
0733 
0734   // >>---- Global match? ---- <<
0735   if (not evt_match) {
0736     m_match = false;
0737   }
0738   {
0739     if (m_dumpMode) {
0740       std::lock_guard<std::mutex> guard(m_fileGuard);
0741       m_dumpFile << eventInfo.dumpToFile_.rdbuf() << std::flush;
0742     }
0743   }
0744   //if collection is empty, add empty digi
0745   if (eventInfo.m_dedigis.empty()) {
0746     if (verbose())
0747       std::cout << "\n [L1Comparator] adding empty collection to DErecord\n";
0748     eventInfo.m_dedigis.push_back(L1DataEmulDigi());
0749   }
0750 
0751   // >>---- d|e record ---- <<
0752   std::unique_ptr<L1DataEmulRecord> record(new L1DataEmulRecord(
0753       evt_match, runDoSys, eventInfo.DEmatchEvt, eventInfo.DEncand, eventInfo.m_dedigis, gltdigimon));
0754   if (verbose()) {
0755     std::cout << "\n [L1Comparator] printing DErecord"
0756               << "(entry:" << eventInfo.nevt_ << "|evt:" << eventInfo.evtNum_ << "|run:" << eventInfo.runNum_ << "):\n"
0757               << std::flush;
0758     std::cout << *record << "\n" << std::flush;
0759   }
0760 
0761   iEvent.put(std::move(record));
0762 
0763   if (verbose())
0764     std::cout << "L1comparator::analize() end. " << eventInfo.nevt_ << std::endl;
0765 }
0766 
0767 template <class T>
0768 void L1Comparator::process(T const* data, T const* emul, const int sys, const int cid, EventInfo& eventInfo) const {
0769   if (verbose())
0770     std::cout << "L1Comparator::process -ing system:" << sys << " (" << SystLabel[sys] << "), data type " << cid
0771               << "...\n"
0772               << std::flush;
0773   if (verbose())
0774     std::cout << "L1Comparator::process debug "
0775               << " (size " << data->size() << "," << emul->size() << ")"
0776               << ".\n"
0777               << std::flush;
0778 
0779   ///tmp: for getting a clean dump (avoid empty entries)
0780   bool prt = false;
0781   if (!m_dumpMode)
0782     prt = false;
0783   else if (m_dumpMode == -1)
0784     prt = true;
0785   else if (m_dumpMode > 0) {
0786     DEcompare<T> tmp(data, emul);
0787     if (tmp.get_ncand(0) == 0 && tmp.get_ncand(1) == 0)
0788       prt = false;
0789     else
0790       prt = !tmp.do_compare(eventInfo.dumpToFile_, 0);
0791   }
0792 
0793   //declare de compare object
0794   DEcompare<T> cmp(data, emul);
0795 
0796   int ndata = cmp.get_ncand(0);
0797   int nemul = cmp.get_ncand(1);
0798 
0799   if (verbose())
0800     std::cout << "L1Comparator::process "
0801               << " system:" << SystLabel[sys] << "(id " << sys << ")"
0802               << " type:" << cmp.GetName(0) << "(" << cmp.de_type() << ")"
0803               << " ndata:" << ndata << " nemul:" << nemul << " (size " << data->size() << "," << emul->size() << ")"
0804               << ".\n"
0805               << std::flush;
0806 
0807   if (ndata == 0 && nemul == 0) {
0808     if (verbose())
0809       std::cout << "L1Comparator::process "
0810                 << "empty collections -- exiting!\n"
0811                 << std::flush;
0812     return;
0813   }
0814 
0815   eventInfo.dumpToFile_ << std::setiosflags(std::ios::showpoint | std::ios::fixed | std::ios::right |
0816                                             std::ios::adjustfield);
0817   std::cout << std::setiosflags(std::ios::showpoint | std::ios::fixed | std::ios::right | std::ios::adjustfield);
0818 
0819   if (eventInfo.dumpEvent_ && prt) {
0820     eventInfo.dumpToFile_ << "\nEntry: " << eventInfo.nevt_ << " (event:" << eventInfo.evtNum_
0821                           << " | run:" << eventInfo.runNum_ << ")\n"
0822                           << std::flush;
0823     eventInfo.dumpEvent_ = false;
0824   }
0825 
0826   if (prt)
0827     eventInfo.dumpToFile_ << "\n  sys:" << SystLabel[sys] << " (" << sys << "), type:" << cid  //cmp.GetName()
0828                           << " ...\n";
0829 
0830   if (verbose())
0831     std::cout << "L1Comparator::process print:\n" << std::flush << cmp.print() << std::flush;
0832 
0833   ///perform comparison
0834   eventInfo.DEmatchEvt[sys] &= cmp.do_compare(eventInfo.dumpToFile_, m_dumpMode);
0835 
0836   ///gather results
0837   L1DEDigiCollection dg = cmp.getDEDigis();
0838 
0839   if (verbose())
0840     for (L1DEDigiCollection::iterator it = dg.begin(); it != dg.end(); it++)
0841       std::cout << *it << "\n";
0842 
0843   ///over-write system-id: needed eg for GMT input, CSC tf reg cand, CTP&CTF
0844   for (L1DEDigiCollection::iterator it = dg.begin(); it != dg.end(); it++)
0845     it->setSid(sys);
0846   ///over-write data type: needed eg for GCT jet types, regional muon sources
0847   for (L1DEDigiCollection::iterator it = dg.begin(); it != dg.end(); it++)
0848     it->setCid(cid);
0849 
0850   ///append d|e digis to the record's collection
0851   eventInfo.m_dedigis.insert(eventInfo.m_dedigis.end(), dg.begin(), dg.end());
0852   for (int i = 0; i < 2; i++)
0853     eventInfo.DEncand[sys][i] += cmp.get_ncand(i);
0854 
0855   if (verbose())
0856     std::cout << "L1Comparator::process "
0857               << " system:" << SystLabel[sys] << " type:" << cmp.GetName(0) << " ndata:" << eventInfo.DEncand[sys][0]
0858               << " nemul:" << eventInfo.DEncand[sys][1] << " (size " << data->size() << "," << emul->size() << ")"
0859               << " ndigis:" << dg.size() << " agree? " << eventInfo.DEmatchEvt[sys] << std::endl;
0860 
0861   if (verbose())
0862     std::cout << "L1Comparator::process -ing system:" << sys << " (" << SystLabel[sys] << ")...done.\n" << std::flush;
0863 }
0864 
0865 template <class myCol>
0866 bool L1Comparator::CompareCollections(edm::Handle<myCol> data,
0867                                       edm::Handle<myCol> emul,
0868                                       std::ostream& dumpStream) const {
0869   bool match = true;
0870   typedef typename myCol::size_type col_sz;
0871   typedef typename myCol::iterator col_it;
0872   col_sz ndata = data->size();
0873   col_sz nemul = emul->size();
0874   if (ndata != nemul) {
0875     match &= false;
0876     dumpStream << " #cand mismatch!"
0877                << "\tdata: " << ndata << "\temul: " << nemul << std::endl;
0878   }
0879   col_it itd = data->begin();
0880   col_it itm = emul->begin();
0881   for (col_sz i = 0; i < ndata; i++) {
0882     match &= dumpCandidate(*itd++, *itm++, dumpStream);
0883   }
0884   return match;
0885 }
0886 
0887 template <class T>
0888 bool L1Comparator::dumpCandidate(const T& dt, const T& em, std::ostream& s) const {
0889   if (dt == em)
0890     return true;
0891   s << dt << std::endl;
0892   s << em << std::endl << std::endl;
0893   return false;
0894 }