Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:08:38

0001 #include <vector>
0002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0003 #include "DQM/SiStripCommon/interface/APVShot.h"
0004 #include "DataFormats/SiStripDigi/interface/SiStripDigi.h"
0005 #include "DataFormats/Common/interface/DetSet.h"
0006 #include "DataFormats/Common/interface/DetSetVector.h"
0007 #include "DataFormats/DetId/interface/DetId.h"
0008 #include "DQM/SiStripCommon/interface/APVShotFinder.h"
0009 
0010 APVShotFinder::APVShotFinder(const bool zs) : _zs(zs), _shots() {}
0011 
0012 APVShotFinder::APVShotFinder(const edm::DetSet<SiStripDigi>& digis, const bool zs) : _zs(zs), _shots() {
0013   computeShots(digis);
0014 }
0015 
0016 APVShotFinder::APVShotFinder(const edm::DetSetVector<SiStripDigi>& digicoll, const bool zs) : _zs(zs), _shots() {
0017   computeShots(digicoll);
0018 }
0019 
0020 void APVShotFinder::computeShots(const edm::DetSet<SiStripDigi>& digis) {
0021   _shots.clear();
0022   addShots(digis);
0023 }
0024 
0025 void APVShotFinder::computeShots(const edm::DetSetVector<SiStripDigi>& digicoll) {
0026   _shots.clear();
0027 
0028   for (edm::DetSetVector<SiStripDigi>::const_iterator it = digicoll.begin(); it != digicoll.end(); ++it) {
0029     addShots(*it);
0030   }
0031 }
0032 
0033 void APVShotFinder::addShots(const edm::DetSet<SiStripDigi>& digis) {
0034   DetId detid(digis.detId());
0035 
0036   int laststrip = -1;
0037   int apv = -1;
0038   std::vector<SiStripDigi> temp;
0039 
0040   for (edm::DetSet<SiStripDigi>::const_iterator digi = digis.begin(); digi != digis.end(); digi++) {
0041     if (!_zs || digi->adc() > 0) {
0042       if (laststrip >= digi->strip())
0043         edm::LogWarning("StripNotInOrder") << "Strips not in order in DetSet<SiStripDigi>";
0044       laststrip = digi->strip();
0045 
0046       int newapv = digi->strip() / 128;
0047       if (newapv != apv) {
0048         if (apv >= 0) {
0049           if (temp.size() > 64) {
0050             APVShot shot(temp, detid, _zs);
0051             _shots.push_back(shot);
0052           }
0053           temp.clear();
0054         }
0055         apv = newapv;
0056       }
0057 
0058       temp.push_back(*digi);
0059     }
0060   }
0061   // last strip
0062   if (temp.size() > 64) {
0063     APVShot shot(temp, detid, _zs);
0064     _shots.push_back(shot);
0065   }
0066   temp.clear();
0067 }
0068 
0069 const std::vector<APVShot>& APVShotFinder::getShots() const { return _shots; }