CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch1/src/RecoTracker/MeasurementDet/plugins/TkMeasurementDetSet.h

Go to the documentation of this file.
00001 #ifndef StMeasurementDetSet_H
00002 #define StMeasurementDetSet_H
00003 
00004 #include<vector>
00005 class TkStripMeasurementDet;
00006 class TkGluedMeasurementDet;
00007 class SiStripRecHitMatcher;
00008 class StripClusterParameterEstimator;
00009 
00010 #include "DataFormats/Common/interface/DetSetVector.h"
00011 #include "DataFormats/Common/interface/DetSetVectorNew.h"
00012 #include "DataFormats/SiStripCluster/interface/SiStripCluster.h"
00013 #include "DataFormats/Common/interface/Handle.h"
00014 #include "DataFormats/Common/interface/RefGetter.h"
00015 
00016 #include "CondFormats/SiStripObjects/interface/SiStripBadStrip.h"
00017 #include "CalibFormats/SiStripObjects/interface/SiStripQuality.h"
00018 
00019 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00020 
00021 /* Struct of arrays supporting "members of Tk...MeasurementDet
00022  * implemented with vectors, to be optimized...
00023  */
00024 class StMeasurementDetSet {
00025 public:
00026 
00027   typedef edmNew::DetSet<SiStripCluster> StripDetset;
00028   typedef StripDetset::const_iterator new_const_iterator;
00029   
00030   typedef std::vector<SiStripCluster>::const_iterator const_iterator;
00031   
00032   typedef edm::LazyGetter<SiStripCluster> LazyGetter;
00033   typedef edm::RefGetter<SiStripCluster> RefGetter;
00034 
00035    enum QualityFlags { BadModules=1, // for everybody
00036                        /* Strips: */ BadAPVFibers=2, BadStrips=4, MaskBad128StripBlocks=8 }; 
00037 
00038 
00039   struct BadStripCuts {
00040     BadStripCuts() : maxBad(9999), maxConsecutiveBad(9999) {}
00041     BadStripCuts(const edm::ParameterSet &pset) :
00042       maxBad(pset.getParameter<uint32_t>("maxBad")),
00043       maxConsecutiveBad(pset.getParameter<uint32_t>("maxConsecutiveBad")) {}
00044     uint16_t maxBad, maxConsecutiveBad;
00045   };
00046   
00047   struct BadStripBlock {
00048     short first;
00049     short last;
00050     BadStripBlock(const SiStripBadStrip::data &data) : first(data.firstStrip), last(data.firstStrip+data.range-1) { }
00051   };
00052   
00053   
00054   StMeasurementDetSet(const SiStripRecHitMatcher* matcher,
00055                       const StripClusterParameterEstimator* cpe,
00056                       bool regional):
00057     theMatcher(matcher), theCPE(cpe), regional_(regional){}
00058   
00059   
00060   void init(std::vector<TkStripMeasurementDet> & stripDets);
00061 
00062    
00063   std::vector<bool>  & clusterToSkip() const { return theStripsToSkip; }
00064   
00065   void setLazyGetter( edm::Handle<LazyGetter> const & lg) { regionalHandle_=lg;}
00066  
00067   void update(int i,const StripDetset & detSet ) { 
00068     detSet_[i] = detSet;     
00069     empty_[i] = false;
00070   }
00071   
00072   void update(int i, std::vector<SiStripCluster>::const_iterator begin ,std::vector<SiStripCluster>::const_iterator end) { 
00073     clusterI_[2*i] = begin - regionalHandle_->begin_record();
00074     clusterI_[2*i+1] = end - regionalHandle_->begin_record();
00075     
00076     empty_[i] = false;
00077     activeThisEvent_[i] = true;
00078   }
00079   
00080   
00081   const SiStripRecHitMatcher*  matcher() const { return theMatcher;}
00082   const StripClusterParameterEstimator*  stripCPE() const { return theCPE;}
00083 
00084 
00085   int nDet() const { return id_.size();}
00086 
00087   unsigned int id(int i) const { return id_[i]; }
00088   unsigned char subId(int i) const { return subId_[i];}
00089 
00090   int find(unsigned int jd, int i=0) {
00091     return std::lower_bound(id_.begin()+i,id_.end(),jd)-id_.begin();
00092   }
00093   
00094   bool isRegional() const { return regional_;}
00095   bool empty(int i) const { return empty_[i];}  
00096   bool isActive(int i) const { return activeThisEvent_[i] && activeThisPeriod_[i]; }
00097 
00098   void setEmpty(int i) {empty_[i] = true; activeThisEvent_[i] = true; }
00099   
00100   void setEmpty() {
00101     std::fill(empty_.begin(),empty_.end(),true);
00102     std::fill(activeThisEvent_.begin(), activeThisEvent_.end(),true);
00103   }
00104   
00107   void setActive(int i, bool active) { activeThisPeriod_[i] = active; activeThisEvent_[i] = true; if (!active) empty_[i] = true; }
00110   void setActiveThisEvent(int i, bool active) { activeThisEvent_[i] = active;  if (!active) empty_[i] = true; }
00111   
00112   
00113   edm::Handle<edmNew::DetSetVector<SiStripCluster> > & handle() {  return handle_;}
00114   StripDetset & detSet(int i) { return detSet_[i];}
00115   
00116   edm::Handle<edm::LazyGetter<SiStripCluster> > & regionalHandle() { return regionalHandle_;}
00117   unsigned int beginClusterI(int i) const {return clusterI_[2*i];}
00118   unsigned int endClusterI(int i) const {return clusterI_[2*i+1];}
00119   
00120   int totalStrips(int i) const { return totalStrips_[i];}
00121   
00122   
00123   
00124   void setMaskBad128StripBlocks(bool maskThem) { maskBad128StripBlocks_ = maskThem; }
00125   BadStripCuts & badStripCuts(int i) { return  badStripCuts_[subId_[i]];}
00126   
00127   
00128   bool maskBad128StripBlocks() const { return maskBad128StripBlocks_;}
00129   bool hasAny128StripBad(int i) const { return  hasAny128StripBad_[i];}
00130   
00131   std::vector<BadStripBlock> & getBadStripBlocks(int i) { return badStripBlocks_[i]; }
00132   std::vector<BadStripBlock> const & badStripBlocks(int i) const {return badStripBlocks_[i]; }
00133 
00134 
00135   bool isMasked(int i, const SiStripCluster &cluster) const {
00136     int offset =  nbad128*i;
00137     if ( bad128Strip_[offset+( cluster.firstStrip() >> 7)] ) {
00138       if ( bad128Strip_[offset+( (cluster.firstStrip()+cluster.amplitudes().size())  >> 7)] ||
00139            bad128Strip_[offset+( static_cast<int32_t>(cluster.barycenter()-0.499999) >> 7)] ) {
00140         return true;
00141       }
00142     } else {
00143       if ( bad128Strip_[offset+( (cluster.firstStrip()+cluster.amplitudes().size())  >> 7)] &&
00144            bad128Strip_[offset+( static_cast<int32_t>(cluster.barycenter()-0.499999) >> 7)] ) {
00145         return true;
00146       }
00147     }
00148     return false;
00149   }
00150   
00151   
00152   void set128StripStatus(int i, bool good, int idx=-1);  
00153 
00154   void initializeStripStatus(const SiStripQuality *quality, int qualityFlags, int qualityDebugFlags, edm::ParameterSet cutPset);
00155 
00156 private:
00157   
00158   friend class  MeasurementTrackerImpl;
00159   
00160   // globals
00161   const SiStripRecHitMatcher*       theMatcher;
00162   const StripClusterParameterEstimator* theCPE;
00163   
00164   edm::Handle<edmNew::DetSetVector<SiStripCluster> > handle_;
00165   edm::Handle<edm::LazyGetter<SiStripCluster> > regionalHandle_;
00166   
00167   mutable std::vector<bool> theStripsToSkip;
00168   
00169   bool regional_;
00170   
00171   mutable bool maskBad128StripBlocks_;
00172   BadStripCuts badStripCuts_[4];
00173   
00174   // members of TkStripMeasurementDet
00175   std::vector<unsigned int> id_;
00176   std::vector<unsigned char> subId_;
00177   
00178   std::vector<int> totalStrips_;
00179   
00180   static const int nbad128 = 6;
00181   std::vector<bool> bad128Strip_;
00182   std::vector<bool> hasAny128StripBad_;
00183   
00184   std::vector<std::vector<BadStripBlock>> badStripBlocks_;  
00185 
00186 
00187   std::vector<bool> empty_;
00188   
00189   std::vector<bool> activeThisEvent_,activeThisPeriod_;
00190   
00191   // full reco
00192   std::vector<StripDetset> detSet_;
00193   
00194   // --- regional unpacking
00195 
00196   // begin,end "pairs"
00197   std::vector<unsigned int> clusterI_;
00198   
00199   
00200 };
00201 
00202 
00203 #endif // StMeasurementDetSet_H