#include <IteratedMedianCMNSubtractor.h>
Public Member Functions | |
void | init (const edm::EventSetup &es) |
void | subtract (const uint32_t &, std::vector< float > &) |
void | subtract (const uint32_t &, std::vector< int16_t > &) |
Private Member Functions | |
IteratedMedianCMNSubtractor (double sigma, int iterations) | |
template<typename T > | |
void | subtract_ (const uint32_t &, std::vector< T > &) |
Private Attributes | |
double | cut_to_avoid_signal_ |
int | iterations_ |
uint32_t | noise_cache_id |
edm::ESHandle< SiStripNoises > | noiseHandle |
uint32_t | quality_cache_id |
edm::ESHandle< SiStripQuality > | qualityHandle |
Friends | |
class | SiStripRawProcessingFactory |
Definition at line 10 of file IteratedMedianCMNSubtractor.h.
IteratedMedianCMNSubtractor::IteratedMedianCMNSubtractor | ( | double | sigma, |
int | iterations | ||
) | [inline, private] |
Definition at line 25 of file IteratedMedianCMNSubtractor.h.
: cut_to_avoid_signal_(sigma), iterations_(iterations), noise_cache_id(0), quality_cache_id(0) {};
void IteratedMedianCMNSubtractor::init | ( | const edm::EventSetup & | es | ) | [virtual] |
Reimplemented from SiStripCommonModeNoiseSubtractor.
Definition at line 152 of file IteratedMedianCMNSubtractor.cc.
References edm::EventSetup::get(), noise_cache_id, noiseHandle, quality_cache_id, and qualityHandle.
{ uint32_t n_cache_id = es.get<SiStripNoisesRcd>().cacheIdentifier(); uint32_t q_cache_id = es.get<SiStripQualityRcd>().cacheIdentifier(); if(n_cache_id != noise_cache_id) { es.get<SiStripNoisesRcd>().get( noiseHandle ); noise_cache_id = n_cache_id; } if(q_cache_id != quality_cache_id) { es.get<SiStripQualityRcd>().get( qualityHandle ); quality_cache_id = q_cache_id; } }
void IteratedMedianCMNSubtractor::subtract | ( | const uint32_t & | detId, |
std::vector< int16_t > & | digis | ||
) | [virtual] |
Implements SiStripCommonModeNoiseSubtractor.
Definition at line 166 of file IteratedMedianCMNSubtractor.cc.
References subtract_().
{ subtract_(detId,digis);}
void IteratedMedianCMNSubtractor::subtract | ( | const uint32_t & | detId, |
std::vector< float > & | digis | ||
) | [virtual] |
Implements SiStripCommonModeNoiseSubtractor.
Definition at line 167 of file IteratedMedianCMNSubtractor.cc.
References subtract_().
{ subtract_(detId,digis);}
void IteratedMedianCMNSubtractor::subtract_ | ( | const uint32_t & | detId, |
std::vector< T > & | digis | ||
) | [inline, private] |
Definition at line 172 of file IteratedMedianCMNSubtractor.cc.
References SiStripCommonModeNoiseSubtractor::_vmedians, sistrip::APV, begin, cut_to_avoid_signal_, end, iterations_, j, python::rootplot::utilities::ls(), noiseHandle, evf::evtn::offset(), convertSQLiteXML::ok, and qualityHandle.
Referenced by subtract().
{ SiStripNoises::Range detNoiseRange = noiseHandle->getRange(detId); SiStripQuality::Range detQualityRange = qualityHandle->getRange(detId); typename std::vector<T>::iterator fs,ls; float offset = 0; std::pair<float,float> subset[128]; bool ok[128]; int subsetSize=0; typedef std::pair<float,float> const * iterator; SelectElem selector(subset,ok); _vmedians.clear(); for( uint16_t APV=0; APV< digis.size()/128; ++APV) { subsetSize=0; // fill subset vector with all good strips and their noises for (uint16_t istrip=APV*128; istrip<(APV+1)*128; ++istrip) { if ( !qualityHandle->IsStripBad(detQualityRange,istrip) ) { std::pair<float,float> pin((float)digis[istrip], (float)noiseHandle->getNoiseFast(istrip,detNoiseRange)); subset[subsetSize]= pin; ok[subsetSize++]=true; } } if (subsetSize == 0) continue; // std::cout << "subset size " << subsetSize << std::endl; ElemIterator begin(selector,subset,subset+subsetSize); ElemIterator end(selector,subset+subsetSize,subset+subsetSize); // caluate offset for all good strips (first iteration) offset = pairMedian(begin,end); // for second, third... iterations, remove strips over threshold // and recalculate offset on remaining strips int nokold=subsetSize; for ( int ii = 0; ii<iterations_-1; ++ii ) { int nok=0; for (int j=0; j!=subsetSize;++j) { iterator si = subset+j; ok[j] = si->first-offset < cut_to_avoid_signal_*si->second; ++nok; } if (nok==nokold) break; // std::cout << "converged at " << ii << std::endl; if (nok == 0 ) break; offset = pairMedian(begin,end); nokold=nok; } _vmedians.push_back(std::pair<short,float>(APV,offset)); // remove offset fs = digis.begin()+APV*128; ls = digis.begin()+(APV+1)*128; while (fs < ls) { *fs = static_cast<T>(*fs-offset); fs++; } } // std::cout << "IMCMNS end " << _vmedians.size() << std::endl; }
friend class SiStripRawProcessingFactory [friend] |
Reimplemented from SiStripCommonModeNoiseSubtractor.
Definition at line 12 of file IteratedMedianCMNSubtractor.h.
double IteratedMedianCMNSubtractor::cut_to_avoid_signal_ [private] |
Definition at line 29 of file IteratedMedianCMNSubtractor.h.
Referenced by subtract_().
int IteratedMedianCMNSubtractor::iterations_ [private] |
Definition at line 31 of file IteratedMedianCMNSubtractor.h.
Referenced by subtract_().
uint32_t IteratedMedianCMNSubtractor::noise_cache_id [private] |
Definition at line 34 of file IteratedMedianCMNSubtractor.h.
Referenced by init().
Definition at line 32 of file IteratedMedianCMNSubtractor.h.
Referenced by init(), and subtract_().
uint32_t IteratedMedianCMNSubtractor::quality_cache_id [private] |
Definition at line 34 of file IteratedMedianCMNSubtractor.h.
Referenced by init().
Definition at line 33 of file IteratedMedianCMNSubtractor.h.
Referenced by init(), and subtract_().