CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TkStripMeasurementDet.h
Go to the documentation of this file.
1 #ifndef TkStripMeasurementDet_H
2 #define TkStripMeasurementDet_H
3 
7 
21 
23 
24 #include<tuple>
25 
26 class TrackingRecHit;
27 
28 
29 class TkStripMeasurementDet;
30 
34 
35 
37  TkStripRecHitIter(const TkStripMeasurementDet & imdet,
38  const TrajectoryStateOnSurface & itsos,
39  const MeasurementTrackerEvent & idata) : mdet(&imdet),tsos(&itsos),data(&idata){}
40 
42  const TkStripMeasurementDet & imdet,
43  const TrajectoryStateOnSurface & itsos,
44  const MeasurementTrackerEvent & idata)
45  : mdet(&imdet),tsos(&itsos),data(&idata), clusterI(ci), clusterE(ce) {}
46 
47 
48  const TkStripMeasurementDet * mdet = 0;
51 
54 
55  inline SiStripRecHit2D buildHit() const;
56  inline void advance();
57 
58 public:
59 
60  bool empty() const { return clusterI==clusterE; }
61 
62  bool operator==(TkStripRecHitIter const & rh) {
63  return clusterI==rh.clusterI;
64  }
65  bool operator!=(TkStripRecHitIter const & rh) {
66  return clusterI!=rh.clusterI;
67  }
68  bool operator<(TkStripRecHitIter const & rh) {
69  return clusterI<rh.clusterI;
70  }
71 
73  advance();
74  return *this;
75  }
76 
77  SiStripRecHit2D operator*() const {
78  return buildHit();
79  }
80 
81 };
82 
83 
84 class TkStripMeasurementDet GCC11_FINAL : public MeasurementDet {
85 public:
86 
89 
90  typedef SiStripRecHit2D::ClusterRef SiStripClusterRef;
91 
94 
95  typedef std::vector<SiStripCluster>::const_iterator const_iterator;
96 
98 
99  TkStripMeasurementDet( const GeomDet* gdet, StMeasurementConditionSet & conditionSet );
100 
101  void setIndex(int i) { index_=i;}
102 
103  void setEmpty(StMeasurementDetSet & theDets) const { theDets.setEmpty(index()); }
104 
105  bool isEmpty(const StMeasurementDetSet & theDets) const {return theDets.empty(index());}
106 
107  int index() const { return index_;}
108 
109  unsigned int rawId() const { return conditionSet().id(index()); }
110  unsigned char subId() const { return conditionSet().subId(index());}
111 
112 
113  const detset & theSet(const StMeasurementDetSet & theDets) const {return theDets.detSet(index());}
114  const detset & detSet(const StMeasurementDetSet & theDets) const {return theDets.detSet(index());}
115 
116 
118  bool isActive(const MeasurementTrackerEvent & data) const { return data.stripData().isActive(index()); }
119 
120  //TO BE IMPLEMENTED
121  bool hasBadComponents( const TrajectoryStateOnSurface &tsos, const MeasurementTrackerEvent & data ) const {return false;}
122 
123 
124  std::tuple<TkStripRecHitIter,TkStripRecHitIter> hitRange(const TrajectoryStateOnSurface&, const MeasurementTrackerEvent & data) const;
125  void advance(TkStripRecHitIter & hi ) const;
126  SiStripRecHit2D hit(TkStripRecHitIter const & hi ) const;
127 
128  virtual RecHitContainer recHits( const TrajectoryStateOnSurface&, const MeasurementTrackerEvent & data) const;
129 
130 
131  bool empty(const MeasurementTrackerEvent & data) const;
132 
133  void simpleRecHits( const TrajectoryStateOnSurface& ts, const MeasurementTrackerEvent & data, std::vector<SiStripRecHit2D> &result) const ;
134  bool simpleRecHits( const TrajectoryStateOnSurface& ts, const MeasurementEstimator& est, const MeasurementTrackerEvent & data, std::vector<SiStripRecHit2D> &result) const ;
135 
136  // simple hits
137  virtual bool recHits(SimpleHitContainer & result,
138  const TrajectoryStateOnSurface& stateOnThisDet, const MeasurementEstimator&, const MeasurementTrackerEvent & data) const;
139 
140  // TTRH
141  virtual bool recHits( const TrajectoryStateOnSurface& stateOnThisDet, const MeasurementEstimator& est, const MeasurementTrackerEvent & data,
142  RecHitContainer & result, std::vector<float> & diffs) const;
143 
144 
145  virtual bool measurements( const TrajectoryStateOnSurface& stateOnThisDet,
147  TempMeasurements & result) const;
148 
149  const StripGeomDetUnit& specificGeomDet() const {return static_cast<StripGeomDetUnit const &>(fastGeomDet());}
150 
151 
152  template<class ClusterRefT>
154  buildRecHit( const ClusterRefT &cluster, const TrajectoryStateOnSurface& ltp) const {
155  const GeomDetUnit& gdu( specificGeomDet());
156  LocalValues lv = cpe()->localParameters( *cluster, gdu, ltp);
157  return std::make_shared<SiStripRecHit2D>( lv.first, lv.second, fastGeomDet(), cluster);
158  }
159 
160 
161  template<class ClusterRefT>
162  void
163  buildRecHits( const ClusterRefT& cluster, const TrajectoryStateOnSurface& ltp, const RecHitContainer& _res) const {
164  RecHitContainer res = _res;
165  const GeomDetUnit& gdu( specificGeomDet());
166  VLocalValues vlv = cpe()->localParametersV( *cluster, gdu, ltp);
167  for(VLocalValues::const_iterator it=vlv.begin();it!=vlv.end();++it)
168  res.push_back(std::make_shared<SiStripRecHit2D>( it->first, it->second, fastGeomDet(), cluster));
169  }
170 
171 
172  template<class ClusterRefT>
173  bool filteredRecHits( const ClusterRefT& cluster, const TrajectoryStateOnSurface& ltp, const MeasurementEstimator& est, const std::vector<bool> & skipClusters,
174  RecHitContainer & result, std::vector<float> & diffs) const {
175  if (isMasked(*cluster)) return true;
176  const GeomDetUnit& gdu( specificGeomDet());
177  if (!accept(cluster, skipClusters)) return true;
178  VLocalValues const & vlv = cpe()->localParametersV( *cluster, gdu, ltp);
179  bool isCompatible(false);
180  for(auto vl : vlv) {
181  SiStripRecHit2D recHit(vl.first, vl.second, fastGeomDet(), cluster);
182  std::pair<bool,double> diffEst = est.estimate(ltp, recHit);
183  LogDebug("TkStripMeasurementDet")<<" chi2=" << diffEst.second;
184  if ( diffEst.first ) {
185  result.push_back(std::move(std::make_shared<SiStripRecHit2D>(recHit)));
186  diffs.push_back(diffEst.second);
187  isCompatible = true;
188  }
189  }
190  return isCompatible;
191  }
192 
193 
194  template<class ClusterRefT>
195  bool filteredRecHits( const ClusterRefT& cluster, const TrajectoryStateOnSurface& ltp, const MeasurementEstimator& est, const std::vector<bool> & skipClusters,
196  std::vector<SiStripRecHit2D> & result) const {
197  if (isMasked(*cluster)) return true;
198  const GeomDetUnit& gdu( specificGeomDet());
199  if (!accept(cluster, skipClusters)) return true;
200  VLocalValues const & vlv = cpe()->localParametersV( *cluster, gdu, ltp);
201  bool isCompatible(false);
202  for(auto vl : vlv) {
203  auto && recHit = SiStripRecHit2D( vl.first, vl.second, gdu, cluster);
204  std::pair<bool,double> diffEst = est.estimate(ltp, recHit);
205  LogDebug("TkStripMeasurementDet")<<" chi2=" << diffEst.second;
206  if ( diffEst.first ) {
207  result.push_back(std::move(recHit));
208  isCompatible = true;
209  }
210  }
211  return isCompatible;
212  }
213 
214 
215 
216 
218  void setActiveThisPeriod(StMeasurementDetSet & theDets, bool active) { conditionSet().setActive(index(),active);}
219 
222  void setActiveThisEvent(StMeasurementDetSet & theDets, bool active) const { theDets.setActiveThisEvent(index(),active); }
223 
225  bool hasAllGoodChannels() const { return (!hasAny128StripBad()) && badStripBlocks().empty(); }
226 
228  void set128StripStatus(bool good, int idx=-1) {
229  conditionSet().set128StripStatus(index(),good,idx);
230  }
231 
233 
235  bool testStrips(float utraj, float uerr) const;
236 
238 
239  std::vector<BadStripBlock> & getBadStripBlocks() { return conditionSet().getBadStripBlocks(index()); }
240  std::vector<BadStripBlock> const & badStripBlocks() const { return conditionSet().badStripBlocks(index()); }
241 
242  bool maskBad128StripBlocks() const { return conditionSet().maskBad128StripBlocks();}
243 
244 private:
245  int index_;
247  StMeasurementConditionSet & conditionSet() { return *theDetConditions; }
248  const StMeasurementConditionSet & conditionSet() const { return *theDetConditions; }
249 
250  const StripClusterParameterEstimator* cpe() const { return conditionSet().stripCPE(); }
251 
252  // --- regional unpacking
253  int totalStrips() const { return conditionSet().totalStrips(index()); }
254  BadStripCuts const & badStripCuts() const { return conditionSet().badStripCuts(index());}
255 
256  bool hasAny128StripBad() const { return conditionSet().hasAny128StripBad(index()); }
257 
258 
259  inline bool isMasked(const SiStripCluster &cluster) const {
260  return conditionSet().isMasked(index(), cluster);
261  }
262 
263 
264  template<class ClusterRefT>
265  void buildSimpleRecHit( const ClusterRefT& cluster,
266  const TrajectoryStateOnSurface& ltp,
267  std::vector<SiStripRecHit2D>& res) const {
268  const GeomDetUnit& gdu( specificGeomDet());
269  VLocalValues const & vlv = cpe()->localParametersV( *cluster, gdu, ltp);
270  for(VLocalValues::const_iterator it=vlv.begin();it!=vlv.end();++it){
271  res.push_back(SiStripRecHit2D( it->first, it->second, gdu, cluster));
272  }
273  }
274 
275 
276 
277 
278 
279 
280 
281 public:
282  inline bool accept(SiStripClusterRef const & r, const std::vector<bool> & skipClusters) const {
283  if(skipClusters.empty()) return true;
284  if (r.key()>=skipClusters.size()){
285  LogDebug("TkStripMeasurementDet")<<r.key()<<" is larger than: "<<skipClusters.size()
286  <<"\n This must be a new cluster, and therefore should not be skiped most likely.";
287  // edm::LogError("WrongStripMasking")<<r.key()<<" is larger than: "<<skipClusters.size()<<" no skipping done"; // protect for on demand???
288  return true;
289  }
290  return (not (skipClusters[r.key()]));
291  }
292 
293 };
294 
295 
296 inline
297 SiStripRecHit2D TkStripRecHitIter::buildHit() const {
298  return mdet->hit(*this);
299 }
300 inline
302  mdet->advance(*this);
303 }
304 
305 
306 
307 #endif
#define LogDebug(id)
const StMeasurementConditionSet & conditionSet() const
virtual ~TkStripMeasurementDet()
int i
Definition: DBlmapReader.cc:9
bool hasBadComponents(const TrajectoryStateOnSurface &tsos, const MeasurementTrackerEvent &data) const
new_const_iterator clusterE
const StripDetset & detSet(int i) const
const TrajectoryStateOnSurface * tsos
StMeasurementConditionSet::BadStripBlock BadStripBlock
SiStripRecHit2D operator*() const
bool operator==(TkStripRecHitIter const &rh)
bool hasAny128StripBad() const
TrackingRecHit::RecHitPointer buildRecHit(const ClusterRefT &cluster, const TrajectoryStateOnSurface &ltp) const
std::vector< ConstRecHitPointer > RecHitContainer
TkStripRecHitIter(const TkStripMeasurementDet &imdet, const TrajectoryStateOnSurface &itsos, const MeasurementTrackerEvent &idata)
data_type const * const_iterator
Definition: DetSetNew.h:30
void set128StripStatus(bool good, int idx=-1)
Sets the status of a block of 128 strips (or all blocks if idx=-1)
bool hasAllGoodChannels() const
does this module have at least one bad strip, APV or channel?
const StMeasurementDetSet & stripData() const
StMeasurementConditionSet & conditionSet()
int totalStrips() const
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:26
const StripGeomDetUnit & specificGeomDet() const
const StripClusterParameterEstimator * cpe() const
bool isActive(const MeasurementTrackerEvent &data) const
Is this module active in reconstruction? It must be both &#39;setActiveThisEvent&#39; and &#39;setActive&#39;...
int index() const
const MeasurementTrackerEvent * data
const GeomDet & fastGeomDet() const
const detset & theSet(const StMeasurementDetSet &theDets) const
edmNew::DetSet< SiStripCluster > detset
void setActiveThisEvent(int i, bool active)
Turn on/off the module for reconstruction for one events. This per-event flag is cleared by any call ...
void setActiveThisPeriod(StMeasurementDetSet &theDets, bool active)
Turn on/off the module for reconstruction, for the full run or lumi (using info from DB...
void setActiveThisEvent(StMeasurementDetSet &theDets, bool active) const
Turn on/off the module for reconstruction for one events. This per-event flag is cleared by any call ...
tuple result
Definition: query.py:137
void buildSimpleRecHit(const ClusterRefT &cluster, const TrajectoryStateOnSurface &ltp, std::vector< SiStripRecHit2D > &res) const
SiStripRecHit2D::ClusterRef SiStripClusterRef
bool filteredRecHits(const ClusterRefT &cluster, const TrajectoryStateOnSurface &ltp, const MeasurementEstimator &est, const std::vector< bool > &skipClusters, std::vector< SiStripRecHit2D > &result) const
const detset & detSet(const StMeasurementDetSet &theDets) const
virtual HitReturnType estimate(const TrajectoryStateOnSurface &ts, const TrackingRecHit &hit) const =0
TkStripRecHitIter(new_const_iterator ci, new_const_iterator ce, const TkStripMeasurementDet &imdet, const TrajectoryStateOnSurface &itsos, const MeasurementTrackerEvent &idata)
unsigned char subId() const
std::shared_ptr< TrackingRecHit const > RecHitPointer
const TkStripMeasurementDet * mdet
virtual RecHitContainer recHits(const TrajectoryStateOnSurface &, const MeasurementTrackerEvent &) const =0
std::vector< BadStripBlock > const & badStripBlocks() const
bool operator<(TkStripRecHitIter const &rh)
void setIndex(int i)
std::vector< BadStripBlock > & getBadStripBlocks()
TkStripRecHitIter & operator++()
void buildRecHits(const ClusterRefT &cluster, const TrajectoryStateOnSurface &ltp, const RecHitContainer &_res) const
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
StMeasurementConditionSet::BadStripCuts BadStripCuts
bool isActive(int i) const
bool maskBad128StripBlocks() const
std::pair< LocalPoint, LocalError > LocalValues
new_const_iterator clusterI
void setEmpty(StMeasurementDetSet &theDets) const
bool empty(int i) const
unsigned int rawId() const
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
bool filteredRecHits(const ClusterRefT &cluster, const TrajectoryStateOnSurface &ltp, const MeasurementEstimator &est, const std::vector< bool > &skipClusters, RecHitContainer &result, std::vector< float > &diffs) const
StripClusterParameterEstimator::VLocalValues VLocalValues
bool isEmpty(const StMeasurementDetSet &theDets) const
bool accept(SiStripClusterRef const &r, const std::vector< bool > &skipClusters) const
BadStripCuts const & badStripCuts() const
std::vector< SiStripCluster >::const_iterator const_iterator
detset::const_iterator new_const_iterator
bool operator!=(TkStripRecHitIter const &rh)
bool isMasked(const SiStripCluster &cluster) const
SiStripRecHit2D buildHit() const
detset::const_iterator new_const_iterator
StripClusterParameterEstimator::LocalValues LocalValues
StMeasurementConditionSet * theDetConditions
virtual bool measurements(const TrajectoryStateOnSurface &stateOnThisDet, const MeasurementEstimator &est, const MeasurementTrackerEvent &data, TempMeasurements &result) const =0
Unlimited (trivial) bounds.