CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CSCDigiValidator.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: CSCDigiValidator
4 // Class: CSCDigiValidator
5 //
13 //
14 // Original Author: Lindsey Gray
15 // Created: Tue Jul 28 18:04:11 CEST 2009
16 // $Id: CSCDigiValidator.cc,v 1.3 2011/11/01 16:31:54 asakharo Exp $
17 //
18 //
19 
20 
21 // system include files
22 #include <memory>
23 #include <map>
24 #include <vector>
25 #include <algorithm>
26 
27 // user include files
31 
48 
49 
50 
51 
52 //
53 // constructors and destructor
54 //
56  wire1(iConfig.getUntrackedParameter<edm::InputTag>("inputWire")),
57  strip1(iConfig.getUntrackedParameter<edm::InputTag>("inputStrip")),
58  comp1(iConfig.getUntrackedParameter<edm::InputTag>("inputComp")),
59  clct1(iConfig.getUntrackedParameter<edm::InputTag>("inputCLCT")),
60  alct1(iConfig.getUntrackedParameter<edm::InputTag>("inputALCT")),
61  lct1(iConfig.getUntrackedParameter<edm::InputTag>("inputCorrLCT")),
62  csctf1(iConfig.getUntrackedParameter<edm::InputTag>("inputCSCTF")),
63  csctfstubs1(iConfig.getUntrackedParameter<edm::InputTag>("inputCSCTFStubs")),
64  wire2(iConfig.getUntrackedParameter<edm::InputTag>("repackWire")),
65  strip2(iConfig.getUntrackedParameter<edm::InputTag>("repackStrip")),
66  comp2(iConfig.getUntrackedParameter<edm::InputTag>("repackComp")),
67  clct2(iConfig.getUntrackedParameter<edm::InputTag>("repackCLCT")),
68  alct2(iConfig.getUntrackedParameter<edm::InputTag>("repackALCT")),
69  lct2(iConfig.getUntrackedParameter<edm::InputTag>("repackCorrLCT")),
70  csctf2(iConfig.getUntrackedParameter<edm::InputTag>("repackCSCTF")),
71  csctfstubs2(iConfig.getUntrackedParameter<edm::InputTag>("repackCSCTFStubs"))
72  // reorderStrips(iConfig.getUntrackedParameter<bool>("applyStripReordering",true))
73 {
74  //now do what ever initialization is needed
75  // produces<std::map<std::string,unsigned> >(); // # of errors enumerated by error type
76 }
77 
78 
80 {
81 
82  // do anything here that needs to be done at desctruction time
83  // (e.g. close files, deallocate resources etc.)
84 
85 }
86 
87 
88 //
89 // member functions
90 //
91 
92 // ------------ method called to for each event ------------
93 bool
95 {
96  bool _err = false;
97  using namespace edm;
98 
99  typedef std::map<CSCDetId,
100  std::pair<std::vector<CSCWireDigi>,std::vector<CSCWireDigi> > >
101  matchingDetWireCollection;
102  typedef std::map<CSCDetId,
103  std::pair<std::vector<CSCStripDigi>,std::vector<CSCStripDigi> > >
104  matchingDetStripCollection;
105  typedef std::map<CSCDetId,
106  std::pair<std::vector<CSCComparatorDigi>,std::vector<CSCComparatorDigi> > >
107  matchingDetComparatorCollection;
108  typedef std::map<CSCDetId,
109  std::pair<std::vector<CSCCLCTDigi>,std::vector<CSCCLCTDigi> > >
110  matchingDetCLCTCollection;
111  typedef std::map<CSCDetId,
112  std::pair<std::vector<CSCALCTDigi>,std::vector<CSCALCTDigi> > >
113  matchingDetALCTCollection;
114  typedef std::map<CSCDetId,
115  std::pair<std::vector<CSCCorrelatedLCTDigi>,std::vector<CSCCorrelatedLCTDigi> > >
116  matchingDetLCTCollection;
117 
118  // std::auto_ptr<std::map<std::string,unsigned> >
119  // errors(new std::map<std::string,unsigned>);
120 
122  iSetup.get<CSCChamberMapRcd>().get(hcham);
123  const CSCChamberMap* theMapping = hcham.product();
124 
128  Handle<CSCCLCTDigiCollection> _clct, _sclct;
129  Handle<CSCALCTDigiCollection> _alct, _salct;
131  Handle<L1CSCTrackCollection> _trk, _strk;
133 
134  // get wire digis before and after unpacking
135  iEvent.getByLabel(wire1,_swi);
136  iEvent.getByLabel(wire2,_wi);
137 
138  //get strip digis before and after unpacking
139  iEvent.getByLabel(strip1,_sst);
140  iEvent.getByLabel(strip2,_st);
141 
142  //get comparator digis before and after unpacking
143  iEvent.getByLabel(comp1,_scmp);
144  iEvent.getByLabel(comp2,_cmp);
145 
146  //get clcts
147  iEvent.getByLabel(clct1,_sclct);
148  iEvent.getByLabel(clct2,_clct);
149 
150  //get alcts
151  iEvent.getByLabel(alct1,_salct);
152  iEvent.getByLabel(alct2,_alct);
153 
154  //get lcts
155  iEvent.getByLabel(lct1,_slct);
156  iEvent.getByLabel(lct2,_lct);
157 
158  //get l1 tracks
159  iEvent.getByLabel(csctf1,_strk);
160  iEvent.getByLabel(csctfstubs1,_sdt);
161  iEvent.getByLabel(csctf2,_trk);
162  iEvent.getByLabel(csctfstubs2,_dt);
163 
164  //get DT stubs for L1 Tracks
165 
167  wi = _wi->begin(), swi= _swi->begin();
169  st = _st->begin(), sst = _sst->begin();
171  cmp = _cmp->begin(), scmp = _scmp->begin();
173  clct = _clct->begin(), sclct = _sclct->begin();
175  alct = _alct->begin(), salct = _salct->begin();
177  lct = _lct->begin(), slct = _slct->begin();
178  L1CSCTrackCollection::const_iterator
179  trk = _trk->begin(), strk = _strk->begin();
180  std::vector<csctf::TrackStub>::const_iterator
181  dt = _dt->get().begin(), sdt = _sdt->get().begin();
182  // WARNING 5_0_X
183  dt++; dt--; sdt++; sdt--;
184 
185  //per detID, create lists of various digi types
186  matchingDetWireCollection wires;
187  matchingDetStripCollection strips;
188  matchingDetComparatorCollection comps;
189  matchingDetCLCTCollection clcts;
190  matchingDetALCTCollection alcts;
191  matchingDetLCTCollection lcts,trackstubs;
193 
194  //wires
195  for(;wi != _wi->end();++wi)
196  {
198  b=(*wi).second.first,e=(*wi).second.second;
199  std::vector<CSCWireDigi>::iterator
200  beg=wires[(*wi).first].first.end();
201  wires[(*wi).first].first.insert(beg,b,e);
202  }
203  for(;swi != _swi->end();++swi)
204  {
206  b=(*swi).second.first,e=(*swi).second.second;
207  //convert sim ring 4(ME1/a) to ring 1
208  CSCDetId _id = (*swi).first;
209  if((*swi).first.ring() == 4)
210  _id = CSCDetId((*swi).first.endcap(),(*swi).first.station(),
211  1, (*swi).first.chamber(),(*swi).first.layer());
212 
213  std::vector<CSCWireDigi>::iterator
214  beg=wires[_id].second.end();
215 
216  wires[_id].second.insert(beg,b,e);
217  // automatically combine wire digis after each insertion
218  wires[_id].second = sanitizeWireDigis(wires[_id].second.begin(),
219  wires[_id].second.end());
220  }
221 
222  //strips
223  for(;st != _st->end();++st)
224  {
226  b=(*st).second.first,e=(*st).second.second;
227  std::vector<CSCStripDigi>::iterator
228  beg=strips[(*st).first].first.end();
229 
230  //need to remove strips with no active ADCs
231  std::vector<CSCStripDigi> zs = zeroSupStripDigis(b,e);
232 
233  strips[(*st).first].first.insert(beg,zs.begin(),zs.end());
234  }
235  for(;sst != _sst->end();++sst)
236  {
238  b=(*sst).second.first,e=(*sst).second.second;
239  // conversion of ring 4->1 not necessary here
240  CSCDetId _id = (*sst).first;
241  //if((*sst).first.ring() == 4)
242  // _id = CSCDetId((*sst).first.endcap(),(*sst).first.station(),
243  // 1, (*sst).first.chamber(),(*sst).first.layer());
244 
245  std::vector<CSCStripDigi>::iterator
246  beg=strips[_id].second.end();
247 
248  std::vector<CSCStripDigi> relab = relabelStripDigis(theMapping,(*sst).first,b,e);
249 
250  strips[_id].second.insert(beg,relab.begin(),relab.end());
251  //strips[_id].second.insert(beg,b,e);
252  }
253 
254  //comparators
255  for(;cmp != _cmp->end();++cmp)
256  {
258  b=(*cmp).second.first,e=(*cmp).second.second;
259  std::vector<CSCComparatorDigi>::iterator
260  beg=comps[(*cmp).first].first.end();
261 
262  comps[(*cmp).first].first.insert(beg,b,e);
263  }
264  for(;scmp != _scmp->end();++scmp)
265  {
267  b=(*scmp).second.first,e=(*scmp).second.second;
268  // convert sim ring 4 (ME1/a) to ring 1
269  CSCDetId _id = (*scmp).first;
270  if((*scmp).first.ring() == 4)
271  _id = CSCDetId((*scmp).first.endcap(),(*scmp).first.station(),
272  1, (*scmp).first.chamber(),(*scmp).first.layer());
273 
274  std::vector<CSCComparatorDigi>::iterator
275  beg=comps[_id].second.begin();
276 
277  if((*scmp).first.ring()==4)
278  beg=comps[_id].second.end();
279 
280  std::vector<CSCComparatorDigi> zs =
281  zeroSupCompDigis(b,e);
282 
283  std::vector<CSCComparatorDigi> relab =
284  relabelCompDigis(theMapping,(*scmp).first,
285  zs.begin(),
286  zs.end());
287 
288  comps[_id].second.insert(beg,relab.begin(),relab.end());
289  }
290 
291  //CLCTs
292  for(;clct != _clct->end();++clct)
293  {
295  b=(*clct).second.first,e=(*clct).second.second;
296  std::vector<CSCCLCTDigi>::iterator
297  beg=clcts[(*clct).first].first.end();
298 
299  clcts[(*clct).first].first.insert(beg,b,e);
300  }
301  for(;sclct != _sclct->end();++sclct)
302  {
304  b=(*sclct).second.first,e=(*sclct).second.second;
305  // convert sim ring 4 (ME1/a) to ring 1
306  CSCDetId _id = (*sclct).first;
307  if((*sclct).first.ring() == 4)
308  _id = CSCDetId((*sclct).first.endcap(),(*sclct).first.station(),
309  1, (*sclct).first.chamber(),(*sclct).first.layer());
310 
311  std::vector<CSCCLCTDigi>::iterator
312  beg=clcts[_id].second.begin();
313 
314  if((*sclct).first.ring()==4)
315  beg=clcts[_id].second.end();
316 
317  clcts[_id].second.insert(beg,b,e);
318  }
319 
320  //ALCTs
321  for(;alct != _alct->end();++alct)
322  {
324  b=(*alct).second.first,e=(*alct).second.second;
325  std::vector<CSCALCTDigi>::iterator
326  beg=alcts[(*alct).first].first.end();
327 
328  alcts[(*alct).first].first.insert(beg,b,e);
329  }
330  for(;salct != _salct->end();++salct)
331  {
333  b=(*salct).second.first,e=(*salct).second.second;
334  // convert sim ring 4 (ME1/a) to ring 1
335  CSCDetId _id = (*salct).first;
336  if((*salct).first.ring() == 4)
337  _id = CSCDetId((*salct).first.endcap(),(*salct).first.station(),
338  1, (*salct).first.chamber(),(*salct).first.layer());
339 
340  std::vector<CSCALCTDigi>::iterator
341  beg=alcts[_id].second.begin();
342 
343  if((*salct).first.ring()==4)
344  beg=alcts[_id].second.end();
345 
346  alcts[_id].second.insert(beg,b,e);
347  }
348 
349  // Correlated LCTs
350  for(;lct != _lct->end();++lct)
351  {
353  b=(*lct).second.first,e=(*lct).second.second;
354  std::vector<CSCCorrelatedLCTDigi>::iterator
355  beg=lcts[(*lct).first].first.end();
356 
357  lcts[(*lct).first].first.insert(beg,b,e);
358  }
359  for(;slct != _slct->end();++slct)
360  {
362  b=(*slct).second.first,e=(*slct).second.second;
363  // convert sim ring 4 (ME1/a) to ring 1
364  CSCDetId _id = (*slct).first;
365  if((*slct).first.ring() == 4)
366  _id = CSCDetId((*slct).first.endcap(),(*slct).first.station(),
367  1, (*slct).first.chamber(),(*slct).first.layer());
368 
369  std::vector<CSCCorrelatedLCTDigi>::iterator
370  beg=lcts[_id].second.begin();
371 
372  if((*slct).first.ring()==4)
373  beg=lcts[_id].second.end();
374 
375  lcts[_id].second.insert(beg,b,e);
376  }
377  // remove attached LCT digis from tracks, should be put into their own collection and checked separately
378  for(; trk != _trk->end(); ++trk)
379  {
380  tracks.push_back(trk->first);
381 
382  }
383  for(;strk != _strk->end(); ++strk)
384  {
385  simtracks.push_back(strk->first);
386  }
387 
388  //now loop through each set and process if there are differences!
389  matchingDetWireCollection::const_iterator w;
390  matchingDetStripCollection::const_iterator s;
391  matchingDetComparatorCollection::const_iterator c;
392  matchingDetCLCTCollection::const_iterator cl;
393  matchingDetALCTCollection::const_iterator al;
394  matchingDetLCTCollection::const_iterator lc;
395 
396  for(w = wires.begin(); w != wires.end(); ++w)
397  {
398  if(w->second.first.size() != w->second.second.size())
399  {
400  std::cout << "Major error! # of wire digis in detID: " << w->first
401  << " is not equal between sim and unpacked!" << std::endl;
402  //eventually do more in this case!
403 
404  std::vector<CSCWireDigi> a = w->second.second;
405  std::vector<CSCWireDigi> b = w->second.first;
406  std::cout << "SIM OUTPUT:" << std::endl;
407  for(std::vector<CSCWireDigi>::const_iterator i = a.begin(); i != a.end(); ++i)
408  i->print();
409  std::cout << "UNPACKER OUTPUT:" << std::endl;
410  for(std::vector<CSCWireDigi>::const_iterator i = b.begin(); i != b.end(); ++i)
411  i->print();
412 
413  }
414  int max = std::min(w->second.first.size(),w->second.second.size());
415  std::vector<CSCWireDigi> cv = w->second.first;
416  std::vector<CSCWireDigi> sv = w->second.second;
417  for(int i = 0; i < max; ++i)
418  {
419  if(sv[i].getWireGroup() != cv[i].getWireGroup())
420  {
421  std::cout << "In detId: " << w->first << std::endl;
422  std::cout << "Wire Groups do not match: " << sv[i].getWireGroup()
423  << " != " << cv[i].getWireGroup() << std::endl;
424  }
425  if(sv[i].getTimeBin() != cv[i].getTimeBin())
426  {
427  std::cout << "In detId: " << w->first << std::endl;
428  std::cout << "First Time Bins do not match: " << sv[i].getTimeBin()
429  << " != " << cv[i].getTimeBin() << std::endl;
430  }
431  if(sv[i].getTimeBinWord() != cv[i].getTimeBinWord())
432  {
433  std::cout << "In detId: " << w->first << std::endl;
434  std::cout << "Time Bin Words do not match: " << sv[i].getTimeBinWord()
435  << " != " << cv[i].getTimeBinWord() << std::endl;
436  }
437  }
438  }
439  for(s = strips.begin(); s != strips.end(); ++s)
440  {
441  if(s->second.first.size() != s->second.second.size())
442  {
443  std::cout << "Major error! # of strip digis in detID: " << s->first
444  << " is not equal between sim and unpacked!" << std::endl;
445  //eventually do more in this case!
446 
447  std::vector<CSCStripDigi> a = s->second.second;
448  std::vector<CSCStripDigi> b = s->second.first;
449  std::cout << "SIM OUTPUT:" << std::endl;
450  for(std::vector<CSCStripDigi>::const_iterator i = a.begin(); i != a.end(); ++i)
451  i->print();
452  std::cout << "UNPACKER OUTPUT:" << std::endl;
453  for(std::vector<CSCStripDigi>::const_iterator i = b.begin(); i != b.end(); ++i)
454  i->print();
455  }
456  int max = std::min(s->second.first.size(),s->second.second.size());
457  std::vector<CSCStripDigi> cv = s->second.first;
458  std::vector<CSCStripDigi> sv = s->second.second;
459  for(int i = 0; i < max; ++i)
460  {
461  bool me1a = s->first.station()==1 && s->first.ring()==4;
462  bool me1b = s->first.station()==1 && s->first.ring()==1;
463  bool zplus = s->first.endcap()==1;
464  int k=i;
465 
466  if(me1a && zplus) k=max-i-1;
467  if(me1b && !zplus) k=max-i-1;
468 
469  if(sv[k].getStrip() != cv[i].getStrip())
470  {
471  std::cout << "In detId: " << s->first << std::endl;
472  std::cout << "Strips do not match: " << sv[k].getStrip()
473  << " != " << cv[i].getStrip() << std::endl;
474  }
475  if(sv[k].getADCCounts().size() != cv[i].getADCCounts().size())
476  {
477  std::cout << "In detId: " << s->first << std::endl;
478  std::cout << "ADC Readouts not of equal size!" << std::endl;
479  std::cout << sv[k].getADCCounts().size() << ' '
480  << cv[i].getADCCounts().size() << std::endl;
481  }
482  else
483  {
484  std::vector<int> sADC = sv[k].getADCCounts();
485  std::vector<int> uADC = cv[i].getADCCounts();
486 
487  for(unsigned iadc = 0; iadc < sADC.size(); ++iadc)
488  if(sADC[iadc] != uADC[iadc])
489  {
490  std::cout << "In detId: " << s->first << std::endl;
491  std::cout << "ADC counts not equal at index: " << iadc << std::endl
492  << std::hex <<sADC[iadc] << " != " << uADC[iadc] << std::dec
493  << std::endl;
494  }
495  }
496  if(sv[k].getADCOverflow().size() != cv[i].getADCOverflow().size())
497  {
498  std::cout << "In detId: " << s->first << std::endl;
499  std::cout << "ADC Overflows not of equal size!" << std::endl;
500  std::cout << sv[k].getADCOverflow().size() << ' '
501  << cv[i].getADCOverflow().size() << std::endl;
502  }
503  else
504  {
505  std::vector<uint16_t> sADC = sv[k].getADCOverflow();
506  std::vector<uint16_t> uADC = cv[i].getADCOverflow();
507 
508  for(unsigned iadc = 0; iadc < sADC.size(); ++iadc)
509  if(sADC[iadc] != uADC[iadc])
510  {
511  std::cout << "In detId: " << s->first << std::endl;
512  std::cout << "ADC overflows not equal at index: " << iadc << std::endl
513  << std::hex <<sADC[iadc] << " != " << uADC[iadc] << std::dec
514  << std::endl;
515  }
516  }
517  if(sv[k].getOverlappedSample().size() != cv[i].getOverlappedSample().size())
518  {
519  std::cout << "In detId: " << s->first << std::endl;
520  std::cout << "Overlapped Samples not of equal size!" << std::endl;
521  std::cout << sv[k].getOverlappedSample().size() << ' '
522  << cv[i].getOverlappedSample().size() << std::endl;
523  }
524  else
525  {
526  std::vector<uint16_t> sADC = sv[k].getOverlappedSample();
527  std::vector<uint16_t> uADC = cv[i].getOverlappedSample();
528 
529  for(unsigned iadc = 0; iadc < sADC.size(); ++iadc)
530  if(sADC[iadc] != uADC[iadc])
531  {
532  std::cout << "In detId: " << s->first << std::endl;
533  std::cout << "Overlapped Samples not equal at index: " << iadc << std::endl
534  << std::hex <<sADC[iadc] << " != " << uADC[iadc] << std::dec
535  << std::endl;
536  }
537  }
538  if(sv[k].getErrorstat().size() != cv[i].getErrorstat().size())
539  {
540  std::cout << "In detId: " << s->first << std::endl;
541  std::cout << "Errorstat not of equal size!" << std::endl;
542  std::cout << sv[k].getErrorstat().size() << ' '
543  << cv[i].getErrorstat().size() << std::endl;
544  }
545  else
546  {
547  std::vector<uint16_t> sADC = sv[k].getErrorstat();
548  std::vector<uint16_t> uADC = cv[i].getErrorstat();
549 
550  for(unsigned iadc = 0; iadc < sADC.size(); ++iadc)
551  if(sADC[iadc] != uADC[iadc])
552  {
553  std::cout << "In detId: " << s->first << std::endl;
554  std::cout << "Errorstat not equal at index: " << iadc << std::endl
555  << std::hex <<sADC[iadc] << " != " << uADC[iadc] << std::dec
556  << std::endl;
557  }
558  }
559  if(sv[k].pedestal() != cv[i].pedestal())
560  {
561  std::cout << "In detId: " << s->first << std::endl;
562  std::cout << "Pedestals not equal: " << sv[k].pedestal() << " != "
563  << cv[i].pedestal() << std::endl;
564  }
565  if(sv[k].amplitude() != cv[i].amplitude())
566  {
567  std::cout << "In detId: " << s->first << std::endl;
568  std::cout << "Amplitudes not equal: " << sv[k].amplitude() << " != "
569  << cv[i].amplitude() << std::endl;
570  }
571  }
572  }
573  for(c = comps.begin(); c != comps.end(); ++c)
574  {
575  if(c->second.first.size() != c->second.second.size())
576  {
577  std::cout << "Major error! # of comparator digis in detID: " << c->first
578  << " is not equal between sim and unpacked!" << std::endl;
579  //eventually do more in this case!
580 
581  std::vector<CSCComparatorDigi> a = c->second.second;
582  std::vector<CSCComparatorDigi> b = c->second.first;
583  std::cout << "SIM OUTPUT:" << std::endl;
584  for(std::vector<CSCComparatorDigi>::const_iterator i = a.begin(); i != a.end(); ++i)
585  i->print();
586  std::cout << "UNPACKER OUTPUT:" << std::endl;
587  for(std::vector<CSCComparatorDigi>::const_iterator i = b.begin(); i != b.end(); ++i)
588  i->print();
589  }
590  int max = std::min(c->second.first.size(),c->second.second.size());
591  std::vector<CSCComparatorDigi> cv = c->second.first;
592  std::vector<CSCComparatorDigi> sv = c->second.second;
593  for(int i = 0; i < max; ++i)
594  {
595  if(sv[i].getStrip() != cv[i].getStrip())
596  {
597  std::cout << "In detId: " << s->first << std::endl;
598  std::cout << "Comparator strips do not match: " << sv[i].getStrip()
599  << " != " << cv[i].getStrip() << std::endl;
600  }
601  if(sv[i].getComparator() != cv[i].getComparator())
602  {
603  std::cout << "In detId: " << c->first << std::endl;
604  std::cout << "Comparators do not match: " << sv[i].getComparator()
605  << " != " << cv[i].getComparator() << std::endl;
606  }
607  if(sv[i].getTimeBinWord() != cv[i].getTimeBinWord())
608  {
609  std::cout << "In detId: " << c->first << std::endl;
610  std::cout << "Comparator time bins words do not match: " << sv[i].getTimeBinWord()
611  << " != " << cv[i].getTimeBinWord() << std::endl;
612  }
613  }
614  }
615  for(cl = clcts.begin(); cl != clcts.end(); ++cl)
616  {
617  if(cl->second.first.size() != cl->second.second.size())
618  {
619  std::cout << "Major error! # of CLCT digis in detID: " << cl->first
620  << " is not equal between sim and unpacked!" << std::endl;
621  //eventually do more in this case!
622 
623  std::vector<CSCCLCTDigi> a = cl->second.second;
624  std::vector<CSCCLCTDigi> b = cl->second.first;
625  std::cout << "SIM OUTPUT:" << std::endl;
626  for(std::vector<CSCCLCTDigi>::const_iterator i = a.begin(); i != a.end(); ++i)
627  i->print();
628  std::cout << "UNPACKER OUTPUT:" << std::endl;
629  for(std::vector<CSCCLCTDigi>::const_iterator i = b.begin(); i != b.end(); ++i)
630  i->print();
631  }
632  int max = std::min(cl->second.first.size(),cl->second.second.size());
633  std::vector<CSCCLCTDigi> cv = cl->second.first;
634  std::vector<CSCCLCTDigi> sv = cl->second.second;
635  for(int i = 0; i < max; ++i)
636  {
637  if(cv[i].getKeyStrip() != sv[i].getKeyStrip())
638  {
639  std::cout << "In detId: " << cl->first << std::endl;
640  std::cout << "CLCT key strips do not match: " << sv[i].getKeyStrip()
641  << " != " << cv[i].getKeyStrip() << std::endl;
642  }
643  if(cv[i].getStrip() != sv[i].getStrip())
644  {
645  std::cout << "In detId: " << cl->first << std::endl;
646  std::cout << "CLCT strips do not match: " << sv[i].getStrip()
647  << " != " << cv[i].getStrip() << std::endl;
648  }
649  if(cv[i].isValid() != sv[i].isValid())
650  {
651  std::cout << "In detId: " << cl->first << std::endl;
652  std::cout << "CLCT Valid bits do not match: " << sv[i].isValid()
653  << " != " << cv[i].isValid() << std::endl;
654  }
655  if(cv[i].getQuality() != sv[i].getQuality())
656  {
657  std::cout << "In detId: " << cl->first << std::endl;
658  std::cout << "CLCT qualities do not match: " << sv[i].getQuality()
659  << " != " << cv[i].getQuality() << std::endl;
660  }
661  if(cv[i].getPattern() != sv[i].getPattern())
662  {
663  std::cout << "In detId: " << cl->first << std::endl;
664  std::cout << "CLCT patterns do not match: " << sv[i].getPattern()
665  << " != " << cv[i].getPattern() << std::endl;
666  }
667  if(cv[i].getStripType() != sv[i].getStripType())
668  {
669  std::cout << "In detId: " << cl->first << std::endl;
670  std::cout << "CLCT strip types do not match: " << sv[i].getStripType()
671  << " != " << cv[i].getStripType() << std::endl;
672  }
673  if(cv[i].getBend() != sv[i].getBend())
674  {
675  std::cout << "In detId: " << cl->first << std::endl;
676  std::cout << "CLCT bends do not match: " << sv[i].getBend()
677  << " != " << cv[i].getBend() << std::endl;
678  }
679  if(cv[i].getCFEB() != sv[i].getCFEB())
680  {
681  std::cout << "In detId: " << cl->first << std::endl;
682  std::cout << "CLCT CFEBs do not match: " << sv[i].getCFEB()
683  << " != " << cv[i].getCFEB() << std::endl;
684  }
685  if(((short)cv[i].getBX()) != ((short)sv[i].getBX()) - 4)
686  {
687  std::cout << "In detId: " << cl->first << std::endl;
688  std::cout << "CLCT BX do not match: " << sv[i].getBX() - 4
689  << " != " << cv[i].getBX() << std::endl;
690  }
691  if(cv[i].getFullBX() != sv[i].getFullBX())
692  {
693  std::cout << "In detId: " << cl->first << std::endl;
694  std::cout << "CLCT Full BX do not match: " << sv[i].getFullBX()
695  << " != " << cv[i].getFullBX() << std::endl;
696  }
697  if(cv[i].getTrknmb() != sv[i].getTrknmb())
698  {
699  std::cout << "In detId: " << cl->first << std::endl;
700  std::cout << "CLCT Track numbers do not match: " << sv[i].getTrknmb()
701  << " != " << cv[i].getTrknmb() << std::endl;
702  }
703  }
704  }
705  for(al = alcts.begin(); al != alcts.end(); ++al)
706  {
707  if(al->second.first.size() != al->second.second.size())
708  {
709  std::cout << "Major error! # of ALCT digis in detID: " << al->first
710  << " is not equal between sim and unpacked!" << std::endl;
711  //eventually do more in this case!
712 
713  std::vector<CSCALCTDigi> a = al->second.second;
714  std::vector<CSCALCTDigi> b = al->second.first;
715  std::cout << "SIM OUTPUT:" << std::endl;
716  for(std::vector<CSCALCTDigi>::const_iterator i = a.begin(); i != a.end(); ++i)
717  i->print();
718  std::cout << "UNPACKER OUTPUT:" << std::endl;
719  for(std::vector<CSCALCTDigi>::const_iterator i = b.begin(); i != b.end(); ++i)
720  i->print();
721  }
722  int max = std::min(al->second.first.size(),al->second.second.size());
723  std::vector<CSCALCTDigi> cv = al->second.first;
724  std::vector<CSCALCTDigi> sv = al->second.second;
725  for(int i = 0; i < max; ++i)
726  {
727  if(cv[i].getKeyWG() != sv[i].getKeyWG())
728  {
729  std::cout << "In detId: " << al->first << std::endl;
730  std::cout << "ALCT key wire groups do not match: " << sv[i].getKeyWG()
731  << " != " << cv[i].getKeyWG() << std::endl;
732  }
733  if(cv[i].isValid() != sv[i].isValid())
734  {
735  std::cout << "In detId: " << al->first << std::endl;
736  std::cout << "ALCT Valid bits do not match: " << sv[i].isValid()
737  << " != " << cv[i].isValid() << std::endl;
738  }
739  if(cv[i].getQuality() != sv[i].getQuality())
740  {
741  std::cout << "In detId: " << al->first << std::endl;
742  std::cout << "ALCT qualities do not match: " << sv[i].getQuality()
743  << " != " << cv[i].getQuality() << std::endl;
744  }
745  if(cv[i].getAccelerator() != sv[i].getAccelerator())
746  {
747  std::cout << "In detId: " << al->first << std::endl;
748  std::cout << "ALCT accelerator bits do not match: " << sv[i].getAccelerator()
749  << " != " << cv[i].getAccelerator() << std::endl;
750  }
751  if(cv[i].getCollisionB() != sv[i].getCollisionB())
752  {
753  std::cout << "In detId: " << al->first << std::endl;
754  std::cout << "ALCT CollisionB flags do not match: " << sv[i].getCollisionB()
755  << " != " << cv[i].getCollisionB() << std::endl;
756  }
757  if((cv[i].getBX()) != (sv[i].getBX()))
758  {
759  std::cout << "In detId: " << al->first << std::endl;
760  std::cout << "ALCT BX do not match: " << sv[i].getBX()
761  << " != " << cv[i].getBX() << std::endl;
762  }
763  if(cv[i].getFullBX() != sv[i].getFullBX())
764  {
765  std::cout << "In detId: " << cl->first << std::endl;
766  std::cout << "ALCT Full BX do not match: " << sv[i].getFullBX()
767  << " != " << cv[i].getFullBX() << std::endl;
768  }
769  }
770  }
771  for(lc = lcts.begin(); lc != lcts.end(); ++lc)
772  {
773  if(lc->second.first.size() != lc->second.second.size())
774  {
775  std::cout << "Major error! # of Correlated LCT digis in detID: " << lc->first
776  << " is not equal between sim and unpacked!" << std::endl;
777  //eventually do more in this case!
778 
779  std::vector<CSCCorrelatedLCTDigi> a = lc->second.second;
780  std::vector<CSCCorrelatedLCTDigi> b = lc->second.first;
781  std::cout << "SIM OUTPUT:" << std::endl;
782  for(std::vector<CSCCorrelatedLCTDigi>::const_iterator i = a.begin(); i != a.end(); ++i)
783  i->print();
784  std::cout << "UNPACKER OUTPUT:" << std::endl;
785  for(std::vector<CSCCorrelatedLCTDigi>::const_iterator i = b.begin(); i != b.end(); ++i)
786  i->print();
787  }
788  int max = std::min(lc->second.first.size(),lc->second.second.size());
789  std::vector<CSCCorrelatedLCTDigi> cv = lc->second.first;
790  std::vector<CSCCorrelatedLCTDigi> sv = lc->second.second;
791  for(int i = 0; i < max; ++i)
792  {
793  if(cv[i].getStrip() != sv[i].getStrip())
794  {
795  std::cout << "In detId: " << lc->first << std::endl;
796  std::cout << "Correlated LCT strips do not match: " << sv[i].getStrip()
797  << " != " << cv[i].getStrip() << std::endl;
798  }
799  if(cv[i].getKeyWG() != sv[i].getKeyWG())
800  {
801  std::cout << "In detId: " << lc->first << std::endl;
802  std::cout << "Correlated LCT key wire groups do not match: " << sv[i].getKeyWG()
803  << " != " << cv[i].getKeyWG() << std::endl;
804  }
805  if(cv[i].isValid() != sv[i].isValid())
806  {
807  std::cout << "In detId: " << lc->first << std::endl;
808  std::cout << "Correlated LCT Valid bits do not match: " << sv[i].isValid()
809  << " != " << cv[i].isValid() << std::endl;
810  }
811  if(cv[i].getQuality() != sv[i].getQuality())
812  {
813  std::cout << "In detId: " << lc->first << std::endl;
814  std::cout << "Correlated LCT qualities do not match: " << sv[i].getQuality()
815  << " != " << cv[i].getQuality() << std::endl;
816  }
817  if(cv[i].getPattern() != sv[i].getPattern())
818  {
819  std::cout << "In detId: " << lc->first << std::endl;
820  std::cout << "Correlated LCT ALCT patterns do not match: " << sv[i].getPattern()
821  << " != " << cv[i].getPattern() << std::endl;
822  }
823  if(cv[i].getCLCTPattern() != sv[i].getCLCTPattern())
824  {
825  std::cout << "In detId: " << lc->first << std::endl;
826  std::cout << "Correlated LCT CLCT patterns do not match: " << sv[i].getCLCTPattern()
827  << " != " << cv[i].getCLCTPattern() << std::endl;
828  }
829  if(cv[i].getStripType() != sv[i].getStripType())
830  {
831  std::cout << "In detId: " << lc->first << std::endl;
832  std::cout << "Correlated LCT strip types do not match: " << sv[i].getStripType()
833  << " != " << cv[i].getStripType() << std::endl;
834  }
835  if(cv[i].getBend() != sv[i].getBend())
836  {
837  std::cout << "In detId: " << lc->first << std::endl;
838  std::cout << "Correlated LCT bends do not match: " << sv[i].getBend()
839  << " != " << cv[i].getBend() << std::endl;
840  }
841  if(cv[i].getMPCLink() != sv[i].getMPCLink())
842  {
843  std::cout << "In detId: " << lc->first << std::endl;
844  std::cout << "Correlated LCT MPC Links do not match: " << sv[i].getMPCLink()
845  << " != " << cv[i].getMPCLink() << std::endl;
846  }
847  if((cv[i].getBX()) != (sv[i].getBX()-6))
848  {
849  std::cout << "In detId: " << lc->first << std::endl;
850  std::cout << "Correlated LCT BX do not match: " << sv[i].getBX()-6
851  << " != " << cv[i].getBX() << std::endl;
852  }
853  if(cv[i].getCSCID() != sv[i].getCSCID())
854  {
855  std::cout << "In detId: " << lc->first << std::endl;
856  std::cout << "Correlated LCT CSCIDs do not match: " << sv[i].getCSCID()
857  << " != " << cv[i].getCSCID() << std::endl;
858  }
859  if(cv[i].getBX0() != sv[i].getBX0())
860  {
861  std::cout << "In detId: " << lc->first << std::endl;
862  std::cout << "Correlated LCT BX0s do not match: " << sv[i].getBX0()
863  << " != " << cv[i].getBX0() << std::endl;
864  }
865  if(cv[i].getSyncErr() != sv[i].getSyncErr())
866  {
867  std::cout << "In detId: " << lc->first << std::endl;
868  std::cout << "Correlated LCT SyncErrs do not match: " << sv[i].getSyncErr()
869  << " != " << cv[i].getSyncErr() << std::endl;
870  }
871  if(cv[i].getTrknmb() != sv[i].getTrknmb())
872  {
873  std::cout << "In detId: " << lc->first << std::endl;
874  std::cout << "Correlated LCT Track numbers do not match: " << sv[i].getTrknmb()
875  << " != " << cv[i].getTrknmb() << std::endl;
876  }
877  }
878  }
879  if(tracks.get().size() != simtracks.get().size())
880  {
881  std::cout << "Major error! # of L1 Tracks is not equal between sim and unpacked!" << std::endl;
882  std::vector<csc::L1Track> a = simtracks.get();
883  std::vector<csc::L1Track> b = tracks.get();
884  std::cout << "SIM OUTPUT:" << std::endl;
885  for(std::vector<csc::L1Track>::const_iterator i = a.begin(); i != a.end(); ++i)
886  i->print();
887  std::cout << "UNPACKER OUTPUT:" << std::endl;
888  for(std::vector<csc::L1Track>::const_iterator i = b.begin(); i != b.end(); ++i)
889  i->print();
890  }
891 
892 
893  // iEvent.put(errors);
894  return _err;
895 }
896 
897 // this function takes the sim wire digis and combines wire digis from the same wire
898 // into one wire digi, as in the data.
899 // returns a vector of the combined wire digis
900 std::vector<CSCWireDigi>
901 CSCDigiValidator::sanitizeWireDigis(std::vector<CSCWireDigi>::const_iterator b,
902  std::vector<CSCWireDigi>::const_iterator e)
903 {
904  typedef std::map<int,std::vector<CSCWireDigi> > wire2digi;
905 
906  std::vector<CSCWireDigi> _r; // the resulting vector of wire digis
907  wire2digi _wr2digis; // map of wires to a set of digis
908 
909  for(std::vector<CSCWireDigi>::const_iterator i = b; i != e; ++i)
910  _wr2digis[i->getWireGroup()].push_back(*i);
911 
912  for(wire2digi::const_iterator i = _wr2digis.begin(); i != _wr2digis.end(); ++i)
913  {
914  int wire = i->first;
915  unsigned tbin = 0x0;
916 
917  for(std::vector<CSCWireDigi>::const_iterator d = i->second.begin();
918  d != i->second.end(); ++d)
919  {
920  std::vector<int> binson = d->getTimeBinsOn();
921  for(std::vector<int>::const_iterator t = binson.begin();
922  t != binson.end(); ++t)
923  tbin |= 1<<(*t);
924  }
925 
926  _r.push_back(CSCWireDigi(wire,tbin));
927  }
928 
929  return _r;
930 }
931 
932 std::vector<CSCStripDigi>
934  std::vector<CSCStripDigi>::const_iterator b,
935  std::vector<CSCStripDigi>::const_iterator e)
936 {
937  std::vector<CSCStripDigi> _r; // the vector of strip digis with appropriate strip #'s
938 
939  //bool me1a = _id.station()==1 && _id.ring()==4;
940  //bool zplus = _id.endcap()==1;
941  //bool me1b = _id.station()==1 && _id.ring()==1;
942 
943  for(std::vector<CSCStripDigi>::const_iterator i = b; i != e; ++i)
944  {
945  int strip=i->getStrip();
946 
947  //if(me1a&&zplus) strip=17-strip;
948  //if(me1b&&!zplus) strip=(65-strip-1)%(m->dmb(_id)*16) + 1;
949  //if(me1a) strip+=64;
950 
951  _r.push_back(CSCStripDigi(strip,i->getADCCounts(),i->getADCOverflow(),
952  i->getOverlappedSample(),i->getErrorstat()));
953  }
954  return _r;
955 }
956 
957 std::vector<CSCComparatorDigi>
959  std::vector<CSCComparatorDigi>::const_iterator b,
960  std::vector<CSCComparatorDigi>::const_iterator e)
961 {
962  std::vector<CSCComparatorDigi> _r; // the vector of comp digis with appropriate strip #'s
963 
964  bool me1a = _id.station()==1 && _id.ring()==4;
965  //bool zplus = _id.endcap()==1;
966  //bool me1b = _id.station()==1 && _id.ring()==1;
967 
968  for(std::vector<CSCComparatorDigi>::const_iterator i = b; i != e; ++i)
969  {
970  int strip=i->getStrip();
971 
972  // if(me1a&&zplus) strip=17-strip;
973  // if(me1b&&!zplus) strip=65-strip;
974  if(me1a) strip+=64;
975 
976  _r.push_back(CSCComparatorDigi(strip,i->getComparator(),
977  i->getTimeBinWord()));
978  }
979  return _r;
980 }
981 
982 std::vector<CSCStripDigi>
983 CSCDigiValidator::sanitizeStripDigis(std::vector<CSCStripDigi>::const_iterator b,
984  std::vector<CSCStripDigi>::const_iterator e)
985 {
986  std::vector<CSCStripDigi> _r; // vector of digis in proper order
987 
988  return _r;
989 }
990 
991 std::vector<CSCStripDigi>
992 CSCDigiValidator::zeroSupStripDigis(std::vector<CSCStripDigi>::const_iterator b,
993  std::vector<CSCStripDigi>::const_iterator e)
994 {
995  std::vector<CSCStripDigi> _r; // zero-suppressed strip digis
996  std::vector<int> counts;
997 
998  for(std::vector<CSCStripDigi>::const_iterator i = b; i != e; ++i)
999  {
1000  bool nonzero=false;
1001  counts = i->getADCCounts();
1002  for(std::vector<int>::const_iterator a = counts.begin(); a != counts.end(); ++a)
1003  if((*a) != 0) nonzero = true;
1004 
1005  if(nonzero) _r.push_back(*i);
1006  }
1007 
1008  return _r;
1009 }
1010 
1011 // remove comparator digis on or after the 10th time bin, for now, will be configurable later.
1012 std::vector<CSCComparatorDigi>
1013 CSCDigiValidator::zeroSupCompDigis(std::vector<CSCComparatorDigi>::const_iterator b,
1014  std::vector<CSCComparatorDigi>::const_iterator e)
1015 {
1016  std::vector<CSCComparatorDigi> _r;
1017 
1018  for(std::vector<CSCComparatorDigi>::const_iterator i = b; i != e; ++i)
1019  {
1020  bool present = false;
1021 
1022  if(i->getTimeBin() < 10) present=true;
1023 
1024  if(present) _r.push_back(*i);
1025  }
1026 
1027  return _r;
1028 }
1029 
1030 // ------------ method called once each job just before starting event loop ------------
1031 void
1033 {
1034 }
1035 
1036 // ------------ method called once each job just after ending the event loop ------------
1037 void
1039 {
1040 }
edm::InputTag strip2
float dt
Definition: AMPTWrapper.h:126
int i
Definition: DBlmapReader.cc:9
edm::InputTag csctfstubs2
edm::InputTag alct2
std::vector< CSCStripDigi > sanitizeStripDigis(std::vector< CSCStripDigi >::const_iterator, std::vector< CSCStripDigi >::const_iterator)
std::vector< CSCComparatorDigi > zeroSupCompDigis(std::vector< CSCComparatorDigi >::const_iterator, std::vector< CSCComparatorDigi >::const_iterator)
void strip(std::string &input, const std::string &blanks=" \n\t")
Definition: stringTools.cc:16
std::vector< CSCComparatorDigi > relabelCompDigis(const CSCChamberMap *m, CSCDetId _id, std::vector< CSCComparatorDigi >::const_iterator b, std::vector< CSCComparatorDigi >::const_iterator e)
edm::InputTag wire2
#define min(a, b)
Definition: mlp_lapack.h:161
edm::InputTag csctfstubs1
edm::InputTag wire1
U second(std::pair< T, U > const &p)
int iEvent
Definition: GenABIO.cc:243
edm::InputTag comp1
const T & max(const T &a, const T &b)
edm::InputTag alct1
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
float cl
Definition: Combine.cc:71
edm::InputTag comp2
int k[5][pyjets_maxn]
edm::InputTag strip1
int ring() const
Definition: CSCDetId.h:77
CSCDigiValidator(const edm::ParameterSet &)
tuple tracks
Definition: testEve_cfg.py:39
edm::InputTag clct2
const T & get() const
Definition: EventSetup.h:55
double b
Definition: hdecay.h:120
std::vector< DigiType >::const_iterator const_iterator
edm::InputTag lct1
virtual void beginJob()
std::vector< CSCStripDigi > zeroSupStripDigis(std::vector< CSCStripDigi >::const_iterator, std::vector< CSCStripDigi >::const_iterator)
virtual void endJob()
double a
Definition: hdecay.h:121
int station() const
Definition: CSCDetId.h:88
tuple cout
Definition: gather_cfg.py:121
edm::InputTag clct1
edm::InputTag csctf2
std::vector< CSCWireDigi > sanitizeWireDigis(std::vector< CSCWireDigi >::const_iterator, std::vector< CSCWireDigi >::const_iterator)
tuple size
Write out results.
std::vector< CSCStripDigi > relabelStripDigis(const CSCChamberMap *, CSCDetId, std::vector< CSCStripDigi >::const_iterator, std::vector< CSCStripDigi >::const_iterator)
virtual bool filter(edm::Event &, const edm::EventSetup &)
T w() const
edm::InputTag lct2
edm::InputTag csctf1