00001
00002
00003
00004
00005
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <memory>
00023 #include <map>
00024 #include <vector>
00025 #include <algorithm>
00026
00027
00028 #include "EventFilter/CSCRawToDigi/interface/CSCDigiValidator.h"
00029 #include "FWCore/Framework/interface/Event.h"
00030 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00031
00032 #include "DataFormats/Common/interface/Handle.h"
00033 #include "FWCore/Framework/interface/ESHandle.h"
00034 #include "FWCore/Framework/interface/EventSetup.h"
00035 #include "DataFormats/MuonDetId/interface/CSCDetId.h"
00036 #include "DataFormats/CSCDigi/interface/CSCWireDigiCollection.h"
00037 #include "DataFormats/CSCDigi/interface/CSCStripDigiCollection.h"
00038 #include "DataFormats/CSCDigi/interface/CSCComparatorDigiCollection.h"
00039 #include "DataFormats/CSCDigi/interface/CSCALCTDigiCollection.h"
00040 #include "DataFormats/CSCDigi/interface/CSCCLCTDigiCollection.h"
00041 #include "DataFormats/CSCDigi/interface/CSCCorrelatedLCTDigiCollection.h"
00042 #include "DataFormats/L1CSCTrackFinder/interface/TrackStub.h"
00043 #include "DataFormats/L1CSCTrackFinder/interface/CSCTriggerContainer.h"
00044 #include "DataFormats/L1CSCTrackFinder/interface/L1CSCTrackCollection.h"
00045 #include "FWCore/Framework/interface/ESHandle.h"
00046 #include "CondFormats/CSCObjects/interface/CSCChamberMap.h"
00047 #include "CondFormats/DataRecord/interface/CSCChamberMapRcd.h"
00048
00049
00050
00051
00052
00053
00054
00055 CSCDigiValidator::CSCDigiValidator(const edm::ParameterSet& iConfig) :
00056 wire1(iConfig.getUntrackedParameter<edm::InputTag>("inputWire")),
00057 strip1(iConfig.getUntrackedParameter<edm::InputTag>("inputStrip")),
00058 comp1(iConfig.getUntrackedParameter<edm::InputTag>("inputComp")),
00059 clct1(iConfig.getUntrackedParameter<edm::InputTag>("inputCLCT")),
00060 alct1(iConfig.getUntrackedParameter<edm::InputTag>("inputALCT")),
00061 lct1(iConfig.getUntrackedParameter<edm::InputTag>("inputCorrLCT")),
00062 csctf1(iConfig.getUntrackedParameter<edm::InputTag>("inputCSCTF")),
00063 csctfstubs1(iConfig.getUntrackedParameter<edm::InputTag>("inputCSCTFStubs")),
00064 wire2(iConfig.getUntrackedParameter<edm::InputTag>("repackWire")),
00065 strip2(iConfig.getUntrackedParameter<edm::InputTag>("repackStrip")),
00066 comp2(iConfig.getUntrackedParameter<edm::InputTag>("repackComp")),
00067 clct2(iConfig.getUntrackedParameter<edm::InputTag>("repackCLCT")),
00068 alct2(iConfig.getUntrackedParameter<edm::InputTag>("repackALCT")),
00069 lct2(iConfig.getUntrackedParameter<edm::InputTag>("repackCorrLCT")),
00070 csctf2(iConfig.getUntrackedParameter<edm::InputTag>("repackCSCTF")),
00071 csctfstubs2(iConfig.getUntrackedParameter<edm::InputTag>("repackCSCTFStubs"))
00072
00073 {
00074
00075
00076 }
00077
00078
00079 CSCDigiValidator::~CSCDigiValidator()
00080 {
00081
00082
00083
00084
00085 }
00086
00087
00088
00089
00090
00091
00092
00093 bool
00094 CSCDigiValidator::filter(edm::Event& iEvent, const edm::EventSetup& iSetup)
00095 {
00096 bool _err = false;
00097 using namespace edm;
00098
00099 typedef std::map<CSCDetId,
00100 std::pair<std::vector<CSCWireDigi>,std::vector<CSCWireDigi> > >
00101 matchingDetWireCollection;
00102 typedef std::map<CSCDetId,
00103 std::pair<std::vector<CSCStripDigi>,std::vector<CSCStripDigi> > >
00104 matchingDetStripCollection;
00105 typedef std::map<CSCDetId,
00106 std::pair<std::vector<CSCComparatorDigi>,std::vector<CSCComparatorDigi> > >
00107 matchingDetComparatorCollection;
00108 typedef std::map<CSCDetId,
00109 std::pair<std::vector<CSCCLCTDigi>,std::vector<CSCCLCTDigi> > >
00110 matchingDetCLCTCollection;
00111 typedef std::map<CSCDetId,
00112 std::pair<std::vector<CSCALCTDigi>,std::vector<CSCALCTDigi> > >
00113 matchingDetALCTCollection;
00114 typedef std::map<CSCDetId,
00115 std::pair<std::vector<CSCCorrelatedLCTDigi>,std::vector<CSCCorrelatedLCTDigi> > >
00116 matchingDetLCTCollection;
00117
00118
00119
00120
00121 edm::ESHandle<CSCChamberMap> hcham;
00122 iSetup.get<CSCChamberMapRcd>().get(hcham);
00123 const CSCChamberMap* theMapping = hcham.product();
00124
00125 Handle<CSCWireDigiCollection> _wi,_swi;
00126 Handle<CSCStripDigiCollection> _st,_sst;
00127 Handle<CSCComparatorDigiCollection> _cmp,_scmp;
00128 Handle<CSCCLCTDigiCollection> _clct, _sclct;
00129 Handle<CSCALCTDigiCollection> _alct, _salct;
00130 Handle<CSCCorrelatedLCTDigiCollection> _lct, _slct;
00131 Handle<L1CSCTrackCollection> _trk, _strk;
00132 Handle<CSCTriggerContainer<csctf::TrackStub> > _dt, _sdt;
00133
00134
00135 iEvent.getByLabel(wire1,_swi);
00136 iEvent.getByLabel(wire2,_wi);
00137
00138
00139 iEvent.getByLabel(strip1,_sst);
00140 iEvent.getByLabel(strip2,_st);
00141
00142
00143 iEvent.getByLabel(comp1,_scmp);
00144 iEvent.getByLabel(comp2,_cmp);
00145
00146
00147 iEvent.getByLabel(clct1,_sclct);
00148 iEvent.getByLabel(clct2,_clct);
00149
00150
00151 iEvent.getByLabel(alct1,_salct);
00152 iEvent.getByLabel(alct2,_alct);
00153
00154
00155 iEvent.getByLabel(lct1,_slct);
00156 iEvent.getByLabel(lct2,_lct);
00157
00158
00159 iEvent.getByLabel(csctf1,_strk);
00160 iEvent.getByLabel(csctfstubs1,_sdt);
00161 iEvent.getByLabel(csctf2,_trk);
00162 iEvent.getByLabel(csctfstubs2,_dt);
00163
00164
00165
00166 CSCWireDigiCollection::DigiRangeIterator
00167 wi = _wi->begin(), swi= _swi->begin();
00168 CSCStripDigiCollection::DigiRangeIterator
00169 st = _st->begin(), sst = _sst->begin();
00170 CSCComparatorDigiCollection::DigiRangeIterator
00171 cmp = _cmp->begin(), scmp = _scmp->begin();
00172 CSCCLCTDigiCollection::DigiRangeIterator
00173 clct = _clct->begin(), sclct = _sclct->begin();
00174 CSCALCTDigiCollection::DigiRangeIterator
00175 alct = _alct->begin(), salct = _salct->begin();
00176 CSCCorrelatedLCTDigiCollection::DigiRangeIterator
00177 lct = _lct->begin(), slct = _slct->begin();
00178 L1CSCTrackCollection::const_iterator
00179 trk = _trk->begin(), strk = _strk->begin();
00180 std::vector<csctf::TrackStub>::const_iterator
00181 dt = _dt->get().begin(), sdt = _sdt->get().begin();
00182
00183 dt++; dt--; sdt++; sdt--;
00184
00185
00186 matchingDetWireCollection wires;
00187 matchingDetStripCollection strips;
00188 matchingDetComparatorCollection comps;
00189 matchingDetCLCTCollection clcts;
00190 matchingDetALCTCollection alcts;
00191 matchingDetLCTCollection lcts,trackstubs;
00192 CSCTriggerContainer<csc::L1Track> tracks, simtracks;
00193
00194
00195 for(;wi != _wi->end();++wi)
00196 {
00197 CSCWireDigiCollection::const_iterator
00198 b=(*wi).second.first,e=(*wi).second.second;
00199 std::vector<CSCWireDigi>::iterator
00200 beg=wires[(*wi).first].first.end();
00201 wires[(*wi).first].first.insert(beg,b,e);
00202 }
00203 for(;swi != _swi->end();++swi)
00204 {
00205 CSCWireDigiCollection::const_iterator
00206 b=(*swi).second.first,e=(*swi).second.second;
00207
00208 CSCDetId _id = (*swi).first;
00209 if((*swi).first.ring() == 4)
00210 _id = CSCDetId((*swi).first.endcap(),(*swi).first.station(),
00211 1, (*swi).first.chamber(),(*swi).first.layer());
00212
00213 std::vector<CSCWireDigi>::iterator
00214 beg=wires[_id].second.end();
00215
00216 wires[_id].second.insert(beg,b,e);
00217
00218 wires[_id].second = sanitizeWireDigis(wires[_id].second.begin(),
00219 wires[_id].second.end());
00220 }
00221
00222
00223 for(;st != _st->end();++st)
00224 {
00225 CSCStripDigiCollection::const_iterator
00226 b=(*st).second.first,e=(*st).second.second;
00227 std::vector<CSCStripDigi>::iterator
00228 beg=strips[(*st).first].first.end();
00229
00230
00231 std::vector<CSCStripDigi> zs = zeroSupStripDigis(b,e);
00232
00233 strips[(*st).first].first.insert(beg,zs.begin(),zs.end());
00234 }
00235 for(;sst != _sst->end();++sst)
00236 {
00237 CSCStripDigiCollection::const_iterator
00238 b=(*sst).second.first,e=(*sst).second.second;
00239
00240 CSCDetId _id = (*sst).first;
00241
00242
00243
00244
00245 std::vector<CSCStripDigi>::iterator
00246 beg=strips[_id].second.end();
00247
00248 std::vector<CSCStripDigi> relab = relabelStripDigis(theMapping,(*sst).first,b,e);
00249
00250 strips[_id].second.insert(beg,relab.begin(),relab.end());
00251
00252 }
00253
00254
00255 for(;cmp != _cmp->end();++cmp)
00256 {
00257 CSCComparatorDigiCollection::const_iterator
00258 b=(*cmp).second.first,e=(*cmp).second.second;
00259 std::vector<CSCComparatorDigi>::iterator
00260 beg=comps[(*cmp).first].first.end();
00261
00262 comps[(*cmp).first].first.insert(beg,b,e);
00263 }
00264 for(;scmp != _scmp->end();++scmp)
00265 {
00266 CSCComparatorDigiCollection::const_iterator
00267 b=(*scmp).second.first,e=(*scmp).second.second;
00268
00269 CSCDetId _id = (*scmp).first;
00270 if((*scmp).first.ring() == 4)
00271 _id = CSCDetId((*scmp).first.endcap(),(*scmp).first.station(),
00272 1, (*scmp).first.chamber(),(*scmp).first.layer());
00273
00274 std::vector<CSCComparatorDigi>::iterator
00275 beg=comps[_id].second.begin();
00276
00277 if((*scmp).first.ring()==4)
00278 beg=comps[_id].second.end();
00279
00280 std::vector<CSCComparatorDigi> zs =
00281 zeroSupCompDigis(b,e);
00282
00283 std::vector<CSCComparatorDigi> relab =
00284 relabelCompDigis(theMapping,(*scmp).first,
00285 zs.begin(),
00286 zs.end());
00287
00288 comps[_id].second.insert(beg,relab.begin(),relab.end());
00289 }
00290
00291
00292 for(;clct != _clct->end();++clct)
00293 {
00294 CSCCLCTDigiCollection::const_iterator
00295 b=(*clct).second.first,e=(*clct).second.second;
00296 std::vector<CSCCLCTDigi>::iterator
00297 beg=clcts[(*clct).first].first.end();
00298
00299 clcts[(*clct).first].first.insert(beg,b,e);
00300 }
00301 for(;sclct != _sclct->end();++sclct)
00302 {
00303 CSCCLCTDigiCollection::const_iterator
00304 b=(*sclct).second.first,e=(*sclct).second.second;
00305
00306 CSCDetId _id = (*sclct).first;
00307 if((*sclct).first.ring() == 4)
00308 _id = CSCDetId((*sclct).first.endcap(),(*sclct).first.station(),
00309 1, (*sclct).first.chamber(),(*sclct).first.layer());
00310
00311 std::vector<CSCCLCTDigi>::iterator
00312 beg=clcts[_id].second.begin();
00313
00314 if((*sclct).first.ring()==4)
00315 beg=clcts[_id].second.end();
00316
00317 clcts[_id].second.insert(beg,b,e);
00318 }
00319
00320
00321 for(;alct != _alct->end();++alct)
00322 {
00323 CSCALCTDigiCollection::const_iterator
00324 b=(*alct).second.first,e=(*alct).second.second;
00325 std::vector<CSCALCTDigi>::iterator
00326 beg=alcts[(*alct).first].first.end();
00327
00328 alcts[(*alct).first].first.insert(beg,b,e);
00329 }
00330 for(;salct != _salct->end();++salct)
00331 {
00332 CSCALCTDigiCollection::const_iterator
00333 b=(*salct).second.first,e=(*salct).second.second;
00334
00335 CSCDetId _id = (*salct).first;
00336 if((*salct).first.ring() == 4)
00337 _id = CSCDetId((*salct).first.endcap(),(*salct).first.station(),
00338 1, (*salct).first.chamber(),(*salct).first.layer());
00339
00340 std::vector<CSCALCTDigi>::iterator
00341 beg=alcts[_id].second.begin();
00342
00343 if((*salct).first.ring()==4)
00344 beg=alcts[_id].second.end();
00345
00346 alcts[_id].second.insert(beg,b,e);
00347 }
00348
00349
00350 for(;lct != _lct->end();++lct)
00351 {
00352 CSCCorrelatedLCTDigiCollection::const_iterator
00353 b=(*lct).second.first,e=(*lct).second.second;
00354 std::vector<CSCCorrelatedLCTDigi>::iterator
00355 beg=lcts[(*lct).first].first.end();
00356
00357 lcts[(*lct).first].first.insert(beg,b,e);
00358 }
00359 for(;slct != _slct->end();++slct)
00360 {
00361 CSCCorrelatedLCTDigiCollection::const_iterator
00362 b=(*slct).second.first,e=(*slct).second.second;
00363
00364 CSCDetId _id = (*slct).first;
00365 if((*slct).first.ring() == 4)
00366 _id = CSCDetId((*slct).first.endcap(),(*slct).first.station(),
00367 1, (*slct).first.chamber(),(*slct).first.layer());
00368
00369 std::vector<CSCCorrelatedLCTDigi>::iterator
00370 beg=lcts[_id].second.begin();
00371
00372 if((*slct).first.ring()==4)
00373 beg=lcts[_id].second.end();
00374
00375 lcts[_id].second.insert(beg,b,e);
00376 }
00377
00378 for(; trk != _trk->end(); ++trk)
00379 {
00380 tracks.push_back(trk->first);
00381
00382 }
00383 for(;strk != _strk->end(); ++strk)
00384 {
00385 simtracks.push_back(strk->first);
00386 }
00387
00388
00389 matchingDetWireCollection::const_iterator w;
00390 matchingDetStripCollection::const_iterator s;
00391 matchingDetComparatorCollection::const_iterator c;
00392 matchingDetCLCTCollection::const_iterator cl;
00393 matchingDetALCTCollection::const_iterator al;
00394 matchingDetLCTCollection::const_iterator lc;
00395
00396 for(w = wires.begin(); w != wires.end(); ++w)
00397 {
00398 if(w->second.first.size() != w->second.second.size())
00399 {
00400 std::cout << "Major error! # of wire digis in detID: " << w->first
00401 << " is not equal between sim and unpacked!" << std::endl;
00402
00403
00404 std::vector<CSCWireDigi> a = w->second.second;
00405 std::vector<CSCWireDigi> b = w->second.first;
00406 std::cout << "SIM OUTPUT:" << std::endl;
00407 for(std::vector<CSCWireDigi>::const_iterator i = a.begin(); i != a.end(); ++i)
00408 i->print();
00409 std::cout << "UNPACKER OUTPUT:" << std::endl;
00410 for(std::vector<CSCWireDigi>::const_iterator i = b.begin(); i != b.end(); ++i)
00411 i->print();
00412
00413 }
00414 int max = std::min(w->second.first.size(),w->second.second.size());
00415 std::vector<CSCWireDigi> cv = w->second.first;
00416 std::vector<CSCWireDigi> sv = w->second.second;
00417 for(int i = 0; i < max; ++i)
00418 {
00419 if(sv[i].getWireGroup() != cv[i].getWireGroup())
00420 {
00421 std::cout << "In detId: " << w->first << std::endl;
00422 std::cout << "Wire Groups do not match: " << sv[i].getWireGroup()
00423 << " != " << cv[i].getWireGroup() << std::endl;
00424 }
00425 if(sv[i].getTimeBin() != cv[i].getTimeBin())
00426 {
00427 std::cout << "In detId: " << w->first << std::endl;
00428 std::cout << "First Time Bins do not match: " << sv[i].getTimeBin()
00429 << " != " << cv[i].getTimeBin() << std::endl;
00430 }
00431 if(sv[i].getTimeBinWord() != cv[i].getTimeBinWord())
00432 {
00433 std::cout << "In detId: " << w->first << std::endl;
00434 std::cout << "Time Bin Words do not match: " << sv[i].getTimeBinWord()
00435 << " != " << cv[i].getTimeBinWord() << std::endl;
00436 }
00437 }
00438 }
00439 for(s = strips.begin(); s != strips.end(); ++s)
00440 {
00441 if(s->second.first.size() != s->second.second.size())
00442 {
00443 std::cout << "Major error! # of strip digis in detID: " << s->first
00444 << " is not equal between sim and unpacked!" << std::endl;
00445
00446
00447 std::vector<CSCStripDigi> a = s->second.second;
00448 std::vector<CSCStripDigi> b = s->second.first;
00449 std::cout << "SIM OUTPUT:" << std::endl;
00450 for(std::vector<CSCStripDigi>::const_iterator i = a.begin(); i != a.end(); ++i)
00451 i->print();
00452 std::cout << "UNPACKER OUTPUT:" << std::endl;
00453 for(std::vector<CSCStripDigi>::const_iterator i = b.begin(); i != b.end(); ++i)
00454 i->print();
00455 }
00456 int max = std::min(s->second.first.size(),s->second.second.size());
00457 std::vector<CSCStripDigi> cv = s->second.first;
00458 std::vector<CSCStripDigi> sv = s->second.second;
00459 for(int i = 0; i < max; ++i)
00460 {
00461 bool me1a = s->first.station()==1 && s->first.ring()==4;
00462 bool me1b = s->first.station()==1 && s->first.ring()==1;
00463 bool zplus = s->first.endcap()==1;
00464 int k=i;
00465
00466 if(me1a && zplus) k=max-i-1;
00467 if(me1b && !zplus) k=max-i-1;
00468
00469 if(sv[k].getStrip() != cv[i].getStrip())
00470 {
00471 std::cout << "In detId: " << s->first << std::endl;
00472 std::cout << "Strips do not match: " << sv[k].getStrip()
00473 << " != " << cv[i].getStrip() << std::endl;
00474 }
00475 if(sv[k].getADCCounts().size() != cv[i].getADCCounts().size())
00476 {
00477 std::cout << "In detId: " << s->first << std::endl;
00478 std::cout << "ADC Readouts not of equal size!" << std::endl;
00479 std::cout << sv[k].getADCCounts().size() << ' '
00480 << cv[i].getADCCounts().size() << std::endl;
00481 }
00482 else
00483 {
00484 std::vector<int> sADC = sv[k].getADCCounts();
00485 std::vector<int> uADC = cv[i].getADCCounts();
00486
00487 for(unsigned iadc = 0; iadc < sADC.size(); ++iadc)
00488 if(sADC[iadc] != uADC[iadc])
00489 {
00490 std::cout << "In detId: " << s->first << std::endl;
00491 std::cout << "ADC counts not equal at index: " << iadc << std::endl
00492 << std::hex <<sADC[iadc] << " != " << uADC[iadc] << std::dec
00493 << std::endl;
00494 }
00495 }
00496 if(sv[k].getADCOverflow().size() != cv[i].getADCOverflow().size())
00497 {
00498 std::cout << "In detId: " << s->first << std::endl;
00499 std::cout << "ADC Overflows not of equal size!" << std::endl;
00500 std::cout << sv[k].getADCOverflow().size() << ' '
00501 << cv[i].getADCOverflow().size() << std::endl;
00502 }
00503 else
00504 {
00505 std::vector<uint16_t> sADC = sv[k].getADCOverflow();
00506 std::vector<uint16_t> uADC = cv[i].getADCOverflow();
00507
00508 for(unsigned iadc = 0; iadc < sADC.size(); ++iadc)
00509 if(sADC[iadc] != uADC[iadc])
00510 {
00511 std::cout << "In detId: " << s->first << std::endl;
00512 std::cout << "ADC overflows not equal at index: " << iadc << std::endl
00513 << std::hex <<sADC[iadc] << " != " << uADC[iadc] << std::dec
00514 << std::endl;
00515 }
00516 }
00517 if(sv[k].getOverlappedSample().size() != cv[i].getOverlappedSample().size())
00518 {
00519 std::cout << "In detId: " << s->first << std::endl;
00520 std::cout << "Overlapped Samples not of equal size!" << std::endl;
00521 std::cout << sv[k].getOverlappedSample().size() << ' '
00522 << cv[i].getOverlappedSample().size() << std::endl;
00523 }
00524 else
00525 {
00526 std::vector<uint16_t> sADC = sv[k].getOverlappedSample();
00527 std::vector<uint16_t> uADC = cv[i].getOverlappedSample();
00528
00529 for(unsigned iadc = 0; iadc < sADC.size(); ++iadc)
00530 if(sADC[iadc] != uADC[iadc])
00531 {
00532 std::cout << "In detId: " << s->first << std::endl;
00533 std::cout << "Overlapped Samples not equal at index: " << iadc << std::endl
00534 << std::hex <<sADC[iadc] << " != " << uADC[iadc] << std::dec
00535 << std::endl;
00536 }
00537 }
00538 if(sv[k].getErrorstat().size() != cv[i].getErrorstat().size())
00539 {
00540 std::cout << "In detId: " << s->first << std::endl;
00541 std::cout << "Errorstat not of equal size!" << std::endl;
00542 std::cout << sv[k].getErrorstat().size() << ' '
00543 << cv[i].getErrorstat().size() << std::endl;
00544 }
00545 else
00546 {
00547 std::vector<uint16_t> sADC = sv[k].getErrorstat();
00548 std::vector<uint16_t> uADC = cv[i].getErrorstat();
00549
00550 for(unsigned iadc = 0; iadc < sADC.size(); ++iadc)
00551 if(sADC[iadc] != uADC[iadc])
00552 {
00553 std::cout << "In detId: " << s->first << std::endl;
00554 std::cout << "Errorstat not equal at index: " << iadc << std::endl
00555 << std::hex <<sADC[iadc] << " != " << uADC[iadc] << std::dec
00556 << std::endl;
00557 }
00558 }
00559 if(sv[k].pedestal() != cv[i].pedestal())
00560 {
00561 std::cout << "In detId: " << s->first << std::endl;
00562 std::cout << "Pedestals not equal: " << sv[k].pedestal() << " != "
00563 << cv[i].pedestal() << std::endl;
00564 }
00565 if(sv[k].amplitude() != cv[i].amplitude())
00566 {
00567 std::cout << "In detId: " << s->first << std::endl;
00568 std::cout << "Amplitudes not equal: " << sv[k].amplitude() << " != "
00569 << cv[i].amplitude() << std::endl;
00570 }
00571 }
00572 }
00573 for(c = comps.begin(); c != comps.end(); ++c)
00574 {
00575 if(c->second.first.size() != c->second.second.size())
00576 {
00577 std::cout << "Major error! # of comparator digis in detID: " << c->first
00578 << " is not equal between sim and unpacked!" << std::endl;
00579
00580
00581 std::vector<CSCComparatorDigi> a = c->second.second;
00582 std::vector<CSCComparatorDigi> b = c->second.first;
00583 std::cout << "SIM OUTPUT:" << std::endl;
00584 for(std::vector<CSCComparatorDigi>::const_iterator i = a.begin(); i != a.end(); ++i)
00585 i->print();
00586 std::cout << "UNPACKER OUTPUT:" << std::endl;
00587 for(std::vector<CSCComparatorDigi>::const_iterator i = b.begin(); i != b.end(); ++i)
00588 i->print();
00589 }
00590 int max = std::min(c->second.first.size(),c->second.second.size());
00591 std::vector<CSCComparatorDigi> cv = c->second.first;
00592 std::vector<CSCComparatorDigi> sv = c->second.second;
00593 for(int i = 0; i < max; ++i)
00594 {
00595 if(sv[i].getStrip() != cv[i].getStrip())
00596 {
00597 std::cout << "In detId: " << s->first << std::endl;
00598 std::cout << "Comparator strips do not match: " << sv[i].getStrip()
00599 << " != " << cv[i].getStrip() << std::endl;
00600 }
00601 if(sv[i].getComparator() != cv[i].getComparator())
00602 {
00603 std::cout << "In detId: " << c->first << std::endl;
00604 std::cout << "Comparators do not match: " << sv[i].getComparator()
00605 << " != " << cv[i].getComparator() << std::endl;
00606 }
00607 if(sv[i].getTimeBinWord() != cv[i].getTimeBinWord())
00608 {
00609 std::cout << "In detId: " << c->first << std::endl;
00610 std::cout << "Comparator time bins words do not match: " << sv[i].getTimeBinWord()
00611 << " != " << cv[i].getTimeBinWord() << std::endl;
00612 }
00613 }
00614 }
00615 for(cl = clcts.begin(); cl != clcts.end(); ++cl)
00616 {
00617 if(cl->second.first.size() != cl->second.second.size())
00618 {
00619 std::cout << "Major error! # of CLCT digis in detID: " << cl->first
00620 << " is not equal between sim and unpacked!" << std::endl;
00621
00622
00623 std::vector<CSCCLCTDigi> a = cl->second.second;
00624 std::vector<CSCCLCTDigi> b = cl->second.first;
00625 std::cout << "SIM OUTPUT:" << std::endl;
00626 for(std::vector<CSCCLCTDigi>::const_iterator i = a.begin(); i != a.end(); ++i)
00627 i->print();
00628 std::cout << "UNPACKER OUTPUT:" << std::endl;
00629 for(std::vector<CSCCLCTDigi>::const_iterator i = b.begin(); i != b.end(); ++i)
00630 i->print();
00631 }
00632 int max = std::min(cl->second.first.size(),cl->second.second.size());
00633 std::vector<CSCCLCTDigi> cv = cl->second.first;
00634 std::vector<CSCCLCTDigi> sv = cl->second.second;
00635 for(int i = 0; i < max; ++i)
00636 {
00637 if(cv[i].getKeyStrip() != sv[i].getKeyStrip())
00638 {
00639 std::cout << "In detId: " << cl->first << std::endl;
00640 std::cout << "CLCT key strips do not match: " << sv[i].getKeyStrip()
00641 << " != " << cv[i].getKeyStrip() << std::endl;
00642 }
00643 if(cv[i].getStrip() != sv[i].getStrip())
00644 {
00645 std::cout << "In detId: " << cl->first << std::endl;
00646 std::cout << "CLCT strips do not match: " << sv[i].getStrip()
00647 << " != " << cv[i].getStrip() << std::endl;
00648 }
00649 if(cv[i].isValid() != sv[i].isValid())
00650 {
00651 std::cout << "In detId: " << cl->first << std::endl;
00652 std::cout << "CLCT Valid bits do not match: " << sv[i].isValid()
00653 << " != " << cv[i].isValid() << std::endl;
00654 }
00655 if(cv[i].getQuality() != sv[i].getQuality())
00656 {
00657 std::cout << "In detId: " << cl->first << std::endl;
00658 std::cout << "CLCT qualities do not match: " << sv[i].getQuality()
00659 << " != " << cv[i].getQuality() << std::endl;
00660 }
00661 if(cv[i].getPattern() != sv[i].getPattern())
00662 {
00663 std::cout << "In detId: " << cl->first << std::endl;
00664 std::cout << "CLCT patterns do not match: " << sv[i].getPattern()
00665 << " != " << cv[i].getPattern() << std::endl;
00666 }
00667 if(cv[i].getStripType() != sv[i].getStripType())
00668 {
00669 std::cout << "In detId: " << cl->first << std::endl;
00670 std::cout << "CLCT strip types do not match: " << sv[i].getStripType()
00671 << " != " << cv[i].getStripType() << std::endl;
00672 }
00673 if(cv[i].getBend() != sv[i].getBend())
00674 {
00675 std::cout << "In detId: " << cl->first << std::endl;
00676 std::cout << "CLCT bends do not match: " << sv[i].getBend()
00677 << " != " << cv[i].getBend() << std::endl;
00678 }
00679 if(cv[i].getCFEB() != sv[i].getCFEB())
00680 {
00681 std::cout << "In detId: " << cl->first << std::endl;
00682 std::cout << "CLCT CFEBs do not match: " << sv[i].getCFEB()
00683 << " != " << cv[i].getCFEB() << std::endl;
00684 }
00685 if(((short)cv[i].getBX()) != ((short)sv[i].getBX()) - 4)
00686 {
00687 std::cout << "In detId: " << cl->first << std::endl;
00688 std::cout << "CLCT BX do not match: " << sv[i].getBX() - 4
00689 << " != " << cv[i].getBX() << std::endl;
00690 }
00691 if(cv[i].getFullBX() != sv[i].getFullBX())
00692 {
00693 std::cout << "In detId: " << cl->first << std::endl;
00694 std::cout << "CLCT Full BX do not match: " << sv[i].getFullBX()
00695 << " != " << cv[i].getFullBX() << std::endl;
00696 }
00697 if(cv[i].getTrknmb() != sv[i].getTrknmb())
00698 {
00699 std::cout << "In detId: " << cl->first << std::endl;
00700 std::cout << "CLCT Track numbers do not match: " << sv[i].getTrknmb()
00701 << " != " << cv[i].getTrknmb() << std::endl;
00702 }
00703 }
00704 }
00705 for(al = alcts.begin(); al != alcts.end(); ++al)
00706 {
00707 if(al->second.first.size() != al->second.second.size())
00708 {
00709 std::cout << "Major error! # of ALCT digis in detID: " << al->first
00710 << " is not equal between sim and unpacked!" << std::endl;
00711
00712
00713 std::vector<CSCALCTDigi> a = al->second.second;
00714 std::vector<CSCALCTDigi> b = al->second.first;
00715 std::cout << "SIM OUTPUT:" << std::endl;
00716 for(std::vector<CSCALCTDigi>::const_iterator i = a.begin(); i != a.end(); ++i)
00717 i->print();
00718 std::cout << "UNPACKER OUTPUT:" << std::endl;
00719 for(std::vector<CSCALCTDigi>::const_iterator i = b.begin(); i != b.end(); ++i)
00720 i->print();
00721 }
00722 int max = std::min(al->second.first.size(),al->second.second.size());
00723 std::vector<CSCALCTDigi> cv = al->second.first;
00724 std::vector<CSCALCTDigi> sv = al->second.second;
00725 for(int i = 0; i < max; ++i)
00726 {
00727 if(cv[i].getKeyWG() != sv[i].getKeyWG())
00728 {
00729 std::cout << "In detId: " << al->first << std::endl;
00730 std::cout << "ALCT key wire groups do not match: " << sv[i].getKeyWG()
00731 << " != " << cv[i].getKeyWG() << std::endl;
00732 }
00733 if(cv[i].isValid() != sv[i].isValid())
00734 {
00735 std::cout << "In detId: " << al->first << std::endl;
00736 std::cout << "ALCT Valid bits do not match: " << sv[i].isValid()
00737 << " != " << cv[i].isValid() << std::endl;
00738 }
00739 if(cv[i].getQuality() != sv[i].getQuality())
00740 {
00741 std::cout << "In detId: " << al->first << std::endl;
00742 std::cout << "ALCT qualities do not match: " << sv[i].getQuality()
00743 << " != " << cv[i].getQuality() << std::endl;
00744 }
00745 if(cv[i].getAccelerator() != sv[i].getAccelerator())
00746 {
00747 std::cout << "In detId: " << al->first << std::endl;
00748 std::cout << "ALCT accelerator bits do not match: " << sv[i].getAccelerator()
00749 << " != " << cv[i].getAccelerator() << std::endl;
00750 }
00751 if(cv[i].getCollisionB() != sv[i].getCollisionB())
00752 {
00753 std::cout << "In detId: " << al->first << std::endl;
00754 std::cout << "ALCT CollisionB flags do not match: " << sv[i].getCollisionB()
00755 << " != " << cv[i].getCollisionB() << std::endl;
00756 }
00757 if((cv[i].getBX()) != (sv[i].getBX()))
00758 {
00759 std::cout << "In detId: " << al->first << std::endl;
00760 std::cout << "ALCT BX do not match: " << sv[i].getBX()
00761 << " != " << cv[i].getBX() << std::endl;
00762 }
00763 if(cv[i].getFullBX() != sv[i].getFullBX())
00764 {
00765 std::cout << "In detId: " << cl->first << std::endl;
00766 std::cout << "ALCT Full BX do not match: " << sv[i].getFullBX()
00767 << " != " << cv[i].getFullBX() << std::endl;
00768 }
00769 }
00770 }
00771 for(lc = lcts.begin(); lc != lcts.end(); ++lc)
00772 {
00773 if(lc->second.first.size() != lc->second.second.size())
00774 {
00775 std::cout << "Major error! # of Correlated LCT digis in detID: " << lc->first
00776 << " is not equal between sim and unpacked!" << std::endl;
00777
00778
00779 std::vector<CSCCorrelatedLCTDigi> a = lc->second.second;
00780 std::vector<CSCCorrelatedLCTDigi> b = lc->second.first;
00781 std::cout << "SIM OUTPUT:" << std::endl;
00782 for(std::vector<CSCCorrelatedLCTDigi>::const_iterator i = a.begin(); i != a.end(); ++i)
00783 i->print();
00784 std::cout << "UNPACKER OUTPUT:" << std::endl;
00785 for(std::vector<CSCCorrelatedLCTDigi>::const_iterator i = b.begin(); i != b.end(); ++i)
00786 i->print();
00787 }
00788 int max = std::min(lc->second.first.size(),lc->second.second.size());
00789 std::vector<CSCCorrelatedLCTDigi> cv = lc->second.first;
00790 std::vector<CSCCorrelatedLCTDigi> sv = lc->second.second;
00791 for(int i = 0; i < max; ++i)
00792 {
00793 if(cv[i].getStrip() != sv[i].getStrip())
00794 {
00795 std::cout << "In detId: " << lc->first << std::endl;
00796 std::cout << "Correlated LCT strips do not match: " << sv[i].getStrip()
00797 << " != " << cv[i].getStrip() << std::endl;
00798 }
00799 if(cv[i].getKeyWG() != sv[i].getKeyWG())
00800 {
00801 std::cout << "In detId: " << lc->first << std::endl;
00802 std::cout << "Correlated LCT key wire groups do not match: " << sv[i].getKeyWG()
00803 << " != " << cv[i].getKeyWG() << std::endl;
00804 }
00805 if(cv[i].isValid() != sv[i].isValid())
00806 {
00807 std::cout << "In detId: " << lc->first << std::endl;
00808 std::cout << "Correlated LCT Valid bits do not match: " << sv[i].isValid()
00809 << " != " << cv[i].isValid() << std::endl;
00810 }
00811 if(cv[i].getQuality() != sv[i].getQuality())
00812 {
00813 std::cout << "In detId: " << lc->first << std::endl;
00814 std::cout << "Correlated LCT qualities do not match: " << sv[i].getQuality()
00815 << " != " << cv[i].getQuality() << std::endl;
00816 }
00817 if(cv[i].getPattern() != sv[i].getPattern())
00818 {
00819 std::cout << "In detId: " << lc->first << std::endl;
00820 std::cout << "Correlated LCT ALCT patterns do not match: " << sv[i].getPattern()
00821 << " != " << cv[i].getPattern() << std::endl;
00822 }
00823 if(cv[i].getCLCTPattern() != sv[i].getCLCTPattern())
00824 {
00825 std::cout << "In detId: " << lc->first << std::endl;
00826 std::cout << "Correlated LCT CLCT patterns do not match: " << sv[i].getCLCTPattern()
00827 << " != " << cv[i].getCLCTPattern() << std::endl;
00828 }
00829 if(cv[i].getStripType() != sv[i].getStripType())
00830 {
00831 std::cout << "In detId: " << lc->first << std::endl;
00832 std::cout << "Correlated LCT strip types do not match: " << sv[i].getStripType()
00833 << " != " << cv[i].getStripType() << std::endl;
00834 }
00835 if(cv[i].getBend() != sv[i].getBend())
00836 {
00837 std::cout << "In detId: " << lc->first << std::endl;
00838 std::cout << "Correlated LCT bends do not match: " << sv[i].getBend()
00839 << " != " << cv[i].getBend() << std::endl;
00840 }
00841 if(cv[i].getMPCLink() != sv[i].getMPCLink())
00842 {
00843 std::cout << "In detId: " << lc->first << std::endl;
00844 std::cout << "Correlated LCT MPC Links do not match: " << sv[i].getMPCLink()
00845 << " != " << cv[i].getMPCLink() << std::endl;
00846 }
00847 if((cv[i].getBX()) != (sv[i].getBX()-6))
00848 {
00849 std::cout << "In detId: " << lc->first << std::endl;
00850 std::cout << "Correlated LCT BX do not match: " << sv[i].getBX()-6
00851 << " != " << cv[i].getBX() << std::endl;
00852 }
00853 if(cv[i].getCSCID() != sv[i].getCSCID())
00854 {
00855 std::cout << "In detId: " << lc->first << std::endl;
00856 std::cout << "Correlated LCT CSCIDs do not match: " << sv[i].getCSCID()
00857 << " != " << cv[i].getCSCID() << std::endl;
00858 }
00859 if(cv[i].getBX0() != sv[i].getBX0())
00860 {
00861 std::cout << "In detId: " << lc->first << std::endl;
00862 std::cout << "Correlated LCT BX0s do not match: " << sv[i].getBX0()
00863 << " != " << cv[i].getBX0() << std::endl;
00864 }
00865 if(cv[i].getSyncErr() != sv[i].getSyncErr())
00866 {
00867 std::cout << "In detId: " << lc->first << std::endl;
00868 std::cout << "Correlated LCT SyncErrs do not match: " << sv[i].getSyncErr()
00869 << " != " << cv[i].getSyncErr() << std::endl;
00870 }
00871 if(cv[i].getTrknmb() != sv[i].getTrknmb())
00872 {
00873 std::cout << "In detId: " << lc->first << std::endl;
00874 std::cout << "Correlated LCT Track numbers do not match: " << sv[i].getTrknmb()
00875 << " != " << cv[i].getTrknmb() << std::endl;
00876 }
00877 }
00878 }
00879 if(tracks.get().size() != simtracks.get().size())
00880 {
00881 std::cout << "Major error! # of L1 Tracks is not equal between sim and unpacked!" << std::endl;
00882 std::vector<csc::L1Track> a = simtracks.get();
00883 std::vector<csc::L1Track> b = tracks.get();
00884 std::cout << "SIM OUTPUT:" << std::endl;
00885 for(std::vector<csc::L1Track>::const_iterator i = a.begin(); i != a.end(); ++i)
00886 i->print();
00887 std::cout << "UNPACKER OUTPUT:" << std::endl;
00888 for(std::vector<csc::L1Track>::const_iterator i = b.begin(); i != b.end(); ++i)
00889 i->print();
00890 }
00891
00892
00893
00894 return _err;
00895 }
00896
00897
00898
00899
00900 std::vector<CSCWireDigi>
00901 CSCDigiValidator::sanitizeWireDigis(std::vector<CSCWireDigi>::const_iterator b,
00902 std::vector<CSCWireDigi>::const_iterator e)
00903 {
00904 typedef std::map<int,std::vector<CSCWireDigi> > wire2digi;
00905
00906 std::vector<CSCWireDigi> _r;
00907 wire2digi _wr2digis;
00908
00909 for(std::vector<CSCWireDigi>::const_iterator i = b; i != e; ++i)
00910 _wr2digis[i->getWireGroup()].push_back(*i);
00911
00912 for(wire2digi::const_iterator i = _wr2digis.begin(); i != _wr2digis.end(); ++i)
00913 {
00914 int wire = i->first;
00915 unsigned tbin = 0x0;
00916
00917 for(std::vector<CSCWireDigi>::const_iterator d = i->second.begin();
00918 d != i->second.end(); ++d)
00919 {
00920 std::vector<int> binson = d->getTimeBinsOn();
00921 for(std::vector<int>::const_iterator t = binson.begin();
00922 t != binson.end(); ++t)
00923 tbin |= 1<<(*t);
00924 }
00925
00926 _r.push_back(CSCWireDigi(wire,tbin));
00927 }
00928
00929 return _r;
00930 }
00931
00932 std::vector<CSCStripDigi>
00933 CSCDigiValidator::relabelStripDigis(const CSCChamberMap* m, CSCDetId _id,
00934 std::vector<CSCStripDigi>::const_iterator b,
00935 std::vector<CSCStripDigi>::const_iterator e)
00936 {
00937 std::vector<CSCStripDigi> _r;
00938
00939
00940
00941
00942
00943 for(std::vector<CSCStripDigi>::const_iterator i = b; i != e; ++i)
00944 {
00945 int strip=i->getStrip();
00946
00947
00948
00949
00950
00951 _r.push_back(CSCStripDigi(strip,i->getADCCounts(),i->getADCOverflow(),
00952 i->getOverlappedSample(),i->getErrorstat()));
00953 }
00954 return _r;
00955 }
00956
00957 std::vector<CSCComparatorDigi>
00958 CSCDigiValidator::relabelCompDigis(const CSCChamberMap* m, CSCDetId _id,
00959 std::vector<CSCComparatorDigi>::const_iterator b,
00960 std::vector<CSCComparatorDigi>::const_iterator e)
00961 {
00962 std::vector<CSCComparatorDigi> _r;
00963
00964 bool me1a = _id.station()==1 && _id.ring()==4;
00965
00966
00967
00968 for(std::vector<CSCComparatorDigi>::const_iterator i = b; i != e; ++i)
00969 {
00970 int strip=i->getStrip();
00971
00972
00973
00974 if(me1a) strip+=64;
00975
00976 _r.push_back(CSCComparatorDigi(strip,i->getComparator(),
00977 i->getTimeBinWord()));
00978 }
00979 return _r;
00980 }
00981
00982 std::vector<CSCStripDigi>
00983 CSCDigiValidator::sanitizeStripDigis(std::vector<CSCStripDigi>::const_iterator b,
00984 std::vector<CSCStripDigi>::const_iterator e)
00985 {
00986 std::vector<CSCStripDigi> _r;
00987
00988 return _r;
00989 }
00990
00991 std::vector<CSCStripDigi>
00992 CSCDigiValidator::zeroSupStripDigis(std::vector<CSCStripDigi>::const_iterator b,
00993 std::vector<CSCStripDigi>::const_iterator e)
00994 {
00995 std::vector<CSCStripDigi> _r;
00996 std::vector<int> counts;
00997
00998 for(std::vector<CSCStripDigi>::const_iterator i = b; i != e; ++i)
00999 {
01000 bool nonzero=false;
01001 counts = i->getADCCounts();
01002 for(std::vector<int>::const_iterator a = counts.begin(); a != counts.end(); ++a)
01003 if((*a) != 0) nonzero = true;
01004
01005 if(nonzero) _r.push_back(*i);
01006 }
01007
01008 return _r;
01009 }
01010
01011
01012 std::vector<CSCComparatorDigi>
01013 CSCDigiValidator::zeroSupCompDigis(std::vector<CSCComparatorDigi>::const_iterator b,
01014 std::vector<CSCComparatorDigi>::const_iterator e)
01015 {
01016 std::vector<CSCComparatorDigi> _r;
01017
01018 for(std::vector<CSCComparatorDigi>::const_iterator i = b; i != e; ++i)
01019 {
01020 bool present = false;
01021
01022 if(i->getTimeBin() < 10) present=true;
01023
01024 if(present) _r.push_back(*i);
01025 }
01026
01027 return _r;
01028 }
01029
01030
01031 void
01032 CSCDigiValidator::beginJob()
01033 {
01034 }
01035
01036
01037 void
01038 CSCDigiValidator::endJob()
01039 {
01040 }