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  filter_ = cluster.filter();
30 
31  float halfwidth_ = 0.5f * float(cluster.width());
32 
33  //initialize firstStrip_
34  firstStrip_ = std::max(barycenter_ - halfwidth_, 0.f);
35 
36  if UNLIKELY (firstStrip_ + cluster.width() > maxStrips) {
37  firstStrip_ = maxStrips - cluster.width();
38  }
39 }
40 
42  if (barycenter_ > 0)
43  return charge_;
44  return std::accumulate(begin(), end(), int(0));
45 }
46 
48  if (barycenter_ > 0)
49  return barycenter_;
50 
51  int sumx = 0;
52  int suma = 0;
53  auto asize = size();
54  for (auto i = 0U; i < asize; ++i) {
55  sumx += i * amplitudes_[i];
56  suma += amplitudes_[i];
57  }
58 
59  // strip centers are offcet by half pitch w.r.t. strip numbers,
60  // so one has to add 0.5 to get the correct barycenter position.
61  // Need to mask off the high bit of firstStrip_, which contains the merged status.
62  return float((firstStrip_ & stripIndexMask)) + float(sumx) / float(suma) + 0.5f;
63 }
64 bool SiStripCluster::filter() const {
65  if (barycenter_ > 0)
66  return filter_;
67  return false;
68 }
69 
70 bool SiStripCluster::isFromApprox() const { return (barycenter_ > 0); }
int charge() const
std::pair< SiStripDigiIter, SiStripDigiIter > SiStripDigiRange
auto const * begin() const
auto const * end() const
bool isFromApprox() const
auto size() const
double f[11][100]
bool filter() const
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