CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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)
 
void subtract (const uint32_t &, const uint16_t &, std::vector< int16_t > &)
 
void subtract (const uint32_t &, const uint16_t &, std::vector< float > &)
 
- Public Member Functions inherited from SiStripCommonModeNoiseSubtractor
const std::vector< std::pair
< short, float > > & 
getAPVsCM ()
 
virtual ~SiStripCommonModeNoiseSubtractor ()
 

Private Member Functions

 IteratedMedianCMNSubtractor (double sigma, int iterations)
 
float pairMedian (std::vector< std::pair< float, float > > &sample)
 
template<typename T >
void subtract_ (const uint32_t &, const uint16_t &, std::vector< T > &)
 

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)
virtual

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) {
18  es.get<SiStripQualityRcd>().get( qualityHandle );
19  quality_cache_id = q_cache_id;
20  }
21 }
edm::ESHandle< SiStripNoises > noiseHandle
const T & get() const
Definition: EventSetup.h:55
edm::ESHandle< SiStripQuality > qualityHandle
float IteratedMedianCMNSubtractor::pairMedian ( std::vector< std::pair< float, float > > &  sample)
inlineprivate

Definition at line 90 of file IteratedMedianCMNSubtractor.cc.

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

Referenced by subtract_().

90  {
91  std::vector<std::pair<float,float> >::iterator mid = sample.begin() + sample.size()/2;
92  std::nth_element(sample.begin(), mid, sample.end());
93  if( sample.size() & 1 ) //odd size
94  return (*mid).first;
95  return ( (*std::max_element(sample.begin(), mid)).first + (*mid).first ) / 2.;
96 }
return((rh^lh)&mask)
void IteratedMedianCMNSubtractor::subtract ( const uint32_t &  detId,
const uint16_t &  firstAPV,
std::vector< int16_t > &  digis 
)
virtual

Implements SiStripCommonModeNoiseSubtractor.

Definition at line 23 of file IteratedMedianCMNSubtractor.cc.

References subtract_().

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

Implements SiStripCommonModeNoiseSubtractor.

Definition at line 24 of file IteratedMedianCMNSubtractor.cc.

References subtract_().

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

Definition at line 29 of file IteratedMedianCMNSubtractor.cc.

References SiStripCommonModeNoiseSubtractor::_vmedians, sistrip::APV, cut_to_avoid_signal_, cuy::ii, iterations_, python.rootplot.utilities::ls(), noiseHandle, HLT_25ns14e33_v1_cff::offset, pairMedian(), and qualityHandle.

Referenced by subtract().

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

Friends And Related Function Documentation

friend class SiStripRawProcessingFactory
friend

Definition at line 13 of file IteratedMedianCMNSubtractor.h.

Member Data Documentation

double IteratedMedianCMNSubtractor::cut_to_avoid_signal_
private

Definition at line 30 of file IteratedMedianCMNSubtractor.h.

Referenced by subtract_().

int IteratedMedianCMNSubtractor::iterations_
private

Definition at line 32 of file IteratedMedianCMNSubtractor.h.

Referenced by subtract_().

uint32_t IteratedMedianCMNSubtractor::noise_cache_id
private

Definition at line 35 of file IteratedMedianCMNSubtractor.h.

Referenced by init().

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

Definition at line 33 of file IteratedMedianCMNSubtractor.h.

Referenced by init(), and subtract_().

uint32_t IteratedMedianCMNSubtractor::quality_cache_id
private

Definition at line 35 of file IteratedMedianCMNSubtractor.h.

Referenced by init().

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

Definition at line 34 of file IteratedMedianCMNSubtractor.h.

Referenced by init(), and subtract_().