CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes | Friends
IteratedMedianCMNSubtractor Class Reference

#include <IteratedMedianCMNSubtractor.h>

Inheritance diagram for IteratedMedianCMNSubtractor:
SiStripCommonModeNoiseSubtractor

Public Member Functions

void init (const edm::EventSetup &es) override
 
void subtract (uint32_t detId, uint16_t firstAPV, std::vector< float > &digis) override
 
void subtract (uint32_t detId, uint16_t firstAPV, std::vector< int16_t > &digis) override
 
- Public Member Functions inherited from SiStripCommonModeNoiseSubtractor
const std::vector< std::pair< short, float > > & getAPVsCM () const
 
virtual ~SiStripCommonModeNoiseSubtractor ()
 

Private Member Functions

 IteratedMedianCMNSubtractor (double sigma, int iterations, edm::ConsumesCollector iC)
 
float pairMedian (std::vector< std::pair< float, float > > &sample)
 
template<typename T >
void subtract_ (uint32_t detId, uint16_t firstAPV, std::vector< T > &digis)
 

Private Attributes

double cut_to_avoid_signal_
 
int iterations_
 
const SiStripNoisesnoiseHandle
 
edm::ESGetToken< SiStripNoises, SiStripNoisesRcdnoiseToken_
 
edm::ESWatcher< SiStripNoisesRcdnoiseWatcher_
 
const SiStripQualityqualityHandle
 
edm::ESGetToken< SiStripQuality, SiStripQualityRcdqualityToken_
 
edm::ESWatcher< SiStripQualityRcdqualityWatcher_
 

Friends

class SiStripRawProcessingFactory
 

Additional Inherited Members

- Protected Member Functions inherited from SiStripCommonModeNoiseSubtractor
template<typename T >
float median (std::vector< T > &)
 
 SiStripCommonModeNoiseSubtractor ()
 
- Protected Attributes inherited from SiStripCommonModeNoiseSubtractor
std::vector< std::pair< short, float > > _vmedians
 

Detailed Description

Definition at line 14 of file IteratedMedianCMNSubtractor.h.

Constructor & Destructor Documentation

◆ IteratedMedianCMNSubtractor()

IteratedMedianCMNSubtractor::IteratedMedianCMNSubtractor ( double  sigma,
int  iterations,
edm::ConsumesCollector  iC 
)
inlineprivate

Member Function Documentation

◆ init()

void IteratedMedianCMNSubtractor::init ( const edm::EventSetup es)
overridevirtual

◆ pairMedian()

float IteratedMedianCMNSubtractor::pairMedian ( std::vector< std::pair< float, float > > &  sample)
inlineprivate

Definition at line 78 of file IteratedMedianCMNSubtractor.cc.

78  {
79  std::vector<std::pair<float, float> >::iterator mid = sample.begin() + sample.size() / 2;
80  std::nth_element(sample.begin(), mid, sample.end());
81  if (sample.size() & 1) //odd size
82  return (*mid).first;
83  return ((*std::max_element(sample.begin(), mid)).first + (*mid).first) / 2.;
84 }

References mathSSE::return(), and simplePhotonAnalyzer_cfi::sample.

Referenced by subtract_().

◆ subtract() [1/2]

void IteratedMedianCMNSubtractor::subtract ( uint32_t  detId,
uint16_t  firstAPV,
std::vector< float > &  digis 
)
overridevirtual

Implements SiStripCommonModeNoiseSubtractor.

Definition at line 19 of file IteratedMedianCMNSubtractor.cc.

19  {
20  subtract_(detId, firstAPV, digis);
21 }

References subtract_().

◆ subtract() [2/2]

void IteratedMedianCMNSubtractor::subtract ( uint32_t  detId,
uint16_t  firstAPV,
std::vector< int16_t > &  digis 
)
overridevirtual

Implements SiStripCommonModeNoiseSubtractor.

Definition at line 16 of file IteratedMedianCMNSubtractor.cc.

16  {
17  subtract_(detId, firstAPV, digis);
18 }

References subtract_().

◆ subtract_()

template<typename T >
void IteratedMedianCMNSubtractor::subtract_ ( uint32_t  detId,
uint16_t  firstAPV,
std::vector< T > &  digis 
)
inlineprivate

Definition at line 24 of file IteratedMedianCMNSubtractor.cc.

24  {
25  SiStripNoises::Range detNoiseRange = noiseHandle->getRange(detId);
26  SiStripQuality::Range detQualityRange = qualityHandle->getRange(detId);
27 
28  typename std::vector<T>::iterator fs, ls;
29  float offset = 0;
30  std::vector<std::pair<float, float> > subset;
31  subset.reserve(128);
32 
33  _vmedians.clear();
34 
35  uint16_t APV = firstAPV;
36  for (; APV < digis.size() / 128 + firstAPV; ++APV) {
37  subset.clear();
38  // fill subset vector with all good strips and their noises
39  for (uint16_t istrip = APV * 128; istrip < (APV + 1) * 128; ++istrip) {
40  if (!qualityHandle->IsStripBad(detQualityRange, istrip)) {
41  std::pair<float, float> pin((float)digis[istrip - firstAPV * 128],
42  (float)noiseHandle->getNoiseFast(istrip, detNoiseRange));
43  subset.push_back(pin);
44  }
45  }
46 
47  // caluate offset for all good strips (first iteration)
48  if (!subset.empty())
49  offset = pairMedian(subset);
50 
51  // for second, third... iterations, remove strips over threshold
52  // and recalculate offset on remaining strips
53  for (int ii = 0; ii < iterations_ - 1; ++ii) {
54  std::vector<std::pair<float, float> >::iterator si = subset.begin();
55  while (si != subset.end()) {
56  if (si->first - offset > cut_to_avoid_signal_ * si->second)
57  si = subset.erase(si);
58  else
59  ++si;
60  }
61  if (subset.empty())
62  break;
63  offset = pairMedian(subset);
64  }
65 
66  _vmedians.push_back(std::pair<short, float>(APV, offset));
67 
68  // remove offset
69  fs = digis.begin() + (APV - firstAPV) * 128;
70  ls = digis.begin() + (APV - firstAPV + 1) * 128;
71  while (fs < ls) {
72  *fs = static_cast<T>(*fs - offset);
73  fs++;
74  }
75  }
76 }

References SiStripCommonModeNoiseSubtractor::_vmedians, sistrip::APV, cut_to_avoid_signal_, SiStripNoises::getNoiseFast(), SiStripNoises::getRange(), SiStripBadStrip::getRange(), cuy::ii, SiStripQuality::IsStripBad(), iterations_, eostools::ls(), noiseHandle, hltrates_dqm_sourceclient-live_cfg::offset, pairMedian(), and qualityHandle.

Referenced by subtract().

Friends And Related Function Documentation

◆ SiStripRawProcessingFactory

friend class SiStripRawProcessingFactory
friend

Definition at line 15 of file IteratedMedianCMNSubtractor.h.

Member Data Documentation

◆ cut_to_avoid_signal_

double IteratedMedianCMNSubtractor::cut_to_avoid_signal_
private

Definition at line 31 of file IteratedMedianCMNSubtractor.h.

Referenced by subtract_().

◆ iterations_

int IteratedMedianCMNSubtractor::iterations_
private

Definition at line 33 of file IteratedMedianCMNSubtractor.h.

Referenced by subtract_().

◆ noiseHandle

const SiStripNoises* IteratedMedianCMNSubtractor::noiseHandle
private

Definition at line 36 of file IteratedMedianCMNSubtractor.h.

Referenced by init(), and subtract_().

◆ noiseToken_

edm::ESGetToken<SiStripNoises, SiStripNoisesRcd> IteratedMedianCMNSubtractor::noiseToken_
private

Definition at line 34 of file IteratedMedianCMNSubtractor.h.

Referenced by init().

◆ noiseWatcher_

edm::ESWatcher<SiStripNoisesRcd> IteratedMedianCMNSubtractor::noiseWatcher_
private

Definition at line 38 of file IteratedMedianCMNSubtractor.h.

Referenced by init().

◆ qualityHandle

const SiStripQuality* IteratedMedianCMNSubtractor::qualityHandle
private

Definition at line 37 of file IteratedMedianCMNSubtractor.h.

Referenced by init(), and subtract_().

◆ qualityToken_

edm::ESGetToken<SiStripQuality, SiStripQualityRcd> IteratedMedianCMNSubtractor::qualityToken_
private

Definition at line 35 of file IteratedMedianCMNSubtractor.h.

Referenced by init().

◆ qualityWatcher_

edm::ESWatcher<SiStripQualityRcd> IteratedMedianCMNSubtractor::qualityWatcher_
private

Definition at line 39 of file IteratedMedianCMNSubtractor.h.

Referenced by init().

edm::ESWatcher::check
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
eostools.ls
def ls(path, rec=False)
Definition: eostools.py:349
SiStripNoises::getNoiseFast
static float getNoiseFast(const uint16_t &strip, const Range &range)
Definition: SiStripNoises.h:68
SiStripBadStrip::getRange
const Range getRange(const uint32_t detID) const
Definition: SiStripBadStrip.cc:27
IteratedMedianCMNSubtractor::pairMedian
float pairMedian(std::vector< std::pair< float, float > > &sample)
Definition: IteratedMedianCMNSubtractor.cc:78
IteratedMedianCMNSubtractor::noiseToken_
edm::ESGetToken< SiStripNoises, SiStripNoisesRcd > noiseToken_
Definition: IteratedMedianCMNSubtractor.h:34
simplePhotonAnalyzer_cfi.sample
sample
Definition: simplePhotonAnalyzer_cfi.py:12
SiStripNoises
Definition: SiStripNoises.h:25
SiStripCommonModeNoiseSubtractor::_vmedians
std::vector< std::pair< short, float > > _vmedians
Definition: SiStripCommonModeNoiseSubtractor.h:25
IteratedMedianCMNSubtractor::qualityToken_
edm::ESGetToken< SiStripQuality, SiStripQualityRcd > qualityToken_
Definition: IteratedMedianCMNSubtractor.h:35
IteratedMedianCMNSubtractor::qualityWatcher_
edm::ESWatcher< SiStripQualityRcd > qualityWatcher_
Definition: IteratedMedianCMNSubtractor.h:39
mathSSE::return
return((rh ^ lh) &mask)
SiStripNoises::getRange
const Range getRange(const uint32_t detID) const
Definition: SiStripNoises.cc:34
edm::ConsumesCollector::esConsumes
auto esConsumes()
Definition: ConsumesCollector.h:97
SiStripNoisesRcd
Definition: SiStripCondDataRecords.h:40
IteratedMedianCMNSubtractor::noiseWatcher_
edm::ESWatcher< SiStripNoisesRcd > noiseWatcher_
Definition: IteratedMedianCMNSubtractor.h:38
SiStripBadStrip::Range
std::pair< ContainerIterator, ContainerIterator > Range
Definition: SiStripBadStrip.h:53
SiStripNoises::Range
std::pair< ContainerIterator, ContainerIterator > Range
Definition: SiStripNoises.h:47
SiStripQualityRcd
Definition: SiStripDependentRecords.h:51
SiStripQuality::IsStripBad
bool IsStripBad(const uint32_t &detid, const short &strip) const
Definition: SiStripQuality.cc:582
IteratedMedianCMNSubtractor::subtract_
void subtract_(uint32_t detId, uint16_t firstAPV, std::vector< T > &digis)
Definition: IteratedMedianCMNSubtractor.cc:24
IteratedMedianCMNSubtractor::noiseHandle
const SiStripNoises * noiseHandle
Definition: IteratedMedianCMNSubtractor.h:36
sistrip::APV
Definition: ConstantsForGranularity.h:79
IteratedMedianCMNSubtractor::iterations_
int iterations_
Definition: IteratedMedianCMNSubtractor.h:33
IteratedMedianCMNSubtractor::cut_to_avoid_signal_
double cut_to_avoid_signal_
Definition: IteratedMedianCMNSubtractor.h:31
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:127
IteratedMedianCMNSubtractor::qualityHandle
const SiStripQuality * qualityHandle
Definition: IteratedMedianCMNSubtractor.h:37
hltrates_dqm_sourceclient-live_cfg.offset
offset
Definition: hltrates_dqm_sourceclient-live_cfg.py:82
cuy.ii
ii
Definition: cuy.py:589
SiStripQuality
Definition: SiStripQuality.h:32