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>
5 class TkStripMeasurementDet;
6 class TkStripMeasurementDet;
11 
18 
21 
23 
24 // #define VISTAT
25 
26 #ifdef VISTAT
27 #include<iostream>
28 #define COUT std::cout
29 #else
30 #define COUT LogDebug("")
31 #endif
32 
33 /* Struct of arrays supporting "members of Tk...MeasurementDet
34  * implemented with vectors, to be optimized...
35  ITEMS THAT DO NOT DEPEND ON THE EVENT
36  */
38 public:
39  enum QualityFlags { BadModules=1, // for everybody
41  /* Pixels: */ BadROCs=2 };
42 
43  struct BadStripCuts {
46  maxBad(pset.getParameter<uint32_t>("maxBad")),
47  maxConsecutiveBad(pset.getParameter<uint32_t>("maxConsecutiveBad")) {}
49  };
50 
51  struct BadStripBlock {
52  short first;
53  short last;
54  BadStripBlock(const SiStripBadStrip::data &data) : first(data.firstStrip), last(data.firstStrip+data.range-1) { }
55  };
56 
57 
60  bool regional):
61  theMatcher(matcher), theCPE(cpe), regional_(regional){}
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 isRegional() const { return regional_;}
79  bool isActiveThisPeriod(int i) const { return activeThisPeriod_[i]; }
80 
81 
83  void setActive(int i, bool active) { activeThisPeriod_[i] = active; }
84 
85  int totalStrips(int i) const { return totalStrips_[i];}
86 
87  void setMaskBad128StripBlocks(bool maskThem) { maskBad128StripBlocks_ = maskThem; }
88  const BadStripCuts & badStripCuts(int i) const { return badStripCuts_[subId_[i]];}
89 
91  bool hasAny128StripBad(int i) const { return hasAny128StripBad_[i];}
92 
93  std::vector<BadStripBlock> & getBadStripBlocks(int i) { return badStripBlocks_[i]; }
94  std::vector<BadStripBlock> const & badStripBlocks(int i) const {return badStripBlocks_[i]; }
95 
96  bool isMasked(int i, const SiStripCluster &cluster) const {
97  int offset = nbad128*i;
98  if ( bad128Strip_[offset+( cluster.firstStrip() >> 7)] ) {
99  if ( bad128Strip_[offset+( (cluster.firstStrip()+cluster.amplitudes().size()) >> 7)] ||
100  bad128Strip_[offset+( static_cast<int32_t>(cluster.barycenter()-0.499999) >> 7)] ) {
101  return true;
102  }
103  } else {
104  if ( bad128Strip_[offset+( (cluster.firstStrip()+cluster.amplitudes().size()) >> 7)] &&
105  bad128Strip_[offset+( static_cast<int32_t>(cluster.barycenter()-0.499999) >> 7)] ) {
106  return true;
107  }
108  }
109  return false;
110  }
111 
112 
113  void set128StripStatus(int i, bool good, int idx=-1);
114 
115 private:
116 
118 
119  // globals
122  bool regional_;
123 
126 
127  // members of TkStripMeasurementDet
128  std::vector<unsigned int> id_;
129  std::vector<unsigned char> subId_;
130 
131  std::vector<int> totalStrips_;
132 
133  static const int nbad128 = 6;
134  std::vector<bool> bad128Strip_;
135  std::vector<bool> hasAny128StripBad_;
136 
137  std::vector<std::vector<BadStripBlock>> badStripBlocks_;
138 
139  std::vector<bool> activeThisPeriod_;
140 };
141 
143 public:
144 
147 
148  typedef std::vector<SiStripCluster>::const_iterator const_iterator;
149 
152 
154  conditionSet_(&cond),
155  empty_(cond.nDet(), true),
156  activeThisEvent_(cond.nDet(), true),
157  detSet_(!cond.isRegional() ? cond.nDet() : 0),
158  detIndex_(!cond.isRegional() ? cond.nDet() : 0,-1),
159  ready_(!cond.isRegional() ? cond.nDet() : 0,true),
160  clusterI_(cond.isRegional() ? 2*cond.nDet() : 0),
161  refGetter_(0),
163  stripDefined_(cond.isRegional() ? cond.nDet() : 0),
164  stripUpdated_(cond.isRegional() ? cond.nDet() : 0),
165  stripRegions_(cond.isRegional() ? cond.nDet() : 0)
166  {
167  }
168 
170  printStat();
171  }
172 
173  const StMeasurementConditionSet & conditions() const { return *conditionSet_; }
174 
176 
177  void update(int i,const StripDetset & detSet ) {
178  detSet_[i] = detSet;
179  empty_[i] = false;
180  }
181 
182  void update(int i, int j ) {
183  assert(j>=0); assert(empty_[i]); assert(ready_[i]);
184  detIndex_[i] = j;
185  empty_[i] = false;
186  incReady();
187  }
188 
189  void update(int i, std::vector<SiStripCluster>::const_iterator begin ,std::vector<SiStripCluster>::const_iterator end) {
190  clusterI_[2*i] = begin - regionalHandle_->begin_record();
191  clusterI_[2*i+1] = end - regionalHandle_->begin_record();
192 
193  empty_[i] = false;
194  activeThisEvent_[i] = true;
195  }
196 
197  bool isRegional() const { return conditions().isRegional(); }
198 
199  int size() const { return conditions().nDet(); }
200  int nDet() const { return size();}
201  unsigned int id(int i) const { return conditions().id(i); }
202  int find(unsigned int jd, int i=0) const {
203  return conditions().find(jd,i);
204  }
205 
206  bool empty(int i) const { return empty_[i];}
207  bool isActive(int i) const { return activeThisEvent_[i] && conditions().isActiveThisPeriod(i); }
208 
209  void setEmpty(int i) {empty_[i] = true; activeThisEvent_[i] = true; }
210  void setUpdated(int i) { stripUpdated_[i] = true; }
211 
212  void setEmpty() {
213  printStat();
214  std::fill(empty_.begin(),empty_.end(),true);
215  std::fill(ready_.begin(),ready_.end(),true);
216  std::fill(detIndex_.begin(),detIndex_.end(),-1);
217  std::fill(activeThisEvent_.begin(), activeThisEvent_.end(),true);
218  incTot(size());
219  }
220 
223  void setActiveThisEvent(int i, bool active) { activeThisEvent_[i] = active; if (!active) empty_[i] = true; }
224 
227  // StripDetset & detSet(int i) { return detSet_[i]; }
228  const StripDetset & detSet(int i) const { if (ready_[i]) const_cast<StMeasurementDetSet*>(this)->getDetSet(i); return detSet_[i]; }
229 
232  unsigned int beginClusterI(int i) const {return clusterI_[2*i];}
233  unsigned int endClusterI(int i) const {return clusterI_[2*i+1];}
234 
236  void setRefGetter(const edm::RefGetter<SiStripCluster> &getter) { refGetter_ = &getter; }
237 
239  std::vector<uint32_t> & rawInactiveStripDetIds() { return theRawInactiveStripDetIds_; }
240  const std::vector<uint32_t> & rawInactiveStripDetIds() const { return theRawInactiveStripDetIds_; }
241 
242  void resetOnDemandStrips() { std::fill(stripDefined_.begin(), stripDefined_.end(), false); std::fill(stripUpdated_.begin(), stripUpdated_.end(), false); }
243  const bool stripDefined(int i) const { return stripDefined_[i]; }
244  const bool stripUpdated(int i) const { return stripUpdated_[i]; }
245  void defineStrip(int i, std::pair<unsigned int, unsigned int> range) {
246  stripDefined_[i] = true;
247  stripUpdated_[i] = false;
248  stripRegions_[i] = range;
249  }
250  //const bool gluedUpdated(int i) const { return gluedUpdated_(i); }
251  const std::pair<unsigned int,unsigned int> & regionRange(int i) const { return stripRegions_[i]; }
252 
253 private:
254 
255  void getDetSet(int i) {
256  if(detIndex_[i]>=0) {
257  detSet_[i].set(*handle_,handle_->item(detIndex_[i]));
258  empty_[i]=false; // better be false already
259  incAct();
260  } else { // we should not be here
261  detSet_[i] = StripDetset();
262  empty_[i]=true;
263  }
264  ready_[i]=false;
265  incSet();
266  }
267 
268 
271 
273 
276 
277  std::vector<bool> empty_;
278  std::vector<bool> activeThisEvent_;
279 
280  // full reco
281  std::vector<StripDetset> detSet_;
282  std::vector<int> detIndex_;
283  std::vector<bool> ready_; // to be cleaned
284 
285  // --- regional unpacking
286  // begin,end "pairs"
287  std::vector<unsigned int> clusterI_;
288 
291  // note: not aligned to the index
292  std::vector<uint32_t> theRawInactiveStripDetIds_;
293  // keyed on si-strip index
294  std::vector<bool> stripDefined_, stripUpdated_;
295  std::vector<std::pair<unsigned int, unsigned int> > stripRegions_;
296  // keyed on glued
297  // std::vector<bool> gluedUpdated_;
298 
299 
300 
301 #ifdef VISTAT
302  struct Stat {
303  int totDet=0; // all dets
304  int detReady=0; // dets "updated"
305  int detSet=0; // det actually set not empty
306  int detAct=0; // det actually set with content
307  };
308 
309  mutable Stat stat;
310  void zeroStat() const { stat = Stat(); }
311  void incTot(int n) const { stat.totDet=n;}
312  void incReady() const { stat.detReady++;}
313  void incSet() const { stat.detSet++;}
314  void incAct() const { stat.detAct++;}
315  void printStat() const {
316  COUT << "VI detsets " << stat.totDet <<','<< stat.detReady <<','<< stat.detSet <<','<< stat.detAct << std::endl;
317  }
318 
319 #else
320  static void zeroStat(){}
321  static void incTot(int){}
322  static void incReady() {}
323  static void incSet() {}
324  static void incAct() {}
325  static void printStat(){}
326 #endif
327 
328 };
329 
331 public:
333  theCPE(cpe) {}
334 
335  void init(int size);
336 
337  int nDet() const { return id_.size();}
338  unsigned int id(int i) const { return id_[i]; }
339  int find(unsigned int jd, int i=0) const {
340  return std::lower_bound(id_.begin()+i,id_.end(),jd)-id_.begin();
341  }
342 
344  bool isActiveThisPeriod(int i) const { return activeThisPeriod_[i]; }
345 
348  void setActive(int i, bool active) { activeThisPeriod_[i] = active; }
349 
350 
351 private:
353 
354  // Globals (not-per-event)
356 
357  // Locals, per-event
358  std::vector<unsigned int> id_;
359  std::vector<bool> activeThisPeriod_;
360 
361 };
362 
363 
365 public:
368 
370  conditionSet_(&cond),
371  detSet_(cond.nDet()),
372  empty_(cond.nDet(), true),
373  activeThisEvent_(cond.nDet(), true) {}
374 
375  const PxMeasurementConditionSet & conditions() const { return *conditionSet_; }
376 
377  int size() const { return conditions().nDet(); }
378  int nDet() const { return size();}
379  unsigned int id(int i) const { return conditions().id(i); }
380  int find(unsigned int jd, int i=0) const {
381  return conditions().find(jd,i);
382  }
383 
384  void update(int i,const PixelDetSet & detSet ) {
385  detSet_[i] = detSet;
386  empty_[i] = false;
387  }
388 
389  bool empty(int i) const { return empty_[i];}
390  bool isActive(int i) const { return activeThisEvent_[i] && conditions().isActiveThisPeriod(i); }
391 
392  void setEmpty(int i) {empty_[i] = true; activeThisEvent_[i] = true; }
393 
394  void setEmpty() {
395  std::fill(empty_.begin(),empty_.end(),true);
396  std::fill(activeThisEvent_.begin(), activeThisEvent_.end(),true);
397  }
398  void setActiveThisEvent(bool active) {
399  std::fill(activeThisEvent_.begin(), activeThisEvent_.end(),active);
400  }
401 
404  void setActiveThisEvent(int i, bool active) { activeThisEvent_[i] = active; if (!active) empty_[i] = true; }
407  const PixelDetSet & detSet(int i) const { return detSet_[i];}
408 private:
410 
412 
413  // Globals, per-event
415 
416  // Locals, per-event
417  std::vector<PixelDetSet> detSet_;
418  std::vector<bool> empty_;
419  std::vector<bool> activeThisEvent_;
420 };
421 
422 #endif // StMeasurementDetSet_H
bool isMasked(int i, const SiStripCluster &cluster) const
int find(unsigned int jd, int i=0) const
int i
Definition: DBlmapReader.cc:9
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
const StripDetset & detSet(int i) const
edm::Ref< edmNew::DetSetVector< SiPixelCluster >, SiPixelCluster > SiPixelClusterRef
StMeasurementDetSet(const StMeasurementConditionSet &cond)
void update(int i, int j)
std::vector< bool > stripDefined_
std::vector< bool > ready_
edm::Handle< edm::LazyGetter< SiStripCluster > > & regionalHandle()
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
void defineStrip(int i, std::pair< unsigned int, unsigned int > range)
const edm::Handle< edm::LazyGetter< SiStripCluster > > & regionalHandle() const
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
std::vector< unsigned char > subId_
const BadStripCuts & badStripCuts(int i) const
void setRefGetter(const edm::RefGetter< SiStripCluster > &getter)
edm::LazyGetter< SiStripCluster > LazyGetter
unsigned int id(int i) const
const std::pair< unsigned int, unsigned int > & regionRange(int i) const
const SiStripRecHitMatcher * matcher() const
const StMeasurementConditionSet * conditionSet_
edm::Handle< edm::LazyGetter< SiStripCluster > > regionalHandle_
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 ...
unsigned int endClusterI(int i) const
std::vector< unsigned int > clusterI_
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
unsigned int beginClusterI(int i) const
const edm::Handle< edmNew::DetSetVector< SiStripCluster > > & handle() const
int j
Definition: DBlmapReader.cc:9
PxMeasurementDetSet(const PxMeasurementConditionSet &cond)
const StripClusterParameterEstimator * stripCPE() const
float barycenter() const
StMeasurementConditionSet(const SiStripRecHitMatcher *matcher, const StripClusterParameterEstimator *cpe, bool regional)
std::vector< uint32_t > theRawInactiveStripDetIds_
#define end
Definition: vmac.h:37
unsigned int offset(bool)
void update(int i, const PixelDetSet &detSet)
std::vector< int > totalStrips_
std::vector< bool > hasAny128StripBad_
const StripClusterParameterEstimator * theCPE
std::vector< SiStripCluster >::const_iterator const_iterator
std::vector< bool > empty_
std::vector< uint32_t > & rawInactiveStripDetIds()
void setMaskBad128StripBlocks(bool maskThem)
std::vector< bool > activeThisPeriod_
std::vector< unsigned int > id_
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
std::vector< unsigned int > id_
std::vector< bool > activeThisPeriod_
BadStripBlock(const SiStripBadStrip::data &data)
bool isActive(int i) const
edm::Handle< edmNew::DetSetVector< SiStripCluster > > handle_
std::vector< bool > bad128Strip_
bool empty(int i) const
void setLazyGetter(edm::Handle< LazyGetter > const &lg)
void setActiveThisEvent(bool active)
Pixel cluster – collection of neighboring pixels above threshold.
BadStripCuts(const edm::ParameterSet &pset)
#define begin
Definition: vmac.h:30
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 edm::RefGetter< SiStripCluster > & refGetter() 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
void update(int i, std::vector< SiStripCluster >::const_iterator begin, std::vector< SiStripCluster >::const_iterator end)
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
std::vector< std::pair< unsigned int, unsigned int > > stripRegions_
std::vector< int > detIndex_
const edm::RefGetter< SiStripCluster > * refGetter_
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_
#define COUT
const bool stripDefined(int i) const
bool isActiveThisPeriod(int i) const
const PxMeasurementConditionSet & conditions() const
edm::RefGetter< SiStripCluster > RefGetter
edm::Handle< edmNew::DetSetVector< SiPixelCluster > > & handle()