Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:26:31

0001 #include "RecoLocalTracker/SiStripZeroSuppression/interface/FastLinearCMNSubtractor.h"
0002 
0003 void FastLinearCMNSubtractor::subtract(uint32_t detId, uint16_t firstAPV, std::vector<int16_t>& digis) {
0004   subtract_(detId, firstAPV, digis);
0005 }
0006 void FastLinearCMNSubtractor::subtract(uint32_t detId, uint16_t firstAPV, std::vector<float>& digis) {
0007   subtract_(detId, firstAPV, digis);
0008 }
0009 
0010 template <typename T>
0011 inline void FastLinearCMNSubtractor::subtract_(uint32_t detId, uint16_t firstAPV, std::vector<T>& digis) {
0012   std::vector<T> tmp;
0013   tmp.reserve(128);
0014   typename std::vector<T>::iterator strip(digis.begin()), end(digis.end()), endAPV, high, low;
0015 
0016   while (strip < end) {
0017     endAPV = strip + 128;
0018     tmp.clear();
0019     tmp.insert(tmp.end(), strip, endAPV);
0020     const float offset = median(tmp);
0021 
0022     low = strip;
0023     high = strip + 64;
0024     tmp.clear();
0025     while (high < endAPV)
0026       tmp.push_back(*high++ - *low++);
0027     const float slope = median(tmp) / 64.;
0028 
0029     while (strip < endAPV) {
0030       *strip = static_cast<T>(*strip - (offset + slope * (65 - (endAPV - strip))));
0031       strip++;
0032     }
0033   }
0034 }
0035 
0036 // Details on http://abbaneo.web.cern.ch/abbaneo/cmode/cm.html