CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/RecoLocalTracker/SiStripClusterizer/interface/StripClusterizerAlgorithm.h

Go to the documentation of this file.
00001 #ifndef RecoLocalTracker_StripClusterizerAlgorithm_h
00002 #define RecoLocalTracker_StripClusterizerAlgorithm_h
00003 
00004 namespace edm{class EventSetup;}
00005 class SiStripDigi;
00006 #include "DataFormats/SiStripCluster/interface/SiStripCluster.h"
00007 #include "DataFormats/Common/interface/DetSetVector.h"
00008 #include "DataFormats/Common/interface/DetSetVectorNew.h"
00009 #include "FWCore/Framework/interface/ESHandle.h"
00010 #include "CalibFormats/SiStripObjects/interface/SiStripGain.h"
00011 #include "CondFormats/SiStripObjects/interface/SiStripNoises.h"
00012 #include "CalibFormats/SiStripObjects/interface/SiStripQuality.h"
00013 
00014 class StripClusterizerAlgorithm {
00015   
00016  public:
00017 
00018   virtual ~StripClusterizerAlgorithm() {}
00019   virtual void initialize(const edm::EventSetup&);
00020 
00021   //Offline DetSet interface
00022   typedef edmNew::DetSetVector<SiStripCluster> output_t;
00023   void clusterize(const    edm::DetSetVector<SiStripDigi> &, output_t &);
00024   void clusterize(const edmNew::DetSetVector<SiStripDigi> &, output_t &);
00025   virtual void clusterizeDetUnit(const    edm::DetSet<SiStripDigi> &, output_t::FastFiller &) = 0;
00026   virtual void clusterizeDetUnit(const edmNew::DetSet<SiStripDigi> &, output_t::FastFiller &) = 0;
00027 
00028   //HLT stripByStrip interface
00029   virtual bool stripByStripBegin(uint32_t id) = 0;
00030   virtual void stripByStripAdd(uint16_t strip, uint16_t adc, std::vector<SiStripCluster>& out) = 0;
00031   virtual void stripByStripEnd(std::vector<SiStripCluster>& out) = 0;
00032 
00033   struct InvalidChargeException : public cms::Exception { public: InvalidChargeException(const SiStripDigi&); };
00034 
00035  protected:
00036 
00037   StripClusterizerAlgorithm() : qualityLabel(""), noise_cache_id(0), gain_cache_id(0), quality_cache_id(0) {}
00038 
00039   uint32_t currentId() {return detId;}
00040   virtual void setDetId(const uint32_t);
00041   float noise(const uint16_t& strip) const { return noiseHandle->getNoise( strip, noiseRange ); }
00042   float gain(const uint16_t& strip)  const { return gainHandle->getStripGain( strip, gainRange ); }
00043   bool bad(const uint16_t& strip)    const { return qualityHandle->IsStripBad( qualityRange, strip ); }
00044   bool isModuleUsable(const uint32_t& id)  const { return qualityHandle->IsModuleUsable( id ); }
00045   bool allBadBetween(uint16_t L, const uint16_t& R) const { while( ++L < R  &&  bad(L) ); return L == R; }
00046   std::string qualityLabel;
00047   bool _setDetId;
00048 
00049  private:
00050 
00051   template<class T> void clusterize_(const T& input, output_t& output) {
00052     for(typename T::const_iterator it = input.begin(); it!=input.end(); it++) {
00053       output_t::FastFiller ff(output, it->detId());     
00054       clusterizeDetUnit(*it, ff);       
00055       if(ff.empty()) ff.abort();        
00056     }   
00057   }
00058 
00059 
00060   SiStripApvGain::Range gainRange;
00061   SiStripNoises::Range  noiseRange;
00062   SiStripQuality::Range qualityRange;
00063   edm::ESHandle<SiStripGain> gainHandle;
00064   edm::ESHandle<SiStripNoises> noiseHandle;
00065   edm::ESHandle<SiStripQuality> qualityHandle;
00066   uint32_t noise_cache_id, gain_cache_id, quality_cache_id, detId;
00067 
00068 
00069 };
00070 #endif