CMS 3D CMS Logo

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 
26  wd1_token = consumes<CSCWireDigiCollection>(iConfig.getParameter<edm::InputTag>("inputWire"));
27  wd2_token = consumes<CSCWireDigiCollection>(iConfig.getParameter<edm::InputTag>("repackWire"));
28  sd1_token = consumes<CSCStripDigiCollection>(iConfig.getParameter<edm::InputTag>("inputStrip"));
29  sd2_token = consumes<CSCStripDigiCollection>(iConfig.getParameter<edm::InputTag>("inputStrip"));
30  cd1_token = consumes<CSCComparatorDigiCollection>(iConfig.getParameter<edm::InputTag>("inputComp"));
31  cd2_token = consumes<CSCComparatorDigiCollection>(iConfig.getParameter<edm::InputTag>("RepackComp"));
32  al1_token = consumes<CSCALCTDigiCollection>(iConfig.getParameter<edm::InputTag>("inputALCT"));
33  al2_token = consumes<CSCALCTDigiCollection>(iConfig.getParameter<edm::InputTag>("repackALCT"));
34  cl1_token = consumes<CSCCLCTDigiCollection>(iConfig.getParameter<edm::InputTag>("inputCLCT"));
35  cl2_token = consumes<CSCCLCTDigiCollection>(iConfig.getParameter<edm::InputTag>("repackCLCT"));
36  co1_token = consumes<CSCCorrelatedLCTDigiCollection>(iConfig.getParameter<edm::InputTag>("inputCorrLCT"));
37  co2_token = consumes<CSCCorrelatedLCTDigiCollection>(iConfig.getParameter<edm::InputTag>("repackCorrLCT"));
38  tr1_token = consumes<L1CSCTrackCollection>(iConfig.getParameter<edm::InputTag>("inputCSCTF"));
39  tr2_token = consumes<L1CSCTrackCollection>(iConfig.getParameter<edm::InputTag>("repackCSCTF"));
40  ts1_token = consumes<CSCTriggerContainer<csctf::TrackStub> >(iConfig.getParameter<edm::InputTag>("inputCSCTFStubs"));
41  ts2_token = consumes<CSCTriggerContainer<csctf::TrackStub> >(iConfig.getParameter<edm::InputTag>("repackCSCTFStubs"));
42 
43  // reorderStrips(iConfig.getUntrackedParameter<bool>("applyStripReordering",true))
44 }
45 
47 
49  bool _err = false;
50  using namespace edm;
51 
52  typedef std::map<CSCDetId, std::pair<std::vector<CSCWireDigi>, std::vector<CSCWireDigi> > > matchingDetWireCollection;
53  typedef std::map<CSCDetId, std::pair<std::vector<CSCStripDigi>, std::vector<CSCStripDigi> > >
54  matchingDetStripCollection;
55  typedef std::map<CSCDetId, std::pair<std::vector<CSCComparatorDigi>, std::vector<CSCComparatorDigi> > >
56  matchingDetComparatorCollection;
57  typedef std::map<CSCDetId, std::pair<std::vector<CSCCLCTDigi>, std::vector<CSCCLCTDigi> > > matchingDetCLCTCollection;
58  typedef std::map<CSCDetId, std::pair<std::vector<CSCALCTDigi>, std::vector<CSCALCTDigi> > > matchingDetALCTCollection;
59  typedef std::map<CSCDetId, std::pair<std::vector<CSCCorrelatedLCTDigi>, std::vector<CSCCorrelatedLCTDigi> > >
60  matchingDetLCTCollection;
61 
63  iSetup.get<CSCChamberMapRcd>().get(hcham);
64  const CSCChamberMap* theMapping = hcham.product();
65 
69  Handle<CSCCLCTDigiCollection> _clct, _sclct;
70  Handle<CSCALCTDigiCollection> _alct, _salct;
72  Handle<L1CSCTrackCollection> _trk, _strk;
74 
75  // get wire digis before and after unpacking
76  iEvent.getByToken(wd1_token, _swi);
77  iEvent.getByToken(wd2_token, _wi);
78 
79  //get strip digis before and after unpacking
80  iEvent.getByToken(sd1_token, _sst);
81  iEvent.getByToken(sd2_token, _st);
82 
83  //get comparator digis before and after unpacking
84  iEvent.getByToken(co1_token, _scmp);
85  iEvent.getByToken(co2_token, _cmp);
86 
87  //get clcts
88  iEvent.getByToken(cl1_token, _sclct);
89  iEvent.getByToken(cl2_token, _clct);
90 
91  //get alcts
92  iEvent.getByToken(al1_token, _salct);
93  iEvent.getByToken(al2_token, _alct);
94 
95  //get corr lcts
96  iEvent.getByToken(co1_token, _slct);
97  iEvent.getByToken(co2_token, _lct);
98 
99  //get l1 tracks
100  iEvent.getByToken(tr1_token, _strk);
101  iEvent.getByToken(tr2_token, _trk);
102 
103  //get DT stubs for L1 Tracks
104  iEvent.getByToken(ts1_token, _sdt);
105  iEvent.getByToken(ts2_token, _dt);
106 
107  CSCWireDigiCollection::DigiRangeIterator wi = _wi->begin(), swi = _swi->begin();
108  CSCStripDigiCollection::DigiRangeIterator st = _st->begin(), sst = _sst->begin();
109  CSCComparatorDigiCollection::DigiRangeIterator cmp = _cmp->begin(), scmp = _scmp->begin();
110  CSCCLCTDigiCollection::DigiRangeIterator clct = _clct->begin(), sclct = _sclct->begin();
111  CSCALCTDigiCollection::DigiRangeIterator alct = _alct->begin(), salct = _salct->begin();
112  CSCCorrelatedLCTDigiCollection::DigiRangeIterator lct = _lct->begin(), slct = _slct->begin();
113  L1CSCTrackCollection::const_iterator trk = _trk->begin(), strk = _strk->begin();
114  std::vector<csctf::TrackStub>::const_iterator dt = _dt->get().begin(), sdt = _sdt->get().begin();
115  // WARNING 5_0_X
116  dt++;
117  dt--;
118  sdt++;
119  sdt--;
120 
121  //per detID, create lists of various digi types
122  matchingDetWireCollection wires;
123  matchingDetStripCollection strips;
124  matchingDetComparatorCollection comps;
125  matchingDetCLCTCollection clcts;
126  matchingDetALCTCollection alcts;
127  matchingDetLCTCollection lcts, trackstubs;
129 
130  //wires
131  for (; wi != _wi->end(); ++wi) {
132  CSCWireDigiCollection::const_iterator b = (*wi).second.first, e = (*wi).second.second;
133  std::vector<CSCWireDigi>::iterator beg = wires[(*wi).first].first.end();
134  wires[(*wi).first].first.insert(beg, b, e);
135  }
136  for (; swi != _swi->end(); ++swi) {
137  CSCWireDigiCollection::const_iterator b = (*swi).second.first, e = (*swi).second.second;
138  //convert sim ring 4(ME1/a) to ring 1
139  CSCDetId _id = (*swi).first;
140  if ((*swi).first.ring() == 4)
141  _id = CSCDetId((*swi).first.endcap(), (*swi).first.station(), 1, (*swi).first.chamber(), (*swi).first.layer());
142 
143  std::vector<CSCWireDigi>::iterator beg = wires[_id].second.end();
144 
145  wires[_id].second.insert(beg, b, e);
146  // automatically combine wire digis after each insertion
147  wires[_id].second = sanitizeWireDigis(wires[_id].second.begin(), wires[_id].second.end());
148  }
149 
150  //strips
151  for (; st != _st->end(); ++st) {
152  CSCStripDigiCollection::const_iterator b = (*st).second.first, e = (*st).second.second;
153  std::vector<CSCStripDigi>::iterator beg = strips[(*st).first].first.end();
154 
155  //need to remove strips with no active ADCs
156  std::vector<CSCStripDigi> zs = zeroSupStripDigis(b, e);
157 
158  strips[(*st).first].first.insert(beg, zs.begin(), zs.end());
159  }
160  for (; sst != _sst->end(); ++sst) {
161  CSCStripDigiCollection::const_iterator b = (*sst).second.first, e = (*sst).second.second;
162  // conversion of ring 4->1 not necessary here
163  CSCDetId _id = (*sst).first;
164  //if((*sst).first.ring() == 4)
165  // _id = CSCDetId((*sst).first.endcap(),(*sst).first.station(),
166  // 1, (*sst).first.chamber(),(*sst).first.layer());
167 
168  std::vector<CSCStripDigi>::iterator beg = strips[_id].second.end();
169 
170  std::vector<CSCStripDigi> relab = relabelStripDigis(theMapping, (*sst).first, b, e);
171 
172  strips[_id].second.insert(beg, relab.begin(), relab.end());
173  //strips[_id].second.insert(beg,b,e);
174  }
175 
176  //comparators
177  for (; cmp != _cmp->end(); ++cmp) {
178  CSCComparatorDigiCollection::const_iterator b = (*cmp).second.first, e = (*cmp).second.second;
179  std::vector<CSCComparatorDigi>::iterator beg = comps[(*cmp).first].first.end();
180 
181  comps[(*cmp).first].first.insert(beg, b, e);
182  }
183  for (; scmp != _scmp->end(); ++scmp) {
184  CSCComparatorDigiCollection::const_iterator b = (*scmp).second.first, e = (*scmp).second.second;
185  // convert sim ring 4 (ME1/a) to ring 1
186  CSCDetId _id = (*scmp).first;
187  if ((*scmp).first.ring() == 4)
188  _id =
189  CSCDetId((*scmp).first.endcap(), (*scmp).first.station(), 1, (*scmp).first.chamber(), (*scmp).first.layer());
190 
191  std::vector<CSCComparatorDigi>::iterator beg = comps[_id].second.begin();
192 
193  if ((*scmp).first.ring() == 4)
194  beg = comps[_id].second.end();
195 
196  std::vector<CSCComparatorDigi> zs = zeroSupCompDigis(b, e);
197 
198  std::vector<CSCComparatorDigi> relab = relabelCompDigis(theMapping, (*scmp).first, zs.begin(), zs.end());
199 
200  comps[_id].second.insert(beg, relab.begin(), relab.end());
201  }
202 
203  //CLCTs
204  for (; clct != _clct->end(); ++clct) {
205  CSCCLCTDigiCollection::const_iterator b = (*clct).second.first, e = (*clct).second.second;
206  std::vector<CSCCLCTDigi>::iterator beg = clcts[(*clct).first].first.end();
207 
208  clcts[(*clct).first].first.insert(beg, b, e);
209  }
210  for (; sclct != _sclct->end(); ++sclct) {
211  CSCCLCTDigiCollection::const_iterator b = (*sclct).second.first, e = (*sclct).second.second;
212  // convert sim ring 4 (ME1/a) to ring 1
213  CSCDetId _id = (*sclct).first;
214  if ((*sclct).first.ring() == 4)
215  _id = CSCDetId(
216  (*sclct).first.endcap(), (*sclct).first.station(), 1, (*sclct).first.chamber(), (*sclct).first.layer());
217 
218  std::vector<CSCCLCTDigi>::iterator beg = clcts[_id].second.begin();
219 
220  if ((*sclct).first.ring() == 4)
221  beg = clcts[_id].second.end();
222 
223  clcts[_id].second.insert(beg, b, e);
224  }
225 
226  //ALCTs
227  for (; alct != _alct->end(); ++alct) {
228  CSCALCTDigiCollection::const_iterator b = (*alct).second.first, e = (*alct).second.second;
229  std::vector<CSCALCTDigi>::iterator beg = alcts[(*alct).first].first.end();
230 
231  alcts[(*alct).first].first.insert(beg, b, e);
232  }
233  for (; salct != _salct->end(); ++salct) {
234  CSCALCTDigiCollection::const_iterator b = (*salct).second.first, e = (*salct).second.second;
235  // convert sim ring 4 (ME1/a) to ring 1
236  CSCDetId _id = (*salct).first;
237  if ((*salct).first.ring() == 4)
238  _id = CSCDetId(
239  (*salct).first.endcap(), (*salct).first.station(), 1, (*salct).first.chamber(), (*salct).first.layer());
240 
241  std::vector<CSCALCTDigi>::iterator beg = alcts[_id].second.begin();
242 
243  if ((*salct).first.ring() == 4)
244  beg = alcts[_id].second.end();
245 
246  alcts[_id].second.insert(beg, b, e);
247  }
248 
249  // Correlated LCTs
250  for (; lct != _lct->end(); ++lct) {
251  CSCCorrelatedLCTDigiCollection::const_iterator b = (*lct).second.first, e = (*lct).second.second;
252  std::vector<CSCCorrelatedLCTDigi>::iterator beg = lcts[(*lct).first].first.end();
253 
254  lcts[(*lct).first].first.insert(beg, b, e);
255  }
256  for (; slct != _slct->end(); ++slct) {
257  CSCCorrelatedLCTDigiCollection::const_iterator b = (*slct).second.first, e = (*slct).second.second;
258  // convert sim ring 4 (ME1/a) to ring 1
259  CSCDetId _id = (*slct).first;
260  if ((*slct).first.ring() == 4)
261  _id =
262  CSCDetId((*slct).first.endcap(), (*slct).first.station(), 1, (*slct).first.chamber(), (*slct).first.layer());
263 
264  std::vector<CSCCorrelatedLCTDigi>::iterator beg = lcts[_id].second.begin();
265 
266  if ((*slct).first.ring() == 4)
267  beg = lcts[_id].second.end();
268 
269  lcts[_id].second.insert(beg, b, e);
270  }
271  // remove attached LCT digis from tracks, should be put into their own collection and checked separately
272  for (; trk != _trk->end(); ++trk) {
273  tracks.push_back(trk->first);
274  }
275  for (; strk != _strk->end(); ++strk) {
276  simtracks.push_back(strk->first);
277  }
278 
279  //now loop through each set and process if there are differences!
280  matchingDetWireCollection::const_iterator w;
281  matchingDetStripCollection::const_iterator s;
282  matchingDetComparatorCollection::const_iterator c;
283  matchingDetCLCTCollection::const_iterator cl;
284  matchingDetALCTCollection::const_iterator al;
285  matchingDetLCTCollection::const_iterator lc;
286 
287  for (w = wires.begin(); w != wires.end(); ++w) {
288  if (w->second.first.size() != w->second.second.size()) {
289  std::cout << "Major error! # of wire digis in detID: " << w->first << " is not equal between sim and unpacked!"
290  << std::endl;
291  //eventually do more in this case!
292 
293  std::vector<CSCWireDigi> a = w->second.second;
294  std::vector<CSCWireDigi> b = w->second.first;
295  std::cout << "SIM OUTPUT:" << std::endl;
296  for (std::vector<CSCWireDigi>::const_iterator i = a.begin(); i != a.end(); ++i)
297  i->print();
298  std::cout << "UNPACKER OUTPUT:" << std::endl;
299  for (std::vector<CSCWireDigi>::const_iterator i = b.begin(); i != b.end(); ++i)
300  i->print();
301  }
302  int max = std::min(w->second.first.size(), w->second.second.size());
303  std::vector<CSCWireDigi> cv = w->second.first;
304  std::vector<CSCWireDigi> sv = w->second.second;
305  for (int i = 0; i < max; ++i) {
306  if (sv[i].getWireGroup() != cv[i].getWireGroup()) {
307  std::cout << "In detId: " << w->first << std::endl;
308  std::cout << "Wire Groups do not match: " << sv[i].getWireGroup() << " != " << cv[i].getWireGroup()
309  << std::endl;
310  }
311  if (sv[i].getTimeBin() != cv[i].getTimeBin()) {
312  std::cout << "In detId: " << w->first << std::endl;
313  std::cout << "First Time Bins do not match: " << sv[i].getTimeBin() << " != " << cv[i].getTimeBin()
314  << std::endl;
315  }
316  if (sv[i].getTimeBinWord() != cv[i].getTimeBinWord()) {
317  std::cout << "In detId: " << w->first << std::endl;
318  std::cout << "Time Bin Words do not match: " << sv[i].getTimeBinWord() << " != " << cv[i].getTimeBinWord()
319  << std::endl;
320  }
321  }
322  }
323  for (s = strips.begin(); s != strips.end(); ++s) {
324  if (s->second.first.size() != s->second.second.size()) {
325  std::cout << "Major error! # of strip digis in detID: " << s->first << " is not equal between sim and unpacked!"
326  << std::endl;
327  //eventually do more in this case!
328 
329  std::vector<CSCStripDigi> a = s->second.second;
330  std::vector<CSCStripDigi> b = s->second.first;
331  std::cout << "SIM OUTPUT:" << std::endl;
332  for (std::vector<CSCStripDigi>::const_iterator i = a.begin(); i != a.end(); ++i)
333  i->print();
334  std::cout << "UNPACKER OUTPUT:" << std::endl;
335  for (std::vector<CSCStripDigi>::const_iterator i = b.begin(); i != b.end(); ++i)
336  i->print();
337  }
338  int max = std::min(s->second.first.size(), s->second.second.size());
339  std::vector<CSCStripDigi> cv = s->second.first;
340  std::vector<CSCStripDigi> sv = s->second.second;
341  for (int i = 0; i < max; ++i) {
342  bool me1a = s->first.station() == 1 && s->first.ring() == 4;
343  bool me1b = s->first.station() == 1 && s->first.ring() == 1;
344  bool zplus = s->first.endcap() == 1;
345  int k = i;
346 
347  if (me1a && zplus)
348  k = max - i - 1;
349  if (me1b && !zplus)
350  k = max - i - 1;
351 
352  if (sv[k].getStrip() != cv[i].getStrip()) {
353  std::cout << "In detId: " << s->first << std::endl;
354  std::cout << "Strips do not match: " << sv[k].getStrip() << " != " << cv[i].getStrip() << std::endl;
355  }
356  if (sv[k].getADCCounts().size() != cv[i].getADCCounts().size()) {
357  std::cout << "In detId: " << s->first << std::endl;
358  std::cout << "ADC Readouts not of equal size!" << std::endl;
359  std::cout << sv[k].getADCCounts().size() << ' ' << cv[i].getADCCounts().size() << std::endl;
360  } else {
361  std::vector<int> sADC = sv[k].getADCCounts();
362  std::vector<int> uADC = cv[i].getADCCounts();
363 
364  for (unsigned iadc = 0; iadc < sADC.size(); ++iadc)
365  if (sADC[iadc] != uADC[iadc]) {
366  std::cout << "In detId: " << s->first << std::endl;
367  std::cout << "ADC counts not equal at index: " << iadc << std::endl
368  << std::hex << sADC[iadc] << " != " << uADC[iadc] << std::dec << std::endl;
369  }
370  }
371  if (sv[k].getADCOverflow().size() != cv[i].getADCOverflow().size()) {
372  std::cout << "In detId: " << s->first << std::endl;
373  std::cout << "ADC Overflows not of equal size!" << std::endl;
374  std::cout << sv[k].getADCOverflow().size() << ' ' << cv[i].getADCOverflow().size() << std::endl;
375  } else {
376  std::vector<uint16_t> sADC = sv[k].getADCOverflow();
377  std::vector<uint16_t> uADC = cv[i].getADCOverflow();
378 
379  for (unsigned iadc = 0; iadc < sADC.size(); ++iadc)
380  if (sADC[iadc] != uADC[iadc]) {
381  std::cout << "In detId: " << s->first << std::endl;
382  std::cout << "ADC overflows not equal at index: " << iadc << std::endl
383  << std::hex << sADC[iadc] << " != " << uADC[iadc] << std::dec << std::endl;
384  }
385  }
386  if (sv[k].getOverlappedSample().size() != cv[i].getOverlappedSample().size()) {
387  std::cout << "In detId: " << s->first << std::endl;
388  std::cout << "Overlapped Samples not of equal size!" << std::endl;
389  std::cout << sv[k].getOverlappedSample().size() << ' ' << cv[i].getOverlappedSample().size() << std::endl;
390  } else {
391  std::vector<uint16_t> sADC = sv[k].getOverlappedSample();
392  std::vector<uint16_t> uADC = cv[i].getOverlappedSample();
393 
394  for (unsigned iadc = 0; iadc < sADC.size(); ++iadc)
395  if (sADC[iadc] != uADC[iadc]) {
396  std::cout << "In detId: " << s->first << std::endl;
397  std::cout << "Overlapped Samples not equal at index: " << iadc << std::endl
398  << std::hex << sADC[iadc] << " != " << uADC[iadc] << std::dec << std::endl;
399  }
400  }
401  if (sv[k].getErrorstat().size() != cv[i].getErrorstat().size()) {
402  std::cout << "In detId: " << s->first << std::endl;
403  std::cout << "Errorstat not of equal size!" << std::endl;
404  std::cout << sv[k].getErrorstat().size() << ' ' << cv[i].getErrorstat().size() << std::endl;
405  } else {
406  std::vector<uint16_t> sADC = sv[k].getErrorstat();
407  std::vector<uint16_t> uADC = cv[i].getErrorstat();
408 
409  for (unsigned iadc = 0; iadc < sADC.size(); ++iadc)
410  if (sADC[iadc] != uADC[iadc]) {
411  std::cout << "In detId: " << s->first << std::endl;
412  std::cout << "Errorstat not equal at index: " << iadc << std::endl
413  << std::hex << sADC[iadc] << " != " << uADC[iadc] << std::dec << std::endl;
414  }
415  }
416  if (sv[k].pedestal() != cv[i].pedestal()) {
417  std::cout << "In detId: " << s->first << std::endl;
418  std::cout << "Pedestals not equal: " << sv[k].pedestal() << " != " << cv[i].pedestal() << std::endl;
419  }
420  if (sv[k].amplitude() != cv[i].amplitude()) {
421  std::cout << "In detId: " << s->first << std::endl;
422  std::cout << "Amplitudes not equal: " << sv[k].amplitude() << " != " << cv[i].amplitude() << std::endl;
423  }
424  }
425  }
426  for (c = comps.begin(); c != comps.end(); ++c) {
427  if (c->second.first.size() != c->second.second.size()) {
428  std::cout << "Major error! # of comparator digis in detID: " << c->first
429  << " is not equal between sim and unpacked!" << std::endl;
430  //eventually do more in this case!
431 
432  std::vector<CSCComparatorDigi> a = c->second.second;
433  std::vector<CSCComparatorDigi> b = c->second.first;
434  std::cout << "SIM OUTPUT:" << std::endl;
435  for (std::vector<CSCComparatorDigi>::const_iterator i = a.begin(); i != a.end(); ++i)
436  i->print();
437  std::cout << "UNPACKER OUTPUT:" << std::endl;
438  for (std::vector<CSCComparatorDigi>::const_iterator i = b.begin(); i != b.end(); ++i)
439  i->print();
440  }
441  int max = std::min(c->second.first.size(), c->second.second.size());
442  std::vector<CSCComparatorDigi> cv = c->second.first;
443  std::vector<CSCComparatorDigi> sv = c->second.second;
444  for (int i = 0; i < max; ++i) {
445  if (sv[i].getStrip() != cv[i].getStrip()) {
446  std::cout << "In detId: " << s->first << std::endl;
447  std::cout << "Comparator strips do not match: " << sv[i].getStrip() << " != " << cv[i].getStrip() << std::endl;
448  }
449  if (sv[i].getComparator() != cv[i].getComparator()) {
450  std::cout << "In detId: " << c->first << std::endl;
451  std::cout << "Comparators do not match: " << sv[i].getComparator() << " != " << cv[i].getComparator()
452  << std::endl;
453  }
454  if (sv[i].getTimeBinWord() != cv[i].getTimeBinWord()) {
455  std::cout << "In detId: " << c->first << std::endl;
456  std::cout << "Comparator time bins words do not match: " << sv[i].getTimeBinWord()
457  << " != " << cv[i].getTimeBinWord() << std::endl;
458  }
459  }
460  }
461  for (cl = clcts.begin(); cl != clcts.end(); ++cl) {
462  if (cl->second.first.size() != cl->second.second.size()) {
463  std::cout << "Major error! # of CLCT digis in detID: " << cl->first << " is not equal between sim and unpacked!"
464  << std::endl;
465  //eventually do more in this case!
466 
467  std::vector<CSCCLCTDigi> a = cl->second.second;
468  std::vector<CSCCLCTDigi> b = cl->second.first;
469  std::cout << "SIM OUTPUT:" << std::endl;
470  for (std::vector<CSCCLCTDigi>::const_iterator i = a.begin(); i != a.end(); ++i)
471  i->print();
472  std::cout << "UNPACKER OUTPUT:" << std::endl;
473  for (std::vector<CSCCLCTDigi>::const_iterator i = b.begin(); i != b.end(); ++i)
474  i->print();
475  }
476  int max = std::min(cl->second.first.size(), cl->second.second.size());
477  std::vector<CSCCLCTDigi> cv = cl->second.first;
478  std::vector<CSCCLCTDigi> sv = cl->second.second;
479  for (int i = 0; i < max; ++i) {
480  if (cv[i].getKeyStrip() != sv[i].getKeyStrip()) {
481  std::cout << "In detId: " << cl->first << std::endl;
482  std::cout << "CLCT key strips do not match: " << sv[i].getKeyStrip() << " != " << cv[i].getKeyStrip()
483  << std::endl;
484  }
485  if (cv[i].getStrip() != sv[i].getStrip()) {
486  std::cout << "In detId: " << cl->first << std::endl;
487  std::cout << "CLCT strips do not match: " << sv[i].getStrip() << " != " << cv[i].getStrip() << std::endl;
488  }
489  if (cv[i].isValid() != sv[i].isValid()) {
490  std::cout << "In detId: " << cl->first << std::endl;
491  std::cout << "CLCT Valid bits do not match: " << sv[i].isValid() << " != " << cv[i].isValid() << std::endl;
492  }
493  if (cv[i].getQuality() != sv[i].getQuality()) {
494  std::cout << "In detId: " << cl->first << std::endl;
495  std::cout << "CLCT qualities do not match: " << sv[i].getQuality() << " != " << cv[i].getQuality() << std::endl;
496  }
497  if (cv[i].getPattern() != sv[i].getPattern()) {
498  std::cout << "In detId: " << cl->first << std::endl;
499  std::cout << "CLCT patterns do not match: " << sv[i].getPattern() << " != " << cv[i].getPattern() << std::endl;
500  }
501  if (cv[i].getStripType() != sv[i].getStripType()) {
502  std::cout << "In detId: " << cl->first << std::endl;
503  std::cout << "CLCT strip types do not match: " << sv[i].getStripType() << " != " << cv[i].getStripType()
504  << std::endl;
505  }
506  if (cv[i].getBend() != sv[i].getBend()) {
507  std::cout << "In detId: " << cl->first << std::endl;
508  std::cout << "CLCT bends do not match: " << sv[i].getBend() << " != " << cv[i].getBend() << std::endl;
509  }
510  if (cv[i].getCFEB() != sv[i].getCFEB()) {
511  std::cout << "In detId: " << cl->first << std::endl;
512  std::cout << "CLCT CFEBs do not match: " << sv[i].getCFEB() << " != " << cv[i].getCFEB() << std::endl;
513  }
514  if (((short)cv[i].getBX()) != ((short)sv[i].getBX()) - 4) {
515  std::cout << "In detId: " << cl->first << std::endl;
516  std::cout << "CLCT BX do not match: " << sv[i].getBX() - 4 << " != " << cv[i].getBX() << std::endl;
517  }
518  if (cv[i].getFullBX() != sv[i].getFullBX()) {
519  std::cout << "In detId: " << cl->first << std::endl;
520  std::cout << "CLCT Full BX do not match: " << sv[i].getFullBX() << " != " << cv[i].getFullBX() << std::endl;
521  }
522  if (cv[i].getTrknmb() != sv[i].getTrknmb()) {
523  std::cout << "In detId: " << cl->first << std::endl;
524  std::cout << "CLCT Track numbers do not match: " << sv[i].getTrknmb() << " != " << cv[i].getTrknmb()
525  << std::endl;
526  }
527  }
528  }
529  for (al = alcts.begin(); al != alcts.end(); ++al) {
530  if (al->second.first.size() != al->second.second.size()) {
531  std::cout << "Major error! # of ALCT digis in detID: " << al->first << " is not equal between sim and unpacked!"
532  << std::endl;
533  //eventually do more in this case!
534 
535  std::vector<CSCALCTDigi> a = al->second.second;
536  std::vector<CSCALCTDigi> b = al->second.first;
537  std::cout << "SIM OUTPUT:" << std::endl;
538  for (std::vector<CSCALCTDigi>::const_iterator i = a.begin(); i != a.end(); ++i)
539  i->print();
540  std::cout << "UNPACKER OUTPUT:" << std::endl;
541  for (std::vector<CSCALCTDigi>::const_iterator i = b.begin(); i != b.end(); ++i)
542  i->print();
543  }
544  int max = std::min(al->second.first.size(), al->second.second.size());
545  std::vector<CSCALCTDigi> cv = al->second.first;
546  std::vector<CSCALCTDigi> sv = al->second.second;
547  for (int i = 0; i < max; ++i) {
548  if (cv[i].getKeyWG() != sv[i].getKeyWG()) {
549  std::cout << "In detId: " << al->first << std::endl;
550  std::cout << "ALCT key wire groups do not match: " << sv[i].getKeyWG() << " != " << cv[i].getKeyWG()
551  << std::endl;
552  }
553  if (cv[i].isValid() != sv[i].isValid()) {
554  std::cout << "In detId: " << al->first << std::endl;
555  std::cout << "ALCT Valid bits do not match: " << sv[i].isValid() << " != " << cv[i].isValid() << std::endl;
556  }
557  if (cv[i].getQuality() != sv[i].getQuality()) {
558  std::cout << "In detId: " << al->first << std::endl;
559  std::cout << "ALCT qualities do not match: " << sv[i].getQuality() << " != " << cv[i].getQuality() << std::endl;
560  }
561  if (cv[i].getAccelerator() != sv[i].getAccelerator()) {
562  std::cout << "In detId: " << al->first << std::endl;
563  std::cout << "ALCT accelerator bits do not match: " << sv[i].getAccelerator()
564  << " != " << cv[i].getAccelerator() << std::endl;
565  }
566  if (cv[i].getCollisionB() != sv[i].getCollisionB()) {
567  std::cout << "In detId: " << al->first << std::endl;
568  std::cout << "ALCT CollisionB flags do not match: " << sv[i].getCollisionB() << " != " << cv[i].getCollisionB()
569  << std::endl;
570  }
571  if ((cv[i].getBX()) != (sv[i].getBX())) {
572  std::cout << "In detId: " << al->first << std::endl;
573  std::cout << "ALCT BX do not match: " << sv[i].getBX() << " != " << cv[i].getBX() << std::endl;
574  }
575  if (cv[i].getFullBX() != sv[i].getFullBX()) {
576  std::cout << "In detId: " << cl->first << std::endl;
577  std::cout << "ALCT Full BX do not match: " << sv[i].getFullBX() << " != " << cv[i].getFullBX() << std::endl;
578  }
579  }
580  }
581  for (lc = lcts.begin(); lc != lcts.end(); ++lc) {
582  if (lc->second.first.size() != lc->second.second.size()) {
583  std::cout << "Major error! # of Correlated LCT digis in detID: " << lc->first
584  << " is not equal between sim and unpacked!" << std::endl;
585  //eventually do more in this case!
586 
587  std::vector<CSCCorrelatedLCTDigi> a = lc->second.second;
588  std::vector<CSCCorrelatedLCTDigi> b = lc->second.first;
589  std::cout << "SIM OUTPUT:" << std::endl;
590  for (std::vector<CSCCorrelatedLCTDigi>::const_iterator i = a.begin(); i != a.end(); ++i)
591  i->print();
592  std::cout << "UNPACKER OUTPUT:" << std::endl;
593  for (std::vector<CSCCorrelatedLCTDigi>::const_iterator i = b.begin(); i != b.end(); ++i)
594  i->print();
595  }
596  int max = std::min(lc->second.first.size(), lc->second.second.size());
597  std::vector<CSCCorrelatedLCTDigi> cv = lc->second.first;
598  std::vector<CSCCorrelatedLCTDigi> sv = lc->second.second;
599  for (int i = 0; i < max; ++i) {
600  if (cv[i].getStrip() != sv[i].getStrip()) {
601  std::cout << "In detId: " << lc->first << std::endl;
602  std::cout << "Correlated LCT strips do not match: " << sv[i].getStrip() << " != " << cv[i].getStrip()
603  << std::endl;
604  }
605  if (cv[i].getKeyWG() != sv[i].getKeyWG()) {
606  std::cout << "In detId: " << lc->first << std::endl;
607  std::cout << "Correlated LCT key wire groups do not match: " << sv[i].getKeyWG() << " != " << cv[i].getKeyWG()
608  << std::endl;
609  }
610  if (cv[i].isValid() != sv[i].isValid()) {
611  std::cout << "In detId: " << lc->first << std::endl;
612  std::cout << "Correlated LCT Valid bits do not match: " << sv[i].isValid() << " != " << cv[i].isValid()
613  << std::endl;
614  }
615  if (cv[i].getQuality() != sv[i].getQuality()) {
616  std::cout << "In detId: " << lc->first << std::endl;
617  std::cout << "Correlated LCT qualities do not match: " << sv[i].getQuality() << " != " << cv[i].getQuality()
618  << std::endl;
619  }
620  if (cv[i].getPattern() != sv[i].getPattern()) {
621  std::cout << "In detId: " << lc->first << std::endl;
622  std::cout << "Correlated LCT ALCT patterns do not match: " << sv[i].getPattern() << " != " << cv[i].getPattern()
623  << std::endl;
624  }
625  if (cv[i].getCLCTPattern() != sv[i].getCLCTPattern()) {
626  std::cout << "In detId: " << lc->first << std::endl;
627  std::cout << "Correlated LCT CLCT patterns do not match: " << sv[i].getCLCTPattern()
628  << " != " << cv[i].getCLCTPattern() << std::endl;
629  }
630  if (cv[i].getStripType() != sv[i].getStripType()) {
631  std::cout << "In detId: " << lc->first << std::endl;
632  std::cout << "Correlated LCT strip types do not match: " << sv[i].getStripType()
633  << " != " << cv[i].getStripType() << std::endl;
634  }
635  if (cv[i].getBend() != sv[i].getBend()) {
636  std::cout << "In detId: " << lc->first << std::endl;
637  std::cout << "Correlated LCT bends do not match: " << sv[i].getBend() << " != " << cv[i].getBend() << std::endl;
638  }
639  if (cv[i].getMPCLink() != sv[i].getMPCLink()) {
640  std::cout << "In detId: " << lc->first << std::endl;
641  std::cout << "Correlated LCT MPC Links do not match: " << sv[i].getMPCLink() << " != " << cv[i].getMPCLink()
642  << std::endl;
643  }
644  if ((cv[i].getBX()) != (sv[i].getBX() - 6)) {
645  std::cout << "In detId: " << lc->first << std::endl;
646  std::cout << "Correlated LCT BX do not match: " << sv[i].getBX() - 6 << " != " << cv[i].getBX() << std::endl;
647  }
648  if (cv[i].getCSCID() != sv[i].getCSCID()) {
649  std::cout << "In detId: " << lc->first << std::endl;
650  std::cout << "Correlated LCT CSCIDs do not match: " << sv[i].getCSCID() << " != " << cv[i].getCSCID()
651  << std::endl;
652  }
653  if (cv[i].getBX0() != sv[i].getBX0()) {
654  std::cout << "In detId: " << lc->first << std::endl;
655  std::cout << "Correlated LCT BX0s do not match: " << sv[i].getBX0() << " != " << cv[i].getBX0() << std::endl;
656  }
657  if (cv[i].getSyncErr() != sv[i].getSyncErr()) {
658  std::cout << "In detId: " << lc->first << std::endl;
659  std::cout << "Correlated LCT SyncErrs do not match: " << sv[i].getSyncErr() << " != " << cv[i].getSyncErr()
660  << std::endl;
661  }
662  if (cv[i].getTrknmb() != sv[i].getTrknmb()) {
663  std::cout << "In detId: " << lc->first << std::endl;
664  std::cout << "Correlated LCT Track numbers do not match: " << sv[i].getTrknmb() << " != " << cv[i].getTrknmb()
665  << std::endl;
666  }
667  }
668  }
669  if (tracks.get().size() != simtracks.get().size()) {
670  std::cout << "Major error! # of L1 Tracks is not equal between sim and unpacked!" << std::endl;
671  std::vector<csc::L1Track> a = simtracks.get();
672  std::vector<csc::L1Track> b = tracks.get();
673  std::cout << "SIM OUTPUT:" << std::endl;
674  for (std::vector<csc::L1Track>::const_iterator i = a.begin(); i != a.end(); ++i)
675  i->print();
676  std::cout << "UNPACKER OUTPUT:" << std::endl;
677  for (std::vector<csc::L1Track>::const_iterator i = b.begin(); i != b.end(); ++i)
678  i->print();
679  }
680 
681  return _err;
682 }
683 
684 // this function takes the sim wire digis and combines wire digis from the same wire
685 // into one wire digi, as in the data.
686 // returns a vector of the combined wire digis
687 std::vector<CSCWireDigi> CSCDigiValidator::sanitizeWireDigis(std::vector<CSCWireDigi>::const_iterator b,
688  std::vector<CSCWireDigi>::const_iterator e) {
689  typedef std::map<int, std::vector<CSCWireDigi> > wire2digi;
690 
691  std::vector<CSCWireDigi> _r; // the resulting vector of wire digis
692  wire2digi _wr2digis; // map of wires to a set of digis
693 
694  for (std::vector<CSCWireDigi>::const_iterator i = b; i != e; ++i)
695  _wr2digis[i->getWireGroup()].push_back(*i);
696 
697  for (wire2digi::const_iterator i = _wr2digis.begin(); i != _wr2digis.end(); ++i) {
698  int wire = i->first;
699  unsigned tbin = 0x0;
700 
701  for (std::vector<CSCWireDigi>::const_iterator d = i->second.begin(); d != i->second.end(); ++d) {
702  std::vector<int> binson = d->getTimeBinsOn();
703  for (std::vector<int>::const_iterator t = binson.begin(); t != binson.end(); ++t)
704  tbin |= 1 << (*t);
705  }
706 
707  _r.push_back(CSCWireDigi(wire, tbin));
708  }
709 
710  return _r;
711 }
712 
713 std::vector<CSCStripDigi> CSCDigiValidator::relabelStripDigis(const CSCChamberMap* m,
714  CSCDetId _id,
715  std::vector<CSCStripDigi>::const_iterator b,
716  std::vector<CSCStripDigi>::const_iterator e) {
717  std::vector<CSCStripDigi> _r; // the vector of strip digis with appropriate strip #'s
718 
719  //bool me1a = _id.station()==1 && _id.ring()==4;
720  //bool zplus = _id.endcap()==1;
721  //bool me1b = _id.station()==1 && _id.ring()==1;
722 
723  for (std::vector<CSCStripDigi>::const_iterator i = b; i != e; ++i) {
724  int strip = i->getStrip();
725 
726  //if(me1a&&zplus) strip=17-strip;
727  //if(me1b&&!zplus) strip=(65-strip-1)%(m->dmb(_id)*16) + 1;
728  //if(me1a) strip+=64;
729 
730  _r.push_back(
731  CSCStripDigi(strip, i->getADCCounts(), i->getADCOverflow(), i->getOverlappedSample(), i->getErrorstat()));
732  }
733  return _r;
734 }
735 
736 std::vector<CSCComparatorDigi> CSCDigiValidator::relabelCompDigis(const CSCChamberMap* m,
737  CSCDetId _id,
738  std::vector<CSCComparatorDigi>::const_iterator b,
739  std::vector<CSCComparatorDigi>::const_iterator e) {
740  std::vector<CSCComparatorDigi> _r; // the vector of comp digis with appropriate strip #'s
741 
742  bool me1a = _id.station() == 1 && _id.ring() == 4;
743  //bool zplus = _id.endcap()==1;
744  //bool me1b = _id.station()==1 && _id.ring()==1;
745 
746  for (std::vector<CSCComparatorDigi>::const_iterator i = b; i != e; ++i) {
747  int strip = i->getStrip();
748 
749  // if(me1a&&zplus) strip=17-strip;
750  // if(me1b&&!zplus) strip=65-strip;
751  if (me1a)
752  strip += 64;
753 
754  _r.push_back(CSCComparatorDigi(strip, i->getComparator(), i->getTimeBinWord()));
755  }
756  return _r;
757 }
758 
759 std::vector<CSCStripDigi> CSCDigiValidator::sanitizeStripDigis(std::vector<CSCStripDigi>::const_iterator b,
760  std::vector<CSCStripDigi>::const_iterator e) {
761  std::vector<CSCStripDigi> _r; // vector of digis in proper order
762 
763  return _r;
764 }
765 
766 std::vector<CSCStripDigi> CSCDigiValidator::zeroSupStripDigis(std::vector<CSCStripDigi>::const_iterator b,
767  std::vector<CSCStripDigi>::const_iterator e) {
768  std::vector<CSCStripDigi> _r; // zero-suppressed strip digis
769  std::vector<int> counts;
770 
771  for (std::vector<CSCStripDigi>::const_iterator i = b; i != e; ++i) {
772  bool nonzero = false;
773  counts = i->getADCCounts();
774  for (std::vector<int>::const_iterator a = counts.begin(); a != counts.end(); ++a)
775  if ((*a) != 0)
776  nonzero = true;
777 
778  if (nonzero)
779  _r.push_back(*i);
780  }
781 
782  return _r;
783 }
784 
785 // remove comparator digis on or after the 10th time bin, for now, will be configurable later.
786 std::vector<CSCComparatorDigi> CSCDigiValidator::zeroSupCompDigis(std::vector<CSCComparatorDigi>::const_iterator b,
787  std::vector<CSCComparatorDigi>::const_iterator e) {
788  std::vector<CSCComparatorDigi> _r;
789 
790  for (std::vector<CSCComparatorDigi>::const_iterator i = b; i != e; ++i) {
791  bool present = false;
792 
793  if (i->getTimeBin() < 10)
794  present = true;
795 
796  if (present)
797  _r.push_back(*i);
798  }
799 
800  return _r;
801 }
802 
804 
size
Write out results.
T getParameter(std::string const &) const
float dt
Definition: AMPTWrapper.h:136
edm::EDGetTokenT< CSCComparatorDigiCollection > cd1_token
~CSCDigiValidator() override
std::vector< T > get() const
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:525
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
void endJob() override
edm::EDGetTokenT< CSCCLCTDigiCollection > cl1_token
edm::EDGetTokenT< CSCCLCTDigiCollection > cl2_token
edm::EDGetTokenT< CSCALCTDigiCollection > al1_token
void beginJob() override
cv
Definition: cuy.py:364
edm::EDGetTokenT< CSCCorrelatedLCTDigiCollection > co2_token
edm::EDGetTokenT< CSCALCTDigiCollection > al2_token
void push_back(const T &data)
U second(std::pair< T, U > const &p)
int iEvent
Definition: GenABIO.cc:224
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
d
Definition: ztail.py:151
edm::EDGetTokenT< CSCStripDigiCollection > sd2_token
edm::EDGetTokenT< CSCWireDigiCollection > wd2_token
int ring() const
Definition: CSCDetId.h:68
CSCDigiValidator(const edm::ParameterSet &)
edm::EDGetTokenT< CSCTriggerContainer< csctf::TrackStub > > ts2_token
bool filter(edm::Event &, const edm::EventSetup &) override
double b
Definition: hdecay.h:118
std::vector< DigiType >::const_iterator const_iterator
edm::EDGetTokenT< CSCCorrelatedLCTDigiCollection > co1_token
def nonzero(self)
edm::EDGetTokenT< CSCComparatorDigiCollection > cd2_token
edm::EDGetTokenT< L1CSCTrackCollection > tr2_token
HLT enums.
std::vector< CSCStripDigi > zeroSupStripDigis(std::vector< CSCStripDigi >::const_iterator, std::vector< CSCStripDigi >::const_iterator)
double a
Definition: hdecay.h:119
T get() const
Definition: EventSetup.h:73
strips
#turn off noise in all subdetectors simHcalUnsuppressedDigis.doNoise = False mix.digitizers.hcal.doNoise = False simEcalUnsuppressedDigis.doNoise = False mix.digitizers.ecal.doNoise = False simEcalUnsuppressedDigis.doESNoise = False simSiPixelDigis.AddNoise = False mix.digitizers.pixel.AddNoise = False simSiStripDigis.Noise = False mix.digitizers.strip.AddNoise = False
Definition: DigiDM_cff.py:32
int station() const
Definition: CSCDetId.h:79
std::vector< CSCWireDigi > sanitizeWireDigis(std::vector< CSCWireDigi >::const_iterator, std::vector< CSCWireDigi >::const_iterator)
T const * product() const
Definition: ESHandle.h:86
std::vector< CSCStripDigi > relabelStripDigis(const CSCChamberMap *, CSCDetId, std::vector< CSCStripDigi >::const_iterator, std::vector< CSCStripDigi >::const_iterator)