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
SiStripCommonModeNoiseSubtractor::median
float median(std::vector< T > &)
Definition: SiStripCommonModeNoiseSubtractor.h:29
simplePhotonAnalyzer_cfi.sample
sample
Definition: simplePhotonAnalyzer_cfi.py:12
SiStripCommonModeNoiseSubtractor::subtract
virtual void subtract(uint32_t detId, uint16_t firstStrip, std::vector< int16_t > &digis)=0
SiStripCommonModeNoiseSubtractor::_vmedians
std::vector< std::pair< short, float > > _vmedians
Definition: SiStripCommonModeNoiseSubtractor.h:25
SiStripRawProcessingFactory
Definition: SiStripRawProcessingFactory.h:15
SiStripCommonModeNoiseSubtractor::SiStripCommonModeNoiseSubtractor
SiStripCommonModeNoiseSubtractor()
Definition: SiStripCommonModeNoiseSubtractor.h:21
SiStripCommonModeNoiseSubtractor::getAPVsCM
const std::vector< std::pair< short, float > > & getAPVsCM() const
Definition: SiStripCommonModeNoiseSubtractor.h:18
SiStripCommonModeNoiseSubtractor
Definition: SiStripCommonModeNoiseSubtractor.h:9
edm::EventSetup
Definition: EventSetup.h:57
SiStripCommonModeNoiseSubtractor::~SiStripCommonModeNoiseSubtractor
virtual ~SiStripCommonModeNoiseSubtractor()
Definition: SiStripCommonModeNoiseSubtractor.h:13
EventSetup.h
SiStripCommonModeNoiseSubtractor::init
virtual void init(const edm::EventSetup &es)
Definition: SiStripCommonModeNoiseSubtractor.h:14