CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 <stdint.h>
8 
10 
12 
13  public:
14 
16  virtual void init(const edm::EventSetup& es) {};
17  virtual void subtract(const uint32_t&, const uint16_t&, std::vector<int16_t>&) = 0;
18  virtual void subtract(const uint32_t&, const uint16_t&, std::vector<float>&) = 0;
19 
20  const std::vector< std::pair<short,float> >& getAPVsCM(){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 
31 
32 
33 template<typename T>
34 inline
36 median( std::vector<T>& sample) {
37  typename std::vector<T>::iterator mid = sample.begin() + sample.size()/2;
38  std::nth_element(sample.begin(), mid, sample.end());
39  if( sample.size() & 1 ) //odd size
40  return *mid;
41  return ( *std::max_element(sample.begin(), mid) + *mid ) / 2.;
42 }
43 
44 #endif
virtual void subtract(const uint32_t &, const uint16_t &, std::vector< int16_t > &)=0
const std::vector< std::pair< short, float > > & getAPVsCM()
std::vector< std::pair< short, float > > _vmedians
virtual void init(const edm::EventSetup &es)