CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_2_9_HLT1_bphpatch4/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 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00019 
00020 class TransientTrackingRecHit;
00021 
00022 class TkStripMeasurementDet : public MeasurementDet {
00023 public:
00024 
00025   typedef StripClusterParameterEstimator::LocalValues    LocalValues;
00026   typedef StripClusterParameterEstimator::VLocalValues    VLocalValues;
00027 
00028   typedef SiStripRecHit2D::ClusterRef SiStripClusterRef;
00029 
00030   typedef edm::LazyGetter<SiStripCluster>::value_ref  SiStripRegionalClusterRef;
00031 
00032   typedef edmNew::DetSet<SiStripCluster> detset;
00033   typedef detset::const_iterator new_const_iterator;
00034 
00035   typedef std::vector<SiStripCluster>::const_iterator const_iterator;
00036 
00037   virtual ~TkStripMeasurementDet(){}
00038 
00039   TkStripMeasurementDet( const GeomDet* gdet,
00040                          const StripClusterParameterEstimator* cpe,
00041                          bool regional);
00042 
00043   void update( const detset &detSet, 
00044                const edm::Handle<edmNew::DetSetVector<SiStripCluster> > h,
00045                unsigned int id ) { 
00046     detSet_ = detSet; 
00047     handle_ = h;
00048     id_ = id;
00049     empty = false;
00050     isRegional = false;
00051   }
00052 
00053   void update( std::vector<SiStripCluster>::const_iterator begin ,std::vector<SiStripCluster>::const_iterator end, 
00054                const edm::Handle<edm::LazyGetter<SiStripCluster> > h,
00055                unsigned int id ) { 
00056     regionalHandle_ = h;
00057     beginClusterI_ = begin - regionalHandle_->begin_record();
00058     endClusterI_ = end - regionalHandle_->begin_record();
00059     id_ = id;
00060     empty = false;
00061     activeThisEvent_ = true;
00062     isRegional = true;
00063   }
00064   
00066   bool isActive() const { return activeThisEvent_ && activeThisPeriod_; }
00067                  
00068   //TO BE IMPLEMENTED
00069   bool hasBadComponents( const TrajectoryStateOnSurface &tsos ) const {return false;}
00070 
00071 
00072   void setEmpty(){empty = true; activeThisEvent_ = true; }
00073   
00074   virtual RecHitContainer recHits( const TrajectoryStateOnSurface&) const;
00075   void simpleRecHits( const TrajectoryStateOnSurface& ts, std::vector<SiStripRecHit2D> &result) const ;
00076 
00077   virtual std::vector<TrajectoryMeasurement> 
00078   fastMeasurements( const TrajectoryStateOnSurface& stateOnThisDet, 
00079                     const TrajectoryStateOnSurface& startingState, 
00080                     const Propagator&, 
00081                     const MeasurementEstimator&) const;
00082 
00083   const StripGeomDetUnit& specificGeomDet() const {return *theStripGDU;}
00084 
00085   TransientTrackingRecHit::RecHitPointer
00086   buildRecHit( const SiStripClusterRef&, const TrajectoryStateOnSurface& ltp) const;
00087 
00088   TransientTrackingRecHit::RecHitPointer
00089   buildRecHit( const SiStripRegionalClusterRef&, const TrajectoryStateOnSurface& ltp) const;
00090 
00091     
00092   TkStripMeasurementDet::RecHitContainer 
00093   buildRecHits( const SiStripClusterRef&, const TrajectoryStateOnSurface& ltp) const;
00094   
00095   TkStripMeasurementDet::RecHitContainer 
00096   buildRecHits( const SiStripRegionalClusterRef&, const TrajectoryStateOnSurface& ltp) const;
00097 
00098 
00099   bool  isEmpty() {return empty;}
00100 
00101   unsigned int rawId() const { return id_; }
00102 
00103 
00104   const detset& theSet() {return detSet_;}
00105   int  size() const {return endClusterI_ - beginClusterI_ ; }
00106 
00109   void setActive(bool active) { activeThisPeriod_ = active; activeThisEvent_ = true; if (!active) empty = true; }
00112   void setActiveThisEvent(bool active) { activeThisEvent_ = active;  if (!active) empty = true; }
00113 
00115   bool hasAllGoodChannels() const { return !hasAny128StripBad_ && badStripBlocks_.empty(); }
00116 
00118   void set128StripStatus(bool good, int idx=-1);
00119 
00120   struct BadStripCuts {
00121      BadStripCuts() : maxBad(9999), maxConsecutiveBad(9999) {}
00122      BadStripCuts(const edm::ParameterSet &pset) :
00123         maxBad(pset.getParameter<uint32_t>("maxBad")),
00124         maxConsecutiveBad(pset.getParameter<uint32_t>("maxConsecutiveBad")) {}
00125      uint16_t maxBad, maxConsecutiveBad;
00126   };
00127 
00129   bool testStrips(float utraj, float uerr) const;
00130 
00131   void setBadStripCuts(BadStripCuts cuts) { badStripCuts_ = cuts; }
00132 
00133   struct BadStripBlock {
00134       short first;
00135       short last;
00136       BadStripBlock(const SiStripBadStrip::data &data) : first(data.firstStrip), last(data.firstStrip+data.range-1) { }
00137   };
00138   std::vector<BadStripBlock> &getBadStripBlocks() { return badStripBlocks_; }
00139 
00140   void setMaskBad128StripBlocks(bool maskThem) { maskBad128StripBlocks_ = maskThem; }
00141 
00142 private:
00143 
00144   bool isRegional;
00145 
00146   bool empty;
00147 
00148   bool activeThisEvent_,activeThisPeriod_;
00149 
00150   unsigned int id_;
00151 
00152   detset detSet_;
00153   edm::Handle<edmNew::DetSetVector<SiStripCluster> > handle_;
00154 
00155 
00156   const StripGeomDetUnit*               theStripGDU;
00157   const StripClusterParameterEstimator* theCPE;
00158 
00159 
00160 
00161   bool bad128Strip_[6];
00162   bool hasAny128StripBad_, maskBad128StripBlocks_;
00163 
00164   std::vector<BadStripBlock> badStripBlocks_;  
00165   int totalStrips_;
00166   BadStripCuts badStripCuts_;
00167  
00168 
00169   // --- regional unpacking
00170   edm::Handle<edm::LazyGetter<SiStripCluster> > regionalHandle_;
00171   uint beginClusterI_;
00172   uint endClusterI_;
00173 
00174   inline bool isMasked(const SiStripCluster &cluster) const {
00175       if ( bad128Strip_[cluster.firstStrip() >> 7] ) {
00176           if ( bad128Strip_[(cluster.firstStrip()+cluster.amplitudes().size())  >> 7] ||
00177                bad128Strip_[static_cast<int32_t>(cluster.barycenter()-0.499999) >> 7] ) {
00178               return true;
00179           }
00180       } else {
00181           if ( bad128Strip_[(cluster.firstStrip()+cluster.amplitudes().size())  >> 7] &&
00182                bad128Strip_[static_cast<int32_t>(cluster.barycenter()-0.499999) >> 7] ) {
00183               return true;
00184           }
00185       }
00186       return false;
00187   }
00188   
00189   template<class ClusterRefT>
00190     void buildSimpleRecHit( const ClusterRefT& cluster,
00191                             const TrajectoryStateOnSurface& ltp,
00192                             std::vector<SiStripRecHit2D>& res) const;
00193   
00194   
00195   std::set<SiStripClusterRef> skipClusters_;
00196   std::set<SiStripRegionalClusterRef> skipRegClusters_;
00197   
00198  public:
00199   inline bool accept(SiStripClusterRef & r) const {
00200     return (skipClusters_.find(r) == skipClusters_.end());
00201   }
00202   inline bool accept(SiStripRegionalClusterRef &r) const{
00203     return (skipRegClusters_.find(r) == skipRegClusters_.end());
00204   }
00205 
00206   void unset(){
00207     skipClusters_.clear();
00208     skipRegClusters_.clear();
00209   }
00210   template <typename IT>
00211     void setClusterToSkip(IT begin, IT end){
00212     skipClusters_.clear();
00213     skipClusters_.insert(begin,end);
00214   }
00215   template <typename IT>
00216     void setRegionalClustersToSkip(IT begin, IT end){
00217     skipRegClusters_.clear();
00218     skipRegClusters_.insert(begin,end);
00219   }
00220   
00221 };
00222 
00223 #endif