test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TkMeasurementDetSet.h
Go to the documentation of this file.
1 #ifndef StMeasurementDetSet_H
2 #define StMeasurementDetSet_H
3 
4 #include<vector>
11 class Phase2StripCPE;
12 
19 
22 
24 
25 // #define VISTAT
26 
27 #ifdef VISTAT
28 #include<iostream>
29 #define COUT std::cout
30 #else
31 #define COUT LogDebug("")
32 #endif
33 
34 /* Struct of arrays supporting "members of Tk...MeasurementDet
35  * implemented with vectors, to be optimized...
36  ITEMS THAT DO NOT DEPEND ON THE EVENT
37  */
39 public:
40  enum QualityFlags { BadModules=1, // for everybody
42  /* Pixels: */ BadROCs=2 };
43 
44  struct BadStripCuts {
47  maxBad(pset.getParameter<uint32_t>("maxBad")),
48  maxConsecutiveBad(pset.getParameter<uint32_t>("maxConsecutiveBad")) {}
50  };
51 
52  struct BadStripBlock {
53  short first;
54  short last;
55  BadStripBlock(const SiStripBadStrip::data &data) : first(data.firstStrip), last(data.firstStrip+data.range-1) { }
56  };
57 
58 
61  theMatcher(matcher), theCPE(cpe){}
62 
63 
64  void init(int size);
65 
66  const SiStripRecHitMatcher* matcher() const { return theMatcher;}
68 
69 
70  int nDet() const { return id_.size();}
71  unsigned int id(int i) const { return id_[i]; }
72  unsigned char subId(int i) const { return subId_[i];}
73 
74  int find(unsigned int jd, int i=0) const {
75  return std::lower_bound(id_.begin()+i,id_.end(),jd)-id_.begin();
76  }
77 
78  bool isActiveThisPeriod(int i) const { return activeThisPeriod_[i]; }
79 
80 
82  void setActive(int i, bool active) { activeThisPeriod_[i] = active; }
83 
84  int totalStrips(int i) const { return totalStrips_[i];}
85 
86  void setMaskBad128StripBlocks(bool maskThem) { maskBad128StripBlocks_ = maskThem; }
87  const BadStripCuts & badStripCuts(int i) const { return badStripCuts_[subId_[i]];}
88 
90  bool hasAny128StripBad(int i) const { return hasAny128StripBad_[i];}
91 
93  bool bad128Strip(int offset) const { return bad128Strip_[offset];}
94  bool bad128Strip(int index, int strip) const { return bad128Strip_[nbad128*index+(strip>>7)];}
95 
96  std::vector<BadStripBlock> & getBadStripBlocks(int i) { return badStripBlocks_[i]; }
97  std::vector<BadStripBlock> const & badStripBlocks(int i) const {return badStripBlocks_[i]; }
98 
99  bool isMasked(int i, const SiStripCluster &cluster) const {
100  int offset = nbad128*i;
101  if ( bad128Strip_[offset+( cluster.firstStrip() >> 7)] ) {
102  if ( bad128Strip_[offset+( (cluster.firstStrip()+cluster.amplitudes().size()) >> 7)] ||
103  bad128Strip_[offset+( static_cast<int32_t>(cluster.barycenter()-0.499999) >> 7)] ) {
104  return true;
105  }
106  } else {
107  if ( bad128Strip_[offset+( (cluster.firstStrip()+cluster.amplitudes().size()) >> 7)] &&
108  bad128Strip_[offset+( static_cast<int32_t>(cluster.barycenter()-0.499999) >> 7)] ) {
109  return true;
110  }
111  }
112  return false;
113  }
114 
115 
116  void set128StripStatus(int i, bool good, int idx=-1);
117 
118 private:
119 
121 
122  // globals
125 
128 
129  // members of TkStripMeasurementDet
130  std::vector<unsigned int> id_;
131  std::vector<unsigned char> subId_;
132 
133  std::vector<int> totalStrips_;
134 
135  static const int nbad128 = 6;
136  std::vector<bool> bad128Strip_;
137  std::vector<bool> hasAny128StripBad_;
138 
139  std::vector<std::vector<BadStripBlock>> badStripBlocks_;
140 
141  std::vector<bool> activeThisPeriod_;
142 };
143 
145 public:
146 
149 
150 
152  conditionSet_(&cond),
153  empty_(cond.nDet(), true),
154  activeThisEvent_(cond.nDet(), true),
155  detSet_(cond.nDet()),
156  detIndex_(cond.nDet(),-1),
157  ready_(cond.nDet(),true),
159  stripDefined_(0),
160  stripUpdated_(0),
161  stripRegions_(0)
162  {
163  }
164 
166  printStat();
167  }
168 
169  const StMeasurementConditionSet & conditions() const { return *conditionSet_; }
170 
171 
172  void update(int i,const StripDetset & detSet ) {
173  detSet_[i] = detSet;
174  empty_[i] = false;
175  }
176 
177  void update(int i, int j ) {
178  assert(j>=0); assert(empty_[i]); assert(ready_[i]);
179  detIndex_[i] = j;
180  empty_[i] = false;
181  incReady();
182  }
183 
184  int size() const { return conditions().nDet(); }
185  int nDet() const { return size();}
186  unsigned int id(int i) const { return conditions().id(i); }
187  int find(unsigned int jd, int i=0) const {
188  return conditions().find(jd,i);
189  }
190 
191  bool empty(int i) const { return empty_[i];}
192  bool isActive(int i) const { return activeThisEvent_[i] && conditions().isActiveThisPeriod(i); }
193 
194  void setEmpty(int i) {empty_[i] = true; activeThisEvent_[i] = true; }
195  void setUpdated(int i) { stripUpdated_[i] = true; }
196 
197  void setEmpty() {
198  printStat();
199  std::fill(empty_.begin(),empty_.end(),true);
200  std::fill(ready_.begin(),ready_.end(),true);
201  std::fill(detIndex_.begin(),detIndex_.end(),-1);
202  std::fill(activeThisEvent_.begin(), activeThisEvent_.end(),true);
203  incTot(size());
204  }
205 
208  void setActiveThisEvent(int i, bool active) { activeThisEvent_[i] = active; if (!active) empty_[i] = true; }
209 
212  // StripDetset & detSet(int i) { return detSet_[i]; }
213  const StripDetset & detSet(int i) const { if (ready_[i]) const_cast<StMeasurementDetSet*>(this)->getDetSet(i); return detSet_[i]; }
214 
215 
217  std::vector<uint32_t> & rawInactiveStripDetIds() { return theRawInactiveStripDetIds_; }
218  const std::vector<uint32_t> & rawInactiveStripDetIds() const { return theRawInactiveStripDetIds_; }
219 
220  void resetOnDemandStrips() { std::fill(stripDefined_.begin(), stripDefined_.end(), false); std::fill(stripUpdated_.begin(), stripUpdated_.end(), false); }
221  const bool stripDefined(int i) const { return stripDefined_[i]; }
222  const bool stripUpdated(int i) const { return stripUpdated_[i]; }
223  void defineStrip(int i, std::pair<unsigned int, unsigned int> range) {
224  stripDefined_[i] = true;
225  stripUpdated_[i] = false;
226  stripRegions_[i] = range;
227  }
228 
229 private:
230 
231  void getDetSet(int i) {
232  if(detIndex_[i]>=0) {
233  detSet_[i].set(*handle_,handle_->item(detIndex_[i]));
234  empty_[i]=false; // better be false already
235  incAct();
236  } else { // we should not be here
237  detSet_[i] = StripDetset();
238  empty_[i]=true;
239  }
240  ready_[i]=false;
241  incSet();
242  }
243 
244 
246 
248 
249 
250  // Globals, per-event
252 
253 
254  std::vector<bool> empty_;
255  std::vector<bool> activeThisEvent_;
256 
257  // full reco
258  std::vector<StripDetset> detSet_;
259  std::vector<int> detIndex_;
260  std::vector<bool> ready_; // to be cleaned
261 
262 
263  // note: not aligned to the index
264  std::vector<uint32_t> theRawInactiveStripDetIds_;
265  // keyed on si-strip index
266  std::vector<bool> stripDefined_, stripUpdated_;
267  std::vector<std::pair<unsigned int, unsigned int> > stripRegions_;
268  // keyed on glued
269  // std::vector<bool> gluedUpdated_;
270 
271 
272 
273 #ifdef VISTAT
274  struct Stat {
275  int totDet=0; // all dets
276  int detReady=0; // dets "updated"
277  int detSet=0; // det actually set not empty
278  int detAct=0; // det actually set with content
279  };
280 
281  mutable Stat stat;
282  void zeroStat() const { stat = Stat(); }
283  void incTot(int n) const { stat.totDet=n;}
284  void incReady() const { stat.detReady++;}
285  void incSet() const { stat.detSet++;}
286  void incAct() const { stat.detAct++;}
287  void printStat() const {
288  COUT << "VI detsets " << stat.totDet <<','<< stat.detReady <<','<< stat.detSet <<','<< stat.detAct << std::endl;
289  }
290 
291 #else
292  static void zeroStat(){}
293  static void incTot(int){}
294  static void incReady() {}
295  static void incSet() {}
296  static void incAct() {}
297  static void printStat(){}
298 #endif
299 
300 };
301 
303 public:
305  theCPE(cpe) {}
306 
307  void init(int size);
308 
309  int nDet() const { return id_.size();}
310  unsigned int id(int i) const { return id_[i]; }
311  int find(unsigned int jd, int i=0) const {
312  return std::lower_bound(id_.begin()+i,id_.end(),jd)-id_.begin();
313  }
314 
316  bool isActiveThisPeriod(int i) const { return activeThisPeriod_[i]; }
317 
320  void setActive(int i, bool active) { activeThisPeriod_[i] = active; }
321 
322 
323 private:
325 
326  // Globals (not-per-event)
328 
329  // Locals, per-event
330  std::vector<unsigned int> id_;
331  std::vector<bool> activeThisPeriod_;
332 
333 };
334 
335 
337 public:
340 
342  conditionSet_(&cond),
343  detSet_(cond.nDet()),
344  empty_(cond.nDet(), true),
345  activeThisEvent_(cond.nDet(), true) {}
346 
347  const PxMeasurementConditionSet & conditions() const { return *conditionSet_; }
348 
349  int size() const { return conditions().nDet(); }
350  int nDet() const { return size();}
351  unsigned int id(int i) const { return conditions().id(i); }
352  int find(unsigned int jd, int i=0) const {
353  return conditions().find(jd,i);
354  }
355 
356  void update(int i,const PixelDetSet & detSet ) {
357  detSet_[i] = detSet;
358  empty_[i] = false;
359  }
360 
361  bool empty(int i) const { return empty_[i];}
362  bool isActive(int i) const { return activeThisEvent_[i] && conditions().isActiveThisPeriod(i); }
363 
364  void setEmpty(int i) {empty_[i] = true; activeThisEvent_[i] = true; }
365 
366  void setEmpty() {
367  std::fill(empty_.begin(),empty_.end(),true);
368  std::fill(activeThisEvent_.begin(), activeThisEvent_.end(),true);
369  }
370  void setActiveThisEvent(bool active) {
371  std::fill(activeThisEvent_.begin(), activeThisEvent_.end(),active);
372  }
373 
376  void setActiveThisEvent(int i, bool active) { activeThisEvent_[i] = active; if (!active) empty_[i] = true; }
379  const PixelDetSet & detSet(int i) const { return detSet_[i];}
380 private:
382 
384 
385  // Globals, per-event
387 
388  // Locals, per-event
389  std::vector<PixelDetSet> detSet_;
390  std::vector<bool> empty_;
391  std::vector<bool> activeThisEvent_;
392 };
393 
394 //FIXME:just temporary solution for phase2 OT that works!
396 public:
398  theCPE(cpe) {}
399 
400  void init(int size);
401 
402  int nDet() const { return id_.size();}
403  unsigned int id(int i) const { return id_[i]; }
404  int find(unsigned int jd, int i=0) const {
405  return std::lower_bound(id_.begin()+i,id_.end(),jd)-id_.begin();
406  }
407 
409  bool isActiveThisPeriod(int i) const { return activeThisPeriod_[i]; }
410 
413  void setActive(int i, bool active) { activeThisPeriod_[i] = active; }
414 
415 
416 private:
418 
419  // Globals (not-per-event)
421 
422  // Locals, per-event
423  std::vector<unsigned int> id_;
424  std::vector<bool> activeThisPeriod_;
425 
426 };
427 
429 public:
432 
434  conditionSet_(&cond),
435  detSet_(cond.nDet()),
436  empty_(cond.nDet(), true),
437  activeThisEvent_(cond.nDet(), true) {}
438 
440 
441  int size() const { return conditions().nDet(); }
442  int nDet() const { return size();}
443  unsigned int id(int i) const { return conditions().id(i); }
444  int find(unsigned int jd, int i=0) const {
445  return conditions().find(jd,i);
446  }
447 
448  void update(int i,const Phase2DetSet & detSet ) {
449  detSet_[i] = detSet;
450  empty_[i] = false;
451  }
452 
453  bool empty(int i) const { return empty_[i];}
454  bool isActive(int i) const { return activeThisEvent_[i] && conditions().isActiveThisPeriod(i); }
455 
456  void setEmpty(int i) {empty_[i] = true; activeThisEvent_[i] = true; }
457 
458  void setEmpty() {
459  std::fill(empty_.begin(),empty_.end(),true);
460  std::fill(activeThisEvent_.begin(), activeThisEvent_.end(),true);
461  }
462  void setActiveThisEvent(bool active) {
463  std::fill(activeThisEvent_.begin(), activeThisEvent_.end(),active);
464  }
465  void setActiveThisEvent(int i, bool active) { activeThisEvent_[i] = active; if (!active) empty_[i] = true; }
468  const Phase2DetSet & detSet(int i) const { return detSet_[i];}
469 private:
471 
473 
474  //Globals, per-event
476 
477  // Locals, per-event
478  std::vector<Phase2DetSet> detSet_;
479  std::vector<bool> empty_;
480  std::vector<bool> activeThisEvent_;
481 };
482 
483 #endif // StMeasurementDetSet_H
bool isMasked(int i, const SiStripCluster &cluster) const
edmNew::DetSet< Phase2TrackerCluster1D > Phase2DetSet
int find(unsigned int jd, int i=0) const
int i
Definition: DBlmapReader.cc:9
edm::Handle< edmNew::DetSetVector< Phase2TrackerCluster1D > > & handle()
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< std::vector< BadStripBlock > > badStripBlocks_
string fill
Definition: lumiContext.py:319
PxMeasurementConditionSet(const PixelClusterParameterEstimator *cpe)
unsigned int id(int i) const
const PixelClusterParameterEstimator * theCPE
void setActive(int i, bool active)
Turn on/off the module for reconstruction, for the full run or lumi (using info from DB...
const StripDetset & detSet(int i) const
edm::Handle< edmNew::DetSetVector< Phase2TrackerCluster1D > > handle_
bool bad128Strip(int index, int strip) const
edm::Ref< edmNew::DetSetVector< SiPixelCluster >, SiPixelCluster > SiPixelClusterRef
StMeasurementDetSet(const StMeasurementConditionSet &cond)
void update(int i, int j)
assert(m_qm.get())
std::vector< bool > stripDefined_
std::vector< bool > ready_
const Phase2DetSet & detSet(int i) const
const PxMeasurementConditionSet * conditionSet_
void update(int i, const StripDetset &detSet)
const StMeasurementConditionSet & conditions() const
StripDetset::const_iterator new_const_iterator
uint16_t firstStrip() const
data_type const * const_iterator
Definition: DetSetNew.h:30
const edm::Handle< edmNew::DetSetVector< SiPixelCluster > > & handle() const
bool isActiveThisPeriod(int i) const
unsigned int id(int i) const
edm::Ref< edmNew::DetSetVector< Phase2TrackerCluster1D >, Phase2TrackerCluster1D > Phase2TrackerCluster1DRef
void defineStrip(int i, std::pair< unsigned int, unsigned int > range)
std::vector< bool > empty_
const bool stripUpdated(int i) const
unsigned int id(int i) const
bool empty(int i) const
unsigned int id(int i) const
edmNew::DetSet< SiStripCluster > StripDetset
int find(unsigned int jd, int i=0) const
Item const & item(size_t cell) const
std::vector< unsigned char > subId_
const BadStripCuts & badStripCuts(int i) const
const ClusterParameterEstimator< Phase2TrackerCluster1D > * cpe() const
unsigned int id(int i) const
const SiStripRecHitMatcher * matcher() const
const StMeasurementConditionSet * conditionSet_
int find(unsigned int jd, int i=0) const
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 ...
const edm::Handle< edmNew::DetSetVector< Phase2TrackerCluster1D > > & handle() const
void setActive(int i, bool active)
Turn on/off the module for reconstruction, for the full run or lumi (using info from DB...
bool isActive(int i) const
std::vector< BadStripBlock > & getBadStripBlocks(int i)
edm::Handle< edmNew::DetSetVector< SiPixelCluster > > handle_
bool hasAny128StripBad(int i) const
const edm::Handle< edmNew::DetSetVector< SiStripCluster > > & handle() const
int j
Definition: DBlmapReader.cc:9
std::vector< Phase2DetSet > detSet_
PxMeasurementDetSet(const PxMeasurementConditionSet &cond)
const StripClusterParameterEstimator * stripCPE() const
float barycenter() const
std::vector< uint32_t > theRawInactiveStripDetIds_
std::vector< unsigned int > id_
StMeasurementConditionSet(const SiStripRecHitMatcher *matcher, const StripClusterParameterEstimator *cpe)
void update(int i, const PixelDetSet &detSet)
std::vector< int > totalStrips_
std::vector< bool > hasAny128StripBad_
const StripClusterParameterEstimator * theCPE
void setActiveThisEvent(int i, bool active)
std::vector< bool > empty_
std::vector< uint32_t > & rawInactiveStripDetIds()
void setMaskBad128StripBlocks(bool maskThem)
std::vector< bool > activeThisPeriod_
std::vector< unsigned int > id_
std::vector< unsigned int > id_
std::vector< bool > activeThisPeriod_
const Phase2OTMeasurementConditionSet & conditions() const
BadStripBlock(const SiStripBadStrip::data &data)
bool isActive(int i) const
edm::Handle< edmNew::DetSetVector< SiStripCluster > > handle_
std::vector< bool > bad128Strip_
int find(unsigned int jd, int i=0) const
std::vector< bool > activeThisEvent_
bool empty(int i) const
void setActiveThisEvent(bool active)
Pixel cluster – collection of neighboring pixels above threshold.
BadStripCuts(const edm::ParameterSet &pset)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
static void incTot(int)
std::vector< StripDetset > detSet_
std::vector< bool > activeThisEvent_
int find(unsigned int jd, int i=0) const
const PixelClusterParameterEstimator * pixelCPE() const
std::vector< BadStripBlock > const & badStripBlocks(int i) const
std::vector< bool > activeThisEvent_
int find(unsigned int jd, int i=0) const
const ClusterParameterEstimator< Phase2TrackerCluster1D > * theCPE
void setActiveThisEvent(bool active)
void setActive(int i, bool active)
Turn on/off the module for reconstruction, for the full run or lumi (using info from DB...
edm::Handle< edmNew::DetSetVector< SiStripCluster > > & handle()
void set128StripStatus(int i, bool good, int idx=-1)
const PixelDetSet & detSet(int i) const
Phase2OTMeasurementDetSet(const Phase2OTMeasurementConditionSet &cond)
std::vector< std::pair< unsigned int, unsigned int > > stripRegions_
std::vector< int > detIndex_
unsigned int id(int i) const
void update(int i, const Phase2DetSet &detSet)
std::vector< PixelDetSet > detSet_
const SiStripRecHitMatcher * theMatcher
edmNew::DetSet< SiPixelCluster > PixelDetSet
const std::vector< uint32_t > & rawInactiveStripDetIds() const
tuple size
Write out results.
unsigned char subId(int i) const
const std::vector< uint8_t > & amplitudes() const
std::vector< bool > stripUpdated_
bool bad128Strip(int offset) const
note: index is 6*detector index + offset!
#define COUT
const bool stripDefined(int i) const
const Phase2OTMeasurementConditionSet * conditionSet_
bool isActiveThisPeriod(int i) const
Phase2OTMeasurementConditionSet(const ClusterParameterEstimator< Phase2TrackerCluster1D > *cpe)
const PxMeasurementConditionSet & conditions() const
edm::Handle< edmNew::DetSetVector< SiPixelCluster > > & handle()