File indexing completed on 2024-04-06 12:26:31
0001 #include "RecoLocalTracker/SiStripZeroSuppression/interface/MedianCMNSubtractor.h"
0002
0003 void MedianCMNSubtractor::subtract(uint32_t detId, uint16_t firstAPV, std::vector<int16_t>& digis) {
0004 subtract_(detId, firstAPV, digis);
0005 }
0006 void MedianCMNSubtractor::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 MedianCMNSubtractor::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;
0015
0016 _vmedians.clear();
0017
0018 while (strip < end) {
0019 endAPV = strip + 128;
0020 tmp.clear();
0021 tmp.insert(tmp.end(), strip, endAPV);
0022 const float offset = median(tmp);
0023
0024 _vmedians.push_back(std::pair<short, float>((strip - digis.begin()) / 128 + firstAPV, offset));
0025
0026 while (strip < endAPV) {
0027 *strip = static_cast<T>(*strip - offset);
0028 strip++;
0029 }
0030 }
0031 }