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