CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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, 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,
SiStripNoisesRcd
noiseToken_
 
edm::ESWatcher< SiStripNoisesRcdnoiseWatcher_
 
const SiStripQualityqualityHandle
 
edm::ESGetToken
< SiStripQuality,
SiStripQualityRcd
qualityToken_
 
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 ( double  sigma,
int  iterations,
edm::ConsumesCollector  iC 
)
inlineprivate

Member Function Documentation

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

Reimplemented from SiStripCommonModeNoiseSubtractor.

Definition at line 7 of file IteratedMedianCMNSubtractor.cc.

References edm::ESWatcher< T >::check(), edm::EventSetup::getData(), noiseHandle, noiseToken_, noiseWatcher_, qualityHandle, qualityToken_, and qualityWatcher_.

7  {
8  if (noiseWatcher_.check(es)) {
10  }
11  if (qualityWatcher_.check(es)) {
13  }
14 }
edm::ESGetToken< SiStripQuality, SiStripQualityRcd > qualityToken_
bool getData(T &iHolder) const
Definition: EventSetup.h:128
edm::ESWatcher< SiStripNoisesRcd > noiseWatcher_
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
edm::ESWatcher< SiStripQualityRcd > qualityWatcher_
edm::ESGetToken< SiStripNoises, SiStripNoisesRcd > noiseToken_
float IteratedMedianCMNSubtractor::pairMedian ( std::vector< std::pair< float, float > > &  sample)
inlineprivate

Definition at line 78 of file IteratedMedianCMNSubtractor.cc.

References gpuVertexFinder::return, and compare_using_db::sample.

Referenced by subtract_().

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 }
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.

References subtract_().

16  {
17  subtract_(detId, firstAPV, digis);
18 }
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 19 of file IteratedMedianCMNSubtractor.cc.

References subtract_().

19  {
20  subtract_(detId, firstAPV, digis);
21 }
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 24 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().

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 }
float pairMedian(std::vector< std::pair< float, float > > &sample)
bool IsStripBad(const uint32_t &detid, const short &strip) const
def ls
Definition: eostools.py:349
int ii
Definition: cuy.py:589
static float getNoiseFast(const uint16_t &strip, const Range &range)
Definition: SiStripNoises.h:68
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

Friends And Related Function Documentation

friend class SiStripRawProcessingFactory
friend

Definition at line 15 of file IteratedMedianCMNSubtractor.h.

Member Data Documentation

double IteratedMedianCMNSubtractor::cut_to_avoid_signal_
private

Definition at line 31 of file IteratedMedianCMNSubtractor.h.

Referenced by subtract_().

int IteratedMedianCMNSubtractor::iterations_
private

Definition at line 33 of file IteratedMedianCMNSubtractor.h.

Referenced by subtract_().

const SiStripNoises* IteratedMedianCMNSubtractor::noiseHandle
private

Definition at line 36 of file IteratedMedianCMNSubtractor.h.

Referenced by init(), and subtract_().

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

Definition at line 34 of file IteratedMedianCMNSubtractor.h.

Referenced by init().

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

Definition at line 38 of file IteratedMedianCMNSubtractor.h.

Referenced by init().

const SiStripQuality* IteratedMedianCMNSubtractor::qualityHandle
private

Definition at line 37 of file IteratedMedianCMNSubtractor.h.

Referenced by init(), and subtract_().

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

Definition at line 35 of file IteratedMedianCMNSubtractor.h.

Referenced by init().

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

Definition at line 39 of file IteratedMedianCMNSubtractor.h.

Referenced by init().