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 
10 
22 
25 
26 #include<tuple>
27 
28 class TrackingRecHit;
29 
30 
32 
36 
37 
40  const TrajectoryStateOnSurface & itsos,
41  const MeasurementTrackerEvent & idata) : mdet(&imdet),tsos(&itsos),data(&idata){}
42 
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 
50  const TkStripMeasurementDet * mdet = 0;
51  const TrajectoryStateOnSurface * tsos=0;
53 
56 
57  inline SiStripRecHit2D buildHit() const;
58  inline void advance();
59 
60 public:
61 
62  bool empty() const { return clusterI==clusterE; }
63 
64  bool operator==(TkStripRecHitIter const & rh) {
65  return clusterI==rh.clusterI;
66  }
67  bool operator!=(TkStripRecHitIter const & rh) {
68  return clusterI!=rh.clusterI;
69  }
70  bool operator<(TkStripRecHitIter const & rh) {
71  return clusterI<rh.clusterI;
72  }
73 
75  advance();
76  return *this;
77  }
78 
80  return buildHit();
81  }
82 
83 };
84 
85 
87 public:
88 
91 
93 
96 
97  typedef std::vector<SiStripCluster>::const_iterator const_iterator;
98 
100 
101  TkStripMeasurementDet( const GeomDet* gdet, StMeasurementConditionSet & conditionSet );
102 
103  void setIndex(int i) { index_=i;}
104 
105  void setEmpty(StMeasurementDetSet & theDets) const { theDets.setEmpty(index()); }
106 
107  bool isEmpty(const StMeasurementDetSet & theDets) const {return theDets.empty(index());}
108 
109  int index() const { return index_;}
110 
111  unsigned int rawId() const { return conditionSet().id(index()); }
112  unsigned char subId() const { return conditionSet().subId(index());}
113 
114 
115  const detset & theSet(const StMeasurementDetSet & theDets) const {return theDets.detSet(index());}
116  const detset & detSet(const StMeasurementDetSet & theDets) const {return theDets.detSet(index());}
117 
118 
120  bool isActive(const MeasurementTrackerEvent & data) const { return data.stripData().isActive(index()); }
121 
122  //TO BE IMPLEMENTED
123  bool hasBadComponents( const TrajectoryStateOnSurface &tsos, const MeasurementTrackerEvent & data ) const {return false;}
124 
125 
126  std::tuple<TkStripRecHitIter,TkStripRecHitIter> hitRange(const TrajectoryStateOnSurface&, const MeasurementTrackerEvent & data) const;
127  void advance(TkStripRecHitIter & hi ) const;
128  SiStripRecHit2D hit(TkStripRecHitIter const & hi ) const;
129 
130  virtual RecHitContainer recHits( const TrajectoryStateOnSurface&, const MeasurementTrackerEvent & data) const;
131 
132 
133  bool empty(const MeasurementTrackerEvent & data) const;
134 
135  void simpleRecHits( const TrajectoryStateOnSurface& ts, const MeasurementTrackerEvent & data, std::vector<SiStripRecHit2D> &result) const ;
136  bool simpleRecHits( const TrajectoryStateOnSurface& ts, const MeasurementEstimator& est, const MeasurementTrackerEvent & data, std::vector<SiStripRecHit2D> &result) const ;
137 
138  // simple hits
139  virtual bool recHits(SimpleHitContainer & result,
140  const TrajectoryStateOnSurface& stateOnThisDet, const MeasurementEstimator&, const MeasurementTrackerEvent & data) const;
141 
142  // TTRH
143  virtual bool recHits( const TrajectoryStateOnSurface& stateOnThisDet, const MeasurementEstimator& est, const MeasurementTrackerEvent & data,
144  RecHitContainer & result, std::vector<float> & diffs) const;
145 
146 
147  virtual bool measurements( const TrajectoryStateOnSurface& stateOnThisDet,
149  TempMeasurements & result) const;
150 
151  const StripGeomDetUnit& specificGeomDet() const {return static_cast<StripGeomDetUnit const &>(fastGeomDet());}
152 
153 
154  template<class ClusterRefT>
156  buildRecHit( const ClusterRefT &cluster, const TrajectoryStateOnSurface& ltp) const {
157  const GeomDetUnit& gdu( specificGeomDet());
158  LocalValues lv = cpe()->localParameters( *cluster, gdu, ltp);
159  return std::make_shared<SiStripRecHit2D>( lv.first, lv.second, fastGeomDet(), cluster);
160  }
161 
162 
163  template<class ClusterRefT>
164  void
165  buildRecHits( const ClusterRefT& cluster, const TrajectoryStateOnSurface& ltp, const RecHitContainer& _res) const {
166  RecHitContainer res = _res;
167  const GeomDetUnit& gdu( specificGeomDet());
168  VLocalValues vlv = cpe()->localParametersV( *cluster, gdu, ltp);
169  for(VLocalValues::const_iterator it=vlv.begin();it!=vlv.end();++it)
170  res.push_back(std::make_shared<SiStripRecHit2D>( it->first, it->second, fastGeomDet(), cluster));
171  }
172 
173 
174  template<class ClusterRefT>
175  bool filteredRecHits( const ClusterRefT& cluster, StripCPE::AlgoParam const& cpepar,
176  const TrajectoryStateOnSurface& ltp, const MeasurementEstimator& est, const std::vector<bool> & skipClusters,
177  RecHitContainer & result, std::vector<float> & diffs) const {
178  if (isMasked(*cluster)) return true;
179  if (!accept(cluster, skipClusters)) return true;
180  if (!est.preFilter(ltp, ClusterFilterPayload(rawId(),&*cluster) )) return true; // avoids shadow; consistent with previous statement...
181  auto const & vl = cpe()->localParameters( *cluster, cpepar);
182  SiStripRecHit2D recHit(vl.first, vl.second, fastGeomDet(), cluster); // FIXME add cluster count in OmniRef (and move again to multiple sub-clusters..)
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  }
189  return diffEst.first;
190  }
191 
192 
193  template<class ClusterRefT>
194  bool filteredRecHits( const ClusterRefT& cluster, StripCPE::AlgoParam const& cpepar,
195  const TrajectoryStateOnSurface& ltp, const MeasurementEstimator& est, const std::vector<bool> & skipClusters,
196  std::vector<SiStripRecHit2D> & result) const {
197  if (isMasked(*cluster)) return true;
198  if (!accept(cluster, skipClusters)) return true;
199  if (!est.preFilter(ltp, ClusterFilterPayload(rawId(),&*cluster) )) return true; // avoids shadow; consistent with previous statement...
200  auto const & vl = cpe()->localParameters( *cluster, cpepar);
201  result.emplace_back( vl.first, vl.second, fastGeomDet(), cluster); // FIXME add cluster count in OmniRef
202  std::pair<bool,double> diffEst = est.estimate(ltp, result.back());
203  LogDebug("TkStripMeasurementDet")<<" chi2=" << diffEst.second;
204  if ( !diffEst.first ) result.pop_back();
205  return diffEst.first;
206  }
207 
208 
209 
210 
212  void setActiveThisPeriod(StMeasurementDetSet & theDets, bool active) { conditionSet().setActive(index(),active);}
213 
216  void setActiveThisEvent(StMeasurementDetSet & theDets, bool active) const { theDets.setActiveThisEvent(index(),active); }
217 
219  bool hasAllGoodChannels() const { return (!hasAny128StripBad()) && badStripBlocks().empty(); }
220 
222  void set128StripStatus(bool good, int idx=-1) {
223  conditionSet().set128StripStatus(index(),good,idx);
224  }
225 
227 
229  bool testStrips(float utraj, float uerr) const;
230 
232 
233  std::vector<BadStripBlock> & getBadStripBlocks() { return conditionSet().getBadStripBlocks(index()); }
234  std::vector<BadStripBlock> const & badStripBlocks() const { return conditionSet().badStripBlocks(index()); }
235 
236  bool maskBad128StripBlocks() const { return conditionSet().maskBad128StripBlocks();}
237 
238 private:
241 
242 
243  int index_;
245  StMeasurementConditionSet & conditionSet() { return *theDetConditions; }
246  const StMeasurementConditionSet & conditionSet() const { return *theDetConditions; }
247 
248  const StripCPE * cpe() const { return static_cast<const StripCPE *>(conditionSet().stripCPE()); }
249 
250  // --- regional unpacking
251  int totalStrips() const { return conditionSet().totalStrips(index()); }
252  BadStripCuts const & badStripCuts() const { return conditionSet().badStripCuts(index());}
253 
254  bool hasAny128StripBad() const { return conditionSet().hasAny128StripBad(index()); }
255 
256 
257  inline bool isMasked(const SiStripCluster &cluster) const {
258  return conditionSet().isMasked(index(), cluster);
259  }
260 
261 
263  const detset & detSet,
264  const TrajectoryStateOnSurface& ltp,
265  std::vector<SiStripRecHit2D>& res) const {
266  const GeomDetUnit& gdu( specificGeomDet());
267  declareDynArray(LocalValues,clusters.size(),alv);
268  cpe()->localParameters(clusters, alv, gdu, ltp.localParameters());
269  res.reserve(alv.size());
270  for (unsigned int i=0; i< clusters.size(); ++i)
271  res.emplace_back( alv[i].first, alv[i].second, gdu, detSet.makeRefTo( data.stripData().handle(), clusters[i]) );
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  return accept(r.key(), skipClusters);
284  }
285 
286  inline bool accept(unsigned int key, const std::vector<bool> & skipClusters) const {
287  if(skipClusters.empty()) return true;
288  if (key>=skipClusters.size()){
289  LogDebug("TkStripMeasurementDet")<<key<<" is larger than: "<<skipClusters.size()
290  <<"\n This must be a new cluster, and therefore should not be skiped most likely.";
291  return true;
292  }
293  return (not (skipClusters[key]));
294  }
295 
296 
297 };
298 
299 
300 inline
302  return mdet->hit(*this);
303 }
304 inline
306  mdet->advance(*this);
307 }
308 
309 
310 
311 #endif
#define LogDebug(id)
DynArray< SiStripCluster const * > AClusters
#define dso_hidden
int i
Definition: DBlmapReader.cc:9
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
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)
std::pair< LocalPoint, LocalError > LocalValues
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 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:84
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
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
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
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
new_const_iterator clusterI
bool empty(int i) const
TrackingRecHit::ConstRecHitContainer RecHitContainer
SiStripRecHit2D::ClusterRef SiStripClusterRef
const detset & detSet(const StMeasurementDetSet &theDets) const
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
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:58
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:95
unsigned int size() const
Definition: DynArray.h:44
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