CMS 3D CMS Logo

SiStripCommonModeNoiseSubtractor.h
Go to the documentation of this file.
1 #ifndef RECOLOCALTRACKER_SISTRIPZEROSUPPRESSION_SISTRIPCOMMONMODENOISESUBTRACTOR_H
2 #define RECOLOCALTRACKER_SISTRIPZEROSUPPRESSION_SISTRIPCOMMONMODENOISESUBTRACTOR_H
3 
5 #include <vector>
6 #include <algorithm>
7 #include <cstdint>
8 
11 
12 public:
14  virtual void init(const edm::EventSetup& es){};
15  virtual void subtract(uint32_t detId, uint16_t firstStrip, std::vector<int16_t>& digis) = 0;
16  virtual void subtract(uint32_t detId, uint16_t firstStrip, std::vector<float>& digis) = 0;
17 
18  const std::vector<std::pair<short, float> >& getAPVsCM() const { return _vmedians; }
19 
20 protected:
22  template <typename T>
23  float median(std::vector<T>&);
24 
25  std::vector<std::pair<short, float> > _vmedians;
26 };
27 
28 template <typename T>
29 inline float SiStripCommonModeNoiseSubtractor::median(std::vector<T>& sample) {
30  typename std::vector<T>::iterator mid = sample.begin() + sample.size() / 2;
31  std::nth_element(sample.begin(), mid, sample.end());
32  if (sample.size() & 1) //odd size
33  return *mid;
34  return (*std::max_element(sample.begin(), mid) + *mid) / 2.;
35 }
36 #endif
const std::vector< std::pair< short, float > > & getAPVsCM() const
virtual void subtract(uint32_t detId, uint16_t firstStrip, std::vector< int16_t > &digis)=0
virtual void init(const edm::EventSetup &es)
std::vector< std::pair< short, float > > _vmedians