File indexing completed on 2025-01-21 01:39:40
0001 #include "FWCore/Utilities/interface/Likely.h"
0002 #include "DataFormats/SiStripCluster/interface/SiStripCluster.h"
0003
0004 SiStripCluster::SiStripCluster(const SiStripDigiRange& range) : firstStrip_(range.first->strip()), error_x(-99999.9) {
0005 std::vector<uint8_t> v;
0006 v.reserve(range.second - range.first);
0007
0008 uint16_t lastStrip = 0;
0009 bool firstInloop = true;
0010 for (SiStripDigiIter i = range.first; i != range.second; i++) {
0011
0012 if (!firstInloop && i->strip() != lastStrip + 1) {
0013 for (int j = 0; j < i->strip() - (lastStrip + 1); j++) {
0014 v.push_back(0);
0015 }
0016 }
0017 lastStrip = i->strip();
0018 firstInloop = false;
0019
0020 v.push_back(i->adc());
0021 }
0022 amplitudes_ = v;
0023 initQB();
0024 }
0025
0026 SiStripCluster::SiStripCluster(const SiStripApproximateCluster cluster, const uint16_t maxStrips) : error_x(-99999.9) {
0027 barycenter_ = cluster.barycenter() / 10.0;
0028 charge_ = cluster.width() * cluster.avgCharge();
0029 amplitudes_.resize(cluster.width(), cluster.avgCharge());
0030 filter_ = cluster.filter();
0031
0032 float halfwidth_ = 0.5f * float(cluster.width());
0033
0034
0035 firstStrip_ = std::max(barycenter_ - halfwidth_, 0.f);
0036
0037 if UNLIKELY (firstStrip_ + cluster.width() > maxStrips) {
0038 firstStrip_ = maxStrips - cluster.width();
0039 }
0040 firstStrip_ |= approximateMask;
0041 }