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
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, RecHitContainer res) const {
00108 const GeomDetUnit& gdu( specificGeomDet());
00109 VLocalValues vlv = cpe()->localParametersV( *cluster, gdu, ltp);
00110 for(VLocalValues::const_iterator it=vlv.begin();it!=vlv.end();++it)
00111 res.push_back(TSiStripRecHit2DLocalPos::build( it->first, it->second, &fastGeomDet(), cluster, cpe()));
00112 }
00113
00114
00115 template<class ClusterRefT>
00116 bool filteredRecHits( const ClusterRefT& cluster, const TrajectoryStateOnSurface& ltp, const MeasurementEstimator& est,
00117 RecHitContainer & result, std::vector<float> & diffs) const {
00118 if (isMasked(*cluster)) return true;
00119 const GeomDetUnit& gdu( specificGeomDet());
00120 if (!accept(cluster)) return true;
00121 VLocalValues const & vlv = cpe()->localParametersV( *cluster, gdu, ltp);
00122 bool isCompatible(false);
00123 for(auto vl : vlv) {
00124 auto && recHit = TSiStripRecHit2DLocalPos::build( vl.first, vl.second, &fastGeomDet(), cluster, cpe());
00125 std::pair<bool,double> diffEst = est.estimate(ltp, *recHit);
00126 if ( diffEst.first ) {
00127 result.push_back(std::move(recHit));
00128 diffs.push_back(diffEst.second);
00129 isCompatible = true;
00130 }
00131 }
00132 return isCompatible;
00133 }
00134
00135
00136
00139 void setActive(bool active) { theDets().setActive(index(),active);}
00142 void setActiveThisEvent(bool active) { theDets().setActiveThisEvent(index(),active); }
00143
00145 bool hasAllGoodChannels() const { return (!hasAny128StripBad()) && badStripBlocks().empty(); }
00146
00148 void set128StripStatus(bool good, int idx=-1) {
00149 theDets().set128StripStatus(index(),good,idx);
00150 }
00151
00152 typedef StMeasurementDetSet::BadStripCuts BadStripCuts;
00153
00155 bool testStrips(float utraj, float uerr) const;
00156
00157 typedef StMeasurementDetSet::BadStripBlock BadStripBlock;
00158
00159 std::vector<BadStripBlock> & getBadStripBlocks() { return theDets().getBadStripBlocks(index()); }
00160 std::vector<BadStripBlock> const & badStripBlocks() const { return theDets().badStripBlocks(index()); }
00161
00162 bool maskBad128StripBlocks() const { return theDets().maskBad128StripBlocks();}
00163
00164
00165
00166 private:
00167
00168 StMeasurementDetSet & theDets() { return *theDets_;}
00169 StMeasurementDetSet & theDets() const { return *theDets_;}
00170
00171 StMeasurementDetSet * theDets_;
00172 int index_;
00173
00174
00175
00176 edm::Handle<edmNew::DetSetVector<SiStripCluster> > const & handle() const { return theDets().handle();}
00177 edm::Handle<edm::LazyGetter<SiStripCluster> > const & regionalHandle() const { return theDets().regionalHandle();}
00178
00179 const StripClusterParameterEstimator* cpe() const { return theDets().stripCPE(); }
00180
00181
00182 const std::vector<bool> & skipClusters() const { return theDets().clusterToSkip();}
00183
00184
00185
00186 int totalStrips() const { return theDets().totalStrips(index()); }
00187 BadStripCuts const & badStripCuts() const { return theDets().badStripCuts(index());}
00188
00189 bool hasAny128StripBad() const { return theDets().hasAny128StripBad(index()); }
00190
00191
00192
00193
00194 inline bool isMasked(const SiStripCluster &cluster) const {
00195 return theDets().isMasked(index(), cluster);
00196 }
00197
00198
00199 template<class ClusterRefT>
00200 void buildSimpleRecHit( const ClusterRefT& cluster,
00201 const TrajectoryStateOnSurface& ltp,
00202 std::vector<SiStripRecHit2D>& res) const {
00203 const GeomDetUnit& gdu( specificGeomDet());
00204 VLocalValues const & vlv = cpe()->localParametersV( *cluster, gdu, ltp);
00205 for(VLocalValues::const_iterator it=vlv.begin();it!=vlv.end();++it){
00206 res.push_back(SiStripRecHit2D( it->first, it->second, rawId(), cluster));
00207 }
00208 }
00209
00210
00211
00212
00213 public:
00214 inline bool accept(SiStripClusterRef const & r) const {
00215 if(skipClusters().empty()) return true;
00216 if (r.key()>=skipClusters().size()){
00217 edm::LogError("WrongStripMasking")<<r.key()<<" is larger than: "<<skipClusters().size()<<" no skipping done";
00218 return true;
00219 }
00220 return (not (skipClusters()[r.key()]));
00221 }
00222 inline bool accept(SiStripRegionalClusterRef const &r) const{
00223 if(skipClusters().empty()) return true;
00224 if (r.key()>=skipClusters().size()){
00225 LogDebug("TkStripMeasurementDet")<<r.key()<<" is larger than: "<<skipClusters().size()
00226 <<"\n This must be a new cluster, and therefore should not be skiped most likely.";
00227 return true;
00228 }
00229 return (not (skipClusters()[r.key()]));
00230 }
00231
00232 };
00233
00234 #endif