Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:10:24

0001 /**\class CSCDigiValidator
0002 */
0003 
0004 // Original Author:  Lindsey Gray
0005 //         Created:  Tue Jul 28 18:04:11 CEST 2009
0006 
0007 #include <memory>
0008 #include <string>
0009 #include <map>
0010 #include <vector>
0011 #include <algorithm>
0012 #include <iostream>
0013 
0014 #include <FWCore/Framework/interface/ConsumesCollector.h>
0015 #include "FWCore/Framework/interface/Frameworkfwd.h"
0016 #include "FWCore/Framework/interface/one/EDFilter.h"
0017 #include "FWCore/Framework/interface/Event.h"
0018 #include "FWCore/Framework/interface/EventSetup.h"
0019 #include "FWCore/Framework/interface/MakerMacros.h"
0020 #include "FWCore/Utilities/interface/InputTag.h"
0021 #include "FWCore/Utilities/interface/ESGetToken.h"
0022 #include "FWCore/Framework/interface/ESHandle.h"
0023 #include "DataFormats/Common/interface/Handle.h"
0024 
0025 #include "DataFormats/CSCDigi/interface/CSCWireDigiCollection.h"
0026 #include "DataFormats/CSCDigi/interface/CSCStripDigiCollection.h"
0027 #include "DataFormats/CSCDigi/interface/CSCComparatorDigiCollection.h"
0028 #include "DataFormats/CSCDigi/interface/CSCALCTDigiCollection.h"
0029 #include "DataFormats/CSCDigi/interface/CSCCLCTDigiCollection.h"
0030 #include "DataFormats/CSCDigi/interface/CSCCorrelatedLCTDigiCollection.h"
0031 #include "DataFormats/L1CSCTrackFinder/interface/CSCTriggerContainer.h"
0032 #include "DataFormats/L1CSCTrackFinder/interface/L1CSCTrackCollection.h"
0033 #include "DataFormats/L1CSCTrackFinder/interface/TrackStub.h"
0034 #include "CondFormats/CSCObjects/interface/CSCChamberMap.h"
0035 #include "CondFormats/DataRecord/interface/CSCChamberMapRcd.h"
0036 
0037 #include "DataFormats/L1CSCTrackFinder/interface/L1Track.h"
0038 
0039 class CSCWireDigi;
0040 class CSCStripDigi;
0041 class CSCComparatorDigi;
0042 class CSCCLCTDigi;
0043 class CSCALCTDigi;
0044 class CSCCorrelatedLCTDigi;
0045 class CSCDetId;
0046 class CSCChamberMap;
0047 
0048 class CSCDigiValidator : public edm::one::EDFilter<> {
0049 public:
0050   explicit CSCDigiValidator(const edm::ParameterSet&);
0051   ~CSCDigiValidator() override;
0052 
0053 private:
0054   void beginJob() override;
0055   bool filter(edm::Event&, const edm::EventSetup&) override;
0056   void endJob() override;
0057 
0058   std::vector<CSCWireDigi> sanitizeWireDigis(std::vector<CSCWireDigi>::const_iterator,
0059                                              std::vector<CSCWireDigi>::const_iterator);
0060   std::vector<CSCStripDigi> relabelStripDigis(const CSCChamberMap*,
0061                                               CSCDetId,
0062                                               std::vector<CSCStripDigi>::const_iterator,
0063                                               std::vector<CSCStripDigi>::const_iterator);
0064   std::vector<CSCStripDigi> sanitizeStripDigis(std::vector<CSCStripDigi>::const_iterator,
0065                                                std::vector<CSCStripDigi>::const_iterator);
0066   std::vector<CSCStripDigi> zeroSupStripDigis(std::vector<CSCStripDigi>::const_iterator,
0067                                               std::vector<CSCStripDigi>::const_iterator);
0068   std::vector<CSCComparatorDigi> relabelCompDigis(const CSCChamberMap* m,
0069                                                   CSCDetId _id,
0070                                                   std::vector<CSCComparatorDigi>::const_iterator b,
0071                                                   std::vector<CSCComparatorDigi>::const_iterator e);
0072   std::vector<CSCComparatorDigi> zeroSupCompDigis(std::vector<CSCComparatorDigi>::const_iterator,
0073                                                   std::vector<CSCComparatorDigi>::const_iterator);
0074 
0075   // ----------member data ---------------------------
0076   edm::InputTag wire1, strip1, comp1, clct1, alct1, lct1, csctf1, csctfstubs1;
0077   edm::InputTag wire2, strip2, comp2, clct2, alct2, lct2, csctf2, csctfstubs2;
0078 
0079   edm::EDGetTokenT<CSCWireDigiCollection> wd1_token;
0080   edm::EDGetTokenT<CSCStripDigiCollection> sd1_token;
0081   edm::EDGetTokenT<CSCComparatorDigiCollection> cd1_token;
0082   edm::EDGetTokenT<CSCALCTDigiCollection> al1_token;
0083   edm::EDGetTokenT<CSCCLCTDigiCollection> cl1_token;
0084   edm::EDGetTokenT<CSCCorrelatedLCTDigiCollection> co1_token;
0085   edm::EDGetTokenT<L1CSCTrackCollection> tr1_token;
0086   edm::EDGetTokenT<CSCTriggerContainer<csctf::TrackStub> > ts1_token;
0087 
0088   edm::EDGetTokenT<CSCWireDigiCollection> wd2_token;
0089   edm::EDGetTokenT<CSCStripDigiCollection> sd2_token;
0090   edm::EDGetTokenT<CSCComparatorDigiCollection> cd2_token;
0091   edm::EDGetTokenT<CSCALCTDigiCollection> al2_token;
0092   edm::EDGetTokenT<CSCCLCTDigiCollection> cl2_token;
0093   edm::EDGetTokenT<CSCCorrelatedLCTDigiCollection> co2_token;
0094   edm::EDGetTokenT<L1CSCTrackCollection> tr2_token;
0095   edm::EDGetTokenT<CSCTriggerContainer<csctf::TrackStub> > ts2_token;
0096   edm::ESGetToken<CSCChamberMap, CSCChamberMapRcd> cham_token;
0097 };
0098 
0099 CSCDigiValidator::CSCDigiValidator(const edm::ParameterSet& iConfig) {
0100   wd1_token = consumes<CSCWireDigiCollection>(iConfig.getParameter<edm::InputTag>("inputWire"));
0101   wd2_token = consumes<CSCWireDigiCollection>(iConfig.getParameter<edm::InputTag>("repackWire"));
0102   sd1_token = consumes<CSCStripDigiCollection>(iConfig.getParameter<edm::InputTag>("inputStrip"));
0103   sd2_token = consumes<CSCStripDigiCollection>(iConfig.getParameter<edm::InputTag>("inputStrip"));
0104   cd1_token = consumes<CSCComparatorDigiCollection>(iConfig.getParameter<edm::InputTag>("inputComp"));
0105   cd2_token = consumes<CSCComparatorDigiCollection>(iConfig.getParameter<edm::InputTag>("RepackComp"));
0106   al1_token = consumes<CSCALCTDigiCollection>(iConfig.getParameter<edm::InputTag>("inputALCT"));
0107   al2_token = consumes<CSCALCTDigiCollection>(iConfig.getParameter<edm::InputTag>("repackALCT"));
0108   cl1_token = consumes<CSCCLCTDigiCollection>(iConfig.getParameter<edm::InputTag>("inputCLCT"));
0109   cl2_token = consumes<CSCCLCTDigiCollection>(iConfig.getParameter<edm::InputTag>("repackCLCT"));
0110   co1_token = consumes<CSCCorrelatedLCTDigiCollection>(iConfig.getParameter<edm::InputTag>("inputCorrLCT"));
0111   co2_token = consumes<CSCCorrelatedLCTDigiCollection>(iConfig.getParameter<edm::InputTag>("repackCorrLCT"));
0112   tr1_token = consumes<L1CSCTrackCollection>(iConfig.getParameter<edm::InputTag>("inputCSCTF"));
0113   tr2_token = consumes<L1CSCTrackCollection>(iConfig.getParameter<edm::InputTag>("repackCSCTF"));
0114   ts1_token = consumes<CSCTriggerContainer<csctf::TrackStub> >(iConfig.getParameter<edm::InputTag>("inputCSCTFStubs"));
0115   ts2_token = consumes<CSCTriggerContainer<csctf::TrackStub> >(iConfig.getParameter<edm::InputTag>("repackCSCTFStubs"));
0116   cham_token = esConsumes<CSCChamberMap, CSCChamberMapRcd>();
0117 }
0118 
0119 CSCDigiValidator::~CSCDigiValidator() {}
0120 
0121 bool CSCDigiValidator::filter(edm::Event& iEvent, const edm::EventSetup& iSetup) {
0122   bool _err = false;
0123   using namespace edm;
0124 
0125   typedef std::map<CSCDetId, std::pair<std::vector<CSCWireDigi>, std::vector<CSCWireDigi> > > matchingDetWireCollection;
0126   typedef std::map<CSCDetId, std::pair<std::vector<CSCStripDigi>, std::vector<CSCStripDigi> > >
0127       matchingDetStripCollection;
0128   typedef std::map<CSCDetId, std::pair<std::vector<CSCComparatorDigi>, std::vector<CSCComparatorDigi> > >
0129       matchingDetComparatorCollection;
0130   typedef std::map<CSCDetId, std::pair<std::vector<CSCCLCTDigi>, std::vector<CSCCLCTDigi> > > matchingDetCLCTCollection;
0131   typedef std::map<CSCDetId, std::pair<std::vector<CSCALCTDigi>, std::vector<CSCALCTDigi> > > matchingDetALCTCollection;
0132   typedef std::map<CSCDetId, std::pair<std::vector<CSCCorrelatedLCTDigi>, std::vector<CSCCorrelatedLCTDigi> > >
0133       matchingDetLCTCollection;
0134 
0135   edm::ESHandle<CSCChamberMap> hcham = iSetup.getHandle(cham_token);
0136   const CSCChamberMap* theMapping = hcham.product();
0137 
0138   Handle<CSCWireDigiCollection> _wi, _swi;
0139   Handle<CSCStripDigiCollection> _st, _sst;
0140   Handle<CSCComparatorDigiCollection> _cmp, _scmp;
0141   Handle<CSCCLCTDigiCollection> _clct, _sclct;
0142   Handle<CSCALCTDigiCollection> _alct, _salct;
0143   Handle<CSCCorrelatedLCTDigiCollection> _lct, _slct;
0144   Handle<L1CSCTrackCollection> _trk, _strk;
0145   Handle<CSCTriggerContainer<csctf::TrackStub> > _dt, _sdt;
0146 
0147   // get wire digis before and after unpacking
0148   iEvent.getByToken(wd1_token, _swi);
0149   iEvent.getByToken(wd2_token, _wi);
0150 
0151   //get strip digis before and after unpacking
0152   iEvent.getByToken(sd1_token, _sst);
0153   iEvent.getByToken(sd2_token, _st);
0154 
0155   //get comparator digis before and after unpacking
0156   iEvent.getByToken(co1_token, _scmp);
0157   iEvent.getByToken(co2_token, _cmp);
0158 
0159   //get clcts
0160   iEvent.getByToken(cl1_token, _sclct);
0161   iEvent.getByToken(cl2_token, _clct);
0162 
0163   //get alcts
0164   iEvent.getByToken(al1_token, _salct);
0165   iEvent.getByToken(al2_token, _alct);
0166 
0167   //get corr lcts
0168   iEvent.getByToken(co1_token, _slct);
0169   iEvent.getByToken(co2_token, _lct);
0170 
0171   //get l1 tracks
0172   iEvent.getByToken(tr1_token, _strk);
0173   iEvent.getByToken(tr2_token, _trk);
0174 
0175   //get DT stubs for L1 Tracks
0176   iEvent.getByToken(ts1_token, _sdt);
0177   iEvent.getByToken(ts2_token, _dt);
0178 
0179   CSCWireDigiCollection::DigiRangeIterator wi = _wi->begin(), swi = _swi->begin();
0180   CSCStripDigiCollection::DigiRangeIterator st = _st->begin(), sst = _sst->begin();
0181   CSCComparatorDigiCollection::DigiRangeIterator cmp = _cmp->begin(), scmp = _scmp->begin();
0182   CSCCLCTDigiCollection::DigiRangeIterator clct = _clct->begin(), sclct = _sclct->begin();
0183   CSCALCTDigiCollection::DigiRangeIterator alct = _alct->begin(), salct = _salct->begin();
0184   CSCCorrelatedLCTDigiCollection::DigiRangeIterator lct = _lct->begin(), slct = _slct->begin();
0185   L1CSCTrackCollection::const_iterator trk = _trk->begin(), strk = _strk->begin();
0186 
0187   //per detID, create lists of various digi types
0188   matchingDetWireCollection wires;
0189   matchingDetStripCollection strips;
0190   matchingDetComparatorCollection comps;
0191   matchingDetCLCTCollection clcts;
0192   matchingDetALCTCollection alcts;
0193   matchingDetLCTCollection lcts, trackstubs;
0194   CSCTriggerContainer<csc::L1Track> tracks, simtracks;
0195 
0196   //wires
0197   for (; wi != _wi->end(); ++wi) {
0198     CSCWireDigiCollection::const_iterator b = (*wi).second.first, e = (*wi).second.second;
0199     std::vector<CSCWireDigi>::iterator beg = wires[(*wi).first].first.end();
0200     wires[(*wi).first].first.insert(beg, b, e);
0201   }
0202   for (; swi != _swi->end(); ++swi) {
0203     CSCWireDigiCollection::const_iterator b = (*swi).second.first, e = (*swi).second.second;
0204     //convert sim ring 4(ME1/a) to ring 1
0205     CSCDetId _id = (*swi).first;
0206     if ((*swi).first.ring() == 4)
0207       _id = CSCDetId((*swi).first.endcap(), (*swi).first.station(), 1, (*swi).first.chamber(), (*swi).first.layer());
0208 
0209     std::vector<CSCWireDigi>::iterator beg = wires[_id].second.end();
0210 
0211     wires[_id].second.insert(beg, b, e);
0212     // automatically combine wire digis after each insertion
0213     wires[_id].second = sanitizeWireDigis(wires[_id].second.begin(), wires[_id].second.end());
0214   }
0215 
0216   //strips
0217   for (; st != _st->end(); ++st) {
0218     CSCStripDigiCollection::const_iterator b = (*st).second.first, e = (*st).second.second;
0219     std::vector<CSCStripDigi>::iterator beg = strips[(*st).first].first.end();
0220 
0221     //need to remove strips with no active ADCs
0222     std::vector<CSCStripDigi> zs = zeroSupStripDigis(b, e);
0223 
0224     strips[(*st).first].first.insert(beg, zs.begin(), zs.end());
0225   }
0226   for (; sst != _sst->end(); ++sst) {
0227     CSCStripDigiCollection::const_iterator b = (*sst).second.first, e = (*sst).second.second;
0228     // conversion of ring 4->1 not necessary here
0229     CSCDetId _id = (*sst).first;
0230     //if((*sst).first.ring() == 4)
0231     //   _id = CSCDetId((*sst).first.endcap(),(*sst).first.station(),
0232     //      1, (*sst).first.chamber(),(*sst).first.layer());
0233 
0234     std::vector<CSCStripDigi>::iterator beg = strips[_id].second.end();
0235 
0236     std::vector<CSCStripDigi> relab = relabelStripDigis(theMapping, (*sst).first, b, e);
0237 
0238     strips[_id].second.insert(beg, relab.begin(), relab.end());
0239     //strips[_id].second.insert(beg,b,e);
0240   }
0241 
0242   //comparators
0243   for (; cmp != _cmp->end(); ++cmp) {
0244     CSCComparatorDigiCollection::const_iterator b = (*cmp).second.first, e = (*cmp).second.second;
0245     std::vector<CSCComparatorDigi>::iterator beg = comps[(*cmp).first].first.end();
0246 
0247     comps[(*cmp).first].first.insert(beg, b, e);
0248   }
0249   for (; scmp != _scmp->end(); ++scmp) {
0250     CSCComparatorDigiCollection::const_iterator b = (*scmp).second.first, e = (*scmp).second.second;
0251     // convert sim ring 4 (ME1/a) to ring 1
0252     CSCDetId _id = (*scmp).first;
0253     if ((*scmp).first.ring() == 4)
0254       _id =
0255           CSCDetId((*scmp).first.endcap(), (*scmp).first.station(), 1, (*scmp).first.chamber(), (*scmp).first.layer());
0256 
0257     std::vector<CSCComparatorDigi>::iterator beg = comps[_id].second.begin();
0258 
0259     if ((*scmp).first.ring() == 4)
0260       beg = comps[_id].second.end();
0261 
0262     std::vector<CSCComparatorDigi> zs = zeroSupCompDigis(b, e);
0263 
0264     std::vector<CSCComparatorDigi> relab = relabelCompDigis(theMapping, (*scmp).first, zs.begin(), zs.end());
0265 
0266     comps[_id].second.insert(beg, relab.begin(), relab.end());
0267   }
0268 
0269   //CLCTs
0270   for (; clct != _clct->end(); ++clct) {
0271     CSCCLCTDigiCollection::const_iterator b = (*clct).second.first, e = (*clct).second.second;
0272     std::vector<CSCCLCTDigi>::iterator beg = clcts[(*clct).first].first.end();
0273 
0274     clcts[(*clct).first].first.insert(beg, b, e);
0275   }
0276   for (; sclct != _sclct->end(); ++sclct) {
0277     CSCCLCTDigiCollection::const_iterator b = (*sclct).second.first, e = (*sclct).second.second;
0278     // convert sim ring 4 (ME1/a) to ring 1
0279     CSCDetId _id = (*sclct).first;
0280     if ((*sclct).first.ring() == 4)
0281       _id = CSCDetId(
0282           (*sclct).first.endcap(), (*sclct).first.station(), 1, (*sclct).first.chamber(), (*sclct).first.layer());
0283 
0284     std::vector<CSCCLCTDigi>::iterator beg = clcts[_id].second.begin();
0285 
0286     if ((*sclct).first.ring() == 4)
0287       beg = clcts[_id].second.end();
0288 
0289     clcts[_id].second.insert(beg, b, e);
0290   }
0291 
0292   //ALCTs
0293   for (; alct != _alct->end(); ++alct) {
0294     CSCALCTDigiCollection::const_iterator b = (*alct).second.first, e = (*alct).second.second;
0295     std::vector<CSCALCTDigi>::iterator beg = alcts[(*alct).first].first.end();
0296 
0297     alcts[(*alct).first].first.insert(beg, b, e);
0298   }
0299   for (; salct != _salct->end(); ++salct) {
0300     CSCALCTDigiCollection::const_iterator b = (*salct).second.first, e = (*salct).second.second;
0301     // convert sim ring 4 (ME1/a) to ring 1
0302     CSCDetId _id = (*salct).first;
0303     if ((*salct).first.ring() == 4)
0304       _id = CSCDetId(
0305           (*salct).first.endcap(), (*salct).first.station(), 1, (*salct).first.chamber(), (*salct).first.layer());
0306 
0307     std::vector<CSCALCTDigi>::iterator beg = alcts[_id].second.begin();
0308 
0309     if ((*salct).first.ring() == 4)
0310       beg = alcts[_id].second.end();
0311 
0312     alcts[_id].second.insert(beg, b, e);
0313   }
0314 
0315   // Correlated LCTs
0316   for (; lct != _lct->end(); ++lct) {
0317     CSCCorrelatedLCTDigiCollection::const_iterator b = (*lct).second.first, e = (*lct).second.second;
0318     std::vector<CSCCorrelatedLCTDigi>::iterator beg = lcts[(*lct).first].first.end();
0319 
0320     lcts[(*lct).first].first.insert(beg, b, e);
0321   }
0322   for (; slct != _slct->end(); ++slct) {
0323     CSCCorrelatedLCTDigiCollection::const_iterator b = (*slct).second.first, e = (*slct).second.second;
0324     // convert sim ring 4 (ME1/a) to ring 1
0325     CSCDetId _id = (*slct).first;
0326     if ((*slct).first.ring() == 4)
0327       _id =
0328           CSCDetId((*slct).first.endcap(), (*slct).first.station(), 1, (*slct).first.chamber(), (*slct).first.layer());
0329 
0330     std::vector<CSCCorrelatedLCTDigi>::iterator beg = lcts[_id].second.begin();
0331 
0332     if ((*slct).first.ring() == 4)
0333       beg = lcts[_id].second.end();
0334 
0335     lcts[_id].second.insert(beg, b, e);
0336   }
0337   // remove attached LCT digis from tracks, should be put into their own collection and checked separately
0338   for (; trk != _trk->end(); ++trk) {
0339     tracks.push_back(trk->first);
0340   }
0341   for (; strk != _strk->end(); ++strk) {
0342     simtracks.push_back(strk->first);
0343   }
0344 
0345   //now loop through each set and process if there are differences!
0346   matchingDetWireCollection::const_iterator w;
0347   matchingDetStripCollection::const_iterator s;
0348   matchingDetComparatorCollection::const_iterator c;
0349   matchingDetCLCTCollection::const_iterator cl;
0350   matchingDetALCTCollection::const_iterator al;
0351   matchingDetLCTCollection::const_iterator lc;
0352 
0353   for (w = wires.begin(); w != wires.end(); ++w) {
0354     if (w->second.first.size() != w->second.second.size()) {
0355       std::cout << "Major error! # of wire digis in detID: " << w->first << " is not equal between sim and unpacked!"
0356                 << std::endl;
0357       //eventually do more in this case!
0358 
0359       std::vector<CSCWireDigi> a = w->second.second;
0360       std::vector<CSCWireDigi> b = w->second.first;
0361       std::cout << "SIM OUTPUT:" << std::endl;
0362       for (std::vector<CSCWireDigi>::const_iterator i = a.begin(); i != a.end(); ++i)
0363         i->print();
0364       std::cout << "UNPACKER OUTPUT:" << std::endl;
0365       for (std::vector<CSCWireDigi>::const_iterator i = b.begin(); i != b.end(); ++i)
0366         i->print();
0367     }
0368     int max = std::min(w->second.first.size(), w->second.second.size());
0369     std::vector<CSCWireDigi> cv = w->second.first;
0370     std::vector<CSCWireDigi> sv = w->second.second;
0371     for (int i = 0; i < max; ++i) {
0372       if (sv[i].getWireGroup() != cv[i].getWireGroup()) {
0373         std::cout << "In detId: " << w->first << std::endl;
0374         std::cout << "Wire Groups do not match: " << sv[i].getWireGroup() << " != " << cv[i].getWireGroup()
0375                   << std::endl;
0376       }
0377       if (sv[i].getTimeBin() != cv[i].getTimeBin()) {
0378         std::cout << "In detId: " << w->first << std::endl;
0379         std::cout << "First Time Bins do not match: " << sv[i].getTimeBin() << " != " << cv[i].getTimeBin()
0380                   << std::endl;
0381       }
0382       if (sv[i].getTimeBinWord() != cv[i].getTimeBinWord()) {
0383         std::cout << "In detId: " << w->first << std::endl;
0384         std::cout << "Time Bin Words do not match: " << sv[i].getTimeBinWord() << " != " << cv[i].getTimeBinWord()
0385                   << std::endl;
0386       }
0387     }
0388   }
0389   for (s = strips.begin(); s != strips.end(); ++s) {
0390     if (s->second.first.size() != s->second.second.size()) {
0391       std::cout << "Major error! # of strip digis in detID: " << s->first << " is not equal between sim and unpacked!"
0392                 << std::endl;
0393       //eventually do more in this case!
0394 
0395       std::vector<CSCStripDigi> a = s->second.second;
0396       std::vector<CSCStripDigi> b = s->second.first;
0397       std::cout << "SIM OUTPUT:" << std::endl;
0398       for (std::vector<CSCStripDigi>::const_iterator i = a.begin(); i != a.end(); ++i)
0399         i->print();
0400       std::cout << "UNPACKER OUTPUT:" << std::endl;
0401       for (std::vector<CSCStripDigi>::const_iterator i = b.begin(); i != b.end(); ++i)
0402         i->print();
0403     }
0404     int max = std::min(s->second.first.size(), s->second.second.size());
0405     std::vector<CSCStripDigi> cv = s->second.first;
0406     std::vector<CSCStripDigi> sv = s->second.second;
0407     for (int i = 0; i < max; ++i) {
0408       bool me1a = s->first.station() == 1 && s->first.ring() == 4;
0409       bool me1b = s->first.station() == 1 && s->first.ring() == 1;
0410       bool zplus = s->first.endcap() == 1;
0411       int k = i;
0412 
0413       if (me1a && zplus)
0414         k = max - i - 1;
0415       if (me1b && !zplus)
0416         k = max - i - 1;
0417 
0418       if (sv[k].getStrip() != cv[i].getStrip()) {
0419         std::cout << "In detId: " << s->first << std::endl;
0420         std::cout << "Strips do not match: " << sv[k].getStrip() << " != " << cv[i].getStrip() << std::endl;
0421       }
0422       if (sv[k].getADCCounts().size() != cv[i].getADCCounts().size()) {
0423         std::cout << "In detId: " << s->first << std::endl;
0424         std::cout << "ADC Readouts not of equal size!" << std::endl;
0425         std::cout << sv[k].getADCCounts().size() << ' ' << cv[i].getADCCounts().size() << std::endl;
0426       } else {
0427         std::vector<int> sADC = sv[k].getADCCounts();
0428         std::vector<int> uADC = cv[i].getADCCounts();
0429 
0430         for (unsigned iadc = 0; iadc < sADC.size(); ++iadc)
0431           if (sADC[iadc] != uADC[iadc]) {
0432             std::cout << "In detId: " << s->first << std::endl;
0433             std::cout << "ADC counts not equal at index: " << iadc << std::endl
0434                       << std::hex << sADC[iadc] << " != " << uADC[iadc] << std::dec << std::endl;
0435           }
0436       }
0437       if (sv[k].getADCOverflow().size() != cv[i].getADCOverflow().size()) {
0438         std::cout << "In detId: " << s->first << std::endl;
0439         std::cout << "ADC Overflows not of equal size!" << std::endl;
0440         std::cout << sv[k].getADCOverflow().size() << ' ' << cv[i].getADCOverflow().size() << std::endl;
0441       } else {
0442         std::vector<uint16_t> sADC = sv[k].getADCOverflow();
0443         std::vector<uint16_t> uADC = cv[i].getADCOverflow();
0444 
0445         for (unsigned iadc = 0; iadc < sADC.size(); ++iadc)
0446           if (sADC[iadc] != uADC[iadc]) {
0447             std::cout << "In detId: " << s->first << std::endl;
0448             std::cout << "ADC overflows not equal at index: " << iadc << std::endl
0449                       << std::hex << sADC[iadc] << " != " << uADC[iadc] << std::dec << std::endl;
0450           }
0451       }
0452       if (sv[k].getOverlappedSample().size() != cv[i].getOverlappedSample().size()) {
0453         std::cout << "In detId: " << s->first << std::endl;
0454         std::cout << "Overlapped Samples not of equal size!" << std::endl;
0455         std::cout << sv[k].getOverlappedSample().size() << ' ' << cv[i].getOverlappedSample().size() << std::endl;
0456       } else {
0457         std::vector<uint16_t> sADC = sv[k].getOverlappedSample();
0458         std::vector<uint16_t> uADC = cv[i].getOverlappedSample();
0459 
0460         for (unsigned iadc = 0; iadc < sADC.size(); ++iadc)
0461           if (sADC[iadc] != uADC[iadc]) {
0462             std::cout << "In detId: " << s->first << std::endl;
0463             std::cout << "Overlapped Samples not equal at index: " << iadc << std::endl
0464                       << std::hex << sADC[iadc] << " != " << uADC[iadc] << std::dec << std::endl;
0465           }
0466       }
0467       if (sv[k].getErrorstat().size() != cv[i].getErrorstat().size()) {
0468         std::cout << "In detId: " << s->first << std::endl;
0469         std::cout << "Errorstat not of equal size!" << std::endl;
0470         std::cout << sv[k].getErrorstat().size() << ' ' << cv[i].getErrorstat().size() << std::endl;
0471       } else {
0472         std::vector<uint16_t> sADC = sv[k].getErrorstat();
0473         std::vector<uint16_t> uADC = cv[i].getErrorstat();
0474 
0475         for (unsigned iadc = 0; iadc < sADC.size(); ++iadc)
0476           if (sADC[iadc] != uADC[iadc]) {
0477             std::cout << "In detId: " << s->first << std::endl;
0478             std::cout << "Errorstat not equal at index: " << iadc << std::endl
0479                       << std::hex << sADC[iadc] << " != " << uADC[iadc] << std::dec << std::endl;
0480           }
0481       }
0482       if (sv[k].pedestal() != cv[i].pedestal()) {
0483         std::cout << "In detId: " << s->first << std::endl;
0484         std::cout << "Pedestals not equal: " << sv[k].pedestal() << " != " << cv[i].pedestal() << std::endl;
0485       }
0486       if (sv[k].amplitude() != cv[i].amplitude()) {
0487         std::cout << "In detId: " << s->first << std::endl;
0488         std::cout << "Amplitudes not equal: " << sv[k].amplitude() << " != " << cv[i].amplitude() << std::endl;
0489       }
0490     }
0491   }
0492   for (c = comps.begin(); c != comps.end(); ++c) {
0493     if (c->second.first.size() != c->second.second.size()) {
0494       std::cout << "Major error! # of comparator digis in detID: " << c->first
0495                 << " is not equal between sim and unpacked!" << std::endl;
0496       //eventually do more in this case!
0497 
0498       std::vector<CSCComparatorDigi> a = c->second.second;
0499       std::vector<CSCComparatorDigi> b = c->second.first;
0500       std::cout << "SIM OUTPUT:" << std::endl;
0501       for (std::vector<CSCComparatorDigi>::const_iterator i = a.begin(); i != a.end(); ++i)
0502         i->print();
0503       std::cout << "UNPACKER OUTPUT:" << std::endl;
0504       for (std::vector<CSCComparatorDigi>::const_iterator i = b.begin(); i != b.end(); ++i)
0505         i->print();
0506     }
0507     int max = std::min(c->second.first.size(), c->second.second.size());
0508     std::vector<CSCComparatorDigi> cv = c->second.first;
0509     std::vector<CSCComparatorDigi> sv = c->second.second;
0510     for (int i = 0; i < max; ++i) {
0511       if (sv[i].getStrip() != cv[i].getStrip()) {
0512         std::cout << "In detId: " << s->first << std::endl;
0513         std::cout << "Comparator strips do not match: " << sv[i].getStrip() << " != " << cv[i].getStrip() << std::endl;
0514       }
0515       if (sv[i].getComparator() != cv[i].getComparator()) {
0516         std::cout << "In detId: " << c->first << std::endl;
0517         std::cout << "Comparators do not match: " << sv[i].getComparator() << " != " << cv[i].getComparator()
0518                   << std::endl;
0519       }
0520       if (sv[i].getTimeBinWord() != cv[i].getTimeBinWord()) {
0521         std::cout << "In detId: " << c->first << std::endl;
0522         std::cout << "Comparator time bins words do not match: " << sv[i].getTimeBinWord()
0523                   << " != " << cv[i].getTimeBinWord() << std::endl;
0524       }
0525     }
0526   }
0527   for (cl = clcts.begin(); cl != clcts.end(); ++cl) {
0528     if (cl->second.first.size() != cl->second.second.size()) {
0529       std::cout << "Major error! # of CLCT digis in detID: " << cl->first << " is not equal between sim and unpacked!"
0530                 << std::endl;
0531       //eventually do more in this case!
0532 
0533       std::vector<CSCCLCTDigi> a = cl->second.second;
0534       std::vector<CSCCLCTDigi> b = cl->second.first;
0535       std::cout << "SIM OUTPUT:" << std::endl;
0536       for (std::vector<CSCCLCTDigi>::const_iterator i = a.begin(); i != a.end(); ++i)
0537         i->print();
0538       std::cout << "UNPACKER OUTPUT:" << std::endl;
0539       for (std::vector<CSCCLCTDigi>::const_iterator i = b.begin(); i != b.end(); ++i)
0540         i->print();
0541     }
0542     int max = std::min(cl->second.first.size(), cl->second.second.size());
0543     std::vector<CSCCLCTDigi> cv = cl->second.first;
0544     std::vector<CSCCLCTDigi> sv = cl->second.second;
0545     for (int i = 0; i < max; ++i) {
0546       if (cv[i].getKeyStrip() != sv[i].getKeyStrip()) {
0547         std::cout << "In detId: " << cl->first << std::endl;
0548         std::cout << "CLCT key strips do not match: " << sv[i].getKeyStrip() << " != " << cv[i].getKeyStrip()
0549                   << std::endl;
0550       }
0551       if (cv[i].getStrip() != sv[i].getStrip()) {
0552         std::cout << "In detId: " << cl->first << std::endl;
0553         std::cout << "CLCT strips do not match: " << sv[i].getStrip() << " != " << cv[i].getStrip() << std::endl;
0554       }
0555       if (cv[i].isValid() != sv[i].isValid()) {
0556         std::cout << "In detId: " << cl->first << std::endl;
0557         std::cout << "CLCT Valid bits do not match: " << sv[i].isValid() << " != " << cv[i].isValid() << std::endl;
0558       }
0559       if (cv[i].getQuality() != sv[i].getQuality()) {
0560         std::cout << "In detId: " << cl->first << std::endl;
0561         std::cout << "CLCT qualities do not match: " << sv[i].getQuality() << " != " << cv[i].getQuality() << std::endl;
0562       }
0563       if (cv[i].getPattern() != sv[i].getPattern()) {
0564         std::cout << "In detId: " << cl->first << std::endl;
0565         std::cout << "CLCT patterns do not match: " << sv[i].getPattern() << " != " << cv[i].getPattern() << std::endl;
0566       }
0567       if (cv[i].getStripType() != sv[i].getStripType()) {
0568         std::cout << "In detId: " << cl->first << std::endl;
0569         std::cout << "CLCT strip types do not match: " << sv[i].getStripType() << " != " << cv[i].getStripType()
0570                   << std::endl;
0571       }
0572       if (cv[i].getBend() != sv[i].getBend()) {
0573         std::cout << "In detId: " << cl->first << std::endl;
0574         std::cout << "CLCT bends do not match: " << sv[i].getBend() << " != " << cv[i].getBend() << std::endl;
0575       }
0576       if (cv[i].getCFEB() != sv[i].getCFEB()) {
0577         std::cout << "In detId: " << cl->first << std::endl;
0578         std::cout << "CLCT CFEBs do not match: " << sv[i].getCFEB() << " != " << cv[i].getCFEB() << std::endl;
0579       }
0580       if (((short)cv[i].getBX()) != ((short)sv[i].getBX()) - 4) {
0581         std::cout << "In detId: " << cl->first << std::endl;
0582         std::cout << "CLCT BX do not match: " << sv[i].getBX() - 4 << " != " << cv[i].getBX() << std::endl;
0583       }
0584       if (cv[i].getFullBX() != sv[i].getFullBX()) {
0585         std::cout << "In detId: " << cl->first << std::endl;
0586         std::cout << "CLCT Full BX do not match: " << sv[i].getFullBX() << " != " << cv[i].getFullBX() << std::endl;
0587       }
0588       if (cv[i].getTrknmb() != sv[i].getTrknmb()) {
0589         std::cout << "In detId: " << cl->first << std::endl;
0590         std::cout << "CLCT Track numbers do not match: " << sv[i].getTrknmb() << " != " << cv[i].getTrknmb()
0591                   << std::endl;
0592       }
0593     }
0594   }
0595   for (al = alcts.begin(); al != alcts.end(); ++al) {
0596     if (al->second.first.size() != al->second.second.size()) {
0597       std::cout << "Major error! # of ALCT digis in detID: " << al->first << " is not equal between sim and unpacked!"
0598                 << std::endl;
0599       //eventually do more in this case!
0600 
0601       std::vector<CSCALCTDigi> a = al->second.second;
0602       std::vector<CSCALCTDigi> b = al->second.first;
0603       std::cout << "SIM OUTPUT:" << std::endl;
0604       for (std::vector<CSCALCTDigi>::const_iterator i = a.begin(); i != a.end(); ++i)
0605         i->print();
0606       std::cout << "UNPACKER OUTPUT:" << std::endl;
0607       for (std::vector<CSCALCTDigi>::const_iterator i = b.begin(); i != b.end(); ++i)
0608         i->print();
0609     }
0610     int max = std::min(al->second.first.size(), al->second.second.size());
0611     std::vector<CSCALCTDigi> cv = al->second.first;
0612     std::vector<CSCALCTDigi> sv = al->second.second;
0613     for (int i = 0; i < max; ++i) {
0614       if (cv[i].getKeyWG() != sv[i].getKeyWG()) {
0615         std::cout << "In detId: " << al->first << std::endl;
0616         std::cout << "ALCT key wire groups do not match: " << sv[i].getKeyWG() << " != " << cv[i].getKeyWG()
0617                   << std::endl;
0618       }
0619       if (cv[i].isValid() != sv[i].isValid()) {
0620         std::cout << "In detId: " << al->first << std::endl;
0621         std::cout << "ALCT Valid bits do not match: " << sv[i].isValid() << " != " << cv[i].isValid() << std::endl;
0622       }
0623       if (cv[i].getQuality() != sv[i].getQuality()) {
0624         std::cout << "In detId: " << al->first << std::endl;
0625         std::cout << "ALCT qualities do not match: " << sv[i].getQuality() << " != " << cv[i].getQuality() << std::endl;
0626       }
0627       if (cv[i].getAccelerator() != sv[i].getAccelerator()) {
0628         std::cout << "In detId: " << al->first << std::endl;
0629         std::cout << "ALCT accelerator bits do not match: " << sv[i].getAccelerator()
0630                   << " != " << cv[i].getAccelerator() << std::endl;
0631       }
0632       if (cv[i].getCollisionB() != sv[i].getCollisionB()) {
0633         std::cout << "In detId: " << al->first << std::endl;
0634         std::cout << "ALCT CollisionB flags do not match: " << sv[i].getCollisionB() << " != " << cv[i].getCollisionB()
0635                   << std::endl;
0636       }
0637       if ((cv[i].getBX()) != (sv[i].getBX())) {
0638         std::cout << "In detId: " << al->first << std::endl;
0639         std::cout << "ALCT BX do not match: " << sv[i].getBX() << " != " << cv[i].getBX() << std::endl;
0640       }
0641       if (cv[i].getFullBX() != sv[i].getFullBX()) {
0642         std::cout << "In detId: " << cl->first << std::endl;
0643         std::cout << "ALCT Full BX do not match: " << sv[i].getFullBX() << " != " << cv[i].getFullBX() << std::endl;
0644       }
0645     }
0646   }
0647   for (lc = lcts.begin(); lc != lcts.end(); ++lc) {
0648     if (lc->second.first.size() != lc->second.second.size()) {
0649       std::cout << "Major error! # of Correlated LCT digis in detID: " << lc->first
0650                 << " is not equal between sim and unpacked!" << std::endl;
0651       //eventually do more in this case!
0652 
0653       std::vector<CSCCorrelatedLCTDigi> a = lc->second.second;
0654       std::vector<CSCCorrelatedLCTDigi> b = lc->second.first;
0655       std::cout << "SIM OUTPUT:" << std::endl;
0656       for (std::vector<CSCCorrelatedLCTDigi>::const_iterator i = a.begin(); i != a.end(); ++i)
0657         i->print();
0658       std::cout << "UNPACKER OUTPUT:" << std::endl;
0659       for (std::vector<CSCCorrelatedLCTDigi>::const_iterator i = b.begin(); i != b.end(); ++i)
0660         i->print();
0661     }
0662     int max = std::min(lc->second.first.size(), lc->second.second.size());
0663     std::vector<CSCCorrelatedLCTDigi> cv = lc->second.first;
0664     std::vector<CSCCorrelatedLCTDigi> sv = lc->second.second;
0665     for (int i = 0; i < max; ++i) {
0666       if (cv[i].getStrip() != sv[i].getStrip()) {
0667         std::cout << "In detId: " << lc->first << std::endl;
0668         std::cout << "Correlated LCT strips do not match: " << sv[i].getStrip() << " != " << cv[i].getStrip()
0669                   << std::endl;
0670       }
0671       if (cv[i].getKeyWG() != sv[i].getKeyWG()) {
0672         std::cout << "In detId: " << lc->first << std::endl;
0673         std::cout << "Correlated LCT key wire groups do not match: " << sv[i].getKeyWG() << " != " << cv[i].getKeyWG()
0674                   << std::endl;
0675       }
0676       if (cv[i].isValid() != sv[i].isValid()) {
0677         std::cout << "In detId: " << lc->first << std::endl;
0678         std::cout << "Correlated LCT Valid bits do not match: " << sv[i].isValid() << " != " << cv[i].isValid()
0679                   << std::endl;
0680       }
0681       if (cv[i].getQuality() != sv[i].getQuality()) {
0682         std::cout << "In detId: " << lc->first << std::endl;
0683         std::cout << "Correlated LCT qualities do not match: " << sv[i].getQuality() << " != " << cv[i].getQuality()
0684                   << std::endl;
0685       }
0686       if (cv[i].getPattern() != sv[i].getPattern()) {
0687         std::cout << "In detId: " << lc->first << std::endl;
0688         std::cout << "Correlated LCT ALCT patterns do not match: " << sv[i].getPattern() << " != " << cv[i].getPattern()
0689                   << std::endl;
0690       }
0691       if (cv[i].getCLCTPattern() != sv[i].getCLCTPattern()) {
0692         std::cout << "In detId: " << lc->first << std::endl;
0693         std::cout << "Correlated LCT CLCT patterns do not match: " << sv[i].getCLCTPattern()
0694                   << " != " << cv[i].getCLCTPattern() << std::endl;
0695       }
0696       if (cv[i].getStripType() != sv[i].getStripType()) {
0697         std::cout << "In detId: " << lc->first << std::endl;
0698         std::cout << "Correlated LCT strip types do not match: " << sv[i].getStripType()
0699                   << " != " << cv[i].getStripType() << std::endl;
0700       }
0701       if (cv[i].getBend() != sv[i].getBend()) {
0702         std::cout << "In detId: " << lc->first << std::endl;
0703         std::cout << "Correlated LCT bends do not match: " << sv[i].getBend() << " != " << cv[i].getBend() << std::endl;
0704       }
0705       if (cv[i].getMPCLink() != sv[i].getMPCLink()) {
0706         std::cout << "In detId: " << lc->first << std::endl;
0707         std::cout << "Correlated LCT MPC Links do not match: " << sv[i].getMPCLink() << " != " << cv[i].getMPCLink()
0708                   << std::endl;
0709       }
0710       if ((cv[i].getBX()) != (sv[i].getBX() - 6)) {
0711         std::cout << "In detId: " << lc->first << std::endl;
0712         std::cout << "Correlated LCT BX do not match: " << sv[i].getBX() - 6 << " != " << cv[i].getBX() << std::endl;
0713       }
0714       if (cv[i].getCSCID() != sv[i].getCSCID()) {
0715         std::cout << "In detId: " << lc->first << std::endl;
0716         std::cout << "Correlated LCT CSCIDs do not match: " << sv[i].getCSCID() << " != " << cv[i].getCSCID()
0717                   << std::endl;
0718       }
0719       if (cv[i].getBX0() != sv[i].getBX0()) {
0720         std::cout << "In detId: " << lc->first << std::endl;
0721         std::cout << "Correlated LCT BX0s do not match: " << sv[i].getBX0() << " != " << cv[i].getBX0() << std::endl;
0722       }
0723       if (cv[i].getSyncErr() != sv[i].getSyncErr()) {
0724         std::cout << "In detId: " << lc->first << std::endl;
0725         std::cout << "Correlated LCT SyncErrs do not match: " << sv[i].getSyncErr() << " != " << cv[i].getSyncErr()
0726                   << std::endl;
0727       }
0728       if (cv[i].getTrknmb() != sv[i].getTrknmb()) {
0729         std::cout << "In detId: " << lc->first << std::endl;
0730         std::cout << "Correlated LCT Track numbers do not match: " << sv[i].getTrknmb() << " != " << cv[i].getTrknmb()
0731                   << std::endl;
0732       }
0733     }
0734   }
0735   if (tracks.get().size() != simtracks.get().size()) {
0736     std::cout << "Major error! # of L1 Tracks is not equal between sim and unpacked!" << std::endl;
0737     std::vector<csc::L1Track> a = simtracks.get();
0738     std::vector<csc::L1Track> b = tracks.get();
0739     std::cout << "SIM OUTPUT:" << std::endl;
0740     for (std::vector<csc::L1Track>::const_iterator i = a.begin(); i != a.end(); ++i)
0741       i->print();
0742     std::cout << "UNPACKER OUTPUT:" << std::endl;
0743     for (std::vector<csc::L1Track>::const_iterator i = b.begin(); i != b.end(); ++i)
0744       i->print();
0745   }
0746 
0747   return _err;
0748 }
0749 
0750 // this function takes the sim wire digis and combines wire digis from the same wire
0751 // into one wire digi, as in the data.
0752 // returns a vector of the combined wire digis
0753 std::vector<CSCWireDigi> CSCDigiValidator::sanitizeWireDigis(std::vector<CSCWireDigi>::const_iterator b,
0754                                                              std::vector<CSCWireDigi>::const_iterator e) {
0755   typedef std::map<int, std::vector<CSCWireDigi> > wire2digi;
0756 
0757   std::vector<CSCWireDigi> _r;  // the resulting vector of wire digis
0758   wire2digi _wr2digis;          // map of wires to a set of digis
0759 
0760   for (std::vector<CSCWireDigi>::const_iterator i = b; i != e; ++i)
0761     _wr2digis[i->getWireGroup()].push_back(*i);
0762 
0763   for (wire2digi::const_iterator i = _wr2digis.begin(); i != _wr2digis.end(); ++i) {
0764     int wire = i->first;
0765     unsigned tbin = 0x0;
0766 
0767     for (std::vector<CSCWireDigi>::const_iterator d = i->second.begin(); d != i->second.end(); ++d) {
0768       std::vector<int> binson = d->getTimeBinsOn();
0769       for (std::vector<int>::const_iterator t = binson.begin(); t != binson.end(); ++t)
0770         tbin |= 1 << (*t);
0771     }
0772 
0773     _r.push_back(CSCWireDigi(wire, tbin));
0774   }
0775 
0776   return _r;
0777 }
0778 
0779 std::vector<CSCStripDigi> CSCDigiValidator::relabelStripDigis(const CSCChamberMap* m,
0780                                                               CSCDetId _id,
0781                                                               std::vector<CSCStripDigi>::const_iterator b,
0782                                                               std::vector<CSCStripDigi>::const_iterator e) {
0783   std::vector<CSCStripDigi> _r;  // the vector of strip digis with appropriate strip #'s
0784 
0785   //bool me1a = _id.station()==1 && _id.ring()==4;
0786   //bool zplus = _id.endcap()==1;
0787   //bool me1b = _id.station()==1 && _id.ring()==1;
0788 
0789   for (std::vector<CSCStripDigi>::const_iterator i = b; i != e; ++i) {
0790     int strip = i->getStrip();
0791 
0792     //if(me1a&&zplus) strip=17-strip;
0793     //if(me1b&&!zplus) strip=(65-strip-1)%(m->dmb(_id)*16) + 1;
0794     //if(me1a) strip+=64;
0795 
0796     _r.push_back(
0797         CSCStripDigi(strip, i->getADCCounts(), i->getADCOverflow(), i->getOverlappedSample(), i->getErrorstat()));
0798   }
0799   return _r;
0800 }
0801 
0802 std::vector<CSCComparatorDigi> CSCDigiValidator::relabelCompDigis(const CSCChamberMap* m,
0803                                                                   CSCDetId _id,
0804                                                                   std::vector<CSCComparatorDigi>::const_iterator b,
0805                                                                   std::vector<CSCComparatorDigi>::const_iterator e) {
0806   std::vector<CSCComparatorDigi> _r;  // the vector of comp digis with appropriate strip #'s
0807 
0808   bool me1a = _id.station() == 1 && _id.ring() == 4;
0809   //bool zplus = _id.endcap()==1;
0810   //bool me1b = _id.station()==1 && _id.ring()==1;
0811 
0812   for (std::vector<CSCComparatorDigi>::const_iterator i = b; i != e; ++i) {
0813     int strip = i->getStrip();
0814 
0815     //    if(me1a&&zplus) strip=17-strip;
0816     //    if(me1b&&!zplus) strip=65-strip;
0817     if (me1a)
0818       strip += 64;
0819 
0820     _r.push_back(CSCComparatorDigi(strip, i->getComparator(), i->getTimeBinWord()));
0821   }
0822   return _r;
0823 }
0824 
0825 std::vector<CSCStripDigi> CSCDigiValidator::sanitizeStripDigis(std::vector<CSCStripDigi>::const_iterator b,
0826                                                                std::vector<CSCStripDigi>::const_iterator e) {
0827   std::vector<CSCStripDigi> _r;  // vector of digis in proper order
0828 
0829   return _r;
0830 }
0831 
0832 std::vector<CSCStripDigi> CSCDigiValidator::zeroSupStripDigis(std::vector<CSCStripDigi>::const_iterator b,
0833                                                               std::vector<CSCStripDigi>::const_iterator e) {
0834   std::vector<CSCStripDigi> _r;  // zero-suppressed strip digis
0835   std::vector<int> counts;
0836 
0837   for (std::vector<CSCStripDigi>::const_iterator i = b; i != e; ++i) {
0838     bool nonzero = false;
0839     counts = i->getADCCounts();
0840     for (std::vector<int>::const_iterator a = counts.begin(); a != counts.end(); ++a)
0841       if ((*a) != 0)
0842         nonzero = true;
0843 
0844     if (nonzero)
0845       _r.push_back(*i);
0846   }
0847 
0848   return _r;
0849 }
0850 
0851 // remove comparator digis on or after the 10th time bin, for now, will be configurable later.
0852 std::vector<CSCComparatorDigi> CSCDigiValidator::zeroSupCompDigis(std::vector<CSCComparatorDigi>::const_iterator b,
0853                                                                   std::vector<CSCComparatorDigi>::const_iterator e) {
0854   std::vector<CSCComparatorDigi> _r;
0855 
0856   for (std::vector<CSCComparatorDigi>::const_iterator i = b; i != e; ++i) {
0857     bool present = false;
0858 
0859     if (i->getTimeBin() < 10)
0860       present = true;
0861 
0862     if (present)
0863       _r.push_back(*i);
0864   }
0865 
0866   return _r;
0867 }
0868 
0869 void CSCDigiValidator::beginJob() {}
0870 
0871 void CSCDigiValidator::endJob() {}
0872 
0873 #include "FWCore/Framework/interface/MakerMacros.h"
0874 DEFINE_FWK_MODULE(CSCDigiValidator);