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 
10 
12 
13  public:
14 
16  virtual void init(const edm::EventSetup& es) {};
17  virtual void subtract(uint32_t detId, uint16_t firstStrip, std::vector<int16_t>& digis) = 0;
18  virtual void subtract(uint32_t detId, uint16_t firstStrip, std::vector<float>& digis) = 0;
19 
20  const std::vector< std::pair<short,float> >& getAPVsCM() const { return _vmedians; }
21 
22  protected:
23 
25  template<typename T> float median(std::vector<T>&);
26 
27  std::vector< std::pair<short,float> > _vmedians;
28 };
29 
30 template<typename T>
31 inline
33 median( std::vector<T>& sample) {
34  typename std::vector<T>::iterator mid = sample.begin() + sample.size()/2;
35  std::nth_element(sample.begin(), mid, sample.end());
36  if( sample.size() & 1 ) //odd size
37  return *mid;
38  return ( *std::max_element(sample.begin(), mid) + *mid ) / 2.;
39 }
40 #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
std::vector< std::pair< short, float > > _vmedians
virtual void init(const edm::EventSetup &es)