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