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 
20 
23 
24 #include<tuple>
25 
26 class TrackingRecHit;
27 
28 
30 
34 
35 
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;
49  const TrajectoryStateOnSurface * tsos=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 
78  return buildHit();
79  }
80 
81 };
82 
83 
85 public:
86 
89 
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  if (!est.preFilter(ltp, ClusterFilterPayload(rawId(),&*cluster) )) return true; // avoids shadow; consistent with previous statement...
179  VLocalValues const & vlv = cpe()->localParametersV( *cluster, gdu, ltp);
180  bool isCompatible(false);
181  for(auto vl : vlv) {
182  SiStripRecHit2D recHit(vl.first, vl.second, fastGeomDet(), cluster); // FIXME add cluster count in OmniRef
183  std::pair<bool,double> diffEst = est.estimate(ltp, recHit);
184  LogDebug("TkStripMeasurementDet")<<" chi2=" << diffEst.second;
185  if ( diffEst.first ) {
186  result.push_back(std::move(std::make_shared<SiStripRecHit2D>(recHit)));
187  diffs.push_back(diffEst.second);
188  isCompatible = true;
189  }
190  }
191  return isCompatible;
192  }
193 
194 
195  template<class ClusterRefT>
196  bool filteredRecHits( const ClusterRefT& cluster, const TrajectoryStateOnSurface& ltp, const MeasurementEstimator& est, const std::vector<bool> & skipClusters,
197  std::vector<SiStripRecHit2D> & result) const {
198  if (isMasked(*cluster)) return true;
199  const GeomDetUnit& gdu( specificGeomDet());
200  if (!accept(cluster, skipClusters)) return true;
201  if (!est.preFilter(ltp, ClusterFilterPayload(rawId(),&*cluster) )) return true; // avoids shadow; consistent with previous statement...
202  VLocalValues const & vlv = cpe()->localParametersV( *cluster, gdu, ltp);
203  bool isCompatible(false);
204  for(auto vl : vlv) {
205  auto && recHit = SiStripRecHit2D( vl.first, vl.second, gdu, cluster); // FIXME add cluster count in OmniRef
206  std::pair<bool,double> diffEst = est.estimate(ltp, recHit);
207  LogDebug("TkStripMeasurementDet")<<" chi2=" << diffEst.second;
208  if ( diffEst.first ) {
209  result.push_back(std::move(recHit));
210  isCompatible = true;
211  }
212  }
213  return isCompatible;
214  }
215 
216 
217 
218 
220  void setActiveThisPeriod(StMeasurementDetSet & theDets, bool active) { conditionSet().setActive(index(),active);}
221 
224  void setActiveThisEvent(StMeasurementDetSet & theDets, bool active) const { theDets.setActiveThisEvent(index(),active); }
225 
227  bool hasAllGoodChannels() const { return (!hasAny128StripBad()) && badStripBlocks().empty(); }
228 
230  void set128StripStatus(bool good, int idx=-1) {
231  conditionSet().set128StripStatus(index(),good,idx);
232  }
233 
235 
237  bool testStrips(float utraj, float uerr) const;
238 
240 
241  std::vector<BadStripBlock> & getBadStripBlocks() { return conditionSet().getBadStripBlocks(index()); }
242  std::vector<BadStripBlock> const & badStripBlocks() const { return conditionSet().badStripBlocks(index()); }
243 
244  bool maskBad128StripBlocks() const { return conditionSet().maskBad128StripBlocks();}
245 
246 private:
247  int index_;
249  StMeasurementConditionSet & conditionSet() { return *theDetConditions; }
250  const StMeasurementConditionSet & conditionSet() const { return *theDetConditions; }
251 
252  const StripClusterParameterEstimator* cpe() const { return conditionSet().stripCPE(); }
253 
254  // --- regional unpacking
255  int totalStrips() const { return conditionSet().totalStrips(index()); }
256  BadStripCuts const & badStripCuts() const { return conditionSet().badStripCuts(index());}
257 
258  bool hasAny128StripBad() const { return conditionSet().hasAny128StripBad(index()); }
259 
260 
261  inline bool isMasked(const SiStripCluster &cluster) const {
262  return conditionSet().isMasked(index(), cluster);
263  }
264 
265 
266  template<class ClusterRefT>
267  void buildSimpleRecHit( const ClusterRefT& cluster,
268  const TrajectoryStateOnSurface& ltp,
269  std::vector<SiStripRecHit2D>& res) const {
270  const GeomDetUnit& gdu( specificGeomDet());
271  VLocalValues const & vlv = cpe()->localParametersV( *cluster, gdu, ltp);
272  for(VLocalValues::const_iterator it=vlv.begin();it!=vlv.end();++it){
273  res.push_back(SiStripRecHit2D( it->first, it->second, gdu, cluster));
274  }
275  }
276 
277 
278 
279 
280 
281 
282 
283 public:
284  inline bool accept(SiStripClusterRef const & r, const std::vector<bool> & skipClusters) const {
285  if(skipClusters.empty()) return true;
286  if (r.key()>=skipClusters.size()){
287  LogDebug("TkStripMeasurementDet")<<r.key()<<" is larger than: "<<skipClusters.size()
288  <<"\n This must be a new cluster, and therefore should not be skiped most likely.";
289  // edm::LogError("WrongStripMasking")<<r.key()<<" is larger than: "<<skipClusters.size()<<" no skipping done"; // protect for on demand???
290  return true;
291  }
292  return (not (skipClusters[r.key()]));
293  }
294 
295 };
296 
297 
298 inline
300  return mdet->hit(*this);
301 }
302 inline
304  mdet->advance(*this);
305 }
306 
307 
308 
309 #endif
#define LogDebug(id)
#define dso_hidden
int i
Definition: DBlmapReader.cc:9
StMeasurementConditionSet::BadStripCuts BadStripCuts
new_const_iterator clusterE
void buildSimpleRecHit(const ClusterRefT &cluster, const TrajectoryStateOnSurface &ltp, std::vector< SiStripRecHit2D > &res) const
const StripDetset & detSet(int i) const
virtual bool preFilter(const TrajectoryStateOnSurface &, OpaquePayload const &) const
const detset & theSet(const StMeasurementDetSet &theDets) const
edmNew::DetSet< SiStripCluster > detset
SiStripRecHit2D operator*() const
StripClusterParameterEstimator::VLocalValues VLocalValues
unsigned char subId() const
bool operator==(TkStripRecHitIter const &rh)
StripClusterParameterEstimator::LocalValues LocalValues
bool filteredRecHits(const ClusterRefT &cluster, const TrajectoryStateOnSurface &ltp, const MeasurementEstimator &est, const std::vector< bool > &skipClusters, std::vector< SiStripRecHit2D > &result) const
BadStripCuts const & badStripCuts() const
TkStripRecHitIter(const TkStripMeasurementDet &imdet, const TrajectoryStateOnSurface &itsos, const MeasurementTrackerEvent &idata)
data_type const * const_iterator
Definition: DetSetNew.h:30
key_type key() const
Accessor for product key.
Definition: Ref.h:264
bool accept(SiStripClusterRef const &r, const std::vector< bool > &skipClusters) const
const StMeasurementDetSet & stripData() const
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:30
bool isMasked(const SiStripCluster &cluster) const
SiStripRecHit2D hit(TkStripRecHitIter const &hi) const
tuple result
Definition: mps_fire.py:95
const GeomDet & fastGeomDet() const
StMeasurementConditionSet & conditionSet()
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 ...
bool filteredRecHits(const ClusterRefT &cluster, const TrajectoryStateOnSurface &ltp, const MeasurementEstimator &est, const std::vector< bool > &skipClusters, RecHitContainer &result, std::vector< float > &diffs) const
std::vector< BadStripBlock > const & badStripBlocks() const
bool hasBadComponents(const TrajectoryStateOnSurface &tsos, const MeasurementTrackerEvent &data) const
def move
Definition: eostools.py:510
void buildRecHits(const ClusterRefT &cluster, const TrajectoryStateOnSurface &ltp, const RecHitContainer &_res) const
virtual HitReturnType estimate(const TrajectoryStateOnSurface &ts, const TrackingRecHit &hit) const =0
bool hasAllGoodChannels() const
does this module have at least one bad strip, APV or channel?
void advance(TkStripRecHitIter &hi) const
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 ...
TkStripRecHitIter(new_const_iterator ci, new_const_iterator ce, const TkStripMeasurementDet &imdet, const TrajectoryStateOnSurface &itsos, const MeasurementTrackerEvent &idata)
StMeasurementConditionSet::BadStripBlock BadStripBlock
std::vector< SiStripCluster >::const_iterator const_iterator
std::shared_ptr< TrackingRecHit const > RecHitPointer
const TkStripMeasurementDet * mdet
virtual RecHitContainer recHits(const TrajectoryStateOnSurface &, const MeasurementTrackerEvent &) const =0
std::vector< BadStripBlock > & getBadStripBlocks()
bool operator<(TkStripRecHitIter const &rh)
TrackingRecHit::RecHitPointer buildRecHit(const ClusterRefT &cluster, const TrajectoryStateOnSurface &ltp) const
void set128StripStatus(bool good, int idx=-1)
Sets the status of a block of 128 strips (or all blocks if idx=-1)
TkStripRecHitIter & operator++()
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
bool isActive(const MeasurementTrackerEvent &data) const
Is this module active in reconstruction? It must be both &#39;setActiveThisEvent&#39; and &#39;setActive&#39;...
const StripGeomDetUnit & specificGeomDet() const
void setActiveThisPeriod(StMeasurementDetSet &theDets, bool active)
Turn on/off the module for reconstruction, for the full run or lumi (using info from DB...
bool isActive(int i) const
bool isEmpty(const StMeasurementDetSet &theDets) const
std::pair< LocalPoint, LocalError > LocalValues
new_const_iterator clusterI
tuple skipClusters
const StripClusterParameterEstimator * cpe() const
bool empty(int i) const
TrackingRecHit::ConstRecHitContainer RecHitContainer
SiStripRecHit2D::ClusterRef SiStripClusterRef
const detset & detSet(const StMeasurementDetSet &theDets) const
detset::const_iterator new_const_iterator
unsigned int rawId() const
detset::const_iterator new_const_iterator
StMeasurementConditionSet * theDetConditions
void setEmpty(StMeasurementDetSet &theDets) const
bool operator!=(TkStripRecHitIter const &rh)
SiStripRecHit2D buildHit() const
const StMeasurementConditionSet & conditionSet() const
virtual bool measurements(const TrajectoryStateOnSurface &stateOnThisDet, const MeasurementEstimator &est, const MeasurementTrackerEvent &data, TempMeasurements &result) const =0