CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/RecoTracker/MeasurementDet/plugins/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 "TkMeasurementDetSet.h"
00006 
00007 #include "RecoLocalTracker/ClusterParameterEstimator/interface/StripClusterParameterEstimator.h"
00008 #include "DataFormats/TrackerRecHit2D/interface/OmniClusterRef.h"
00009 #include "DataFormats/SiStripCluster/interface/SiStripClusterCollection.h"
00010 #include "Geometry/TrackerGeometryBuilder/interface/StripGeomDetUnit.h"
00011 #include "DataFormats/Common/interface/DetSetVector.h"
00012 #include "DataFormats/Common/interface/DetSetVectorNew.h"
00013 #include "DataFormats/SiStripCluster/interface/SiStripCluster.h"
00014 #include "DataFormats/Common/interface/Handle.h"
00015 #include "CondFormats/SiStripObjects/interface/SiStripNoises.h"
00016 #include "CondFormats/SiStripObjects/interface/SiStripBadStrip.h"
00017 #include "DataFormats/Common/interface/RefGetter.h"
00018 #include "DataFormats/TrackerRecHit2D/interface/SiStripRecHit2D.h"
00019 #include "RecoTracker/TransientTrackingRecHit/interface/TSiStripRecHit2DLocalPos.h"
00020 
00021 #include "TrackingTools/DetLayers/interface/MeasurementEstimator.h"
00022 
00023 class TransientTrackingRecHit;
00024 
00025 class TkStripMeasurementDet GCC11_FINAL : public MeasurementDet {
00026 public:
00027   
00028   typedef StripClusterParameterEstimator::LocalValues    LocalValues;
00029   typedef StripClusterParameterEstimator::VLocalValues    VLocalValues;
00030   
00031   typedef SiStripRecHit2D::ClusterRef SiStripClusterRef;
00032   
00033   typedef edm::LazyGetter<SiStripCluster>::value_ref  SiStripRegionalClusterRef;
00034   
00035   typedef edmNew::DetSet<SiStripCluster> detset;
00036   typedef detset::const_iterator new_const_iterator;
00037   
00038   typedef std::vector<SiStripCluster>::const_iterator const_iterator;
00039   
00040   virtual ~TkStripMeasurementDet(){}
00041   
00042   TkStripMeasurementDet( const GeomDet* gdet, StMeasurementDetSet & dets);
00043 
00044 
00045   void setIndex(int i) { index_=i;}
00046   
00047   void update( const detset &detSet ) { 
00048     theDets().update(index(),detSet);
00049   }
00050   void update( std::vector<SiStripCluster>::const_iterator begin ,std::vector<SiStripCluster>::const_iterator end ) { 
00051     theDets().update(index(), begin, end);
00052   }
00053   
00054   bool isRegional() const { return theDets().isRegional();}
00055   
00056   void setEmpty(){ theDets().setEmpty(index()); }
00057   
00058   bool  isEmpty() const {return theDets().empty(index());}
00059   
00060   int index() const { return index_;}
00061 
00062   unsigned int rawId() const { return theDets().id(index()); }
00063   unsigned char subId() const { return theDets().subId(index());}
00064   
00065   
00066   const detset & theSet() const {return theDets().detSet(index());}
00067   const detset & detSet() const {return theDets().detSet(index());}
00068   detset & detSet() { return theDets().detSet(index());}
00069   unsigned int beginClusterI() const {return theDets().beginClusterI(index());}
00070   unsigned int endClusterI() const {return theDets().endClusterI(index());}
00071   
00072   int  size() const {return endClusterI() - beginClusterI() ; }
00073   
00074   
00076   bool isActive() const { return theDets().isActive(index()); }
00077   
00078   //TO BE IMPLEMENTED
00079   bool hasBadComponents( const TrajectoryStateOnSurface &tsos ) const {return false;}
00080   
00081   
00082   
00083   virtual RecHitContainer recHits( const TrajectoryStateOnSurface&) const;
00084   void simpleRecHits( const TrajectoryStateOnSurface& ts, std::vector<SiStripRecHit2D> &result) const ;
00085   
00086   virtual bool recHits( const TrajectoryStateOnSurface& stateOnThisDet, const MeasurementEstimator& est,
00087                         RecHitContainer & result, std::vector<float> & diffs) const;
00088   
00089   virtual bool measurements( const TrajectoryStateOnSurface& stateOnThisDet,
00090                              const MeasurementEstimator& est,
00091                              TempMeasurements & result) const;
00092   
00093   const StripGeomDetUnit& specificGeomDet() const {return static_cast<StripGeomDetUnit const &>(fastGeomDet());}
00094   
00095 
00096   template<class ClusterRefT>
00097   TransientTrackingRecHit::RecHitPointer
00098   buildRecHit( const ClusterRefT &cluster, const TrajectoryStateOnSurface& ltp) const {
00099     const GeomDetUnit& gdu( specificGeomDet());
00100     LocalValues lv = cpe()->localParameters( *cluster, gdu, ltp);
00101     return TSiStripRecHit2DLocalPos::build( lv.first, lv.second, &fastGeomDet(), cluster, cpe());
00102   }
00103   
00104   
00105   template<class ClusterRefT>
00106     void
00107     buildRecHits( const ClusterRefT& cluster, const TrajectoryStateOnSurface& ltp,  const RecHitContainer& _res) const {
00108     RecHitContainer res = _res;
00109     const GeomDetUnit& gdu( specificGeomDet());
00110     VLocalValues vlv = cpe()->localParametersV( *cluster, gdu, ltp);
00111     for(VLocalValues::const_iterator it=vlv.begin();it!=vlv.end();++it)
00112       res.push_back(TSiStripRecHit2DLocalPos::build( it->first, it->second, &fastGeomDet(), cluster, cpe()));
00113   }
00114   
00115 
00116   template<class ClusterRefT>
00117   bool filteredRecHits( const ClusterRefT& cluster, const TrajectoryStateOnSurface& ltp,  const MeasurementEstimator& est, 
00118                         RecHitContainer & result, std::vector<float> & diffs) const {
00119     if (isMasked(*cluster)) return true;
00120     const GeomDetUnit& gdu( specificGeomDet());
00121     if (!accept(cluster)) return true;
00122     VLocalValues const & vlv = cpe()->localParametersV( *cluster, gdu, ltp);
00123     bool isCompatible(false);
00124     for(auto vl : vlv) {
00125       auto && recHit  = TSiStripRecHit2DLocalPos::build( vl.first, vl.second, &fastGeomDet(), cluster, cpe()); 
00126       std::pair<bool,double> diffEst = est.estimate(ltp, *recHit);
00127       if ( diffEst.first ) {
00128         result.push_back(std::move(recHit));
00129         diffs.push_back(diffEst.second);
00130         isCompatible = true;
00131       }
00132     }
00133     return isCompatible;
00134   }
00135 
00136 
00137   
00140   void setActive(bool active) { theDets().setActive(index(),active);}
00143   void setActiveThisEvent(bool active) {  theDets().setActiveThisEvent(index(),active); }
00144   
00146   bool hasAllGoodChannels() const { return (!hasAny128StripBad()) && badStripBlocks().empty(); }
00147   
00149   void set128StripStatus(bool good, int idx=-1) {
00150     theDets().set128StripStatus(index(),good,idx);
00151   }
00152   
00153   typedef StMeasurementDetSet::BadStripCuts BadStripCuts;
00154   
00156   bool testStrips(float utraj, float uerr) const;
00157   
00158   typedef StMeasurementDetSet::BadStripBlock BadStripBlock;
00159   
00160   std::vector<BadStripBlock> & getBadStripBlocks() { return theDets().getBadStripBlocks(index()); }
00161   std::vector<BadStripBlock> const & badStripBlocks() const { return theDets().badStripBlocks(index()); }
00162 
00163   bool maskBad128StripBlocks() const { return theDets().maskBad128StripBlocks();}
00164   
00165 
00166   
00167 private:
00168   
00169   StMeasurementDetSet  & theDets() { return *theDets_;}
00170   StMeasurementDetSet  & theDets() const { return *theDets_;}
00171   
00172   StMeasurementDetSet * theDets_;
00173   int index_;
00174   
00175 
00176 
00177   edm::Handle<edmNew::DetSetVector<SiStripCluster> > const & handle() const { return theDets().handle();}
00178   edm::Handle<edm::LazyGetter<SiStripCluster> > const & regionalHandle() const { return theDets().regionalHandle();}
00179   
00180   const StripClusterParameterEstimator* cpe() const { return  theDets().stripCPE(); }
00181   
00182   
00183   const std::vector<bool> & skipClusters() const {  return  theDets().clusterToSkip();}
00184   
00185   // --- regional unpacking
00186   
00187   int totalStrips() const { return theDets().totalStrips(index()); }
00188   BadStripCuts const & badStripCuts() const { return theDets().badStripCuts(index());}
00189   
00190   bool hasAny128StripBad() const { return  theDets().hasAny128StripBad(index()); } 
00191   
00192   
00193   
00194   
00195   inline bool isMasked(const SiStripCluster &cluster) const {
00196     return theDets().isMasked(index(), cluster);
00197   }
00198   
00199 
00200   template<class ClusterRefT>
00201   void buildSimpleRecHit( const ClusterRefT& cluster,
00202                           const TrajectoryStateOnSurface& ltp,
00203                           std::vector<SiStripRecHit2D>& res) const {
00204     const GeomDetUnit& gdu( specificGeomDet());
00205     VLocalValues const & vlv = cpe()->localParametersV( *cluster, gdu, ltp);
00206     for(VLocalValues::const_iterator it=vlv.begin();it!=vlv.end();++it){
00207       res.push_back(SiStripRecHit2D( it->first, it->second, rawId(), cluster));
00208     }
00209   }
00210  
00211   
00212   
00213   
00214 public:
00215   inline bool accept(SiStripClusterRef const & r) const {
00216     if(skipClusters().empty()) return true;
00217     if (r.key()>=skipClusters().size()){
00218       edm::LogError("WrongStripMasking")<<r.key()<<" is larger than: "<<skipClusters().size()<<" no skipping done";
00219       return true;
00220     }
00221     return (not (skipClusters()[r.key()]));
00222   }
00223   inline bool accept(SiStripRegionalClusterRef const &r) const{
00224     if(skipClusters().empty()) return true;
00225     if (r.key()>=skipClusters().size()){
00226       LogDebug("TkStripMeasurementDet")<<r.key()<<" is larger than: "<<skipClusters().size()
00227                                        <<"\n This must be a new cluster, and therefore should not be skiped most likely.";
00228       return true;
00229     }
00230     return (not (skipClusters()[r.key()]));
00231   }
00232 
00233 };
00234 
00235 #endif