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 /* Struct of arrays supporting "members of Tk...MeasurementDet
25  * implemented with vectors, to be optimized...
26  ITEMS THAT DO NOT DEPEND ON THE EVENT
27  */
28 
30 public:
31  enum QualityFlags { BadModules=1, // for everybody
33  /* Pixels: */ BadROCs=2 };
34 
35  struct BadStripCuts {
38  maxBad(pset.getParameter<uint32_t>("maxBad")),
39  maxConsecutiveBad(pset.getParameter<uint32_t>("maxConsecutiveBad")) {}
41  };
42 
43  struct BadStripBlock {
44  short first;
45  short last;
46  BadStripBlock(const SiStripBadStrip::data &data) : first(data.firstStrip), last(data.firstStrip+data.range-1) { }
47  };
48 
49 
52  bool regional):
53  theMatcher(matcher), theCPE(cpe), regional_(regional){}
54 
55 
56  void init(int size);
57 
58  const SiStripRecHitMatcher* matcher() const { return theMatcher;}
60 
61 
62  int nDet() const { return id_.size();}
63  unsigned int id(int i) const { return id_[i]; }
64  unsigned char subId(int i) const { return subId_[i];}
65 
66  int find(unsigned int jd, int i=0) const {
67  return std::lower_bound(id_.begin()+i,id_.end(),jd)-id_.begin();
68  }
69 
70  bool isRegional() const { return regional_;}
71  bool isActiveThisPeriod(int i) const { return activeThisPeriod_[i]; }
72 
73 
75  void setActive(int i, bool active) { activeThisPeriod_[i] = active; }
76 
77  int totalStrips(int i) const { return totalStrips_[i];}
78 
79  void setMaskBad128StripBlocks(bool maskThem) { maskBad128StripBlocks_ = maskThem; }
80  const BadStripCuts & badStripCuts(int i) const { return badStripCuts_[subId_[i]];}
81 
83  bool hasAny128StripBad(int i) const { return hasAny128StripBad_[i];}
84 
85  std::vector<BadStripBlock> & getBadStripBlocks(int i) { return badStripBlocks_[i]; }
86  std::vector<BadStripBlock> const & badStripBlocks(int i) const {return badStripBlocks_[i]; }
87 
88  bool isMasked(int i, const SiStripCluster &cluster) const {
89  int offset = nbad128*i;
90  if ( bad128Strip_[offset+( cluster.firstStrip() >> 7)] ) {
91  if ( bad128Strip_[offset+( (cluster.firstStrip()+cluster.amplitudes().size()) >> 7)] ||
92  bad128Strip_[offset+( static_cast<int32_t>(cluster.barycenter()-0.499999) >> 7)] ) {
93  return true;
94  }
95  } else {
96  if ( bad128Strip_[offset+( (cluster.firstStrip()+cluster.amplitudes().size()) >> 7)] &&
97  bad128Strip_[offset+( static_cast<int32_t>(cluster.barycenter()-0.499999) >> 7)] ) {
98  return true;
99  }
100  }
101  return false;
102  }
103 
104 
105  void set128StripStatus(int i, bool good, int idx=-1);
106 
107 private:
108 
110 
111  // globals
114  bool regional_;
115 
118 
119  // members of TkStripMeasurementDet
120  std::vector<unsigned int> id_;
121  std::vector<unsigned char> subId_;
122 
123  std::vector<int> totalStrips_;
124 
125  static const int nbad128 = 6;
126  std::vector<bool> bad128Strip_;
127  std::vector<bool> hasAny128StripBad_;
128 
129  std::vector<std::vector<BadStripBlock>> badStripBlocks_;
130 
131  std::vector<bool> activeThisPeriod_;
132 };
133 
135 public:
136 
139 
140  typedef std::vector<SiStripCluster>::const_iterator const_iterator;
141 
144 
146  conditionSet_(&cond),
147  empty_(cond.nDet(), true),
148  activeThisEvent_(cond.nDet(), true),
149  detSet_(!cond.isRegional() ? cond.nDet() : 0),
150  clusterI_(cond.isRegional() ? 2*cond.nDet() : 0),
151  refGetter_(0),
153  stripDefined_(cond.isRegional() ? cond.nDet() : 0),
154  stripUpdated_(cond.isRegional() ? cond.nDet() : 0),
155  stripRegions_(cond.isRegional() ? cond.nDet() : 0)
156  {
157  }
158 
159  const StMeasurementConditionSet & conditions() const { return *conditionSet_; }
160 
162 
163  void update(int i,const StripDetset & detSet ) {
164  detSet_[i] = detSet;
165  empty_[i] = false;
166  }
167 
168  void update(int i, std::vector<SiStripCluster>::const_iterator begin ,std::vector<SiStripCluster>::const_iterator end) {
169  clusterI_[2*i] = begin - regionalHandle_->begin_record();
170  clusterI_[2*i+1] = end - regionalHandle_->begin_record();
171 
172  empty_[i] = false;
173  activeThisEvent_[i] = true;
174  }
175 
176  bool isRegional() const { return conditions().isRegional(); }
177 
178  int size() const { return conditions().nDet(); }
179  int nDet() const { return size();}
180  unsigned int id(int i) const { return conditions().id(i); }
181  int find(unsigned int jd, int i=0) const {
182  return conditions().find(jd,i);
183  }
184 
185  bool empty(int i) const { return empty_[i];}
186  bool isActive(int i) const { return activeThisEvent_[i] && conditions().isActiveThisPeriod(i); }
187 
188  void setEmpty(int i) {empty_[i] = true; activeThisEvent_[i] = true; }
189  void setUpdated(int i) { stripUpdated_[i] = true; }
190 
191  void setEmpty() {
192  std::fill(empty_.begin(),empty_.end(),true);
193  std::fill(activeThisEvent_.begin(), activeThisEvent_.end(),true);
194  }
195 
198  void setActiveThisEvent(int i, bool active) { activeThisEvent_[i] = active; if (!active) empty_[i] = true; }
199 
202  StripDetset & detSet(int i) { return detSet_[i]; }
203  const StripDetset & detSet(int i) const { return detSet_[i]; }
204 
207  unsigned int beginClusterI(int i) const {return clusterI_[2*i];}
208  unsigned int endClusterI(int i) const {return clusterI_[2*i+1];}
209 
211  void setRefGetter(const edm::RefGetter<SiStripCluster> &getter) { refGetter_ = &getter; }
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(stripDefined_.begin(), stripDefined_.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  //const bool gluedUpdated(int i) const { return gluedUpdated_(i); }
226  const std::pair<unsigned int,unsigned int> & regionRange(int i) const { return stripRegions_[i]; }
227 
228 private:
231 
233 
236 
237  std::vector<bool> empty_;
238  std::vector<bool> activeThisEvent_;
239 
240  // full reco
241  std::vector<StripDetset> detSet_;
242 
243  // --- regional unpacking
244  // begin,end "pairs"
245  std::vector<unsigned int> clusterI_;
246 
249  // note: not aligned to the index
250  std::vector<uint32_t> theRawInactiveStripDetIds_;
251  // keyed on si-strip index
252  std::vector<bool> stripDefined_, stripUpdated_;
253  std::vector<std::pair<unsigned int, unsigned int> > stripRegions_;
254  // keyed on glued
255  // std::vector<bool> gluedUpdated_;
256 
257 };
258 
260 public:
262  theCPE(cpe) {}
263 
264  void init(int size);
265 
266  int nDet() const { return id_.size();}
267  unsigned int id(int i) const { return id_[i]; }
268  int find(unsigned int jd, int i=0) const {
269  return std::lower_bound(id_.begin()+i,id_.end(),jd)-id_.begin();
270  }
271 
273  bool isActiveThisPeriod(int i) const { return activeThisPeriod_[i]; }
274 
277  void setActive(int i, bool active) { activeThisPeriod_[i] = active; }
278 
279 
280 private:
282 
283  // Globals (not-per-event)
285 
286  // Locals, per-event
287  std::vector<unsigned int> id_;
288  std::vector<bool> activeThisPeriod_;
289 
290 };
291 
292 
294 public:
297 
299  conditionSet_(&cond),
300  detSet_(cond.nDet()),
301  empty_(cond.nDet(), true),
302  activeThisEvent_(cond.nDet(), true) {}
303 
304  const PxMeasurementConditionSet & conditions() const { return *conditionSet_; }
305 
306  int size() const { return conditions().nDet(); }
307  int nDet() const { return size();}
308  unsigned int id(int i) const { return conditions().id(i); }
309  int find(unsigned int jd, int i=0) const {
310  return conditions().find(jd,i);
311  }
312 
313  void update(int i,const PixelDetSet & detSet ) {
314  detSet_[i] = detSet;
315  empty_[i] = false;
316  }
317 
318  bool empty(int i) const { return empty_[i];}
319  bool isActive(int i) const { return activeThisEvent_[i] && conditions().isActiveThisPeriod(i); }
320 
321  void setEmpty(int i) {empty_[i] = true; activeThisEvent_[i] = true; }
322 
323  void setEmpty() {
324  std::fill(empty_.begin(),empty_.end(),true);
325  std::fill(activeThisEvent_.begin(), activeThisEvent_.end(),true);
326  }
327  void setActiveThisEvent(bool active) {
328  std::fill(activeThisEvent_.begin(), activeThisEvent_.end(),active);
329  }
330 
333  void setActiveThisEvent(int i, bool active) { activeThisEvent_[i] = active; if (!active) empty_[i] = true; }
336  const PixelDetSet & detSet(int i) const { return detSet_[i];}
337 private:
339 
341 
342  // Globals, per-event
344 
345  // Locals, per-event
346  std::vector<PixelDetSet> detSet_;
347  std::vector<bool> empty_;
348  std::vector<bool> activeThisEvent_;
349 };
350 
351 #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
StripDetset & detSet(int i)
const PixelClusterParameterEstimator * theCPE
const StripDetset & detSet(int i) const
edm::Ref< edmNew::DetSetVector< SiPixelCluster >, SiPixelCluster > SiPixelClusterRef
StMeasurementDetSet(const StMeasurementConditionSet &cond)
std::vector< bool > stripDefined_
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:27
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
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
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_
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_
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()