CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1Comparator.cc
Go to the documentation of this file.
3 
4 using namespace dedefs;
5 
7 
8  verbose_ = iConfig.getUntrackedParameter<int>("VerboseFlag",0);
9  m_stage1_layer2_ = iConfig.getParameter<bool>("stage1_layer2_");
10 
11  if(verbose())
12  std::cout << "\nL1COMPARATOR constructor...\n" << std::flush;
13 
14  std::vector<unsigned int> dosys(0,DEnsys);
15  dosys =
16  iConfig.getUntrackedParameter<std::vector<unsigned int> >("COMPARE_COLLS", dosys);
17 
18  if((int)dosys.size()!=DEnsys)
19  edm::LogError("L1Comparator")
20  << "wrong selection of systems to be compared\n"
21  << "\t the size of the mask COMPARE_COLLS (" << dosys.size()
22  << ") is not " << DEnsys << std::endl;
23  assert((int)dosys.size()==DEnsys);
24 
25  for(int isys=0; isys<DEnsys; isys++)
26  if( dosys[isys]!=0 && dosys[isys]!=1 )
27  throw cms::Exception("Invalid configuration")
28  << "L1Comparator: comparison flag for system " << isys
29  << " is non boolean: " << dosys[isys] << ". Exiting.\n";
30 
31  for(int i=0; i<DEnsys; i++)
32  m_doSys[i] = dosys[i];
33 
34  if(verbose()) {
35  std::cout << "[L1Comparator] do sys? ";
36  for(int i=0; i<DEnsys; i++)
37  std::cout << m_doSys[i] << " ";
38  std::cout << std::endl;
39 
40  std::cout << "[L1Comparator] list of systems to process: ";
41  for(int i=0; i<DEnsys; i++)
42  if(m_doSys[i])
43  std::cout << SystLabel[i] << " ";
44  std::cout << std::endl;
45  }
46 
48  assert(ETP==0); assert(HTP==1); assert(RCT== 2); assert(GCT== 3);
49  assert(DTP==4); assert(DTF==5); assert(CTP== 6); assert(CTF== 7);
50  assert(RPC==8); assert(LTC==9); assert(GMT==10); assert(GLT==11);
51 
52  if(verbose())
53  std::cout << "[L1Comparator] debug print collection labels\n";
54 
55  m_DEsource[RCT][0] = iConfig.getParameter<edm::InputTag>("RCTsourceData");
56  m_DEsource[RCT][1] = iConfig.getParameter<edm::InputTag>("RCTsourceEmul");
57 
58  m_DEsource[GCT][0] = iConfig.getParameter<edm::InputTag>("GCTsourceData");
59  m_DEsource[GCT][1] = iConfig.getParameter<edm::InputTag>("GCTsourceEmul");
60 
61  m_DEsource[DTP][0] = iConfig.getParameter<edm::InputTag>("DTPsourceData");
62  m_DEsource[DTP][1] = iConfig.getParameter<edm::InputTag>("DTPsourceEmul");
63 
64  m_DEsource[DTF][0] = iConfig.getParameter<edm::InputTag>("DTFsourceData");
65  m_DEsource[DTF][1] = iConfig.getParameter<edm::InputTag>("DTFsourceEmul");
66 
67  m_DEsource[RPC][0] = iConfig.getParameter<edm::InputTag>("RPCsourceData");
68  m_DEsource[RPC][1] = iConfig.getParameter<edm::InputTag>("RPCsourceEmul");
69 
70  m_DEsource[GMT][0] = iConfig.getParameter<edm::InputTag>("GMTsourceData");
71  m_DEsource[GMT][1] = iConfig.getParameter<edm::InputTag>("GMTsourceEmul");
72 
73  for(int sys=0; sys<DEnsys; sys++) {
74  std::string data_label = SystLabel[sys] + "sourceData";
75  std::string emul_label = SystLabel[sys] + "sourceEmul";
76 
77  if(m_doSys[sys] && verbose()) {
78  std::cout << " sys:" << sys << " label:" << SystLabel[sys]
79  << "\n\tdt:" << data_label << " : " <<m_DEsource[sys][0]
80  << "\n\tem:" << emul_label << " : " <<m_DEsource[sys][1]
81  << std::endl;
82  if(sys==CTF) {
83  std::cout << "\tdt:" << data_label << " : " <<m_DEsource[sys][2]
84  << "\n\tem:" << emul_label << " : " <<m_DEsource[sys][3]
85  << std::endl;
86  }
87  }
88  }
89 
90 
92  m_dumpMode = iConfig.getUntrackedParameter<int>("DumpMode",0);
93  m_dumpFileName = iConfig.getUntrackedParameter<std::string>("DumpFile","");
94  if(m_dumpMode) {
95  m_dumpFile.open(m_dumpFileName.c_str(), std::ios::out);
96  if(!m_dumpFile.good())
97  edm::LogInfo("L1ComparatorDumpFileOpenError")
98  << " L1Comparator::L1Comparator() : "
99  << " couldn't open dump file " << m_dumpFileName.c_str() << std::endl;
100  }
101 
102  m_match = true;
103  dumpEvent_ = true;
104  nevt_=-1;
105 
106  for(int i=0; i<DEnsys; i++) {
107  for(int j=0; j<2; j++)
108  DEncand[i][j] = 0;
109  DEmatchEvt[i] = true;
110  }
111 
112  m_dedigis.clear();
114  produces<L1DataEmulRecord>().setBranchAlias("L1DataEmulRecord");
115 
116  if(verbose())
117  std::cout << "\nL1Comparator constructor...done.\n" << std::flush;
118 }
119 
120 
122 
124 
125 void L1Comparator::beginRun(edm::Run const& iRun, const edm::EventSetup& iSetup) {
126 
127  if(verbose())
128  std::cout << "\nL1COMPARATOR beginRun...\n" << std::flush;
129 
130  // disable subsystem if not included in current run configuration
131  try
132  {
134  iSetup.get< L1TriggerKeyRcd >().get( pKey ) ;
135 
136  m_doSys[RCT] &= (!(pKey->subsystemKey( L1TriggerKey::kRCT) .empty()));
137  m_doSys[GCT] &= (!(pKey->subsystemKey( L1TriggerKey::kGCT) .empty()));
138  m_doSys[DTF] &= (!(pKey->subsystemKey( L1TriggerKey::kDTTF) .empty()));
139  m_doSys[CTF] &= (!(pKey->subsystemKey( L1TriggerKey::kCSCTF).empty()));
140  m_doSys[RPC] &= (!(pKey->subsystemKey( L1TriggerKey::kRPC) .empty()));
141  m_doSys[GMT] &= (!(pKey->subsystemKey( L1TriggerKey::kGMT) .empty()));
142  m_doSys[GLT] &= (!(pKey->subsystemKey( L1TriggerKey::kGT) .empty()));
143 
144  if(verbose()) {
145  if ( pKey->subsystemKey( L1TriggerKey::kRCT ).empty() )
146  std::cout << "RCT key is empty. Sub-systems is disabled ("<<m_doSys[RCT]<<")\n";
147  if ( pKey->subsystemKey( L1TriggerKey::kGCT ).empty() )
148  std::cout << "GCT key is empty. Sub-systems is disabled ("<<m_doSys[GCT]<<")\n";
149  if ( pKey->subsystemKey( L1TriggerKey::kDTTF ).empty() )
150  std::cout << "DTTF key is empty. Sub-systems is disabled ("<<m_doSys[DTF]<<")\n";
151  if ( pKey->subsystemKey( L1TriggerKey::kCSCTF).empty() )
152  std::cout << "CSCTF key is empty. Sub-systems is disabled ("<<m_doSys[CTF]<<")\n";
153  if ( pKey->subsystemKey( L1TriggerKey::kRPC ).empty() )
154  std::cout << "RPC key is empty. Sub-systems is disabled ("<<m_doSys[RPC]<<")\n";
155  if ( pKey->subsystemKey( L1TriggerKey::kGMT ).empty() )
156  std::cout << "GMT key is empty. Sub-systems is disabled ("<<m_doSys[GMT]<<")\n";
157  if ( pKey->subsystemKey( L1TriggerKey::kGT ).empty() )
158  std::cout << "GT key is empty. Sub-systems is disabled ("<<m_doSys[GLT]<<")\n";
159  std::cout << "TSC key = " << pKey->tscKey() << std::endl;
160  }
161 
162  //access subsystem key if needed, eg:
163  //std::cout << "RCT key:" << pKey->subsystemKey( L1TriggerKey::kRCT ) << std::endl;
164  }
165  catch( cms::Exception& ex )
166  {
167  edm::LogWarning("L1Comparator")
168  << "No L1TriggerKey found."
169  << std::endl;
170  }
171 
172  if(verbose())
173  std::cout << "L1COMPARATOR beginRun... done\n" << std::flush;
174 
175 }
176 
178  if(m_dumpMode)
179  m_dumpFile << "\n\n-------\n"
180  << "Global data|emulator agreement: "
181  << m_match << std::endl;
182  m_dumpFile.close();
183 }
184 
185 void
187 
188  nevt_++;
189  evtNum_ = iEvent.id().event();
190  runNum_ = iEvent.id().run();
191 
192  if(verbose())
193  std::cout << "\nL1COMPARATOR entry:" << nevt_ << " | evt:" << evtNum_
194  << " | run:" << runNum_ << "\n" << std::flush;
195 
196  //flag whether event id has already been written to dumpFile
197  dumpEvent_ = true;
198 
199  //reset event holder quantities
200  for(int i=0; i<DEnsys; i++) {
201  for(int j=0; j<2; j++)
202  DEncand[i][j] = 0;
203  DEmatchEvt[i] = true;
204  }
205  m_dedigis.clear();
206 
207 
209 
210  // -- RCT [regional calorimeter trigger]
215  if(m_doSys[RCT]) {
216  iEvent.getByLabel(m_DEsource[RCT][0], rct_em_data);
217  iEvent.getByLabel(m_DEsource[RCT][1], rct_em_emul);
218  iEvent.getByLabel(m_DEsource[RCT][0], rct_rgn_data);
219  iEvent.getByLabel(m_DEsource[RCT][1], rct_rgn_emul);
220  }
221 
222  // -- GCT [global calorimeter trigger]
223  edm::Handle<L1GctEmCandCollection> gct_isolaem_data;
224  edm::Handle<L1GctEmCandCollection> gct_isolaem_emul;
225  edm::Handle<L1GctEmCandCollection> gct_noisoem_data;
226  edm::Handle<L1GctEmCandCollection> gct_noisoem_emul;
227  edm::Handle<L1GctJetCandCollection> gct_cenjets_data;
228  edm::Handle<L1GctJetCandCollection> gct_cenjets_emul;
229  edm::Handle<L1GctJetCandCollection> gct_forjets_data;
230  edm::Handle<L1GctJetCandCollection> gct_forjets_emul;
231  edm::Handle<L1GctJetCandCollection> gct_taujets_data;
232  edm::Handle<L1GctJetCandCollection> gct_taujets_emul;
233  edm::Handle<L1GctJetCandCollection> gct_isotaujets_data;
234  edm::Handle<L1GctJetCandCollection> gct_isotaujets_emul;
235 
238  edm::Handle<L1GctEtMissCollection> gct_etmiss_data;
239  edm::Handle<L1GctEtMissCollection> gct_etmiss_emul;
240  edm::Handle<L1GctEtTotalCollection> gct_ettota_data;
241  edm::Handle<L1GctEtTotalCollection> gct_ettota_emul;
242  edm::Handle<L1GctHtMissCollection> gct_htmiss_data;
243  edm::Handle<L1GctHtMissCollection> gct_htmiss_emul;
248  edm::Handle<L1GctJetCountsCollection> gct_jetcnt_data;
250 
251  if(m_doSys[GCT]) {
252  if(m_stage1_layer2_ == false) {
253  iEvent.getByLabel(m_DEsource[GCT][0].label(),"isoEm", gct_isolaem_data);
254  iEvent.getByLabel(m_DEsource[GCT][1].label(),"isoEm", gct_isolaem_emul);
255  iEvent.getByLabel(m_DEsource[GCT][0].label(),"nonIsoEm",gct_noisoem_data);
256  iEvent.getByLabel(m_DEsource[GCT][1].label(),"nonIsoEm",gct_noisoem_emul);
257  iEvent.getByLabel(m_DEsource[GCT][0].label(),"cenJets", gct_cenjets_data);
258  iEvent.getByLabel(m_DEsource[GCT][1].label(),"cenJets", gct_cenjets_emul);
259  iEvent.getByLabel(m_DEsource[GCT][0].label(),"forJets", gct_forjets_data);
260  iEvent.getByLabel(m_DEsource[GCT][1].label(),"forJets", gct_forjets_emul);
261  iEvent.getByLabel(m_DEsource[GCT][0].label(),"tauJets", gct_taujets_data);
262  iEvent.getByLabel(m_DEsource[GCT][1].label(),"tauJets", gct_taujets_emul);
263 
264  iEvent.getByLabel(m_DEsource[GCT][0],gct_ht_data);
265  iEvent.getByLabel(m_DEsource[GCT][1],gct_ht_emul);
266  iEvent.getByLabel(m_DEsource[GCT][0],gct_etmiss_data);
267  iEvent.getByLabel(m_DEsource[GCT][1],gct_etmiss_emul);
268  iEvent.getByLabel(m_DEsource[GCT][0],gct_ettota_data);
269  iEvent.getByLabel(m_DEsource[GCT][1],gct_ettota_emul);
270  iEvent.getByLabel(m_DEsource[GCT][0],gct_htmiss_data);
271  iEvent.getByLabel(m_DEsource[GCT][1],gct_htmiss_emul);
272  iEvent.getByLabel(m_DEsource[GCT][0],gct_hfring_data);
273  iEvent.getByLabel(m_DEsource[GCT][1],gct_hfring_emul);
274  iEvent.getByLabel(m_DEsource[GCT][0],gct_hfbcnt_data);
275  iEvent.getByLabel(m_DEsource[GCT][1],gct_hfbcnt_emul);
276  iEvent.getByLabel(m_DEsource[GCT][0],gct_jetcnt_data);
277  iEvent.getByLabel(m_DEsource[GCT][1],gct_jetcnt_emul);
278  }
279  if(m_stage1_layer2_ == true){
280  iEvent.getByLabel(m_DEsource[GCT][0].label(),"isoEm", gct_isolaem_data);
281  iEvent.getByLabel(m_DEsource[GCT][1].label(),"isoEm", gct_isolaem_emul);
282  iEvent.getByLabel(m_DEsource[GCT][0].label(),"nonIsoEm",gct_noisoem_data);
283  iEvent.getByLabel(m_DEsource[GCT][1].label(),"nonIsoEm",gct_noisoem_emul);
284  iEvent.getByLabel(m_DEsource[GCT][0].label(),"cenJets", gct_cenjets_data);
285  iEvent.getByLabel(m_DEsource[GCT][1].label(),"cenJets", gct_cenjets_emul);
286  iEvent.getByLabel(m_DEsource[GCT][0].label(),"forJets", gct_forjets_data);
287  iEvent.getByLabel(m_DEsource[GCT][1].label(),"forJets", gct_forjets_emul);
288  iEvent.getByLabel(m_DEsource[GCT][0].label(),"tauJets", gct_taujets_data);
289  iEvent.getByLabel(m_DEsource[GCT][1].label(),"tauJets", gct_taujets_emul);
290  iEvent.getByLabel(m_DEsource[GCT][0].label(),"isoTauJets", gct_isotaujets_data);
291  iEvent.getByLabel(m_DEsource[GCT][1].label(),"isoTauJets", gct_isotaujets_emul);
292 
293  iEvent.getByLabel(m_DEsource[GCT][0],gct_ht_data);
294  iEvent.getByLabel(m_DEsource[GCT][1],gct_ht_emul);
295  iEvent.getByLabel(m_DEsource[GCT][0],gct_etmiss_data);
296  iEvent.getByLabel(m_DEsource[GCT][1],gct_etmiss_emul);
297  iEvent.getByLabel(m_DEsource[GCT][0],gct_ettota_data);
298  iEvent.getByLabel(m_DEsource[GCT][1],gct_ettota_emul);
299  iEvent.getByLabel(m_DEsource[GCT][0],gct_htmiss_data);
300  iEvent.getByLabel(m_DEsource[GCT][1],gct_htmiss_emul);
301  iEvent.getByLabel(m_DEsource[GCT][0],gct_hfring_data);
302  iEvent.getByLabel(m_DEsource[GCT][1],gct_hfring_emul);
303  iEvent.getByLabel(m_DEsource[GCT][0],gct_hfbcnt_data);
304  iEvent.getByLabel(m_DEsource[GCT][1],gct_hfbcnt_emul);
305  iEvent.getByLabel(m_DEsource[GCT][0],gct_jetcnt_data);
306  iEvent.getByLabel(m_DEsource[GCT][1],gct_jetcnt_emul);
307  }
308  }
309 
310  // -- DTP [drift tube trigger primitive]
315  if(m_doSys[DTP]) {
316  iEvent.getByLabel(m_DEsource[DTP][0],dtp_ph_data_);
317  iEvent.getByLabel(m_DEsource[DTP][1],dtp_ph_emul_);
318  iEvent.getByLabel(m_DEsource[DTP][0],dtp_th_data_);
319  iEvent.getByLabel(m_DEsource[DTP][1],dtp_th_emul_);
320  }
321  L1MuDTChambPhDigiCollection const* dtp_ph_data = 0;
322  L1MuDTChambPhDigiCollection const* dtp_ph_emul = 0;
323  L1MuDTChambThDigiCollection const* dtp_th_data = 0;
324  L1MuDTChambThDigiCollection const* dtp_th_emul = 0;
325 
326  if(dtp_ph_data_.isValid()) dtp_ph_data = dtp_ph_data_->getContainer();
327  if(dtp_ph_emul_.isValid()) dtp_ph_emul = dtp_ph_emul_->getContainer();
328  if(dtp_th_data_.isValid()) dtp_th_data = dtp_th_data_->getContainer();
329  if(dtp_th_emul_.isValid()) dtp_th_emul = dtp_th_emul_->getContainer();
330 
331  // -- DTF [drift tube track finder]
332  edm::Handle<L1MuDTTrackContainer> dtf_trk_data_;
333  edm::Handle<L1MuDTTrackContainer> dtf_trk_emul_;
334  L1MuRegionalCandCollection const* dtf_trk_data = 0;
335  L1MuRegionalCandCollection const* dtf_trk_emul = 0;
336  if(m_doSys[DTF]) {
337  iEvent.getByLabel(m_DEsource[DTF][0].label(),"DATA",dtf_trk_data_);
338  iEvent.getByLabel(m_DEsource[DTF][1].label(),"DTTF",dtf_trk_emul_);
339  }
340  //extract the regional cands
341  typedef std::vector<L1MuDTTrackCand> L1MuDTTrackCandCollection;
342  L1MuRegionalCandCollection dtf_trk_data_v, dtf_trk_emul_v;
343  dtf_trk_data_v.clear(); dtf_trk_emul_v.clear();
344  if(dtf_trk_data_.isValid()) {
345  L1MuDTTrackCandCollection const *dttc = dtf_trk_data_->getContainer();
346  for(L1MuDTTrackCandCollection::const_iterator it=dttc->begin();
347  it!=dttc->end(); it++)
348  dtf_trk_data_v.push_back(L1MuRegionalCand(*it));
349  }
350  if(dtf_trk_emul_.isValid()) {
351  L1MuDTTrackCandCollection const *dttc = dtf_trk_emul_->getContainer();
352  for(L1MuDTTrackCandCollection::const_iterator it=dttc->begin();
353  it!=dttc->end(); it++)
354  dtf_trk_emul_v.push_back(L1MuRegionalCand(*it));
355  }
356  dtf_trk_data =&dtf_trk_data_v;
357  dtf_trk_emul =&dtf_trk_emul_v;
358 
359 
360  // -- RPC [resistive plate chambers regional trigger]
365  if(m_doSys[RPC]) {
366  iEvent.getByLabel(m_DEsource[RPC][0].label(),"RPCb",rpc_cen_data);
367  iEvent.getByLabel(m_DEsource[RPC][1].label(),"RPCb",rpc_cen_emul);
368  iEvent.getByLabel(m_DEsource[RPC][0].label(),"RPCf",rpc_for_data);
369  iEvent.getByLabel(m_DEsource[RPC][1].label(),"RPCf",rpc_for_emul);
370  }
371 
372  // -- LTC [local trigger controller]
375  if(m_doSys[LTC]) {
376  iEvent.getByLabel(m_DEsource[LTC][0],ltc_data);
377  iEvent.getByLabel(m_DEsource[LTC][1],ltc_emul);
378  }
379 
380  // -- GMT [global muon trigger]
387  //tbd: may compare extended candidates
388  L1MuGMTCandCollection const *gmt_can_data(new L1MuGMTCandCollection);
389  L1MuGMTCandCollection const *gmt_can_emul(new L1MuGMTCandCollection);
390  if(m_doSys[GMT]) {
391  iEvent.getByLabel(m_DEsource[GMT][0], gmt_data);
392  iEvent.getByLabel(m_DEsource[GMT][1], gmt_emul);
393  iEvent.getByLabel(m_DEsource[GMT][0], gmt_rdt_data_);
394  iEvent.getByLabel(m_DEsource[GMT][1], gmt_rdt_emul_);
395  }
396  L1MuGMTCandCollection gmt_can_data_vec, gmt_can_emul_vec;
397  L1MuRegionalCandCollection gmt_rdt_data_vec, gmt_rdt_emul_vec;
398  gmt_can_data_vec.clear(); gmt_can_emul_vec.clear();
399  gmt_rdt_data_vec.clear(); gmt_rdt_emul_vec.clear();
400  if( gmt_rdt_data_.isValid() && gmt_rdt_emul_.isValid() ) {
401  typedef std::vector<L1MuGMTReadoutRecord>::const_iterator GmtRrIt;
402  //get record vector for data
403  std::vector<L1MuGMTReadoutRecord> gmt_rdt_data_bx = gmt_rdt_data_->getRecords();
404  for(GmtRrIt igmtrr=gmt_rdt_data_bx.begin(); igmtrr!=gmt_rdt_data_bx.end(); igmtrr++) {
405  //get gmt cands
406  typedef std::vector<L1MuGMTExtendedCand>::const_iterator GmtECIt;
407  std::vector<L1MuGMTExtendedCand> gmc;
408  gmc = igmtrr->getGMTCands();
409  for(GmtECIt iter1=gmc.begin(); iter1!=gmc.end(); iter1++) {
410  L1MuGMTCand cand(iter1->getDataWord(),iter1->bx());
411  cand.setPhiValue(iter1->phiValue());
412  cand.setEtaValue(iter1->etaValue());
413  cand.setPtValue (iter1->ptValue ());
414  gmt_can_data_vec.push_back(cand);
415  }
416  //get reg cands
417  typedef L1MuRegionalCandCollection::const_iterator GmtRCIt;
419  rmc.clear();
420  rmc = igmtrr->getDTBXCands();
421  gmt_rdt_data_vec.insert(gmt_rdt_data_vec.end(),rmc.begin(),rmc.end());
422  rmc.clear();
423  rmc = igmtrr->getCSCCands();
424  gmt_rdt_data_vec.insert(gmt_rdt_data_vec.end(),rmc.begin(),rmc.end());
425  rmc.clear();
426  rmc = igmtrr->getBrlRPCCands();
427  gmt_rdt_data_vec.insert(gmt_rdt_data_vec.end(),rmc.begin(),rmc.end());
428  rmc.clear();
429  rmc = igmtrr->getFwdRPCCands();
430  gmt_rdt_data_vec.insert(gmt_rdt_data_vec.end(),rmc.begin(),rmc.end());
431  }
432  //get record vector for emul
433  std::vector<L1MuGMTReadoutRecord> gmt_rdt_emul_bx = gmt_rdt_emul_->getRecords();
434  for(GmtRrIt igmtrr=gmt_rdt_emul_bx.begin(); igmtrr!=gmt_rdt_emul_bx.end(); igmtrr++) {
435  //get gmt cands
436  typedef std::vector<L1MuGMTExtendedCand>::const_iterator GmtECIt;
437  std::vector<L1MuGMTExtendedCand> gmc;
438  gmc = igmtrr->getGMTCands();
439  for(GmtECIt iter1=gmc.begin(); iter1!=gmc.end(); iter1++) {
440  gmt_can_emul_vec.push_back(L1MuGMTCand(iter1->getDataWord(),iter1->bx()));
441  }
442  //get reg cands
443  typedef L1MuRegionalCandCollection::const_iterator GmtRCIt;
445  rmc.clear();
446  rmc = igmtrr->getDTBXCands();
447  gmt_rdt_emul_vec.insert(gmt_rdt_emul_vec.end(),rmc.begin(),rmc.end());
448  rmc.clear();
449  rmc = igmtrr->getCSCCands();
450  gmt_rdt_emul_vec.insert(gmt_rdt_emul_vec.end(),rmc.begin(),rmc.end());
451  rmc.clear();
452  rmc = igmtrr->getBrlRPCCands();
453  gmt_rdt_emul_vec.insert(gmt_rdt_emul_vec.end(),rmc.begin(),rmc.end());
454  rmc.clear();
455  rmc = igmtrr->getFwdRPCCands();
456  gmt_rdt_emul_vec.insert(gmt_rdt_emul_vec.end(),rmc.begin(),rmc.end());
457  }
458  }
459  gmt_rdt_data = &gmt_rdt_data_vec;
460  gmt_rdt_emul = &gmt_rdt_emul_vec;
461  gmt_can_data = &gmt_can_data_vec;
462  gmt_can_emul = &gmt_can_emul_vec;
463 
465 
466  //check collections validity
467  bool isValidDE[DEnsys][2];
468  for(int i=0; i<DEnsys; i++) for(int j=0; j<2; j++) isValidDE[i][j]=false;
469 
470  isValidDE[RCT][0] = rct_em_data .isValid(); isValidDE[RCT][1] = rct_em_emul .isValid();
471  isValidDE[RCT][0]&= rct_rgn_data .isValid(); isValidDE[RCT][1] = rct_rgn_emul .isValid();
472 
473  if(m_stage1_layer2_ == false){
474  isValidDE[GCT][0] = gct_isolaem_data .isValid(); isValidDE[GCT][1] = gct_isolaem_emul .isValid();
475  isValidDE[GCT][0]&= gct_noisoem_data .isValid(); isValidDE[GCT][1]&= gct_noisoem_emul .isValid();
476  isValidDE[GCT][0]&= gct_cenjets_data .isValid(); isValidDE[GCT][1]&= gct_cenjets_emul .isValid();
477  isValidDE[GCT][0]&= gct_forjets_data .isValid(); isValidDE[GCT][1]&= gct_forjets_emul .isValid();
478  isValidDE[GCT][0]&= gct_taujets_data .isValid(); isValidDE[GCT][1]&= gct_taujets_emul .isValid();
479  isValidDE[GCT][0]&= gct_etmiss_data .isValid(); isValidDE[GCT][1]&= gct_etmiss_emul .isValid();
480  isValidDE[GCT][0]&= gct_ettota_data .isValid(); isValidDE[GCT][1]&= gct_ettota_emul .isValid();
481  isValidDE[GCT][0]&= gct_htmiss_data .isValid(); isValidDE[GCT][1]&= gct_htmiss_emul .isValid();
482  isValidDE[GCT][0]&= gct_hfring_data .isValid(); isValidDE[GCT][1]&= gct_hfring_emul .isValid();
483  isValidDE[GCT][0]&= gct_hfbcnt_data .isValid(); isValidDE[GCT][1]&= gct_hfbcnt_emul .isValid();
484  }
485 
486  if(m_stage1_layer2_ == true){
487  isValidDE[GCT][0] = gct_isolaem_data .isValid();
488  isValidDE[GCT][1] = gct_isolaem_emul .isValid();
489  isValidDE[GCT][0]&= gct_noisoem_data .isValid();
490  isValidDE[GCT][1]&= gct_noisoem_emul .isValid();
491  isValidDE[GCT][0]&= gct_cenjets_data .isValid();
492  isValidDE[GCT][1]&= gct_cenjets_emul .isValid();
493  isValidDE[GCT][0]&= gct_forjets_data .isValid();
494  isValidDE[GCT][1]&= gct_forjets_emul .isValid();
495  isValidDE[GCT][0]&= gct_taujets_data .isValid();
496  isValidDE[GCT][1]&= gct_taujets_emul .isValid();
497  isValidDE[GCT][0]&= gct_isotaujets_data .isValid();
498  isValidDE[GCT][1]&= gct_isotaujets_emul .isValid();
499  isValidDE[GCT][0]&= gct_etmiss_data .isValid();
500  isValidDE[GCT][1]&= gct_etmiss_emul .isValid();
501  isValidDE[GCT][0]&= gct_ettota_data .isValid();
502  isValidDE[GCT][1]&= gct_ettota_emul .isValid();
503  isValidDE[GCT][0]&= gct_htmiss_data .isValid();
504  isValidDE[GCT][1]&= gct_htmiss_emul .isValid();
505  isValidDE[GCT][0]&= gct_hfring_data .isValid();
506  isValidDE[GCT][1]&= gct_hfring_emul .isValid();
507  isValidDE[GCT][0]&= gct_hfbcnt_data .isValid();
508  isValidDE[GCT][1]&= gct_hfbcnt_emul .isValid();
509  }
510 
511  isValidDE[DTP][0] = dtp_ph_data_.isValid(); isValidDE[DTP][1] = dtp_ph_emul_.isValid();
512  isValidDE[DTP][0]&= dtp_th_data_.isValid(); isValidDE[DTP][1]&= dtp_th_emul_.isValid();
513 
514  isValidDE[DTF][0] = dtf_trk_data_.isValid(); isValidDE[DTF][1] = dtf_trk_emul_.isValid();
515 
516  isValidDE[RPC][0] = rpc_cen_data .isValid(); isValidDE[RPC][1] = rpc_cen_emul .isValid();
517  isValidDE[RPC][0]&= rpc_for_data .isValid(); isValidDE[RPC][1]&= rpc_for_emul .isValid();
518 
519  isValidDE[LTC][0] = ltc_data .isValid(); isValidDE[LTC][1] = ltc_emul .isValid();
520 
521  isValidDE[GMT][0] = gmt_data .isValid(); isValidDE[GMT][1] = gmt_emul .isValid();
522 
523  bool isValid[DEnsys];
524  for(int i=0; i<DEnsys; i++) {
525  isValid[i]=true;
526  for(int j=0; j<2; j++) {
527  isValid[i] &= isValidDE[i][j];
528  }
529  }
530 
531  if(verbose()) {
532  std::cout << "L1Comparator sys isValid? (evt:" << nevt_ << ") ";
533  std::cout << "\n\t&: ";
534  for(int i=0; i<DEnsys; i++)
535  std::cout << isValid[i] << " ";
536  std::cout << "\n\td: ";
537  for(int i=0; i<DEnsys; i++)
538  std::cout << isValidDE[i][0] << " ";
539  std::cout << "\n\te: ";
540  for(int i=0; i<DEnsys; i++)
541  std::cout << isValidDE[i][1] << " ";
542  std::cout << std::endl;
543  }
544 
545  //reset flags...
546  //for(int i=0; i<DEnsys; i++) isValid[i]=true;
547 
548  if(verbose())
549  std::cout << "L1Comparator start processing the collections.\n" << std::flush;
550 
552  if(m_doSys[RCT]&&isValid[RCT]) process<L1CaloEmCollection> ( rct_em_data, rct_em_emul, RCT,RCTem);
553  if(m_doSys[RCT]&&isValid[RCT]) process<L1CaloRegionCollection> ( rct_rgn_data, rct_rgn_emul, RCT,RCTrgn);
554 
555  if(m_stage1_layer2_==false){
556  if(m_doSys[GCT]&&isValid[GCT]) process<L1GctEmCandCollection> (gct_isolaem_data, gct_isolaem_emul, GCT,GCTisolaem);
557  if(m_doSys[GCT]&&isValid[GCT]) process<L1GctEmCandCollection> (gct_noisoem_data, gct_noisoem_emul, GCT,GCTnoisoem);
558  if(m_doSys[GCT]&&isValid[GCT]) process<L1GctJetCandCollection> (gct_cenjets_data, gct_cenjets_emul, GCT,GCTcenjets);
559  if(m_doSys[GCT]&&isValid[GCT]) process<L1GctJetCandCollection> (gct_forjets_data, gct_forjets_emul, GCT,GCTforjets);
560  if(m_doSys[GCT]&&isValid[GCT]) process<L1GctJetCandCollection> (gct_taujets_data, gct_taujets_emul, GCT,GCTtaujets);
561  if(m_doSys[GCT]&&isValid[GCT]) process<L1GctEtHadCollection> (gct_ht_data, gct_ht_emul, GCT,GCTethad);
562  if(m_doSys[GCT]&&isValid[GCT]) process<L1GctEtMissCollection> (gct_etmiss_data, gct_etmiss_emul, GCT,GCTetmiss);
563  if(m_doSys[GCT]&&isValid[GCT]) process<L1GctEtTotalCollection> (gct_ettota_data , gct_ettota_emul, GCT,GCTettot);
564  if(m_doSys[GCT]&&isValid[GCT]) process<L1GctHtMissCollection> (gct_htmiss_data, gct_htmiss_emul, GCT,GCThtmiss);
565  if(m_doSys[GCT]&&isValid[GCT]) process<L1GctHFRingEtSumsCollection> (gct_hfring_data, gct_hfring_emul, GCT,GCThfring);
566  if(m_doSys[GCT]&&isValid[GCT]) process<L1GctHFBitCountsCollection> (gct_hfbcnt_data, gct_hfbcnt_emul, GCT,GCThfbit);
567  }
568 
569  if(m_stage1_layer2_ == true){
570  if(m_doSys[GCT]&&isValid[GCT]) process<L1GctEmCandCollection> (gct_isolaem_data, gct_isolaem_emul, GCT, GCTisolaem);
571  if(m_doSys[GCT]&&isValid[GCT]) process<L1GctEmCandCollection> (gct_noisoem_data, gct_noisoem_emul, GCT, GCTnoisoem);
572  if(m_doSys[GCT]&&isValid[GCT]) process<L1GctJetCandCollection> (gct_cenjets_data, gct_cenjets_emul, GCT, GCTcenjets);
573  if(m_doSys[GCT]&&isValid[GCT]) process<L1GctJetCandCollection> (gct_forjets_data, gct_forjets_emul, GCT, GCTforjets);
574  if(m_doSys[GCT]&&isValid[GCT]) process<L1GctJetCandCollection> (gct_taujets_data, gct_taujets_emul, GCT, GCTtaujets);
575  if(m_doSys[GCT]&&isValid[GCT]) process<L1GctJetCandCollection> (gct_isotaujets_data,gct_isotaujets_emul, GCT, GCTisotaujets);
576  if(m_doSys[GCT]&&isValid[GCT]) process<L1GctEtHadCollection> (gct_ht_data, gct_ht_emul, GCT, GCTethad);
577  if(m_doSys[GCT]&&isValid[GCT]) process<L1GctEtMissCollection> (gct_etmiss_data, gct_etmiss_emul, GCT, GCTetmiss);
578  if(m_doSys[GCT]&&isValid[GCT]) process<L1GctEtTotalCollection> (gct_ettota_data , gct_ettota_emul, GCT, GCTettot);
579  if(m_doSys[GCT]&&isValid[GCT]) process<L1GctHtMissCollection> (gct_htmiss_data, gct_htmiss_emul, GCT, GCThtmiss);
580  if(m_doSys[GCT]&&isValid[GCT]) process<L1GctHFRingEtSumsCollection> (gct_hfring_data, gct_hfring_emul, GCT, GCThfring);
581  if(m_doSys[GCT]&&isValid[GCT]) process<L1GctHFBitCountsCollection> (gct_hfbcnt_data, gct_hfbcnt_emul, GCT, GCThfbit);
582  }
583 
584  if(m_doSys[DTP]&&isValid[DTP]) process<L1MuDTChambPhDigiCollection> ( dtp_ph_data, dtp_ph_emul, DTP,DTtpPh);
585  if(m_doSys[DTP]&&isValid[DTP]) process<L1MuDTChambThDigiCollection> ( dtp_th_data, dtp_th_emul, DTP,DTtpTh);
586 
587  if(m_doSys[DTF]&&isValid[DTF]) process<L1MuRegionalCandCollection> ( dtf_trk_data, dtf_trk_emul, DTF,DTtftrk);
588 
589  if(m_doSys[RPC]&&isValid[RPC]) process<L1MuRegionalCandCollection> ( rpc_cen_data, rpc_cen_emul, RPC,RPCcen);
590  if(m_doSys[RPC]&&isValid[RPC]) process<L1MuRegionalCandCollection> ( rpc_for_data, rpc_for_emul, RPC,RPCfor);
591 
592  if(m_doSys[GMT]&&isValid[GMT]) process<L1MuGMTCandCollection> ( gmt_data, gmt_emul, GMT,GMTmain);
593  if(m_doSys[GMT]&&isValid[GMT]) process<L1MuRegionalCandCollection> ( gmt_rdt_data, gmt_rdt_emul, GMT,GMTrdt);
594  if(m_doSys[GMT]&&isValid[GMT]) process<L1MuGMTCandCollection> ( gmt_can_data, gmt_can_emul, GMT,GMTcnd);
595 
596  // >>---- GLT ---- <<
597  GltDEDigi gltdigimon;
598 
599 
600  if(verbose())
601  std::cout << "L1Comparator done processing all collections.\n" << std::flush;
602 
603  if(verbose()) {
604  std::cout << "[L1Comparator] sys match? << evt." << nevt_ << ": ";
605  for(int i=0; i<DEnsys; i++)
606  std::cout << DEmatchEvt[i] << " ";
607  std::cout << std::endl;
608  }
609 
610 
611  // >>---- Event match? ---- <<
612 
613  bool evt_match = true;
614  for(int i=0; i<DEnsys; i++)
615  evt_match &= DEmatchEvt[i];
616 
617 
618  /* char ok[10];
619  if(evt_match) sprintf(ok,"GOOD :]");
620  else sprintf(ok,"BAD !!!");
621  char dumptofile[1000];
622  sprintf(dumptofile,"\n -> event data and emulator match... %s\n", ok);
623  m_dumpFile<<dumptofile;
624  */
625 
626  // >>---- Global match? ---- <<
627  m_match &= evt_match;
628  m_dumpFile << std::flush;
629 
630  //if collection is empty, add empty digi
631  if(m_dedigis.size()==0) {
632  if(verbose())
633  std::cout << "\n [L1Comparator] adding empty collection to DErecord\n";
634  m_dedigis.push_back(L1DataEmulDigi());
635  }
636 
637  // >>---- d|e record ---- <<
638  std::auto_ptr<L1DataEmulRecord> record
639  (new L1DataEmulRecord(evt_match,m_doSys,DEmatchEvt,DEncand,m_dedigis, gltdigimon));
640  if(verbose()) {
641  std::cout << "\n [L1Comparator] printing DErecord"
642  << "(entry:"<< nevt_
643  << "|evt:" << evtNum_
644  << "|run:" << runNum_
645  << "):\n" << std::flush;
646  std::cout << *record
647  << "\n" << std::flush;
648  }
649 
650  iEvent.put(record);
651 
652  if(verbose())
653  std::cout << "L1comparator::analize() end. " << nevt_ << std::endl;
654 
655 }
656 
657 
658 template <class T>
659 void L1Comparator::process(T const* data, T const* emul, const int sys, const int cid) {
660 
661  if(verbose())
662  std::cout << "L1Comparator::process -ing system:" << sys
663  << " (" << SystLabel[sys] << "), data type " << cid
664  << "...\n" << std::endl;
665  if(verbose())
666  std::cout << "L1Comparator::process debug "
667  << " (size " << data->size() << "," <<emul->size() << ")"
668  << ".\n" << std::endl;
669 
671  bool prt = false;
672  if(!m_dumpMode)
673  prt = false;
674  else if(m_dumpMode==-1)
675  prt=true;
676  else if(m_dumpMode>0) {
677  DEcompare<T> tmp(data,emul);
678  if(tmp.get_ncand(0)==0 && tmp.get_ncand(1)==0)
679  prt=false;
680  else
681  prt = !tmp.do_compare(m_dumpFile,0);
682  }
683 
684  //declare de compare object
685  DEcompare<T> cmp(data,emul);
686 
687  int ndata = cmp.get_ncand(0);
688  int nemul = cmp.get_ncand(1);
689 
690  if(verbose())
691  std::cout << "L1Comparator::process "
692  << " system:" << SystLabel[sys] << "(id " << sys << ")"
693  << " type:" << cmp.GetName(0) << "(" << cmp.de_type() << ")"
694  << " ndata:" << ndata
695  << " nemul:" << nemul
696  << " (size " << data->size() << "," <<emul->size() << ")"
697  << ".\n" << std::endl;
698 
699  if(ndata==0&&nemul==0) {
700  if(verbose())
701  std::cout << "L1Comparator::process "
702  << "empty collections -- exiting!\n" << std::endl;
703  return;
704  }
705 
706  m_dumpFile << std::setiosflags(std::ios::showpoint | std::ios::fixed
707  | std::ios::right | std::ios::adjustfield);
708  std::cout << std::setiosflags(std::ios::showpoint | std::ios::fixed
709  | std::ios::right | std::ios::adjustfield);
710 
711  if(dumpEvent_ && prt ) {
712  m_dumpFile << "\nEntry: " << nevt_
713  << " (event:" << evtNum_
714  << " | run:" << runNum_
715  << ")\n" << std::flush;
716  dumpEvent_=false;
717  }
718 
719  if(prt)
720  m_dumpFile << "\n sys:" << SystLabel[sys]
721  << " (" << sys << "), type:" << cid //cmp.GetName()
722  << " ...\n";
723 
724  if(verbose())
725  std::cout << "L1Comparator::process print:\n" << std::flush
726  << cmp.print()
727  << std::flush;
728 
730  DEmatchEvt[sys] &= cmp.do_compare(m_dumpFile,m_dumpMode);
731 
733  L1DEDigiCollection dg = cmp.getDEDigis();
734 
735  if(verbose())
736  for(L1DEDigiCollection::iterator it=dg.begin(); it!=dg.end();it++)
737  std::cout << *it << "\n";
738 
740  for(L1DEDigiCollection::iterator it=dg.begin(); it!=dg.end();it++)
741  it->setSid(sys);
743  for(L1DEDigiCollection::iterator it=dg.begin(); it!=dg.end();it++)
744  it->setCid(cid);
745 
747  m_dedigis.insert(m_dedigis.end(), dg.begin(), dg.end());
748  for(int i=0; i<2; i++)
749  DEncand[sys][i] += cmp.get_ncand(i);
750 
751  if(verbose())
752  std::cout << "L1Comparator::process "
753  << " system:" << SystLabel[sys]
754  << " type:" << cmp.GetName(0)
755  << " ndata:" << DEncand[sys][0]
756  << " nemul:" << DEncand[sys][1]
757  << " (size " << data->size() << "," <<emul->size() << ")"
758  << " ndigis:" << dg.size()
759  << " agree? " << DEmatchEvt[sys]
760  << std::endl;
761 
762  if(verbose())
763  std::cout << "L1Comparator::process -ing system:"
764  << sys << " (" << SystLabel[sys] << ")...done.\n"
765  << std::flush;
766 }
767 
768 template <class myCol>
770  bool match = true;
771  typedef typename myCol::size_type col_sz;
772  typedef typename myCol::iterator col_it;
773  col_sz ndata = data->size();
774  col_sz nemul = emul->size();
775  if(ndata!=nemul) {
776  match &= false;
777  m_dumpFile << " #cand mismatch!"
778  << "\tdata: " << ndata
779  << "\temul: " << nemul
780  << std::endl;
781  }
782  col_it itd = data -> begin();
783  col_it itm = emul -> begin();
784  for (col_sz i=0; i<ndata; i++) {
785  match &= dumpCandidate(*itd++,*itm++, m_dumpFile);
786  }
787  return match;
788 }
789 
790 template <class T>
791 bool L1Comparator::dumpCandidate( const T& dt, const T& em, std::ostream& s) {
792  if(dt==em)
793  return true;
794  s<<dt<<std::endl;
795  s<<em<<std::endl<<std::endl;
796  return false;
797 }
RunNumber_t run() const
Definition: EventID.h:39
T getParameter(std::string const &) const
EventNumber_t event() const
Definition: EventID.h:41
T getUntrackedParameter(std::string const &, T const &) const
float dt
Definition: AMPTWrapper.h:126
int i
Definition: DBlmapReader.cc:9
const int DEnsys
Definition: DEtrait.h:38
bool verbose
JetCorrectorParameters::Record record
Definition: classes.h:7
L1Comparator(const edm::ParameterSet &)
Definition: L1Comparator.cc:6
std::string print(col_cit it) const
Definition: DEcompare.h:74
virtual void beginJob(void)
assert(m_qm.get())
int get_ncand(typeT) const
Definition: DEcompare.h:121
std::vector< L1DataEmulDigi > L1DEDigiCollection
Definition: DEtrait.h:82
uint16_t size_type
virtual void produce(edm::Event &, const edm::EventSetup &)
L1DEDigiCollection getDEDigis() const
Definition: DEcompare.h:79
int iEvent
Definition: GenABIO.cc:230
void setPhiValue(float phiVal)
Setters for physical values.
Definition: L1MuGMTCand.h:177
int de_type() const
Definition: DEcompare.h:76
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
virtual void endJob()
int j
Definition: DBlmapReader.cc:9
std::string GetName(int i=0) const
Definition: DEcompare.h:73
bool isValid() const
Definition: HandleBase.h:75
std::vector< L1MuDTChambThDigi > L1MuDTChambThDigiCollection
Definition: DEtrait.h:74
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:405
std::vector< L1MuRegionalCand > L1MuRegionalCandCollection
tuple out
Definition: dbtoconf.py:99
bool do_compare(std::ofstream &, int dump=0)
Definition: DEcompare.h:106
std::vector< L1MuDTChambPhDigi > L1MuDTChambPhDigiCollection
Definition: DEtrait.h:73
const T & get() const
Definition: EventSetup.h:55
const std::string SystLabel[DEnsys]
Definition: DEtrait.h:45
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
edm::EventID id() const
Definition: EventBase.h:60
bool dumpCandidate(const T &dt, const T &em, std::ostream &s)
#define begin
Definition: vmac.h:30
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
tuple cout
Definition: gather_cfg.py:121
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
bool CompareCollections(edm::Handle< T > data, edm::Handle< T > emul)
virtual void beginRun(edm::Run const &, const edm::EventSetup &) overridefinal
long double T
std::vector< L1MuGMTCand > L1MuGMTCandCollection
Definition: DEtrait.h:80
void process(T const *, T const *, const int, const int)
Definition: Run.h:41