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