CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
PedestalsAlgorithm Class Reference

Histogram-based analysis for pedestal run. More...

#include <PedestalsAlgorithm.h>

Inheritance diagram for PedestalsAlgorithm:
CommissioningAlgorithm

Public Member Functions

const HistohNoise () const
 
const HistohPeds () const
 
 PedestalsAlgorithm (const edm::ParameterSet &pset, PedestalsAnalysis *const )
 
 ~PedestalsAlgorithm () override
 
- Public Member Functions inherited from CommissioningAlgorithm
void analysis (const std::vector< TH1 * > &)
 
 CommissioningAlgorithm (CommissioningAnalysis *const )
 
 CommissioningAlgorithm ()
 
virtual ~CommissioningAlgorithm ()
 

Private Member Functions

void analyse () override
 
void extract (const std::vector< TH1 * > &) override
 
 PedestalsAlgorithm ()
 

Private Attributes

float deadStripMax_
 
Histo hNoise_
 
Histo hPeds_
 
float noisyStripMin_
 

Additional Inherited Members

- Public Types inherited from CommissioningAlgorithm
typedef std::pair< TH1 *, std::string > Histo
 
- Protected Member Functions inherited from CommissioningAlgorithm
CommissioningAnalysis *const anal () const
 
uint32_t extractFedKey (const TH1 *const )
 

Detailed Description

Histogram-based analysis for pedestal run.

Author
M. Wingham, R.Bainbridge

Definition at line 16 of file PedestalsAlgorithm.h.

Constructor & Destructor Documentation

PedestalsAlgorithm::PedestalsAlgorithm ( const edm::ParameterSet pset,
PedestalsAnalysis * const  anal 
)

Definition at line 16 of file PedestalsAlgorithm.cc.

References deadStripMax_, LogDebug, sistrip::mlCommissioning_, and noisyStripMin_.

17  : CommissioningAlgorithm(anal),
18  hPeds_(nullptr,""),
19  hNoise_(nullptr,""),
20  deadStripMax_(pset.getParameter<double>("DeadStripMax")),
21  noisyStripMin_(pset.getParameter<double>("NoisyStripMin"))
22 {
24  << "[PedestalsAlgorithm::" << __func__ << "]"
25  << " Set maximum noise deviation for dead strip determination to: " << deadStripMax_;
27  << "[PedestalsAlgorithm::" << __func__ << "]"
28  << " Set minimal noise deviation for noisy strip determination to: " << noisyStripMin_;
29 }
#define LogDebug(id)
T getParameter(std::string const &) const
static const char mlCommissioning_[]
PedestalsAlgorithm::~PedestalsAlgorithm ( )
inlineoverride

Definition at line 22 of file PedestalsAlgorithm.h.

References hNoise(), and hPeds().

22 {;}
PedestalsAlgorithm::PedestalsAlgorithm ( )
inlineprivate

Definition at line 30 of file PedestalsAlgorithm.h.

References analyse(), and extract().

30 {;}

Member Function Documentation

void PedestalsAlgorithm::analyse ( )
overrideprivatevirtual

Performs histogram anaysis.

Implements CommissioningAlgorithm.

Definition at line 93 of file PedestalsAlgorithm.cc.

References CommissioningAnalysis::addErrorCode(), CommissioningAlgorithm::anal(), PedestalsAnalysis::dead_, deadStripMax_, hNoise_, hPeds_, sistrip::invalid_, sistrip::maximum_, sistrip::mlCommissioning_, PedestalsAnalysis::noise_, PedestalsAnalysis::noiseMax_, PedestalsAnalysis::noiseMean_, PedestalsAnalysis::noiseMin_, PedestalsAnalysis::noiseSpread_, PedestalsAnalysis::noisy_, noisyStripMin_, sistrip::nullPtr_, sistrip::numberOfBins_, PedestalsAnalysis::peds_, PedestalsAnalysis::pedsMax_, PedestalsAnalysis::pedsMean_, PedestalsAnalysis::pedsMin_, PedestalsAnalysis::pedsSpread_, PedestalsAnalysis::raw_, PedestalsAnalysis::rawMax_, PedestalsAnalysis::rawMean_, PedestalsAnalysis::rawMin_, PedestalsAnalysis::rawSpread_, mathSSE::sqrt(), digitizers_cfi::strip, and tmp.

Referenced by PedestalsAlgorithm().

93  {
94 
95  if ( !anal() ) {
97  << "[PedestalsAlgorithm::" << __func__ << "]"
98  << " NULL pointer to base Analysis object!";
99  return;
100  }
101 
103  PedestalsAnalysis* anal = dynamic_cast<PedestalsAnalysis*>( tmp );
104  if ( !anal ) {
106  << "[PedestalsAlgorithm::" << __func__ << "]"
107  << " NULL pointer to derived Analysis object!";
108  return;
109  }
110 
111  if ( !hPeds_.first ) {
113  return;
114  }
115 
116  if ( !hNoise_.first ) {
118  return;
119  }
120 
121  TProfile* peds_histo = dynamic_cast<TProfile*>(hPeds_.first);
122  TProfile* noise_histo = dynamic_cast<TProfile*>(hNoise_.first);
123 
124  if ( !peds_histo ) {
126  return;
127  }
128 
129  if ( !noise_histo ) {
131  return;
132  }
133 
134  if ( peds_histo->GetNbinsX() != 256 ) {
136  return;
137  }
138 
139  if ( noise_histo->GetNbinsX() != 256 ) {
141  return;
142  }
143 
144  // Iterate through APVs
145  for ( uint16_t iapv = 0; iapv < 2; iapv++ ) {
146 
147  // Used to calc mean and rms for peds and noise
148  float p_sum = 0., p_sum2 = 0., p_max = -1.*sistrip::invalid_, p_min = sistrip::invalid_;
149  float n_sum = 0., n_sum2 = 0., n_max = -1.*sistrip::invalid_, n_min = sistrip::invalid_;
150  float r_sum = 0., r_sum2 = 0., r_max = -1.*sistrip::invalid_, r_min = sistrip::invalid_;
151 
152  // Iterate through strips of APV
153  for ( uint16_t istr = 0; istr < 128; istr++ ) {
154 
155  uint16_t strip = iapv*128 + istr;
156 
157  // Pedestals and raw noise
158  if ( peds_histo ) {
159  if ( peds_histo->GetBinEntries(strip+1) ) {
160 
161  anal->peds_[iapv][istr] = peds_histo->GetBinContent(strip+1);
162  p_sum += anal->peds_[iapv][istr];
163  p_sum2 += (anal->peds_[iapv][istr] * anal->peds_[iapv][istr]);
164  if ( anal->peds_[iapv][istr] > p_max ) { p_max = anal->peds_[iapv][istr]; }
165  if ( anal->peds_[iapv][istr] < p_min ) { p_min = anal->peds_[iapv][istr]; }
166 
167  anal->raw_[iapv][istr] = peds_histo->GetBinError(strip+1);
168  r_sum += anal->raw_[iapv][istr];
169  r_sum2 += (anal->raw_[iapv][istr] * anal->raw_[iapv][istr]);
170  if ( anal->raw_[iapv][istr] > r_max ) { r_max = anal->raw_[iapv][istr]; }
171  if ( anal->raw_[iapv][istr] < r_min ) { r_min = anal->raw_[iapv][istr]; }
172 
173  }
174  }
175 
176  // Noise
177  if ( noise_histo ) {
178  if ( noise_histo->GetBinEntries(strip+1) ) {
179  anal->noise_[iapv][istr] = noise_histo->GetBinContent(strip+1);
180  n_sum += anal->noise_[iapv][istr];
181  n_sum2 += (anal->noise_[iapv][istr] * anal->noise_[iapv][istr]);
182  if ( anal->noise_[iapv][istr] > n_max ) { n_max = anal->noise_[iapv][istr]; }
183  if ( anal->noise_[iapv][istr] < n_min ) { n_min = anal->noise_[iapv][istr]; }
184  }
185  }
186 
187  } // strip loop
188 
189  // Calc mean and rms for peds
190  if ( !anal->peds_[iapv].empty() ) {
191  p_sum /= static_cast<float>( anal->peds_[iapv].size() );
192  p_sum2 /= static_cast<float>( anal->peds_[iapv].size() );
193  anal->pedsMean_[iapv] = p_sum;
194  anal->pedsSpread_[iapv] = sqrt( fabs(p_sum2 - p_sum*p_sum) );
195  }
196 
197  // Calc mean and rms for noise
198  if ( !anal->noise_[iapv].empty() ) {
199  n_sum /= static_cast<float>( anal->noise_[iapv].size() );
200  n_sum2 /= static_cast<float>( anal->noise_[iapv].size() );
201  anal->noiseMean_[iapv] = n_sum;
202  anal->noiseSpread_[iapv] = sqrt( fabs(n_sum2 - n_sum*n_sum) );
203  }
204 
205  // Calc mean and rms for raw noise
206  if ( !anal->raw_[iapv].empty() ) {
207  r_sum /= static_cast<float>( anal->raw_[iapv].size() );
208  r_sum2 /= static_cast<float>( anal->raw_[iapv].size() );
209  anal->rawMean_[iapv] = r_sum;
210  anal->rawSpread_[iapv] = sqrt( fabs(r_sum2 - r_sum*r_sum) );
211  }
212 
213  // Set max and min values for peds, noise and raw noise
214  if ( p_max > -1.*sistrip::maximum_ ) { anal->pedsMax_[iapv] = p_max; }
215  if ( p_min < 1.*sistrip::maximum_ ) { anal->pedsMin_[iapv] = p_min; }
216  if ( n_max > -1.*sistrip::maximum_ ) { anal->noiseMax_[iapv] = n_max; }
217  if ( n_min < 1.*sistrip::maximum_ ) { anal->noiseMin_[iapv] = n_min; }
218  if ( r_max > -1.*sistrip::maximum_ ) { anal->rawMax_[iapv] = r_max; }
219  if ( r_min < 1.*sistrip::maximum_ ) { anal->rawMin_[iapv] = r_min; }
220 
221  // Set dead and noisy strips
222  for ( uint16_t istr = 0; istr < 128; istr++ ) {
223  if ( anal->noiseMin_[iapv] > sistrip::maximum_ ||
224  anal->noiseMax_[iapv] > sistrip::maximum_ ) { continue; }
225  if ( anal->noise_[iapv][istr] < ( anal->noiseMean_[iapv] - deadStripMax_ * anal->noiseSpread_[iapv] ) ) {
226  anal->dead_[iapv].push_back(istr);
227  }
228  else if ( anal->noise_[iapv][istr] > ( anal->noiseMean_[iapv] + noisyStripMin_ * anal->noiseSpread_[iapv] ) ) {
229  anal->noisy_[iapv].push_back(istr);
230  }
231  }
232 
233  } // apv loop
234 
235 }
static const char numberOfBins_[]
static const char mlCommissioning_[]
T sqrt(T t)
Definition: SSEVec.h:18
Histogram-based analysis for pedestal run.
static const uint16_t maximum_
Definition: Constants.h:20
virtual void addErrorCode(const std::string &error)
static const uint16_t invalid_
Definition: Constants.h:16
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
Abstract base for derived classes that provide analysis of commissioning histograms.
CommissioningAnalysis *const anal() const
static const char nullPtr_[]
void PedestalsAlgorithm::extract ( const std::vector< TH1 * > &  histos)
overrideprivatevirtual

Extracts and organises histograms.

Implements CommissioningAlgorithm.

Definition at line 33 of file PedestalsAlgorithm.cc.

References a, CommissioningAnalysis::addErrorCode(), CommissioningAlgorithm::anal(), sistrip::extrainfo::commonMode_, CommissioningAlgorithm::extractFedKey(), CommissioningAnalysis::fedKey(), hNoise_, hPeds_, PedestalsAnalysis::legacy_, sistrip::mlCommissioning_, sistrip::extrainfo::noise_, sistrip::numberOfHistos_, sistrip::PEDESTALS, sistrip::extrainfo::pedestals_, sistrip::extrainfo::pedsAndCmSubNoise_, sistrip::extrainfo::pedsAndRawNoise_, runGCPTkAlMap::title, sistrip::unexpectedExtraInfo_, and sistrip::unexpectedTask_.

Referenced by PedestalsAlgorithm().

33  {
34 
35  if ( !anal() ) {
37  << "[PedestalsAlgorithm::" << __func__ << "]"
38  << " NULL pointer to Analysis object!";
39  return;
40  }
41 
42  // Check number of histograms
43  if ( histos.size() != 2 ) {
45  }
46 
47  // Extract FED key from histo title
48  if ( !histos.empty() ) { anal()->fedKey( extractFedKey( histos.front() ) ); }
49 
50  // Extract histograms
51  std::vector<TH1*>::const_iterator ihis = histos.begin();
52  for ( ; ihis != histos.end(); ihis++ ) {
53 
54  // Check for NULL pointer
55  if ( !(*ihis) ) { continue; }
56 
57  // Check run type
58  SiStripHistoTitle title( (*ihis)->GetName() );
59  if ( title.runType() != sistrip::PEDESTALS ) {
61  continue;
62  }
63 
64  // Extract peds and noise histos (check for legacy names first!)
65  if ( title.extraInfo().find(sistrip::extrainfo::pedsAndRawNoise_) != std::string::npos ) {
66  hPeds_.first = *ihis;
67  hPeds_.second = (*ihis)->GetName();
68  PedestalsAnalysis* a = dynamic_cast<PedestalsAnalysis*>( const_cast<CommissioningAnalysis*>( anal() ) );
69  if ( a ) { a->legacy_ = true; }
70  } else if ( title.extraInfo().find(sistrip::extrainfo::pedsAndCmSubNoise_) != std::string::npos ) {
71  hNoise_.first = *ihis;
72  hNoise_.second = (*ihis)->GetName();
73  PedestalsAnalysis* a = dynamic_cast<PedestalsAnalysis*>( const_cast<CommissioningAnalysis*>( anal() ) );
74  if ( a ) { a->legacy_ = true; }
75  } else if ( title.extraInfo().find(sistrip::extrainfo::pedestals_) != std::string::npos ) {
76  hPeds_.first = *ihis;
77  hPeds_.second = (*ihis)->GetName();
78  } else if ( title.extraInfo().find(sistrip::extrainfo::noise_) != std::string::npos ) {
79  hNoise_.first = *ihis;
80  hNoise_.second = (*ihis)->GetName();
81  } else if ( title.extraInfo().find(sistrip::extrainfo::commonMode_) != std::string::npos ) {
82  //@@ something here for CM plots?
83  } else {
85  }
86 
87  }
88 
89 }
static const char noise_[]
static const char unexpectedTask_[]
const uint32_t & fedKey() const
static const char pedsAndRawNoise_[]
Utility class that holds histogram title.
static const char numberOfHistos_[]
static const char unexpectedExtraInfo_[]
static const char mlCommissioning_[]
uint32_t extractFedKey(const TH1 *const )
Histogram-based analysis for pedestal run.
virtual void addErrorCode(const std::string &error)
static const char commonMode_[]
static const char pedestals_[]
static const char pedsAndCmSubNoise_[]
double a
Definition: hdecay.h:121
Abstract base for derived classes that provide analysis of commissioning histograms.
CommissioningAnalysis *const anal() const
const PedestalsAlgorithm::Histo & PedestalsAlgorithm::hNoise ( ) const
inline

Definition at line 54 of file PedestalsAlgorithm.h.

References hNoise_.

Referenced by ~PedestalsAlgorithm().

54 { return hNoise_; }
const PedestalsAlgorithm::Histo & PedestalsAlgorithm::hPeds ( ) const
inline

Definition at line 52 of file PedestalsAlgorithm.h.

References hPeds_.

Referenced by ~PedestalsAlgorithm().

52 { return hPeds_; }

Member Data Documentation

float PedestalsAlgorithm::deadStripMax_
private

Analysis parameters

Definition at line 47 of file PedestalsAlgorithm.h.

Referenced by analyse(), and PedestalsAlgorithm().

Histo PedestalsAlgorithm::hNoise_
private

Residuals and noise

Definition at line 44 of file PedestalsAlgorithm.h.

Referenced by analyse(), extract(), and hNoise().

Histo PedestalsAlgorithm::hPeds_
private

Pedestals and raw noise

Definition at line 41 of file PedestalsAlgorithm.h.

Referenced by analyse(), extract(), and hPeds().

float PedestalsAlgorithm::noisyStripMin_
private

Definition at line 48 of file PedestalsAlgorithm.h.

Referenced by analyse(), and PedestalsAlgorithm().