CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/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     
00070     empty_[i] = false;
00071   }
00072   
00073   void update(int i, std::vector<SiStripCluster>::const_iterator begin ,std::vector<SiStripCluster>::const_iterator end) { 
00074     clusterI_[2*i] = begin - regionalHandle_->begin_record();
00075     clusterI_[2*i+1] = end - regionalHandle_->begin_record();
00076     
00077     empty_[i] = false;
00078     activeThisEvent_[i] = true;
00079   }
00080   
00081   
00082   const SiStripRecHitMatcher*  matcher() const { return theMatcher;}
00083   const StripClusterParameterEstimator*  stripCPE() const { return theCPE;}
00084 
00085 
00086   int nDet() const { return id_.size();}
00087 
00088   unsigned int id(int i) const { return id_[i]; }
00089   unsigned char subId(int i) const { return subId_[i];}
00090 
00091 
00092   
00093   bool isRegional() const { return regional_;}
00094   bool empty(int i) const { return empty_[i];}  
00095   bool isActive(int i) const { return activeThisEvent_[i] && activeThisPeriod_[i]; }
00096 
00097   void setEmpty(int i) {empty_[i] = true; activeThisEvent_[i] = true; }
00098   
00099   void setEmpty() {
00100     std::fill(empty_.begin(),empty_.end(),true);
00101     std::fill(activeThisEvent_.begin(), activeThisEvent_.end(),true);
00102   }
00103   
00106   void setActive(int i, bool active) { activeThisPeriod_[i] = active; activeThisEvent_[i] = true; if (!active) empty_[i] = true; }
00109   void setActiveThisEvent(int i, bool active) { activeThisEvent_[i] = active;  if (!active) empty_[i] = true; }
00110   
00111   
00112   edm::Handle<edmNew::DetSetVector<SiStripCluster> > & handle() {  return handle_;}
00113   StripDetset & detSet(int i) { return detSet_[i];}
00114   
00115   edm::Handle<edm::LazyGetter<SiStripCluster> > & regionalHandle() { return regionalHandle_;}
00116   unsigned int beginClusterI(int i) const {return clusterI_[2*i];}
00117   unsigned int endClusterI(int i) const {return clusterI_[2*i+1];}
00118   
00119   int totalStrips(int i) const { return totalStrips_[i];}
00120   
00121   
00122   
00123   void setMaskBad128StripBlocks(bool maskThem) { maskBad128StripBlocks_ = maskThem; }
00124   BadStripCuts & badStripCuts(int i) { return  badStripCuts_[subId_[i]];}
00125   
00126   
00127   bool maskBad128StripBlocks() const { return maskBad128StripBlocks_;}
00128   bool hasAny128StripBad(int i) const { return  hasAny128StripBad_[i];}
00129   
00130   std::vector<BadStripBlock> & getBadStripBlocks(int i) { return badStripBlocks_[i]; }
00131   std::vector<BadStripBlock> const & badStripBlocks(int i) const {return badStripBlocks_[i]; }
00132 
00133 
00134   bool isMasked(int i, const SiStripCluster &cluster) const {
00135     int offset =  nbad128*i;
00136     if ( bad128Strip_[offset+( cluster.firstStrip() >> 7)] ) {
00137       if ( bad128Strip_[offset+( (cluster.firstStrip()+cluster.amplitudes().size())  >> 7)] ||
00138            bad128Strip_[offset+( static_cast<int32_t>(cluster.barycenter()-0.499999) >> 7)] ) {
00139         return true;
00140       }
00141     } else {
00142       if ( bad128Strip_[offset+( (cluster.firstStrip()+cluster.amplitudes().size())  >> 7)] &&
00143            bad128Strip_[offset+( static_cast<int32_t>(cluster.barycenter()-0.499999) >> 7)] ) {
00144         return true;
00145       }
00146     }
00147     return false;
00148   }
00149   
00150   
00151   void set128StripStatus(int i, bool good, int idx=-1);  
00152 
00153   void initializeStripStatus(const SiStripQuality *quality, int qualityFlags, int qualityDebugFlags, edm::ParameterSet cutPset);
00154 
00155 private:
00156   
00157   friend class  MeasurementTrackerImpl;
00158   
00159   // globals
00160   const SiStripRecHitMatcher*       theMatcher;
00161   const StripClusterParameterEstimator* theCPE;
00162   
00163   edm::Handle<edmNew::DetSetVector<SiStripCluster> > handle_;
00164   edm::Handle<edm::LazyGetter<SiStripCluster> > regionalHandle_;
00165   
00166   mutable std::vector<bool> theStripsToSkip;
00167   
00168   bool regional_;
00169   
00170   mutable bool maskBad128StripBlocks_;
00171   BadStripCuts badStripCuts_[4];
00172   
00173   // members of TkStripMeasurementDet
00174   std::vector<unsigned int> id_;
00175   std::vector<unsigned char> subId_;
00176   
00177   std::vector<int> totalStrips_;
00178   
00179   static const int nbad128 = 6;
00180   std::vector<bool> bad128Strip_;
00181   std::vector<bool> hasAny128StripBad_;
00182   
00183   std::vector<std::vector<BadStripBlock>> badStripBlocks_;  
00184 
00185 
00186   std::vector<bool> empty_;
00187   
00188   std::vector<bool> activeThisEvent_,activeThisPeriod_;
00189   
00190   // full reco
00191   std::vector<StripDetset> detSet_;
00192   
00193   // --- regional unpacking
00194 
00195   // begin,end "pairs"
00196   std::vector<unsigned int> clusterI_;
00197   
00198   
00199 };
00200 
00201 
00202 #endif // StMeasurementDetSet_H