CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
PercentileCMNSubtractor.cc
Go to the documentation of this file.
2 
3 void PercentileCMNSubtractor::subtract(uint32_t detId, uint16_t firstAPV, std::vector<int16_t>& digis) {
4  subtract_(detId, firstAPV, digis);
5 }
6 void PercentileCMNSubtractor::subtract(uint32_t detId, uint16_t firstAPV, std::vector<float>& digis) {
7  subtract_(detId, firstAPV, digis);
8 }
9 
10 template <typename T>
11 inline void PercentileCMNSubtractor::subtract_(uint32_t detId, uint16_t firstAPV, std::vector<T>& digis) {
12  std::vector<T> tmp;
13  tmp.reserve(128);
14  typename std::vector<T>::iterator strip(digis.begin()), end(digis.end()), endAPV;
15 
16  _vmedians.clear();
17 
18  while (strip < end) {
19  endAPV = strip + 128;
20  tmp.clear();
21  tmp.insert(tmp.end(), strip, endAPV);
22  const float offset = percentile(tmp, percentile_);
23 
24  _vmedians.push_back(std::pair<short, float>((strip - digis.begin()) / 128 + firstAPV, offset));
25 
26  while (strip < endAPV) {
27  *strip = static_cast<T>(*strip - offset);
28  strip++;
29  }
30  }
31 }
32 
33 template <typename T>
34 inline float PercentileCMNSubtractor::percentile(std::vector<T>& sample, double pct) {
35  typename std::vector<T>::iterator mid = sample.begin() + int(sample.size() * pct / 100.0);
36  std::nth_element(sample.begin(), mid, sample.end());
37  return *mid;
38 }
float percentile(std::vector< T > &, double)
string end
Definition: dataset.py:937
void subtract(uint32_t detId, uint16_t firstAPV, std::vector< int16_t > &digis) override
tmp
align.sh
Definition: createJobs.py:716
long double T
std::vector< std::pair< short, float > > _vmedians
void subtract_(uint32_t detId, uint16_t firstAPV, std::vector< T > &digis)