CMS 3D CMS Logo

SiStripCluster.cc
Go to the documentation of this file.
1 
3 
4 SiStripCluster::SiStripCluster(const SiStripDigiRange& range) : firstStrip_(range.first->strip()), error_x(-99999.9) {
5  std::vector<uint8_t> v;
6  v.reserve(range.second - range.first);
7 
8  uint16_t lastStrip = 0;
9  bool firstInloop = true;
10  for (SiStripDigiIter i = range.first; i != range.second; i++) {
12  if (!firstInloop && i->strip() != lastStrip + 1) {
13  for (int j = 0; j < i->strip() - (lastStrip + 1); j++) {
14  v.push_back(0);
15  }
16  }
17  lastStrip = i->strip();
18  firstInloop = false;
19 
20  v.push_back(i->adc());
21  }
22  amplitudes_ = v;
23 }
24 
26  int sumx = 0;
27  int suma = 0;
28  auto asize = size();
29  for (auto i = 0U; i < asize; ++i) {
30  sumx += i * amplitudes_[i];
31  suma += amplitudes_[i];
32  }
33 
34  // strip centers are offcet by half pitch w.r.t. strip numbers,
35  // so one has to add 0.5 to get the correct barycenter position.
36  // Need to mask off the high bit of firstStrip_, which contains the merged status.
37  return float((firstStrip_ & stripIndexMask)) + float(sumx) / float(suma) + 0.5f;
38 }
std::pair< SiStripDigiIter, SiStripDigiIter > SiStripDigiRange
auto size() const
std::vector< SiStripDigi >::const_iterator SiStripDigiIter
float barycenter() const
std::vector< uint8_t > amplitudes_
uint16_t firstStrip_
static const uint16_t stripIndexMask