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< int16_t > &digis) override
 
void subtract (uint32_t detId, uint16_t firstAPV, std::vector< float > &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)
 
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_
 
uint32_t noise_cache_id
 
edm::ESHandle< SiStripNoisesnoiseHandle
 
uint32_t quality_cache_id
 
edm::ESHandle< SiStripQualityqualityHandle
 

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 11 of file IteratedMedianCMNSubtractor.h.

Constructor & Destructor Documentation

IteratedMedianCMNSubtractor::IteratedMedianCMNSubtractor ( double  sigma,
int  iterations 
)
inlineprivate

Member Function Documentation

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

Reimplemented from SiStripCommonModeNoiseSubtractor.

Definition at line 9 of file IteratedMedianCMNSubtractor.cc.

References edm::EventSetup::get(), noise_cache_id, noiseHandle, quality_cache_id, and qualityHandle.

9  {
10  uint32_t n_cache_id = es.get<SiStripNoisesRcd>().cacheIdentifier();
11  uint32_t q_cache_id = es.get<SiStripQualityRcd>().cacheIdentifier();
12 
13  if (n_cache_id != noise_cache_id) {
14  es.get<SiStripNoisesRcd>().get(noiseHandle);
15  noise_cache_id = n_cache_id;
16  }
17  if (q_cache_id != quality_cache_id) {
19  quality_cache_id = q_cache_id;
20  }
21 }
edm::ESHandle< SiStripNoises > noiseHandle
T get() const
Definition: EventSetup.h:73
edm::ESHandle< SiStripQuality > qualityHandle
float IteratedMedianCMNSubtractor::pairMedian ( std::vector< std::pair< float, float > > &  sample)
inlineprivate

Definition at line 85 of file IteratedMedianCMNSubtractor.cc.

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

Referenced by subtract_().

85  {
86  std::vector<std::pair<float, float> >::iterator mid = sample.begin() + sample.size() / 2;
87  std::nth_element(sample.begin(), mid, sample.end());
88  if (sample.size() & 1) //odd size
89  return (*mid).first;
90  return ((*std::max_element(sample.begin(), mid)).first + (*mid).first) / 2.;
91 }
return((rh^lh)&mask)
void IteratedMedianCMNSubtractor::subtract ( uint32_t  detId,
uint16_t  firstAPV,
std::vector< int16_t > &  digis 
)
overridevirtual

Implements SiStripCommonModeNoiseSubtractor.

Definition at line 23 of file IteratedMedianCMNSubtractor.cc.

References subtract_().

23  {
24  subtract_(detId, firstAPV, digis);
25 }
void subtract_(uint32_t detId, uint16_t firstAPV, std::vector< T > &digis)
void IteratedMedianCMNSubtractor::subtract ( uint32_t  detId,
uint16_t  firstAPV,
std::vector< float > &  digis 
)
overridevirtual

Implements SiStripCommonModeNoiseSubtractor.

Definition at line 26 of file IteratedMedianCMNSubtractor.cc.

References subtract_().

26  {
27  subtract_(detId, firstAPV, digis);
28 }
void subtract_(uint32_t detId, uint16_t firstAPV, std::vector< T > &digis)
template<typename T >
void IteratedMedianCMNSubtractor::subtract_ ( uint32_t  detId,
uint16_t  firstAPV,
std::vector< T > &  digis 
)
inlineprivate

Definition at line 31 of file IteratedMedianCMNSubtractor.cc.

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().

31  {
32  SiStripNoises::Range detNoiseRange = noiseHandle->getRange(detId);
33  SiStripQuality::Range detQualityRange = qualityHandle->getRange(detId);
34 
35  typename std::vector<T>::iterator fs, ls;
36  float offset = 0;
37  std::vector<std::pair<float, float> > subset;
38  subset.reserve(128);
39 
40  _vmedians.clear();
41 
42  uint16_t APV = firstAPV;
43  for (; APV < digis.size() / 128 + firstAPV; ++APV) {
44  subset.clear();
45  // fill subset vector with all good strips and their noises
46  for (uint16_t istrip = APV * 128; istrip < (APV + 1) * 128; ++istrip) {
47  if (!qualityHandle->IsStripBad(detQualityRange, istrip)) {
48  std::pair<float, float> pin((float)digis[istrip - firstAPV * 128],
49  (float)noiseHandle->getNoiseFast(istrip, detNoiseRange));
50  subset.push_back(pin);
51  }
52  }
53 
54  // caluate offset for all good strips (first iteration)
55  if (!subset.empty())
56  offset = pairMedian(subset);
57 
58  // for second, third... iterations, remove strips over threshold
59  // and recalculate offset on remaining strips
60  for (int ii = 0; ii < iterations_ - 1; ++ii) {
61  std::vector<std::pair<float, float> >::iterator si = subset.begin();
62  while (si != subset.end()) {
63  if (si->first - offset > cut_to_avoid_signal_ * si->second)
64  si = subset.erase(si);
65  else
66  ++si;
67  }
68  if (subset.empty())
69  break;
70  offset = pairMedian(subset);
71  }
72 
73  _vmedians.push_back(std::pair<short, float>(APV, offset));
74 
75  // remove offset
76  fs = digis.begin() + (APV - firstAPV) * 128;
77  ls = digis.begin() + (APV - firstAPV + 1) * 128;
78  while (fs < ls) {
79  *fs = static_cast<T>(*fs - offset);
80  fs++;
81  }
82  }
83 }
edm::ESHandle< SiStripNoises > noiseHandle
float pairMedian(std::vector< std::pair< float, float > > &sample)
bool IsStripBad(const uint32_t &detid, const short &strip) const
static float getNoiseFast(const uint16_t &strip, const Range &range)
Definition: SiStripNoises.h:66
ii
Definition: cuy.py:590
def ls(path, rec=False)
Definition: eostools.py:349
const Range getRange(const uint32_t detID) const
const Range getRange(const uint32_t detID) const
std::pair< ContainerIterator, ContainerIterator > Range
std::pair< ContainerIterator, ContainerIterator > Range
Definition: SiStripNoises.h:47
long double T
std::vector< std::pair< short, float > > _vmedians
edm::ESHandle< SiStripQuality > qualityHandle

Friends And Related Function Documentation

friend class SiStripRawProcessingFactory
friend

Definition at line 12 of file IteratedMedianCMNSubtractor.h.

Member Data Documentation

double IteratedMedianCMNSubtractor::cut_to_avoid_signal_
private

Definition at line 25 of file IteratedMedianCMNSubtractor.h.

Referenced by subtract_().

int IteratedMedianCMNSubtractor::iterations_
private

Definition at line 27 of file IteratedMedianCMNSubtractor.h.

Referenced by subtract_().

uint32_t IteratedMedianCMNSubtractor::noise_cache_id
private

Definition at line 30 of file IteratedMedianCMNSubtractor.h.

Referenced by init().

edm::ESHandle<SiStripNoises> IteratedMedianCMNSubtractor::noiseHandle
private

Definition at line 28 of file IteratedMedianCMNSubtractor.h.

Referenced by init(), and subtract_().

uint32_t IteratedMedianCMNSubtractor::quality_cache_id
private

Definition at line 30 of file IteratedMedianCMNSubtractor.h.

Referenced by init().

edm::ESHandle<SiStripQuality> IteratedMedianCMNSubtractor::qualityHandle
private

Definition at line 29 of file IteratedMedianCMNSubtractor.h.

Referenced by init(), and subtract_().