CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_2_9_HLT1_bphpatch4/src/DPGAnalysis/SiStripTools/src/APVShotFinder.cc

Go to the documentation of this file.
00001 #include <vector>
00002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00003 #include "DPGAnalysis/SiStripTools/interface/APVShot.h"
00004 #include "DataFormats/SiStripDigi/interface/SiStripDigi.h"
00005 #include "DataFormats/Common/interface/DetSet.h"
00006 #include "DataFormats/Common/interface/DetSetVector.h"
00007 #include "DataFormats/DetId/interface/DetId.h"
00008 #include "DPGAnalysis/SiStripTools/interface/APVShotFinder.h"
00009 
00010 APVShotFinder::APVShotFinder(const bool zs):
00011   _zs(zs), _shots() { }
00012 
00013 APVShotFinder::APVShotFinder(const edm::DetSet<SiStripDigi>& digis, const bool zs):
00014   _zs(zs), _shots() {
00015 
00016   computeShots(digis);
00017 
00018 }
00019 
00020 APVShotFinder::APVShotFinder(const edm::DetSetVector<SiStripDigi>& digicoll, const bool zs):
00021   _zs(zs), _shots() {
00022 
00023   computeShots(digicoll);
00024 
00025 }
00026 
00027 void APVShotFinder::computeShots(const edm::DetSet<SiStripDigi>& digis) {
00028 
00029   _shots.clear();
00030   addShots(digis);
00031   
00032 }
00033 
00034 void APVShotFinder::computeShots(const edm::DetSetVector<SiStripDigi>& digicoll) {
00035 
00036   _shots.clear();
00037 
00038    for(edm::DetSetVector<SiStripDigi>::const_iterator it = digicoll.begin();
00039        it!=digicoll.end();++it) {
00040 
00041      addShots(*it);
00042    }
00043 
00044 }
00045 
00046 void APVShotFinder::addShots(const edm::DetSet<SiStripDigi>& digis) {
00047 
00048   DetId detid(digis.detId());
00049 
00050   int laststrip = -1;
00051   int apv = -1;
00052   std::vector<SiStripDigi> temp;
00053 
00054   for(edm::DetSet<SiStripDigi>::const_iterator digi=digis.begin();digi!=digis.end();digi++) {
00055 
00056     if(!_zs || digi->adc()>0) {
00057       if(laststrip >= digi->strip()) edm::LogWarning("StripNotInOrder") << "Strips not in order in DetSet<SiStripDigi>";
00058       laststrip = digi->strip();
00059       
00060       int newapv = digi->strip()/128;
00061       if( newapv!=apv) {
00062         if(apv>=0) {
00063           if(temp.size() > 64) {
00064             APVShot shot(temp,detid,_zs);
00065             _shots.push_back(shot);
00066           }
00067           temp.clear();
00068         }
00069         apv = newapv;
00070       }
00071       
00072       temp.push_back(*digi);
00073     }
00074   }
00075   // last strip
00076   if(temp.size() > 64) {
00077     APVShot shot(temp,detid,_zs);
00078     _shots.push_back(shot);
00079   }
00080   temp.clear();
00081   
00082 }
00083 
00084 const std::vector<APVShot>& APVShotFinder::getShots() const { return _shots; }
00085 
00086