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 &, std::vector< int16_t > &)
 
void subtract (const uint32_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)
 
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< 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 10 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 152 of file IteratedMedianCMNSubtractor.cc.

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

152  {
153  uint32_t n_cache_id = es.get<SiStripNoisesRcd>().cacheIdentifier();
154  uint32_t q_cache_id = es.get<SiStripQualityRcd>().cacheIdentifier();
155 
156  if(n_cache_id != noise_cache_id) {
157  es.get<SiStripNoisesRcd>().get( noiseHandle );
158  noise_cache_id = n_cache_id;
159  }
160  if(q_cache_id != quality_cache_id) {
161  es.get<SiStripQualityRcd>().get( qualityHandle );
162  quality_cache_id = q_cache_id;
163  }
164 }
edm::ESHandle< SiStripNoises > noiseHandle
const T & get() const
Definition: EventSetup.h:55
edm::ESHandle< SiStripQuality > qualityHandle
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_().

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

Implements SiStripCommonModeNoiseSubtractor.

Definition at line 167 of file IteratedMedianCMNSubtractor.cc.

References subtract_().

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

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

172  {
173 
174 
175  SiStripNoises::Range detNoiseRange = noiseHandle->getRange(detId);
176  SiStripQuality::Range detQualityRange = qualityHandle->getRange(detId);
177 
178  typename std::vector<T>::iterator fs,ls;
179  float offset = 0;
180  std::pair<float,float> subset[128];
181  bool ok[128];
182  int subsetSize=0;
183  typedef std::pair<float,float> const * iterator;
184  SelectElem selector(subset,ok);
185 
186  _vmedians.clear();
187 
188  for( uint16_t APV=0; APV< digis.size()/128; ++APV)
189  {
190  subsetSize=0;
191  // fill subset vector with all good strips and their noises
192  for (uint16_t istrip=APV*128; istrip<(APV+1)*128; ++istrip)
193  {
194  if ( !qualityHandle->IsStripBad(detQualityRange,istrip) )
195  {
196  std::pair<float,float> pin((float)digis[istrip], (float)noiseHandle->getNoiseFast(istrip,detNoiseRange));
197  subset[subsetSize]= pin;
198  ok[subsetSize++]=true;
199  }
200  }
201 
202  if (subsetSize == 0) continue;
203 
204  // std::cout << "subset size " << subsetSize << std::endl;
205 
206  ElemIterator begin(selector,subset,subset+subsetSize);
207  ElemIterator end(selector,subset+subsetSize,subset+subsetSize);
208 
209  // caluate offset for all good strips (first iteration)
210  offset = pairMedian(begin,end);
211 
212  // for second, third... iterations, remove strips over threshold
213  // and recalculate offset on remaining strips
214  int nokold=subsetSize;
215  for ( int ii = 0; ii<iterations_-1; ++ii )
216  {
217  int nok=0;
218  for (int j=0; j!=subsetSize;++j)
219  {
220  iterator si = subset+j;
221  ok[j] = si->first-offset < cut_to_avoid_signal_*si->second;
222  ++nok;
223  }
224  if (nok==nokold) break; // std::cout << "converged at " << ii << std::endl;
225  if (nok == 0 ) break;
226  offset = pairMedian(begin,end);
227  nokold=nok;
228  }
229 
230  _vmedians.push_back(std::pair<short,float>(APV,offset));
231 
232  // remove offset
233  fs = digis.begin()+APV*128;
234  ls = digis.begin()+(APV+1)*128;
235  while (fs < ls) {
236  *fs = static_cast<T>(*fs-offset);
237  fs++;
238  }
239 
240  }
241  // std::cout << "IMCMNS end " << _vmedians.size() << std::endl;
242 
243 }
edm::ESHandle< SiStripNoises > noiseHandle
int j
Definition: DBlmapReader.cc:9
#define end
Definition: vmac.h:38
unsigned int offset(bool)
std::vector< std::pair< short, float > > _vmedians
#define begin
Definition: vmac.h:31
std::pair< ContainerIterator, ContainerIterator > Range
std::pair< ContainerIterator, ContainerIterator > Range
Definition: SiStripNoises.h:41
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 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().

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

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

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

Definition at line 33 of file IteratedMedianCMNSubtractor.h.

Referenced by init(), and subtract_().