CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Friends
SiStripAPVRestorer Class Reference

#include <SiStripAPVRestorer.h>

Public Member Functions

void fixAPVsCM (edm::DetSet< SiStripProcessedRawDigi > &)
 
RawDigiMapGetBaselineMap ()
 
std::vector< DigiMap > & GetSmoothedPoints ()
 
void init (const edm::EventSetup &es)
 
int16_t inspect (const uint32_t &, std::vector< int16_t > &, const std::vector< std::pair< short, float > > &)
 
void LoadMeanCMMap (edm::Event &)
 
void restore (std::vector< int16_t > &)
 
virtual ~SiStripAPVRestorer ()
 

Protected Member Functions

 SiStripAPVRestorer (const edm::ParameterSet &conf)
 

Private Member Functions

template<typename T >
int16_t AbnormalBaselineInspect (std::vector< T > &)
 
template<typename T >
int16_t BaselineAndSaturationInspect (std::vector< T > &)
 
void BaselineFollower (DigiMap &, std::vector< int16_t > &, float)
 
template<typename T >
int16_t BaselineFollowerInspect (std::vector< T > &)
 
template<typename T >
void BaselineFollowerRestore (std::vector< T > &, uint16_t, float)
 
void CreateCMMap (const edm::DetSetVector< SiStripProcessedRawDigi > &)
 
bool FlatRegionsFinder (std::vector< int16_t > &, DigiMap &, float, uint16_t)
 
template<typename T >
void FlatRestore (std::vector< T > &, uint16_t)
 
template<typename T >
int16_t NullInspect (std::vector< T > &)
 
float pairMedian (std::vector< std::pair< float, float > > &)
 

Private Attributes

std::vector< std::string > apvFlags_
 
RawDigiMap BaselineMap_
 
uint32_t consecThreshold_
 
double CutToAvoidSignal_
 
uint32_t DeltaCMThreshold_
 
uint32_t detId_
 
uint32_t deviation_
 
uint32_t distortionThreshold_
 
bool ForceNoRestore_
 
double fraction_
 
uint32_t hitStripThreshold_
 
edm::InputTag inputTag_
 
std::string InspectAlgo_
 
CMMap MeanCMmap_
 
std::vector< float > median_
 
uint32_t minStripsToFit_
 
uint32_t noise_cache_id
 
edm::ESHandle< SiStripNoisesnoiseHandle
 
uint32_t nSaturatedStrip_
 
uint32_t nSigmaNoiseDerTh_
 
uint32_t nSmooth_
 
uint32_t quality_cache_id
 
edm::ESHandle< SiStripQualityqualityHandle
 
std::string RestoreAlgo_
 
double restoreThreshold_
 
bool SelfSelectRestoreAlgo_
 
std::vector< DigiMapSmoothedMaps_
 
bool useRealMeanCM_
 

Friends

class SiStripRawProcessingFactory
 

Detailed Description

Definition at line 27 of file SiStripAPVRestorer.h.

Constructor & Destructor Documentation

virtual SiStripAPVRestorer::~SiStripAPVRestorer ( )
inlinevirtual

Definition at line 33 of file SiStripAPVRestorer.h.

33 {};
SiStripAPVRestorer::SiStripAPVRestorer ( const edm::ParameterSet conf)
protected

Definition at line 10 of file SiStripAPVRestorer.cc.

References apvFlags_, BaselineMap_, median_, and SmoothedMaps_.

10  :
12  ForceNoRestore_(conf.getParameter<bool>("ForceNoRestore")),
13  SelfSelectRestoreAlgo_(conf.getParameter<bool>("SelfSelectRestoreAlgo")),
14  InspectAlgo_(conf.getParameter<std::string>("APVInspectMode")),
15  RestoreAlgo_(conf.getParameter<std::string>("APVRestoreMode")),
16  useRealMeanCM_(conf.getParameter<bool>("useRealMeanCM")),
17  fraction_(conf.getParameter<double>("Fraction")),
18  deviation_(conf.getParameter<uint32_t>("Deviation")),
19  restoreThreshold_(conf.getParameter<double>("restoreThreshold")),
20  DeltaCMThreshold_(conf.getParameter<uint32_t>("DeltaCMThreshold")),
21  nSigmaNoiseDerTh_(conf.getParameter<uint32_t>("nSigmaNoiseDerTh")),
22  consecThreshold_(conf.getParameter<uint32_t>("consecThreshold")),
23  hitStripThreshold_(conf.getParameter<uint32_t>("hitStripThreshold")),
24  nSmooth_(conf.getParameter<uint32_t>("nSmooth")),
25  minStripsToFit_(conf.getParameter<uint32_t>("minStripsToFit")),
26  distortionThreshold_(conf.getParameter<uint32_t>("distortionThreshold")),
27  CutToAvoidSignal_(conf.getParameter<double>("CutToAvoidSignal")),
28  nSaturatedStrip_(conf.getParameter<uint32_t>("nSaturatedStrip"))
29 
30 
31 {
32  apvFlags_.clear();
33  median_.clear();
34  SmoothedMaps_.clear();
35  BaselineMap_.erase(BaselineMap_.begin(), BaselineMap_.end());
36 }
T getParameter(std::string const &) const
std::vector< DigiMap > SmoothedMaps_
std::vector< std::string > apvFlags_
std::vector< float > median_

Member Function Documentation

template<typename T >
int16_t SiStripAPVRestorer::AbnormalBaselineInspect ( std::vector< T > &  digis)
inlineprivate

Definition at line 208 of file SiStripAPVRestorer.cc.

References abs, sistrip::APV, apvFlags_, detId_, deviation_, fraction_, MeanCMmap_, min, qualityHandle, RestoreAlgo_, and useRealMeanCM_.

Referenced by inspect().

208  {
209 
210  SiStripQuality::Range detQualityRange = qualityHandle->getRange(detId_);
211 
212  typename std::vector<T>::iterator fs;
213 
214  int16_t nAPVflagged=0;
215 
216  CMMap::iterator itCMMap;
217  if(useRealMeanCM_) itCMMap = MeanCMmap_.find(detId_);
218 
219 
220  int devCount = 0, qualityCount = 0, minstrip = 0;
221  for( uint16_t APV=0; APV< digis.size()/128; ++APV){
222  int MeanAPVCM = 128;
223  if(useRealMeanCM_&&itCMMap!= MeanCMmap_.end()) MeanAPVCM =(itCMMap->second)[APV];
224  for (uint16_t istrip=APV*128; istrip<(APV+1)*128; ++istrip){
225  fs = digis.begin() + istrip;
226  if ( !qualityHandle->IsStripBad(detQualityRange,istrip) ){
227  qualityCount++;
228  if ( std::abs((int) *fs - MeanAPVCM) > (int)deviation_ ) devCount++;
229  minstrip = std::min((int) *fs, minstrip);
230  }
231  }
232 
233  if( devCount > fraction_ * qualityCount ) {
234  apvFlags_.push_back( RestoreAlgo_ ); //specify any algo to make the restore
235  nAPVflagged++;
236  } else {
237  apvFlags_.push_back( "" );
238  }
239 
240  }
241 
242  return nAPVflagged;
243 
244 }
#define abs(x)
Definition: mlp_lapack.h:159
#define min(a, b)
Definition: mlp_lapack.h:161
std::vector< std::string > apvFlags_
edm::ESHandle< SiStripQuality > qualityHandle
std::pair< ContainerIterator, ContainerIterator > Range
template<typename T >
int16_t SiStripAPVRestorer::BaselineAndSaturationInspect ( std::vector< T > &  digis)
inlineprivate

Definition at line 163 of file SiStripAPVRestorer.cc.

References abs, sistrip::APV, apvFlags_, DeltaCMThreshold_, detId_, MeanCMmap_, median_, nSaturatedStrip_, qualityHandle, strip(), and useRealMeanCM_.

Referenced by inspect().

163  {
164  SiStripQuality::Range detQualityRange = qualityHandle->getRange(detId_);
165 
166 
167  std::vector<T> singleAPVdigi;
168  singleAPVdigi.clear();
169 
170 
171  int16_t nAPVflagged = 0;
172 
173  CMMap::iterator itCMMap;
174  if(useRealMeanCM_) itCMMap = MeanCMmap_.find(detId_);
175 
176  for( uint16_t APV=0; APV< digis.size()/128; ++APV){
177 
178  int MeanAPVCM = 128;
179  if(useRealMeanCM_&&itCMMap!= MeanCMmap_.end()) MeanAPVCM =(itCMMap->second)[APV];
180 
181  singleAPVdigi.clear();
182 
183  uint16_t nSatStrip =0;
184  for(int16_t strip = APV*128; strip < (APV+1)*128; ++strip){
185  singleAPVdigi.push_back(digis[strip]);
186  if(digis[strip] >=1023) ++nSatStrip;
187  }
188 
189  float DeltaCM = median_[APV] -MeanAPVCM;
190 
191 
192  if(DeltaCM < 0 && std::abs(DeltaCM) > DeltaCMThreshold_&&nSatStrip>= nSaturatedStrip_){
193 
194  apvFlags_.push_back( "RestoreAlgo_" ); //specify any algo to make the restore
195  nAPVflagged++;
196  } else{
197  apvFlags_.push_back( "" );
198  }
199 
200  }
201 
202  return nAPVflagged;
203 }
void strip(std::string &input, const std::string &blanks=" \n\t")
Definition: stringTools.cc:16
#define abs(x)
Definition: mlp_lapack.h:159
std::vector< std::string > apvFlags_
edm::ESHandle< SiStripQuality > qualityHandle
std::pair< ContainerIterator, ContainerIterator > Range
std::vector< float > median_
void SiStripAPVRestorer::BaselineFollower ( DigiMap smoothedpoints,
std::vector< int16_t > &  baseline,
float  median 
)
inlineprivate

Definition at line 467 of file SiStripAPVRestorer.cc.

References m, and minStripsToFit_.

Referenced by BaselineFollowerRestore().

467  {
468 
469  baseline.clear();
470  DigiMapIter itSmoothedpoints;
471 
472  //if not enough points
473  if(smoothedpoints.size() < minStripsToFit_){
474  baseline.clear();
475  baseline.insert(baseline.begin(),128, median);
476  } else {
477  baseline.insert(baseline.begin(),128, 0);
478 
479  DigiMapIter itSmoothedpointsBegin, itSmoothedpointsEnd;
480  itSmoothedpointsBegin = smoothedpoints.begin();
481  itSmoothedpointsEnd = --(smoothedpoints.end());
482 
483 
484  uint16_t firstStripFlat = itSmoothedpointsBegin->first;
485  uint16_t lastStripFlat = itSmoothedpointsEnd->first;
486  int16_t firstStipFlatADC= itSmoothedpointsBegin->second;
487  int16_t lastStipFlatADC= itSmoothedpointsEnd->second;
488 
489  //adding here the costant line at the extremities
490  baseline.erase(baseline.begin(), baseline.begin()+firstStripFlat);
491  baseline.insert(baseline.begin(), firstStripFlat, firstStipFlatADC);
492 
493  baseline.erase(baseline.begin()+lastStripFlat, baseline.end());
494  baseline.insert(baseline.end(), 128 - lastStripFlat, lastStipFlatADC);
495 
496 
497  //IMPORTANT: the itSmoothedpointsEnd should be at least smaller than smoothedpoints.end() -1
498  for(itSmoothedpoints = itSmoothedpointsBegin; itSmoothedpoints != itSmoothedpointsEnd; ++itSmoothedpoints){
499  DigiMapIter itSmoothedpointsNext = itSmoothedpoints;
500  ++itSmoothedpointsNext;
501  float strip1 = itSmoothedpoints->first;
502  float strip2 = itSmoothedpointsNext->first;
503  float adc1 = itSmoothedpoints->second;
504  float adc2 = itSmoothedpointsNext->second;
505 
506  baseline[strip1] = adc1;
507  baseline[strip2] = adc2;
508  float m = (adc2 -adc1)/(strip2 -strip1);
509  uint16_t itStrip = strip1 +1;
510  float stripadc = adc1 + m;
511  while(itStrip < strip2){
512  baseline[itStrip] = stripadc;
513  ++itStrip;
514  stripadc+=m;
515  }
516 
517  }
518 
519  }
520 }
std::map< uint16_t, int16_t >::iterator DigiMapIter
template<typename T >
int16_t SiStripAPVRestorer::BaselineFollowerInspect ( std::vector< T > &  digis)
inlineprivate

Definition at line 110 of file SiStripAPVRestorer.cc.

References abs, sistrip::APV, apvFlags_, DeltaCMThreshold_, detId_, FlatRegionsFinder(), MeanCMmap_, median_, qualityHandle, SmoothedMaps_, strip(), and useRealMeanCM_.

Referenced by inspect().

110  {
111  SiStripQuality::Range detQualityRange = qualityHandle->getRange(detId_);
112 
113  std::vector<T> singleAPVdigi;
114  singleAPVdigi.clear();
115 
116 
117  int16_t nAPVflagged = 0;
118 
119  CMMap::iterator itCMMap;
120  if(useRealMeanCM_) itCMMap = MeanCMmap_.find(detId_);
121 
122  for( uint16_t APV=0; APV< digis.size()/128; ++APV){
123 
124  int MeanAPVCM = 128;
125  if(useRealMeanCM_&&itCMMap!= MeanCMmap_.end()) MeanAPVCM =(itCMMap->second)[APV];
126 
127  singleAPVdigi.clear();
128  for(int16_t strip = APV*128; strip < (APV+1)*128; ++strip){
129  singleAPVdigi.push_back(digis[strip]);
130 
131  }
132 
133 
134  float DeltaCM = median_[APV] -MeanAPVCM;
135  //if(DeltaCM > DeltaCMThreshold_){ //to be modified when code is extended
136  // apvFlags_.push_back( RestoreAlgo_ );
137  // nAPVflagged++;
138  //}else
139 
140  DigiMap smoothedmap;
141  if(DeltaCM < 0 && std::abs(DeltaCM) > DeltaCMThreshold_){
142 
143  bool isFlat= FlatRegionsFinder(singleAPVdigi,smoothedmap, median_[APV], APV);
144  if(!isFlat){
145  apvFlags_.push_back( "BaselineFollower" ); //specify any algo to make the restore
146  nAPVflagged++;
147  }else{
148  apvFlags_.push_back( "" );
149  }
150  } else{
151  apvFlags_.push_back( "" );
152  }
153  SmoothedMaps_.push_back(smoothedmap);
154 
155  }
156 
157  return nAPVflagged;
158 }
void strip(std::string &input, const std::string &blanks=" \n\t")
Definition: stringTools.cc:16
std::vector< DigiMap > SmoothedMaps_
#define abs(x)
Definition: mlp_lapack.h:159
std::map< uint16_t, int16_t > DigiMap
std::vector< std::string > apvFlags_
edm::ESHandle< SiStripQuality > qualityHandle
bool FlatRegionsFinder(std::vector< int16_t > &, DigiMap &, float, uint16_t)
std::pair< ContainerIterator, ContainerIterator > Range
std::vector< float > median_
template<typename T >
void SiStripAPVRestorer::BaselineFollowerRestore ( std::vector< T > &  digis,
uint16_t  APVn,
float  median 
)
inlineprivate

Definition at line 289 of file SiStripAPVRestorer.cc.

References BaselineFollower(), BaselineMap_, FlatRegionsFinder(), and SmoothedMaps_.

Referenced by restore().

289  {
290  typename std::vector<T>::iterator firstStrip(digis.begin() + APVn*128), lastStrip(firstStrip + 128), actualStrip;
291 
292  std::vector<int16_t> baseline;
293  baseline.clear();
294  baseline.insert(baseline.begin(),128, 0);
295 
296  std::vector<int16_t> adcs;
297  adcs.clear();
298 
299 
300  //============================= Copying only ADCs of one APV =============================
301  for(actualStrip= firstStrip; actualStrip < lastStrip; ++actualStrip ) adcs.push_back(*actualStrip);
302 
303  //============================= Calculate Median =========================================
304  //this code was here in order to use the median calculated during the inspect
305  //but actually now we use the one calculated by the cmnsubtractor
306  //float median;
307  //if(median_.size()) median = median_[APVn];
308  //else median = this->median(adcs);
309 
310  //============================= Find Flat Regions & Interpolating the baseline & subtracting the baseline =================
311 
312  if(SmoothedMaps_.size()){
313  this->BaselineFollower(SmoothedMaps_[APVn], baseline, median);
314 
315  } else {
316  median=0;
317  DigiMap smoothedpoints;
318  this->FlatRegionsFinder(adcs,smoothedpoints, median, APVn );
319  this->BaselineFollower(smoothedpoints, baseline, median);
320 
321  }
322 
323  //============================= subtracting the baseline =============================================
324 
325  for(int16_t itStrip= 0 ; itStrip< 128; ++itStrip){
326  //int tempDigi = digis[itStrip+APVn*128] - baseline[itStrip] + median;
327  //std::cout << "BaselineFollowerRestore - detId: " << detId_ << " APV: " << APVn << " strip: " << itStrip << " digis: " << digis[itStrip+APVn*128] << " baseline: " << baseline[itStrip] << " median: " << median << " digis after baseline subtraction: " << tempDigi << std::endl;
328  digis[itStrip+APVn*128] -= baseline[itStrip] - median;
329  }
330 
331 
332  //============================= storing baseline to the map =============================================
333  BaselineMap_.insert(BaselineMap_.end(), std::pair< uint16_t, std::vector < int16_t> >(APVn, baseline));
334 
335 
336 }
std::vector< DigiMap > SmoothedMaps_
std::map< uint16_t, int16_t > DigiMap
bool FlatRegionsFinder(std::vector< int16_t > &, DigiMap &, float, uint16_t)
void BaselineFollower(DigiMap &, std::vector< int16_t > &, float)
void SiStripAPVRestorer::CreateCMMap ( const edm::DetSetVector< SiStripProcessedRawDigi > &  Input)
private

Definition at line 586 of file SiStripAPVRestorer.cc.

References edm::DetSetVector< T >::begin(), detId_, edm::DetSetVector< T >::end(), and MeanCMmap_.

Referenced by LoadMeanCMMap().

586  {
587 
588  MeanCMmap_.erase(MeanCMmap_.begin(), MeanCMmap_.end());
589 
590  uint32_t detId_;
593  std::vector<float> MeanCMNValue;
594 
595  for(itInput = Input.begin(); itInput != Input.end(); ++itInput){
596  detId_ = itInput->id;
597  MeanCMNValue.clear();
598  for(itCM = itInput->begin(); itCM != itInput->end(); ++itCM) MeanCMNValue.push_back(itCM->adc());
599  MeanCMmap_.insert(std::pair<uint32_t, std::vector<float> >(detId_,MeanCMNValue));
600  }
601 
602 }
iterator end()
Return the off-the-end iterator.
Definition: DetSetVector.h:352
iterator begin()
Return an iterator to the first DetSet.
Definition: DetSetVector.h:337
collection_type::const_iterator const_iterator
Definition: DetSet.h:31
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:105
void SiStripAPVRestorer::fixAPVsCM ( edm::DetSet< SiStripProcessedRawDigi > &  cmdigis)

Definition at line 547 of file SiStripAPVRestorer.cc.

References apvFlags_, edm::DetSet< T >::begin(), edm::DetSet< T >::clear(), edm::DetSet< T >::end(), edm::DetSet< T >::push_back(), and edm::DetSet< T >::size().

547  {
548 
549  // cmdigis should be the same size as apvFlags_
550  // otherwise something pathological has happened and we do nothing
551  if ( cmdigis.size() != apvFlags_.size() ) return;
552 
554  std::vector<std::string>::const_iterator apvf_iter = apvFlags_.begin();
555 
556  // No way to change the adc value of a SiStripProcessedRawDigi
557  // so we just extract the values, clear the DetSet, and
558  // replace with the proper values.
559 
560  std::vector<float> cmvalues;
561  for( ; cm_iter != cmdigis.end(); ++cm_iter ) cmvalues.push_back( (*cm_iter).adc() );
562  cmdigis.clear();
563 
564  std::vector<float>::const_iterator cmv_iter = cmvalues.begin();
565  while( apvf_iter != apvFlags_.end() ){
566  if( *apvf_iter != "") {
567  //std::cout << " apvFlag was " << *apvf_iter << std::endl;
568  //std::cout << " baseline was " << *cmv_iter << std::endl;
569  cmdigis.push_back( SiStripProcessedRawDigi( -999.) );
570  }
571  else
572  cmdigis.push_back( SiStripProcessedRawDigi( *cmv_iter ) );
573  apvf_iter++;
574  cmv_iter++;
575  }
576 }
iterator end()
Definition: DetSet.h:50
void push_back(const T &t)
Definition: DetSet.h:58
collection_type::iterator iterator
Definition: DetSet.h:30
A signed Digi for the silicon strip detector, containing only adc information, and suitable for stori...
size_type size() const
Definition: DetSet.h:53
std::vector< std::string > apvFlags_
iterator begin()
Definition: DetSet.h:49
void clear()
Definition: DetSet.h:59
bool SiStripAPVRestorer::FlatRegionsFinder ( std::vector< int16_t > &  adcs,
DigiMap smoothedpoints,
float  median,
uint16_t  APVn 
)
inlineprivate

Definition at line 365 of file SiStripAPVRestorer.cc.

References ecalMGPA::adc(), consecThreshold_, detId_, distortionThreshold_, hitStripThreshold_, max(), min, n, noiseHandle, nSigmaNoiseDerTh_, and nSmooth_.

Referenced by BaselineFollowerInspect(), and BaselineFollowerRestore().

365  {
366  SiStripNoises::Range detNoiseRange = noiseHandle->getRange(detId_);
367 
368  DigiMap consecpoints;
369  DigiMapIter itConsecpoints, itSmoothedpoints;
370  consecpoints.erase(consecpoints.begin(), consecpoints.end());
371  smoothedpoints.erase(smoothedpoints.begin(), smoothedpoints.end());
372 
373 
374  //uint32_t idToLook = 369120382; //to be removed
375  //============================= Height above local minimum ===============================
376  std::vector<float> adcsLocalMinSubtracted;
377  adcsLocalMinSubtracted.clear();
378  adcsLocalMinSubtracted.insert(adcsLocalMinSubtracted.begin(), 128,0);
379  for(uint32_t istrip=0; istrip<128; ++istrip) {
380  float localmin = 999.9;
381  for(uint16_t jstrip=std::max(0,(int)(istrip-nSmooth_/2)); jstrip<std::min(128,(int)(istrip+nSmooth_/2)); ++jstrip) {
382  float nextvalue = adcs[jstrip];
383  if(nextvalue < localmin) localmin=nextvalue;
384  }
385  adcsLocalMinSubtracted[istrip] = adcs[istrip] - localmin;
386  }
387 
388 
389  //============================= Find regions with stable slopes ========================
390  std::vector<uint16_t> nConsStrip;
391  nConsStrip.clear();
392 
393  //Creating maps with all the neighborhood strip and putting in a nCosntStip vector how many we have
394  uint16_t consecStrips=0;
395  for(uint32_t istrip=0; istrip<128; ++istrip) {
396  int16_t adc = adcs[istrip];
397 
398 
399  if( adcsLocalMinSubtracted[istrip] < nSigmaNoiseDerTh_ * (float)noiseHandle->getNoiseFast(istrip+APVn*128,detNoiseRange)
400  && adc - median < hitStripThreshold_) {
401  //&& std::abs(adc - adcsLocalMinSubtracted[istrip]) < hitStripThreshold_) { //count of many consecutive strips
402  consecpoints.insert(consecpoints.end(), std::pair<uint16_t, int16_t >(istrip, adc));
403  ++consecStrips;
404 
405  } else if (consecStrips >0){
406  nConsStrip.push_back(consecStrips);
407  consecStrips = 0;
408  }
409 
410 
411  }
412 
413  //to cope with the last flat region of the APV
414  if(consecStrips >0) nConsStrip.push_back(consecStrips);
415 
416 
417  //removing from the map the fist and last points in wide flat regions and erasing from the map too small regions
418  itConsecpoints = consecpoints.begin();
419  float MinSmoothValue=2000., MaxSmoothValue=0.;
420  for(std::vector<uint16_t>::iterator itnConsStrip = nConsStrip.begin(); itnConsStrip < nConsStrip.end(); ++itnConsStrip){
421 
422  consecStrips = *itnConsStrip;
423  if(consecStrips >=consecThreshold_){
424  ++itConsecpoints; //skipping first point
425  uint16_t nFirstStrip = itConsecpoints->first;
426  uint16_t nLastStrip;
427  float smoothValue = 0.0;
428  float stripCount =1;
429  for(uint16_t n =0; n < consecStrips-2; ++n){
430  smoothValue += itConsecpoints->second;
431  if(stripCount == consecThreshold_){
432  smoothValue /= (float)stripCount;
433  nLastStrip = nFirstStrip + stripCount -1;
434  smoothedpoints.insert(smoothedpoints.end(), std::pair<uint16_t, int16_t >(nFirstStrip, smoothValue));
435  smoothedpoints.insert(smoothedpoints.end(), std::pair<uint16_t, int16_t >(nLastStrip, smoothValue));
436  if(smoothValue > MaxSmoothValue) MaxSmoothValue = smoothValue;
437  if(smoothValue < MinSmoothValue) MinSmoothValue = smoothValue;
438  nFirstStrip = nLastStrip+1;
439  smoothValue=0;
440  stripCount=0;
441  }
442  ++stripCount;
443  ++itConsecpoints;
444  }
445  ++itConsecpoints; //and putting the pointer to the new seies of point
446 
447  if(smoothValue>0){
448  --stripCount;
449  smoothValue /= (float)(stripCount);
450  nLastStrip = nFirstStrip + stripCount -1;
451  smoothedpoints.insert(smoothedpoints.end(), std::pair<uint16_t, int16_t >(nFirstStrip, smoothValue));
452  smoothedpoints.insert(smoothedpoints.end(), std::pair<uint16_t, int16_t >(nLastStrip, smoothValue));
453  if(smoothValue > MaxSmoothValue) MaxSmoothValue = smoothValue;
454  if(smoothValue < MinSmoothValue) MinSmoothValue = smoothValue;
455  }
456  } else{
457  for(int n =0; n< consecStrips ; ++n) ++itConsecpoints;
458 
459  }
460  }
461 
462  if( (MaxSmoothValue-MinSmoothValue) > distortionThreshold_) return false;
463  return true;
464 }
int adc(sample_type sample)
get the ADC sample (12 bits)
#define min(a, b)
Definition: mlp_lapack.h:161
std::map< uint16_t, int16_t > DigiMap
const T & max(const T &a, const T &b)
edm::ESHandle< SiStripNoises > noiseHandle
std::map< uint16_t, int16_t >::iterator DigiMapIter
std::pair< ContainerIterator, ContainerIterator > Range
Definition: SiStripNoises.h:41
template<typename T >
void SiStripAPVRestorer::FlatRestore ( std::vector< T > &  digis,
uint16_t  APVn 
)
inlineprivate

Definition at line 341 of file SiStripAPVRestorer.cc.

References BaselineMap_, cmsDriverOptions::counter, and strip().

Referenced by restore().

341  {
342 
343  std::vector<int16_t> baseline;
344  baseline.clear();
345  baseline.insert(baseline.begin(),128, 150);
346  baseline[0]=0; baseline[127]=0;
347  BaselineMap_.insert(BaselineMap_.end(), std::pair< uint16_t, std::vector < int16_t> >(APVn, baseline));
348 
349  typename std::vector<T>::iterator strip(digis.begin() + APVn*128), lastStrip(strip + 128);
350 
351  int counter = 0;
352  while (strip < lastStrip) {
353  *strip = baseline[counter];
354  counter++;
355  strip++;
356  }
357 
358 }
void strip(std::string &input, const std::string &blanks=" \n\t")
Definition: stringTools.cc:16
RawDigiMap& SiStripAPVRestorer::GetBaselineMap ( )
inline

Definition at line 40 of file SiStripAPVRestorer.h.

References BaselineMap_.

40 {return BaselineMap_;}
std::vector< DigiMap >& SiStripAPVRestorer::GetSmoothedPoints ( )
inline

Definition at line 41 of file SiStripAPVRestorer.h.

References SmoothedMaps_.

41 {return SmoothedMaps_;}
std::vector< DigiMap > SmoothedMaps_
void SiStripAPVRestorer::init ( const edm::EventSetup es)

Definition at line 39 of file SiStripAPVRestorer.cc.

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

39  {
40  uint32_t n_cache_id = es.get<SiStripNoisesRcd>().cacheIdentifier();
41  uint32_t q_cache_id = es.get<SiStripQualityRcd>().cacheIdentifier();
42 
43  if(n_cache_id != noise_cache_id) {
44  es.get<SiStripNoisesRcd>().get( noiseHandle );
45  noise_cache_id = n_cache_id;
46  } else {
47  noise_cache_id = n_cache_id;
48  }
49  if(q_cache_id != quality_cache_id) {
50  es.get<SiStripQualityRcd>().get( qualityHandle );
51  quality_cache_id = q_cache_id;
52  }else {
53  quality_cache_id = q_cache_id;
54  }
55 
56 
57 }
edm::ESHandle< SiStripQuality > qualityHandle
edm::ESHandle< SiStripNoises > noiseHandle
const T & get() const
Definition: EventSetup.h:55
int16_t SiStripAPVRestorer::inspect ( const uint32_t &  detId,
std::vector< int16_t > &  digis,
const std::vector< std::pair< short, float > > &  vmedians 
)

Definition at line 60 of file SiStripAPVRestorer.cc.

References AbnormalBaselineInspect(), apvFlags_, BaselineAndSaturationInspect(), BaselineFollowerInspect(), BaselineMap_, detId_, edm::hlt::Exception, i, InspectAlgo_, median_, NullInspect(), and SmoothedMaps_.

60  {
61 
62  detId_ = detId;
63 
64  apvFlags_.clear();
65  median_.clear();
66  SmoothedMaps_.clear();
67  BaselineMap_.erase(BaselineMap_.begin(), BaselineMap_.end());
68 
69  for(size_t i=0; i< vmedians.size(); ++i) median_.push_back(vmedians[i].second);
70 
71  if(InspectAlgo_=="BaselineFollower") return this->BaselineFollowerInspect(digis);
72  if(InspectAlgo_=="AbnormalBaseline") return this->AbnormalBaselineInspect(digis);
73  if(InspectAlgo_=="Null") return this->NullInspect(digis);
74  if(InspectAlgo_=="BaselineAndSaturation") return this->BaselineAndSaturationInspect(digis);
75  throw cms::Exception("Unregistered Inspect Algorithm") << "SiStripAPVRestorer possibilities: (Null), (AbnormalBaseline),(BaselineFollower)";
76 
77 }
int i
Definition: DBlmapReader.cc:9
int16_t AbnormalBaselineInspect(std::vector< T > &)
std::vector< DigiMap > SmoothedMaps_
int16_t NullInspect(std::vector< T > &)
std::vector< std::string > apvFlags_
int16_t BaselineFollowerInspect(std::vector< T > &)
int16_t BaselineAndSaturationInspect(std::vector< T > &)
std::vector< float > median_
void SiStripAPVRestorer::LoadMeanCMMap ( edm::Event iEvent)

Definition at line 578 of file SiStripAPVRestorer.cc.

References CreateCMMap(), edm::Event::getByLabel(), inputTag_, and useRealMeanCM_.

578  {
579  if(useRealMeanCM_){
581  iEvent.getByLabel(inputTag_,inputCM);
582  this->CreateCMMap(*inputCM);
583  }
584 }
void CreateCMMap(const edm::DetSetVector< SiStripProcessedRawDigi > &)
edm::InputTag inputTag_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:359
template<typename T >
int16_t SiStripAPVRestorer::NullInspect ( std::vector< T > &  digis)
inlineprivate

Definition at line 250 of file SiStripAPVRestorer.cc.

References sistrip::APV, apvFlags_, detId_, qualityHandle, RestoreAlgo_, and restoreThreshold_.

Referenced by inspect().

250  {
251 
252  SiStripQuality::Range detQualityRange = qualityHandle->getRange(detId_);
253 
254  typename std::vector<T>::iterator fs;
255 
256  int16_t nAPVflagged = 0;
257 
258  for( uint16_t APV=0; APV< digis.size()/128; ++APV){
259  int zeroCount = 0, qualityCount = 0;
260  for (uint16_t istrip=APV*128; istrip<(APV+1)*128; ++istrip){
261  fs = digis.begin() + istrip;
262  if ( !qualityHandle->IsStripBad(detQualityRange,istrip) ){
263  qualityCount++;
264  if ( (int) *fs < 1 ) zeroCount++;
265  }
266  }
267 
268  if( zeroCount > restoreThreshold_ * qualityCount ) {
269  apvFlags_.push_back( RestoreAlgo_ ); //specify any algo to make the restore
270  nAPVflagged++;
271  } else {
272  apvFlags_.push_back( "" );
273  }
274 
275  }
276 
277  return nAPVflagged;
278 
279 }
std::vector< std::string > apvFlags_
edm::ESHandle< SiStripQuality > qualityHandle
std::pair< ContainerIterator, ContainerIterator > Range
float SiStripAPVRestorer::pairMedian ( std::vector< std::pair< float, float > > &  )
private
void SiStripAPVRestorer::restore ( std::vector< int16_t > &  digis)

Definition at line 80 of file SiStripAPVRestorer.cc.

References sistrip::APV, apvFlags_, BaselineFollowerRestore(), edm::hlt::Exception, FlatRestore(), ForceNoRestore_, median_, RestoreAlgo_, and SelfSelectRestoreAlgo_.

80  {
81 
82  if(ForceNoRestore_) return;
83 
84  for( uint16_t APV=0; APV< digis.size()/128; ++APV){
85  std::string algoToUse = *( apvFlags_.begin() + APV );
86 
87  if ( algoToUse != ""){
88  if(!SelfSelectRestoreAlgo_) algoToUse = RestoreAlgo_;
89 
90  if(algoToUse=="Flat"){
91  this->FlatRestore(digis, APV);
92  }else if(algoToUse=="BaselineFollower"){
93 
94  this->BaselineFollowerRestore(digis, APV, median_[APV]);
95  // }else if(algoToUse=="IterativeMedian"){
96  //this->IterativeMedian(digis, APV);
97  }else{
98  throw cms::Exception("Unregistered Restore Algorithm") << "SiStripAPVRestorer possibilities: (Flat), (BaselineFollower)";
99  }
100  }
101  }
102 
103 }
void BaselineFollowerRestore(std::vector< T > &, uint16_t, float)
std::vector< std::string > apvFlags_
std::vector< float > median_
void FlatRestore(std::vector< T > &, uint16_t)

Friends And Related Function Documentation

friend class SiStripRawProcessingFactory
friend

Definition at line 29 of file SiStripAPVRestorer.h.

Member Data Documentation

std::vector<std::string> SiStripAPVRestorer::apvFlags_
private
RawDigiMap SiStripAPVRestorer::BaselineMap_
private
uint32_t SiStripAPVRestorer::consecThreshold_
private

Definition at line 100 of file SiStripAPVRestorer.h.

Referenced by FlatRegionsFinder().

double SiStripAPVRestorer::CutToAvoidSignal_
private

Definition at line 105 of file SiStripAPVRestorer.h.

uint32_t SiStripAPVRestorer::DeltaCMThreshold_
private

Definition at line 97 of file SiStripAPVRestorer.h.

Referenced by BaselineAndSaturationInspect(), and BaselineFollowerInspect().

uint32_t SiStripAPVRestorer::detId_
private
uint32_t SiStripAPVRestorer::deviation_
private

Definition at line 95 of file SiStripAPVRestorer.h.

Referenced by AbnormalBaselineInspect().

uint32_t SiStripAPVRestorer::distortionThreshold_
private

Definition at line 104 of file SiStripAPVRestorer.h.

Referenced by FlatRegionsFinder().

bool SiStripAPVRestorer::ForceNoRestore_
private

Definition at line 84 of file SiStripAPVRestorer.h.

Referenced by restore().

double SiStripAPVRestorer::fraction_
private

Definition at line 94 of file SiStripAPVRestorer.h.

Referenced by AbnormalBaselineInspect().

uint32_t SiStripAPVRestorer::hitStripThreshold_
private

Definition at line 101 of file SiStripAPVRestorer.h.

Referenced by FlatRegionsFinder().

edm::InputTag SiStripAPVRestorer::inputTag_
private

Definition at line 81 of file SiStripAPVRestorer.h.

Referenced by LoadMeanCMMap().

std::string SiStripAPVRestorer::InspectAlgo_
private

Definition at line 86 of file SiStripAPVRestorer.h.

Referenced by inspect().

CMMap SiStripAPVRestorer::MeanCMmap_
private
std::vector<float> SiStripAPVRestorer::median_
private
uint32_t SiStripAPVRestorer::minStripsToFit_
private

Definition at line 103 of file SiStripAPVRestorer.h.

Referenced by BaselineFollower().

uint32_t SiStripAPVRestorer::noise_cache_id
private

Definition at line 70 of file SiStripAPVRestorer.h.

Referenced by init().

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

Definition at line 69 of file SiStripAPVRestorer.h.

Referenced by FlatRegionsFinder(), and init().

uint32_t SiStripAPVRestorer::nSaturatedStrip_
private

Definition at line 106 of file SiStripAPVRestorer.h.

Referenced by BaselineAndSaturationInspect().

uint32_t SiStripAPVRestorer::nSigmaNoiseDerTh_
private

Definition at line 99 of file SiStripAPVRestorer.h.

Referenced by FlatRegionsFinder().

uint32_t SiStripAPVRestorer::nSmooth_
private

Definition at line 102 of file SiStripAPVRestorer.h.

Referenced by FlatRegionsFinder().

uint32_t SiStripAPVRestorer::quality_cache_id
private

Definition at line 67 of file SiStripAPVRestorer.h.

Referenced by init().

edm::ESHandle<SiStripQuality> SiStripAPVRestorer::qualityHandle
private
std::string SiStripAPVRestorer::RestoreAlgo_
private

Definition at line 87 of file SiStripAPVRestorer.h.

Referenced by AbnormalBaselineInspect(), NullInspect(), and restore().

double SiStripAPVRestorer::restoreThreshold_
private

Definition at line 96 of file SiStripAPVRestorer.h.

Referenced by NullInspect().

bool SiStripAPVRestorer::SelfSelectRestoreAlgo_
private

Definition at line 85 of file SiStripAPVRestorer.h.

Referenced by restore().

std::vector< DigiMap > SiStripAPVRestorer::SmoothedMaps_
private
bool SiStripAPVRestorer::useRealMeanCM_
private