CMS 3D CMS Logo

SiStripCluster.cc
Go to the documentation of this file.
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 
25 SiStripCluster::SiStripCluster(const SiStripApproximateCluster cluster, const uint16_t maxStrips) : error_x(-99999.9) {
26  barycenter_ = cluster.barycenter() / 10.0;
27  charge_ = cluster.width() * cluster.avgCharge();
28  amplitudes_.resize(cluster.width(), cluster.avgCharge());
29 
30  float halfwidth_ = 0.5f * float(cluster.width());
31 
32  //initialize firstStrip_
33  firstStrip_ = std::max(barycenter_ - halfwidth_, 0.f);
34 
35  if UNLIKELY (firstStrip_ + cluster.width() > maxStrips) {
36  firstStrip_ = maxStrips - cluster.width();
37  }
38 }
39 
41  if (barycenter_ > 0)
42  return charge_;
43  return std::accumulate(begin(), end(), int(0));
44 }
45 
47  if (barycenter_ > 0)
48  return barycenter_;
49 
50  int sumx = 0;
51  int suma = 0;
52  auto asize = size();
53  for (auto i = 0U; i < asize; ++i) {
54  sumx += i * amplitudes_[i];
55  suma += amplitudes_[i];
56  }
57 
58  // strip centers are offcet by half pitch w.r.t. strip numbers,
59  // so one has to add 0.5 to get the correct barycenter position.
60  // Need to mask off the high bit of firstStrip_, which contains the merged status.
61  return float((firstStrip_ & stripIndexMask)) + float(sumx) / float(suma) + 0.5f;
62 }
int charge() const
std::pair< SiStripDigiIter, SiStripDigiIter > SiStripDigiRange
auto const * begin() const
auto const * end() const
auto size() const
double f[11][100]
std::vector< SiStripDigi >::const_iterator SiStripDigiIter
float barycenter() const
std::vector< uint8_t > amplitudes_
uint16_t firstStrip_
static const uint16_t stripIndexMask
#define UNLIKELY(x)
Definition: Likely.h:21