CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_8_patch3/src/RecoLocalTracker/SiStripZeroSuppression/src/MedianCMNSubtractor.cc

Go to the documentation of this file.
00001 #include "RecoLocalTracker/SiStripZeroSuppression/interface/MedianCMNSubtractor.h"
00002 
00003 void MedianCMNSubtractor::subtract(const uint32_t& detId,const uint16_t& firstAPV, std::vector<int16_t>& digis) {subtract_(detId,firstAPV,digis);}
00004 void MedianCMNSubtractor::subtract(const uint32_t& detId,const uint16_t& firstAPV, std::vector<float>& digis) {subtract_(detId,firstAPV, digis);}
00005 
00006 template<typename T> 
00007 inline
00008 void MedianCMNSubtractor::
00009 subtract_(const uint32_t& detId,const uint16_t& firstAPV, std::vector<T>& digis){
00010   
00011   std::vector<T> tmp;  tmp.reserve(128);  
00012   typename std::vector<T>::iterator  
00013     strip( digis.begin() ), 
00014     end(   digis.end()   ),
00015     endAPV;
00016   
00017   _vmedians.clear();
00018   
00019   while( strip < end ) {
00020     endAPV = strip+128; tmp.clear();
00021     tmp.insert(tmp.end(),strip,endAPV);
00022     const float offset = median(tmp);
00023 
00024     _vmedians.push_back(std::pair<short,float>((strip-digis.begin())/128+firstAPV,offset));
00025     
00026     while (strip < endAPV) {
00027       *strip = static_cast<T>(*strip-offset);
00028       strip++;
00029     }
00030 
00031   }
00032 }