CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch13/src/RecoTracker/MeasurementDet/interface/TkStripMeasurementDet.h

Go to the documentation of this file.
00001 #ifndef TkStripMeasurementDet_H
00002 #define TkStripMeasurementDet_H
00003 
00004 #include "TrackingTools/MeasurementDet/interface/MeasurementDet.h"
00005 #include "RecoLocalTracker/ClusterParameterEstimator/interface/StripClusterParameterEstimator.h"
00006 #include "DataFormats/SiStripCluster/interface/SiStripClusterCollection.h"
00007 #include "Geometry/TrackerGeometryBuilder/interface/StripGeomDetUnit.h"
00008 #include "DataFormats/Common/interface/DetSetVector.h"
00009 #include "DataFormats/Common/interface/DetSetVectorNew.h"
00010 #include "DataFormats/SiStripCluster/interface/SiStripCluster.h"
00011 #include "DataFormats/Common/interface/Handle.h"
00012 #include "CondFormats/SiStripObjects/interface/SiStripNoises.h"
00013 #include "CondFormats/SiStripObjects/interface/SiStripBadStrip.h"
00014 #include "DataFormats/Common/interface/RefGetter.h"
00015 #include "DataFormats/TrackerRecHit2D/interface/SiStripRecHit2D.h"
00016 
00017 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00018 
00019 class TransientTrackingRecHit;
00020 
00021 class TkStripMeasurementDet : public MeasurementDet {
00022 public:
00023 
00024   //  typedef SiStripClusterCollection::Range                ClusterRange;
00025   //  typedef SiStripClusterCollection::ContainerIterator    ClusterIterator;
00026   typedef StripClusterParameterEstimator::LocalValues    LocalValues;
00027   typedef StripClusterParameterEstimator::VLocalValues    VLocalValues;
00028 
00029   typedef SiStripRecHit2D::ClusterRef SiStripClusterRef;
00030 
00031   typedef edm::LazyGetter<SiStripCluster>::value_ref  SiStripRegionalClusterRef;
00032 
00033   typedef edmNew::DetSet<SiStripCluster> detset;
00034   typedef detset::const_iterator new_const_iterator;
00035 
00036   typedef std::vector<SiStripCluster>::const_iterator const_iterator;
00037 
00038   virtual ~TkStripMeasurementDet(){}
00039 
00040   TkStripMeasurementDet( const GeomDet* gdet,
00041                          const StripClusterParameterEstimator* cpe,
00042                          bool regional);
00043 
00044   void update( const detset &detSet, 
00045                const edm::Handle<edmNew::DetSetVector<SiStripCluster> > h,
00046                unsigned int id ) { 
00047     detSet_ = detSet; 
00048     handle_ = h;
00049     id_ = id;
00050     empty = false;
00051     isRegional = false;
00052   }
00053 
00054   void update( std::vector<SiStripCluster>::const_iterator begin ,std::vector<SiStripCluster>::const_iterator end, 
00055                const edm::Handle<edm::LazyGetter<SiStripCluster> > h,
00056                unsigned int id ) { 
00057     beginCluster = begin;
00058     endCluster   = end;
00059     regionalHandle_ = h;
00060     id_ = id;
00061     empty = false;
00062     activeThisEvent_ = true;
00063     isRegional = true;
00064   }
00065   
00067   bool isActive() const { return activeThisEvent_ && activeThisPeriod_; }
00068                  
00069   //TO BE IMPLEMENTED
00070   bool hasBadComponents( const TrajectoryStateOnSurface &tsos ) const {return false;}
00071 
00072 
00073   void setEmpty(){empty = true; activeThisEvent_ = true; }
00074   
00075   virtual RecHitContainer recHits( const TrajectoryStateOnSurface&) const;
00076   void simpleRecHits( const TrajectoryStateOnSurface& ts, std::vector<SiStripRecHit2D> &result) const ;
00077 
00078   virtual std::vector<TrajectoryMeasurement> 
00079   fastMeasurements( const TrajectoryStateOnSurface& stateOnThisDet, 
00080                     const TrajectoryStateOnSurface& startingState, 
00081                     const Propagator&, 
00082                     const MeasurementEstimator&) const;
00083 
00084   const StripGeomDetUnit& specificGeomDet() const {return *theStripGDU;}
00085 
00086   TransientTrackingRecHit::RecHitPointer
00087   buildRecHit( const SiStripClusterRef&, const TrajectoryStateOnSurface& ltp) const;
00088 
00089   TransientTrackingRecHit::RecHitPointer
00090   buildRecHit( const SiStripRegionalClusterRef&, const TrajectoryStateOnSurface& ltp) const;
00091 
00092     
00093   TkStripMeasurementDet::RecHitContainer 
00094   buildRecHits( const SiStripClusterRef&, const TrajectoryStateOnSurface& ltp) const;
00095   
00096   TkStripMeasurementDet::RecHitContainer 
00097   buildRecHits( const SiStripRegionalClusterRef&, const TrajectoryStateOnSurface& ltp) const;
00098 
00099 
00100   bool  isEmpty() {return empty;}
00101 
00102   unsigned int rawId() const { return id_; }
00103 
00104 
00105   const detset& theSet() {return detSet_;}
00106   int  size() {return endCluster - beginCluster ; }
00107 
00110   void setActive(bool active) { activeThisPeriod_ = active; activeThisEvent_ = true; if (!active) empty = true; }
00113   void setActiveThisEvent(bool active) { activeThisEvent_ = active;  if (!active) empty = true; }
00114 
00116   bool hasAllGoodChannels() const { return !hasAny128StripBad_ && badStripBlocks_.empty(); }
00117 
00119   void set128StripStatus(bool good, int idx=-1);
00120 
00121   struct BadStripCuts {
00122      BadStripCuts() : maxBad(9999), maxConsecutiveBad(9999) {}
00123      BadStripCuts(const edm::ParameterSet &pset) :
00124         maxBad(pset.getParameter<uint32_t>("maxBad")),
00125         maxConsecutiveBad(pset.getParameter<uint32_t>("maxConsecutiveBad")) {}
00126      uint16_t maxBad, maxConsecutiveBad;
00127   };
00128 
00130   bool testStrips(float utraj, float uerr) const;
00131 
00132   void setBadStripCuts(BadStripCuts cuts) { badStripCuts_ = cuts; }
00133 
00134   struct BadStripBlock {
00135       short first;
00136       short last;
00137       BadStripBlock(const SiStripBadStrip::data &data) : first(data.firstStrip), last(data.firstStrip+data.range-1) { }
00138   };
00139   std::vector<BadStripBlock> &getBadStripBlocks() { return badStripBlocks_; }
00140 
00141   void setMaskBad128StripBlocks(bool maskThem) { maskBad128StripBlocks_ = maskThem; }
00142 
00143 private:
00144 
00145   bool isRegional;
00146 
00147   bool empty;
00148 
00149   bool activeThisEvent_,activeThisPeriod_;
00150 
00151   unsigned int id_;
00152 
00153   detset detSet_;
00154   edm::Handle<edmNew::DetSetVector<SiStripCluster> > handle_;
00155 
00156 
00157   const StripGeomDetUnit*               theStripGDU;
00158   const StripClusterParameterEstimator* theCPE;
00159 
00160 
00161 
00162   bool bad128Strip_[6];
00163   bool hasAny128StripBad_, maskBad128StripBlocks_;
00164 
00165   std::vector<BadStripBlock> badStripBlocks_;  
00166   int totalStrips_;
00167   BadStripCuts badStripCuts_;
00168  
00169 
00170   // --- regional unpacking
00171   edm::Handle<edm::LazyGetter<SiStripCluster> > regionalHandle_;
00172   std::vector<SiStripCluster>::const_iterator beginCluster;
00173   std::vector<SiStripCluster>::const_iterator endCluster;
00174   // regional unpacking ---
00175 
00176   inline bool isMasked(const SiStripCluster &cluster) const {
00177       if ( bad128Strip_[cluster.firstStrip() >> 7] ) {
00178           if ( bad128Strip_[(cluster.firstStrip()+cluster.amplitudes().size())  >> 7] ||
00179                bad128Strip_[static_cast<int32_t>(cluster.barycenter()-0.499999) >> 7] ) {
00180               return true;
00181           }
00182       } else {
00183           if ( bad128Strip_[(cluster.firstStrip()+cluster.amplitudes().size())  >> 7] &&
00184                bad128Strip_[static_cast<int32_t>(cluster.barycenter()-0.499999) >> 7] ) {
00185               return true;
00186           }
00187       }
00188       return false;
00189   }
00190   
00191   template<class ClusterRefT>
00192     void buildSimpleRecHit( const ClusterRefT& cluster,
00193                             const TrajectoryStateOnSurface& ltp,
00194                             std::vector<SiStripRecHit2D>& res) const;
00195   
00196 };
00197 
00198 #endif