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