CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TkStripMeasurementDet.h
Go to the documentation of this file.
1 #ifndef TkStripMeasurementDet_H
2 #define TkStripMeasurementDet_H
3 
7 
10 
22 
25 
26 #include <tuple>
27 
28 class TrackingRecHit;
29 
31 
35 
38  const TrajectoryStateOnSurface& itsos,
39  const MeasurementTrackerEvent& idata)
40  : mdet(&imdet), tsos(&itsos), data(&idata) {}
41 
44  const TkStripMeasurementDet& imdet,
45  const TrajectoryStateOnSurface& itsos,
46  const MeasurementTrackerEvent& idata)
47  : mdet(&imdet), tsos(&itsos), data(&idata), clusterI(ci), clusterE(ce) {}
48 
49  const TkStripMeasurementDet* mdet = nullptr;
50  const TrajectoryStateOnSurface* tsos = nullptr;
51  const MeasurementTrackerEvent* data = nullptr;
52 
55 
56  inline SiStripRecHit2D buildHit() const;
57  inline void advance();
58 
59 public:
60  bool empty() const { return clusterI == clusterE; }
61 
62  bool operator==(TkStripRecHitIter const& rh) { return clusterI == rh.clusterI; }
63  bool operator!=(TkStripRecHitIter const& rh) { return clusterI != rh.clusterI; }
64  bool operator<(TkStripRecHitIter const& rh) { return clusterI < rh.clusterI; }
65 
67  advance();
68  return *this;
69  }
70 
71  SiStripRecHit2D operator*() const { return buildHit(); }
72 };
73 
75 public:
78 
80 
83 
84  typedef std::vector<SiStripCluster>::const_iterator const_iterator;
85 
86  ~TkStripMeasurementDet() override {}
87 
88  TkStripMeasurementDet(const GeomDet* gdet, StMeasurementConditionSet& conditionSet);
89 
90  void setIndex(int i) { index_ = i; }
91 
92  void setEmpty(StMeasurementDetSet& theDets) const { theDets.setEmpty(index()); }
93 
94  bool isEmpty(const StMeasurementDetSet& theDets) const { return theDets.empty(index()); }
95 
96  int index() const { return index_; }
97 
98  unsigned int rawId() const { return conditionSet().id(index()); }
99  unsigned char subId() const { return conditionSet().subId(index()); }
100 
101  const detset& theSet(const StMeasurementDetSet& theDets) const { return theDets.detSet(index()); }
102  const detset& detSet(const StMeasurementDetSet& theDets) const { return theDets.detSet(index()); }
103 
105  bool isActive(const MeasurementTrackerEvent& data) const override { return data.stripData().isActive(index()); }
106 
107  //TO BE IMPLEMENTED
108  bool hasBadComponents(const TrajectoryStateOnSurface& tsos, const MeasurementTrackerEvent& data) const override {
109  return false;
110  }
111 
112  std::tuple<TkStripRecHitIter, TkStripRecHitIter> hitRange(const TrajectoryStateOnSurface&,
113  const MeasurementTrackerEvent& data) const;
114  void advance(TkStripRecHitIter& hi) const;
115  SiStripRecHit2D hit(TkStripRecHitIter const& hi) const;
116 
117  RecHitContainer recHits(const TrajectoryStateOnSurface&, const MeasurementTrackerEvent& data) const override;
118 
119  bool empty(const MeasurementTrackerEvent& data) const;
120 
121  void simpleRecHits(const TrajectoryStateOnSurface& ts,
123  std::vector<SiStripRecHit2D>& result) const;
124  bool simpleRecHits(const TrajectoryStateOnSurface& ts,
125  const MeasurementEstimator& est,
127  std::vector<SiStripRecHit2D>& result) const;
128 
129  // simple hits
130  bool recHits(SimpleHitContainer& result,
131  const TrajectoryStateOnSurface& stateOnThisDet,
132  const MeasurementEstimator&,
133  const MeasurementTrackerEvent& data) const override;
134 
135  // TTRH
136  bool recHits(const TrajectoryStateOnSurface& stateOnThisDet,
137  const MeasurementEstimator& est,
139  RecHitContainer& result,
140  std::vector<float>& diffs) const override;
141 
142  bool measurements(const TrajectoryStateOnSurface& stateOnThisDet,
143  const MeasurementEstimator& est,
145  TempMeasurements& result) const override;
146 
147  const StripGeomDetUnit& specificGeomDet() const { return static_cast<StripGeomDetUnit const&>(fastGeomDet()); }
148 
149  template <class ClusterRefT>
150  TrackingRecHit::RecHitPointer buildRecHit(const ClusterRefT& cluster, const TrajectoryStateOnSurface& ltp) const {
151  const GeomDetUnit& gdu(specificGeomDet());
152  LocalValues lv = cpe()->localParameters(*cluster, gdu, ltp);
153  return std::make_shared<SiStripRecHit2D>(lv.first, lv.second, fastGeomDet(), cluster);
154  }
155 
156  template <class ClusterRefT>
157  void buildRecHits(const ClusterRefT& cluster,
158  const TrajectoryStateOnSurface& ltp,
159  const RecHitContainer& _res) const {
160  RecHitContainer res = _res;
161  const GeomDetUnit& gdu(specificGeomDet());
162  VLocalValues vlv = cpe()->localParametersV(*cluster, gdu, ltp);
163  for (VLocalValues::const_iterator it = vlv.begin(); it != vlv.end(); ++it)
164  res.push_back(std::make_shared<SiStripRecHit2D>(it->first, it->second, fastGeomDet(), cluster));
165  }
166 
167  template <class ClusterRefT>
168  bool filteredRecHits(const ClusterRefT& cluster,
169  StripCPE::AlgoParam const& cpepar,
170  const TrajectoryStateOnSurface& ltp,
171  const MeasurementEstimator& est,
172  const std::vector<bool>& skipClusters,
174  std::vector<float>& diffs) const {
175  if (isMasked(*cluster))
176  return true;
177  if (!accept(cluster, skipClusters))
178  return true;
179  if (!est.preFilter(ltp, ClusterFilterPayload(rawId(), &*cluster)))
180  return true; // avoids shadow; consistent with previous statement...
181  auto const& vl = cpe()->localParameters(*cluster, cpepar);
182  SiStripRecHit2D recHit(vl.first,
183  vl.second,
184  fastGeomDet(),
185  cluster); // FIXME add cluster count in OmniRef (and move again to multiple sub-clusters..)
186  std::pair<bool, double> diffEst = est.estimate(ltp, recHit);
187  LogDebug("TkStripMeasurementDet") << " chi2=" << diffEst.second;
188  if (diffEst.first) {
189  result.push_back(std::make_shared<SiStripRecHit2D>(recHit));
190  diffs.push_back(diffEst.second);
191  }
192  return diffEst.first;
193  }
194 
195  template <class ClusterRefT>
196  bool filteredRecHits(const ClusterRefT& cluster,
197  StripCPE::AlgoParam const& cpepar,
198  const TrajectoryStateOnSurface& ltp,
199  const MeasurementEstimator& est,
200  const std::vector<bool>& skipClusters,
201  std::vector<SiStripRecHit2D>& result) const {
202  if (isMasked(*cluster))
203  return true;
204  if (!accept(cluster, skipClusters))
205  return true;
206  if (!est.preFilter(ltp, ClusterFilterPayload(rawId(), &*cluster)))
207  return true; // avoids shadow; consistent with previous statement...
208  auto const& vl = cpe()->localParameters(*cluster, cpepar);
209  result.emplace_back(vl.first, vl.second, fastGeomDet(), cluster); // FIXME add cluster count in OmniRef
210  std::pair<bool, double> diffEst = est.estimate(ltp, result.back());
211  LogDebug("TkStripMeasurementDet") << " chi2=" << diffEst.second;
212  if (!diffEst.first)
213  result.pop_back();
214  return diffEst.first;
215  }
216 
218  void setActiveThisPeriod(StMeasurementDetSet& theDets, bool active) { conditionSet().setActive(index(), active); }
219 
222  void setActiveThisEvent(StMeasurementDetSet& theDets, bool active) const {
223  theDets.setActiveThisEvent(index(), active);
224  }
225 
227  bool hasAllGoodChannels() const { return (!hasAny128StripBad()) && badStripBlocks().empty(); }
228 
230  void set128StripStatus(bool good, int idx = -1) { conditionSet().set128StripStatus(index(), good, idx); }
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:
247 
248  int index_;
250  StMeasurementConditionSet& conditionSet() { return *theDetConditions; }
251  const StMeasurementConditionSet& conditionSet() const { return *theDetConditions; }
252 
253  const StripCPE* cpe() const { return static_cast<const StripCPE*>(conditionSet().stripCPE()); }
254 
255  // --- regional unpacking
256  int totalStrips() const { return conditionSet().totalStrips(index()); }
257  BadStripCuts const& badStripCuts() const { return conditionSet().badStripCuts(index()); }
258 
259  bool hasAny128StripBad() const { return conditionSet().hasAny128StripBad(index()); }
260 
261  inline bool isMasked(const SiStripCluster& cluster) const { return conditionSet().isMasked(index(), cluster); }
262 
265  const detset& detSet,
266  const TrajectoryStateOnSurface& ltp,
267  std::vector<SiStripRecHit2D>& res) const {
268  const GeomDetUnit& gdu(specificGeomDet());
269  declareDynArray(LocalValues, clusters.size(), alv);
270  cpe()->localParameters(clusters, alv, gdu, ltp.localParameters());
271  res.reserve(alv.size());
272  for (unsigned int i = 0; i < clusters.size(); ++i)
273  res.emplace_back(alv[i].first, alv[i].second, gdu, detSet.makeRefTo(data.stripData().handle(), clusters[i]));
274  }
275 
276 public:
277  inline bool accept(SiStripClusterRef const& r, const std::vector<bool>& skipClusters) const {
278  return accept(r.key(), skipClusters);
279  }
280 
281  inline bool accept(unsigned int key, const std::vector<bool>& skipClusters) const {
282  if (skipClusters.empty())
283  return true;
284  if (key >= skipClusters.size()) {
285  LogDebug("TkStripMeasurementDet")
286  << key << " is larger than: " << skipClusters.size()
287  << "\n This must be a new cluster, and therefore should not be skiped most likely.";
288  return true;
289  }
290  return (not(skipClusters[key]));
291  }
292 };
293 
294 inline SiStripRecHit2D TkStripRecHitIter::buildHit() const { return mdet->hit(*this); }
295 inline void TkStripRecHitIter::advance() { mdet->advance(*this); }
296 
297 #endif
std::pair< LocalPoint, LocalError > LocalValues
StMeasurementConditionSet::BadStripCuts BadStripCuts
bool filteredRecHits(const ClusterRefT &cluster, StripCPE::AlgoParam const &cpepar, const TrajectoryStateOnSurface &ltp, const MeasurementEstimator &est, const std::vector< bool > &skipClusters, RecHitContainer &result, std::vector< float > &diffs) const
new_const_iterator clusterE
bool isActive(const MeasurementTrackerEvent &data) const override
Is this module active in reconstruction? It must be both &#39;setActiveThisEvent&#39; and &#39;setActive&#39;...
const StripDetset & detSet(int i) const
virtual bool preFilter(const TrajectoryStateOnSurface &, OpaquePayload const &) const
const detset & theSet(const StMeasurementDetSet &theDets) const
const LocalTrajectoryParameters & localParameters() const
edmNew::DetSet< SiStripCluster > detset
SiStripRecHit2D operator*() const
StripClusterParameterEstimator::VLocalValues VLocalValues
unsigned char subId() const
bool operator==(TkStripRecHitIter const &rh)
StripClusterParameterEstimator::LocalValues LocalValues
BadStripCuts const & badStripCuts() const
TkStripRecHitIter(const TkStripMeasurementDet &imdet, const TrajectoryStateOnSurface &itsos, const MeasurementTrackerEvent &idata)
data_type const * const_iterator
Definition: DetSetNew.h:31
key_type key() const
Accessor for product key.
Definition: Ref.h:250
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:31
bool filteredRecHits(const ClusterRefT &cluster, StripCPE::AlgoParam const &cpepar, const TrajectoryStateOnSurface &ltp, const MeasurementEstimator &est, const std::vector< bool > &skipClusters, std::vector< SiStripRecHit2D > &result) const
bool isMasked(const SiStripCluster &cluster) const
bool accept(unsigned int key, const std::vector< bool > &skipClusters) const
SiStripRecHit2D hit(TkStripRecHitIter const &hi) const
tuple result
Definition: mps_fire.py:311
const GeomDet & fastGeomDet() const
const StripCPE * cpe() 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 ...
std::vector< BadStripBlock > const & badStripBlocks() const
tuple key
prepare the HTCondor submission files and eventually submit them
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
bool hasBadComponents(const TrajectoryStateOnSurface &tsos, const MeasurementTrackerEvent &data) const override
std::shared_ptr< TrackingRecHit const > RecHitPointer
const TkStripMeasurementDet * mdet
virtual RecHitContainer recHits(const TrajectoryStateOnSurface &, const MeasurementTrackerEvent &) const =0
std::vector< BadStripBlock > & getBadStripBlocks()
#define dso_hidden
Definition: Visibility.h:12
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)
auto const good
min quality of good
TkStripRecHitIter & operator++()
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
new_const_iterator clusterI
tuple skipClusters
bool empty(int i) const
DynArray< SiStripCluster const * > AClusters
TrackingRecHit::ConstRecHitContainer RecHitContainer
SiStripRecHit2D::ClusterRef SiStripClusterRef
const detset & detSet(const StMeasurementDetSet &theDets) const
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
detset::const_iterator new_const_iterator
unsigned int rawId() const
void buildSimpleRecHits(AClusters const &clusters, const MeasurementTrackerEvent &data, const detset &detSet, const TrajectoryStateOnSurface &ltp, std::vector< SiStripRecHit2D > &res) const
#define declareDynArray(T, n, x)
Definition: DynArray.h:91
edm::Handle< edmNew::DetSetVector< SiStripCluster > > & handle()
edm::Ref< typename HandleT::element_type, typename HandleT::element_type::value_type::value_type > makeRefTo(HandleT const &handle, const_iterator ci) const
Definition: DetSetNew.h:73
unsigned int size() const
Definition: DynArray.h:60
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
#define LogDebug(id)
virtual bool measurements(const TrajectoryStateOnSurface &stateOnThisDet, const MeasurementEstimator &est, const MeasurementTrackerEvent &data, TempMeasurements &result) const =0