test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PercentileCMNSubtractor.cc
Go to the documentation of this file.
2 
3 void PercentileCMNSubtractor::subtract(const uint32_t& detId, const uint16_t& firstAPV, std::vector<int16_t>& digis) {subtract_(detId, firstAPV, digis);}
4 void PercentileCMNSubtractor::subtract(const uint32_t& detId, const uint16_t& firstAPV, std::vector<float>& digis) {subtract_(detId,firstAPV, digis);}
5 
6 template<typename T>
7 inline
9 subtract_(const uint32_t& detId,const uint16_t& firstAPV, std::vector<T>& digis){
10 
11  std::vector<T> tmp; tmp.reserve(128);
12  typename std::vector<T>::iterator
13  strip( digis.begin() ),
14  end( digis.end() ),
15  endAPV;
16 
17  _vmedians.clear();
18 
19  while( strip < end ) {
20  endAPV = strip+128; 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 
34 
35 template<typename T>
36 inline
38 percentile( std::vector<T>& sample, double pct) {
39  typename std::vector<T>::iterator mid = sample.begin() + int(sample.size()*pct/100.0);
40  std::nth_element(sample.begin(), mid, sample.end());
41  return *mid;
42 }
43 
float percentile(std::vector< T > &, double)
void subtract_(const uint32_t &, const uint16_t &firstAPV, std::vector< T > &)
void subtract(const uint32_t &, const uint16_t &firstAPV, std::vector< int16_t > &)
#define end
Definition: vmac.h:37
std::vector< std::pair< short, float > > _vmedians
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
long double T