CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/DPGAnalysis/SiStripTools/src/APVShot.cc

Go to the documentation of this file.
00001 #include <vector>
00002 #include "DataFormats/SiStripDigi/interface/SiStripDigi.h"
00003 #include "DPGAnalysis/SiStripTools/interface/APVShot.h"
00004 #include "FWCore/Utilities/interface/Exception.h"
00005 #include <algorithm>
00006 
00007 APVShot::APVShot(): 
00008   _zs(true), _apv(-1), _nstrips(0), _median(-1), _detid() { }
00009 
00010 APVShot::APVShot(const bool zs): 
00011   _zs(zs), _apv(-1), _nstrips(0), _median(-1), _detid() { }
00012 
00013 APVShot::APVShot(const std::vector<SiStripDigi>& digis, const DetId& detid, const bool zs):
00014   _zs(zs), _apv(-1), _nstrips(0), _median(-1), _detid() 
00015 { 
00016   computeShot(digis,detid,zs);
00017 }
00018 
00019 void APVShot::computeShot(const std::vector<SiStripDigi>& digis, const DetId& detid, const bool zs) {
00020 
00021   _zs = zs;
00022   _detid = detid;
00023 
00024   _nstrips = 0;
00025   _apv = -1;
00026   _median = -1;
00027 
00028   std::vector<unsigned int> charge;
00029   for(std::vector<SiStripDigi>::const_iterator digi=digis.begin();digi!=digis.end();++digi) {
00030 
00031     if(!_zs || digi->adc()>0) {
00032       int oldapv = _apv;
00033       _apv = digi->strip()/128;
00034       if(oldapv>=0 && oldapv!=_apv) throw cms::Exception("WrongDigiVector") << "Digis from Different APVs" ;
00035       
00036       charge.push_back(digi->adc());
00037       ++_nstrips;
00038     }
00039   }
00040   
00041   // charge to be sorted in descending order
00042 
00043   std::sort(charge.begin(),charge.end()); 
00044   std::reverse(charge.begin(),charge.end());
00045 
00046   if(charge.size()> 64) { _median = float(charge[64]); }
00047 
00048 }
00049 
00050 const bool APVShot::isGenuine() const { return (_nstrips > _threshold); }
00051 
00052 const int APVShot::apvNumber() const { return _apv; }
00053 
00054 const int APVShot::nStrips() const { return _nstrips; }
00055 
00056 const float APVShot::median() const { return _median; }
00057 
00058 const int APVShot::subDet() const { return _detid.subdetId(); }
00059 
00060 const unsigned int APVShot::detId() const { return _detid.rawId(); }
00061 
00062 const int APVShot::_threshold = 64;