Go to the documentation of this file.00001 #ifndef RECOLOCALTRACKER_SISTRIPZEROSUPPRESSION_SISTRIPCOMMONMODENOISESUBTRACTOR_H
00002 #define RECOLOCALTRACKER_SISTRIPZEROSUPPRESSION_SISTRIPCOMMONMODENOISESUBTRACTOR_H
00003
00004 #include "FWCore/Framework/interface/EventSetup.h"
00005 #include <vector>
00006 #include <algorithm>
00007 #include <stdint.h>
00008
00009 class SiStripCommonModeNoiseSubtractor {
00010
00011 friend class SiStripRawProcessingFactory;
00012
00013 public:
00014
00015 virtual ~SiStripCommonModeNoiseSubtractor() {};
00016 virtual void init(const edm::EventSetup& es) {};
00017 virtual void subtract(const uint32_t&, const uint16_t&, std::vector<int16_t>&) = 0;
00018 virtual void subtract(const uint32_t&, const uint16_t&, std::vector<float>&) = 0;
00019
00020 const std::vector< std::pair<short,float> >& getAPVsCM(){return _vmedians;}
00021
00022 protected:
00023
00024 SiStripCommonModeNoiseSubtractor(){};
00025 template<typename T> float median(std::vector<T>&);
00026
00027 std::vector< std::pair<short,float> > _vmedians;
00028 };
00029
00030
00031
00032
00033 template<typename T>
00034 inline
00035 float SiStripCommonModeNoiseSubtractor::
00036 median( std::vector<T>& sample) {
00037 typename std::vector<T>::iterator mid = sample.begin() + sample.size()/2;
00038 std::nth_element(sample.begin(), mid, sample.end());
00039 if( sample.size() & 1 )
00040 return *mid;
00041 return ( *std::max_element(sample.begin(), mid) + *mid ) / 2.;
00042 }
00043
00044 #endif