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 
89  std::vector<BadStripBlock> & getBadStripBlocks(int i) { return badStripBlocks_[i]; }
90  std::vector<BadStripBlock> const & badStripBlocks(int i) const {return badStripBlocks_[i]; }
91 
92  bool isMasked(int i, const SiStripCluster &cluster) const {
93  int offset = nbad128*i;
94  if ( bad128Strip_[offset+( cluster.firstStrip() >> 7)] ) {
95  if ( bad128Strip_[offset+( (cluster.firstStrip()+cluster.amplitudes().size()) >> 7)] ||
96  bad128Strip_[offset+( static_cast<int32_t>(cluster.barycenter()-0.499999) >> 7)] ) {
97  return true;
98  }
99  } else {
100  if ( bad128Strip_[offset+( (cluster.firstStrip()+cluster.amplitudes().size()) >> 7)] &&
101  bad128Strip_[offset+( static_cast<int32_t>(cluster.barycenter()-0.499999) >> 7)] ) {
102  return true;
103  }
104  }
105  return false;
106  }
107 
108 
109  void set128StripStatus(int i, bool good, int idx=-1);
110 
111 private:
112 
114 
115  // globals
118 
121 
122  // members of TkStripMeasurementDet
123  std::vector<unsigned int> id_;
124  std::vector<unsigned char> subId_;
125 
126  std::vector<int> totalStrips_;
127 
128  static const int nbad128 = 6;
129  std::vector<bool> bad128Strip_;
130  std::vector<bool> hasAny128StripBad_;
131 
132  std::vector<std::vector<BadStripBlock>> badStripBlocks_;
133 
134  std::vector<bool> activeThisPeriod_;
135 };
136 
138 public:
139 
142 
143 
145  conditionSet_(&cond),
146  empty_(cond.nDet(), true),
147  activeThisEvent_(cond.nDet(), true),
148  detSet_(cond.nDet()),
149  detIndex_(cond.nDet(),-1),
150  ready_(cond.nDet(),true),
152  stripDefined_(0),
153  stripUpdated_(0),
154  stripRegions_(0)
155  {
156  }
157 
159  printStat();
160  }
161 
162  const StMeasurementConditionSet & conditions() const { return *conditionSet_; }
163 
164 
165  void update(int i,const StripDetset & detSet ) {
166  detSet_[i] = detSet;
167  empty_[i] = false;
168  }
169 
170  void update(int i, int j ) {
171  assert(j>=0); assert(empty_[i]); assert(ready_[i]);
172  detIndex_[i] = j;
173  empty_[i] = false;
174  incReady();
175  }
176 
177  int size() const { return conditions().nDet(); }
178  int nDet() const { return size();}
179  unsigned int id(int i) const { return conditions().id(i); }
180  int find(unsigned int jd, int i=0) const {
181  return conditions().find(jd,i);
182  }
183 
184  bool empty(int i) const { return empty_[i];}
185  bool isActive(int i) const { return activeThisEvent_[i] && conditions().isActiveThisPeriod(i); }
186 
187  void setEmpty(int i) {empty_[i] = true; activeThisEvent_[i] = true; }
188  void setUpdated(int i) { stripUpdated_[i] = true; }
189 
190  void setEmpty() {
191  printStat();
192  std::fill(empty_.begin(),empty_.end(),true);
193  std::fill(ready_.begin(),ready_.end(),true);
194  std::fill(detIndex_.begin(),detIndex_.end(),-1);
195  std::fill(activeThisEvent_.begin(), activeThisEvent_.end(),true);
196  incTot(size());
197  }
198 
201  void setActiveThisEvent(int i, bool active) { activeThisEvent_[i] = active; if (!active) empty_[i] = true; }
202 
205  // StripDetset & detSet(int i) { return detSet_[i]; }
206  const StripDetset & detSet(int i) const { if (ready_[i]) const_cast<StMeasurementDetSet*>(this)->getDetSet(i); return detSet_[i]; }
207 
208 
210  std::vector<uint32_t> & rawInactiveStripDetIds() { return theRawInactiveStripDetIds_; }
211  const std::vector<uint32_t> & rawInactiveStripDetIds() const { return theRawInactiveStripDetIds_; }
212 
213  void resetOnDemandStrips() { std::fill(stripDefined_.begin(), stripDefined_.end(), false); std::fill(stripUpdated_.begin(), stripUpdated_.end(), false); }
214  const bool stripDefined(int i) const { return stripDefined_[i]; }
215  const bool stripUpdated(int i) const { return stripUpdated_[i]; }
216  void defineStrip(int i, std::pair<unsigned int, unsigned int> range) {
217  stripDefined_[i] = true;
218  stripUpdated_[i] = false;
219  stripRegions_[i] = range;
220  }
221 
222 private:
223 
224  void getDetSet(int i) {
225  if(detIndex_[i]>=0) {
226  detSet_[i].set(*handle_,handle_->item(detIndex_[i]));
227  empty_[i]=false; // better be false already
228  incAct();
229  } else { // we should not be here
230  detSet_[i] = StripDetset();
231  empty_[i]=true;
232  }
233  ready_[i]=false;
234  incSet();
235  }
236 
237 
239 
241 
242 
243  // Globals, per-event
245 
246 
247  std::vector<bool> empty_;
248  std::vector<bool> activeThisEvent_;
249 
250  // full reco
251  std::vector<StripDetset> detSet_;
252  std::vector<int> detIndex_;
253  std::vector<bool> ready_; // to be cleaned
254 
255 
256  // note: not aligned to the index
257  std::vector<uint32_t> theRawInactiveStripDetIds_;
258  // keyed on si-strip index
259  std::vector<bool> stripDefined_, stripUpdated_;
260  std::vector<std::pair<unsigned int, unsigned int> > stripRegions_;
261  // keyed on glued
262  // std::vector<bool> gluedUpdated_;
263 
264 
265 
266 #ifdef VISTAT
267  struct Stat {
268  int totDet=0; // all dets
269  int detReady=0; // dets "updated"
270  int detSet=0; // det actually set not empty
271  int detAct=0; // det actually set with content
272  };
273 
274  mutable Stat stat;
275  void zeroStat() const { stat = Stat(); }
276  void incTot(int n) const { stat.totDet=n;}
277  void incReady() const { stat.detReady++;}
278  void incSet() const { stat.detSet++;}
279  void incAct() const { stat.detAct++;}
280  void printStat() const {
281  COUT << "VI detsets " << stat.totDet <<','<< stat.detReady <<','<< stat.detSet <<','<< stat.detAct << std::endl;
282  }
283 
284 #else
285  static void zeroStat(){}
286  static void incTot(int){}
287  static void incReady() {}
288  static void incSet() {}
289  static void incAct() {}
290  static void printStat(){}
291 #endif
292 
293 };
294 
296 public:
298  theCPE(cpe) {}
299 
300  void init(int size);
301 
302  int nDet() const { return id_.size();}
303  unsigned int id(int i) const { return id_[i]; }
304  int find(unsigned int jd, int i=0) const {
305  return std::lower_bound(id_.begin()+i,id_.end(),jd)-id_.begin();
306  }
307 
309  bool isActiveThisPeriod(int i) const { return activeThisPeriod_[i]; }
310 
313  void setActive(int i, bool active) { activeThisPeriod_[i] = active; }
314 
315 
316 private:
318 
319  // Globals (not-per-event)
321 
322  // Locals, per-event
323  std::vector<unsigned int> id_;
324  std::vector<bool> activeThisPeriod_;
325 
326 };
327 
328 
330 public:
333 
335  conditionSet_(&cond),
336  detSet_(cond.nDet()),
337  empty_(cond.nDet(), true),
338  activeThisEvent_(cond.nDet(), true) {}
339 
340  const PxMeasurementConditionSet & conditions() const { return *conditionSet_; }
341 
342  int size() const { return conditions().nDet(); }
343  int nDet() const { return size();}
344  unsigned int id(int i) const { return conditions().id(i); }
345  int find(unsigned int jd, int i=0) const {
346  return conditions().find(jd,i);
347  }
348 
349  void update(int i,const PixelDetSet & detSet ) {
350  detSet_[i] = detSet;
351  empty_[i] = false;
352  }
353 
354  bool empty(int i) const { return empty_[i];}
355  bool isActive(int i) const { return activeThisEvent_[i] && conditions().isActiveThisPeriod(i); }
356 
357  void setEmpty(int i) {empty_[i] = true; activeThisEvent_[i] = true; }
358 
359  void setEmpty() {
360  std::fill(empty_.begin(),empty_.end(),true);
361  std::fill(activeThisEvent_.begin(), activeThisEvent_.end(),true);
362  }
363  void setActiveThisEvent(bool active) {
364  std::fill(activeThisEvent_.begin(), activeThisEvent_.end(),active);
365  }
366 
369  void setActiveThisEvent(int i, bool active) { activeThisEvent_[i] = active; if (!active) empty_[i] = true; }
372  const PixelDetSet & detSet(int i) const { return detSet_[i];}
373 private:
375 
377 
378  // Globals, per-event
380 
381  // Locals, per-event
382  std::vector<PixelDetSet> detSet_;
383  std::vector<bool> empty_;
384  std::vector<bool> activeThisEvent_;
385 };
386 
387 #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_
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)
unsigned int offset(bool)
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_
#define COUT
const bool stripDefined(int i) const
bool isActiveThisPeriod(int i) const
const PxMeasurementConditionSet & conditions() const
edm::Handle< edmNew::DetSetVector< SiPixelCluster > > & handle()