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 
16 
19 
21 
22 // #define VISTAT
23 
24 #ifdef VISTAT
25 #include<iostream>
26 #define COUT std::cout
27 #else
28 #define COUT LogDebug("")
29 #endif
30 
31 /* Struct of arrays supporting "members of Tk...MeasurementDet
32  * implemented with vectors, to be optimized...
33  ITEMS THAT DO NOT DEPEND ON THE EVENT
34  */
36 public:
37  enum QualityFlags { BadModules=1, // for everybody
39  /* Pixels: */ BadROCs=2 };
40 
41  struct BadStripCuts {
44  maxBad(pset.getParameter<uint32_t>("maxBad")),
45  maxConsecutiveBad(pset.getParameter<uint32_t>("maxConsecutiveBad")) {}
47  };
48 
49  struct BadStripBlock {
50  short first;
51  short last;
52  BadStripBlock(const SiStripBadStrip::data &data) : first(data.firstStrip), last(data.firstStrip+data.range-1) { }
53  };
54 
55 
58  theMatcher(matcher), theCPE(cpe){}
59 
60 
61  void init(int size);
62 
63  const SiStripRecHitMatcher* matcher() const { return theMatcher;}
65 
66 
67  int nDet() const { return id_.size();}
68  unsigned int id(int i) const { return id_[i]; }
69  unsigned char subId(int i) const { return subId_[i];}
70 
71  int find(unsigned int jd, int i=0) const {
72  return std::lower_bound(id_.begin()+i,id_.end(),jd)-id_.begin();
73  }
74 
75  bool isActiveThisPeriod(int i) const { return activeThisPeriod_[i]; }
76 
77 
79  void setActive(int i, bool active) { activeThisPeriod_[i] = active; }
80 
81  int totalStrips(int i) const { return totalStrips_[i];}
82 
83  void setMaskBad128StripBlocks(bool maskThem) { maskBad128StripBlocks_ = maskThem; }
84  const BadStripCuts & badStripCuts(int i) const { return badStripCuts_[subId_[i]];}
85 
87  bool hasAny128StripBad(int i) const { return hasAny128StripBad_[i];}
88 
90  bool bad128Strip(int offset) const { return bad128Strip_[offset];}
91  bool bad128Strip(int index, int strip) const { return bad128Strip_[nbad128*index+(strip>>7)];}
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 
125 
126  // members of TkStripMeasurementDet
127  std::vector<unsigned int> id_;
128  std::vector<unsigned char> subId_;
129 
130  std::vector<int> totalStrips_;
131 
132  static const int nbad128 = 6;
133  std::vector<bool> bad128Strip_;
134  std::vector<bool> hasAny128StripBad_;
135 
136  std::vector<std::vector<BadStripBlock>> badStripBlocks_;
137 
138  std::vector<bool> activeThisPeriod_;
139 };
140 
142 public:
143 
146 
147 
149  conditionSet_(&cond),
150  empty_(cond.nDet(), true),
151  activeThisEvent_(cond.nDet(), true),
152  detSet_(cond.nDet()),
153  detIndex_(cond.nDet(),-1),
154  ready_(cond.nDet(),true),
156  stripDefined_(0),
157  stripUpdated_(0),
158  stripRegions_(0)
159  {
160  }
161 
163  printStat();
164  }
165 
166  const StMeasurementConditionSet & conditions() const { return *conditionSet_; }
167 
168 
169  void update(int i,const StripDetset & detSet ) {
170  detSet_[i] = detSet;
171  empty_[i] = false;
172  }
173 
174  void update(int i, int j ) {
175  assert(j>=0); assert(empty_[i]); assert(ready_[i]);
176  detIndex_[i] = j;
177  empty_[i] = false;
178  incReady();
179  }
180 
181  int size() const { return conditions().nDet(); }
182  int nDet() const { return size();}
183  unsigned int id(int i) const { return conditions().id(i); }
184  int find(unsigned int jd, int i=0) const {
185  return conditions().find(jd,i);
186  }
187 
188  bool empty(int i) const { return empty_[i];}
189  bool isActive(int i) const { return activeThisEvent_[i] && conditions().isActiveThisPeriod(i); }
190 
191  void setEmpty(int i) {empty_[i] = true; activeThisEvent_[i] = true; }
192  void setUpdated(int i) { stripUpdated_[i] = true; }
193 
194  void setEmpty() {
195  printStat();
196  std::fill(empty_.begin(),empty_.end(),true);
197  std::fill(ready_.begin(),ready_.end(),true);
198  std::fill(detIndex_.begin(),detIndex_.end(),-1);
199  std::fill(activeThisEvent_.begin(), activeThisEvent_.end(),true);
200  incTot(size());
201  }
202 
205  void setActiveThisEvent(int i, bool active) { activeThisEvent_[i] = active; if (!active) empty_[i] = true; }
206 
209  // StripDetset & detSet(int i) { return detSet_[i]; }
210  const StripDetset & detSet(int i) const { if (ready_[i]) const_cast<StMeasurementDetSet*>(this)->getDetSet(i); return detSet_[i]; }
211 
212 
214  std::vector<uint32_t> & rawInactiveStripDetIds() { return theRawInactiveStripDetIds_; }
215  const std::vector<uint32_t> & rawInactiveStripDetIds() const { return theRawInactiveStripDetIds_; }
216 
217  void resetOnDemandStrips() { std::fill(stripDefined_.begin(), stripDefined_.end(), false); std::fill(stripUpdated_.begin(), stripUpdated_.end(), false); }
218  const bool stripDefined(int i) const { return stripDefined_[i]; }
219  const bool stripUpdated(int i) const { return stripUpdated_[i]; }
220  void defineStrip(int i, std::pair<unsigned int, unsigned int> range) {
221  stripDefined_[i] = true;
222  stripUpdated_[i] = false;
223  stripRegions_[i] = range;
224  }
225 
226 private:
227 
228  void getDetSet(int i) {
229  if(detIndex_[i]>=0) {
230  detSet_[i].set(*handle_,handle_->item(detIndex_[i]));
231  empty_[i]=false; // better be false already
232  incAct();
233  } else { // we should not be here
234  detSet_[i] = StripDetset();
235  empty_[i]=true;
236  }
237  ready_[i]=false;
238  incSet();
239  }
240 
241 
243 
245 
246 
247  // Globals, per-event
249 
250 
251  std::vector<bool> empty_;
252  std::vector<bool> activeThisEvent_;
253 
254  // full reco
255  std::vector<StripDetset> detSet_;
256  std::vector<int> detIndex_;
257  std::vector<bool> ready_; // to be cleaned
258 
259 
260  // note: not aligned to the index
261  std::vector<uint32_t> theRawInactiveStripDetIds_;
262  // keyed on si-strip index
263  std::vector<bool> stripDefined_, stripUpdated_;
264  std::vector<std::pair<unsigned int, unsigned int> > stripRegions_;
265  // keyed on glued
266  // std::vector<bool> gluedUpdated_;
267 
268 
269 
270 #ifdef VISTAT
271  struct Stat {
272  int totDet=0; // all dets
273  int detReady=0; // dets "updated"
274  int detSet=0; // det actually set not empty
275  int detAct=0; // det actually set with content
276  };
277 
278  mutable Stat stat;
279  void zeroStat() const { stat = Stat(); }
280  void incTot(int n) const { stat.totDet=n;}
281  void incReady() const { stat.detReady++;}
282  void incSet() const { stat.detSet++;}
283  void incAct() const { stat.detAct++;}
284  void printStat() const {
285  COUT << "VI detsets " << stat.totDet <<','<< stat.detReady <<','<< stat.detSet <<','<< stat.detAct << std::endl;
286  }
287 
288 #else
289  static void zeroStat(){}
290  static void incTot(int){}
291  static void incReady() {}
292  static void incSet() {}
293  static void incAct() {}
294  static void printStat(){}
295 #endif
296 
297 };
298 
300 public:
302  theCPE(cpe) {}
303 
304  void init(int size);
305 
306  int nDet() const { return id_.size();}
307  unsigned int id(int i) const { return id_[i]; }
308  int find(unsigned int jd, int i=0) const {
309  return std::lower_bound(id_.begin()+i,id_.end(),jd)-id_.begin();
310  }
311 
313  bool isActiveThisPeriod(int i) const { return activeThisPeriod_[i]; }
314 
317  void setActive(int i, bool active) { activeThisPeriod_[i] = active; }
318 
319 
320 private:
322 
323  // Globals (not-per-event)
325 
326  // Locals, per-event
327  std::vector<unsigned int> id_;
328  std::vector<bool> activeThisPeriod_;
329 
330 };
331 
332 
334 public:
337 
339  conditionSet_(&cond),
340  detSet_(cond.nDet()),
341  empty_(cond.nDet(), true),
342  activeThisEvent_(cond.nDet(), true) {}
343 
344  const PxMeasurementConditionSet & conditions() const { return *conditionSet_; }
345 
346  int size() const { return conditions().nDet(); }
347  int nDet() const { return size();}
348  unsigned int id(int i) const { return conditions().id(i); }
349  int find(unsigned int jd, int i=0) const {
350  return conditions().find(jd,i);
351  }
352 
353  void update(int i,const PixelDetSet & detSet ) {
354  detSet_[i] = detSet;
355  empty_[i] = false;
356  }
357 
358  bool empty(int i) const { return empty_[i];}
359  bool isActive(int i) const { return activeThisEvent_[i] && conditions().isActiveThisPeriod(i); }
360 
361  void setEmpty(int i) {empty_[i] = true; activeThisEvent_[i] = true; }
362 
363  void setEmpty() {
364  std::fill(empty_.begin(),empty_.end(),true);
365  std::fill(activeThisEvent_.begin(), activeThisEvent_.end(),true);
366  }
367  void setActiveThisEvent(bool active) {
368  std::fill(activeThisEvent_.begin(), activeThisEvent_.end(),active);
369  }
370 
373  void setActiveThisEvent(int i, bool active) { activeThisEvent_[i] = active; if (!active) empty_[i] = true; }
376  const PixelDetSet & detSet(int i) const { return detSet_[i];}
377 private:
379 
381 
382  // Globals, per-event
384 
385  // Locals, per-event
386  std::vector<PixelDetSet> detSet_;
387  std::vector<bool> empty_;
388  std::vector<bool> activeThisEvent_;
389 };
390 
391 #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
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 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)
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
unsigned int id(int i) const
const SiStripRecHitMatcher * matcher() const
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 ...
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
PxMeasurementDetSet(const PxMeasurementConditionSet &cond)
const StripClusterParameterEstimator * stripCPE() const
float barycenter() const
std::vector< uint32_t > theRawInactiveStripDetIds_
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
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 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
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_
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
bool isActiveThisPeriod(int i) const
const PxMeasurementConditionSet & conditions() const
edm::Handle< edmNew::DetSetVector< SiPixelCluster > > & handle()