CMS 3D CMS Logo

PedsFullNoiseAlgorithm.cc
Go to the documentation of this file.
6 
7 #include "TProfile.h"
8 #include "TH1.h"
9 #include "TH2.h"
10 #include "TF1.h"
11 #include "TFitResult.h"
12 #include "TMath.h"
13 #include "Math/DistFunc.h"
14 #include "Math/ProbFuncMathCore.h"
15 #include "Fit/BinData.h"
16 #include "HFitInterface.h"
17 #include "Math/GoFTest.h"
18 #include <iostream>
19 #include <iomanip>
20 #include <cmath>
21 
22 using namespace sistrip;
23 using namespace std;
24 // ----------------------------------------------------------------------------
25 //
28  hPeds_(nullptr, ""),
29  hNoise_(nullptr, ""),
30  hNoise2D_(nullptr, ""),
31  maxDriftResidualCut_(pset.getParameter<double>("MaxDriftResidualCut")),
32  minStripNoiseCut_(pset.getParameter<double>("MinStripNoiseCut")),
33  maxStripNoiseCut_(pset.getParameter<double>("MaxStripNoiseCut")),
34  maxStripNoiseSignificanceCut_(pset.getParameter<double>("MaxStripNoiseSignificanceCut")),
35  adProbabCut_(pset.getParameter<double>("AdProbabCut")),
36  ksProbabCut_(pset.getParameter<double>("KsProbabCut")),
37  generateRandomHisto_(pset.getParameter<bool>("GenerateRandomHisto")),
38  jbProbabCut_(pset.getParameter<double>("JbProbabCut")),
39  chi2ProbabCut_(pset.getParameter<double>("Chi2ProbabCut")),
40  kurtosisCut_(pset.getParameter<double>("KurtosisCut")),
41  integralTailCut_(pset.getParameter<double>("IntegralTailCut")),
42  integralNsigma_(pset.getParameter<int>("IntegralNsigma")),
43  ashmanDistance_(pset.getParameter<double>("AshmanDistance")),
44  amplitudeRatio_(pset.getParameter<double>("AmplitudeRatio")) {
45  LogDebug(mlCommissioning_) << "[PedsFullNoiseAlgorithm::" << __func__ << "]"
46  << " Set maximum drift of the mean value to: " << maxDriftResidualCut_
47  << " Set minimum noise value to: " << minStripNoiseCut_
48  << " Set maximum noise value to: " << maxStripNoiseCut_
49  << " Set maximum noise significance value to: " << maxStripNoiseSignificanceCut_
50  << " Set minimum Anderson-Darling p-value to: " << adProbabCut_
51  << " Set minimum Kolmogorov-Smirnov p-value to: " << ksProbabCut_
52  << " Set minimum Jacque-Bera p-value to: " << jbProbabCut_
53  << " Set minimum Chi2 p-value to: " << chi2ProbabCut_
54  << " Set N-sigma for the integral to : " << integralNsigma_
55  << " Set maximum integral tail at N-sigma to : " << integralTailCut_
56  << " Set maximum Kurtosis to : " << kurtosisCut_;
57 }
58 
59 // ----------------------------------------------------------------------------
60 //
61 
62 void PedsFullNoiseAlgorithm::extract(const std::vector<TH1*>& histos) {
63  if (!anal()) {
64  edm::LogWarning(mlCommissioning_) << "[PedsFullNoiseAlgorithm::" << __func__ << "]"
65  << " NULL pointer to Analysis object!";
66  return;
67  }
68 
69  // Check number of histograms --> Pedestal, noise and noise2D
70  if (histos.size() != 3) {
72  }
73 
74  // Extract FED key from histo title --> i.e. APV pairs or LLD channel
75  if (!histos.empty()) {
76  anal()->fedKey(extractFedKey(histos.front()));
77  }
78 
79  // Extract 1D histograms
80  std::vector<TH1*>::const_iterator ihis = histos.begin();
81  for (; ihis != histos.end(); ihis++) {
82  // Check for NULL pointer
83  if (!(*ihis)) {
84  continue;
85  }
86 
87  SiStripHistoTitle title((*ihis)->GetName());
88  if (title.runType() != sistrip::PEDS_FULL_NOISE) {
90  continue;
91  }
92 
93  // Extract peds histos
94  if (title.extraInfo().find(sistrip::extrainfo::roughPedestals_) != std::string::npos) {
95  //@@ something here for rough peds?
96  } else if (title.extraInfo().find(sistrip::extrainfo::pedestals_) != std::string::npos) {
97  hPeds_.first = *ihis;
98  hPeds_.second = (*ihis)->GetName();
99  } else if (title.extraInfo().find(sistrip::extrainfo::commonMode_) != std::string::npos) {
100  //@@ something here for CM plots?
101  } else if (title.extraInfo().find(sistrip::extrainfo::noiseProfile_) != std::string::npos) {
102  //@@ something here for noise profile plot?
103  hNoise_.first = *ihis;
104  hNoise_.second = (*ihis)->GetName();
105  } else if (title.extraInfo().find(sistrip::extrainfo::noise2D_) != std::string::npos) {
106  hNoise2D_.first = *ihis;
107  hNoise2D_.second = (*ihis)->GetName();
108  } else {
110  }
111  }
112 }
113 
114 // resetting vectors
116  for (size_t iapv = 0; iapv < ana->peds_.size(); iapv++) {
117  ana->pedsMean_[iapv] = 0.;
118  ana->rawMean_[iapv] = 0.;
119  ana->noiseMean_[iapv] = 0.;
120  ana->pedsSpread_[iapv] = 0.;
121  ana->noiseSpread_[iapv] = 0.;
122  ana->rawSpread_[iapv] = 0.;
123  ana->pedsMax_[iapv] = 0.;
124  ana->pedsMin_[iapv] = 0.;
125  ana->rawMax_[iapv] = 0.;
126  ana->rawMin_[iapv] = 0.;
127  ana->noiseMax_[iapv] = 0.;
128  ana->noiseMin_[iapv] = 0.;
129 
130  for (size_t istrip = 0; istrip < ana->peds_[iapv].size(); istrip++) {
131  ana->peds_[iapv][istrip] = 0.;
132  ana->noise_[iapv][istrip] = 0.;
133  ana->raw_[iapv][istrip] = 0.;
134  ana->adProbab_[iapv][istrip] = 0.;
135  ana->ksProbab_[iapv][istrip] = 0.;
136  ana->jbProbab_[iapv][istrip] = 0.;
137  ana->chi2Probab_[iapv][istrip] = 0.;
138  ana->residualRMS_[iapv][istrip] = 0.;
139  ana->residualSigmaGaus_[iapv][istrip] = 0.;
140  ana->noiseSignificance_[iapv][istrip] = 0.;
141  ana->residualMean_[iapv][istrip] = 0.;
142  ana->residualSkewness_[iapv][istrip] = 0.;
143  ana->residualKurtosis_[iapv][istrip] = 0.;
144  ana->residualIntegralNsigma_[iapv][istrip] = 0.;
145  ana->residualIntegral_[iapv][istrip] = 0.;
146  ana->deadStripBit_[iapv][istrip] = 0;
147  ana->badStripBit_[iapv][istrip] = 0;
148  }
149  }
150 }
151 
152 // -----------------------------------------------------------------------------
153 //
155  // check base analysis object
156  if (!anal()) {
157  edm::LogWarning(mlCommissioning_) << "[PedsFullNoiseAlgorithm::" << __func__ << "]"
158  << " NULL pointer to base Analysis object!";
159  return;
160  }
161 
162  CommissioningAnalysis* tmp = const_cast<CommissioningAnalysis*>(anal());
163  PedsFullNoiseAnalysis* ana = dynamic_cast<PedsFullNoiseAnalysis*>(tmp);
164 
165  // check PedsFullNoiseAnalysis object
166  if (!ana) {
167  edm::LogWarning(mlCommissioning_) << "[PedsFullNoiseAlgorithm::" << __func__ << "]"
168  << " NULL pointer to derived Analysis object!";
169  return;
170  }
171 
172  // check if the histograms exists
173  if (!hPeds_.first) {
175  return;
176  }
177 
178  if (!hNoise_.first) {
180  return;
181  }
182 
183  if (!hNoise2D_.first) {
185  return;
186  }
187 
188  // take the histograms
189  TProfile* histoPeds = dynamic_cast<TProfile*>(hPeds_.first);
190  TProfile* histoNoiseMean = dynamic_cast<TProfile*>(hNoise_.first);
191  TH2S* histoNoise = dynamic_cast<TH2S*>(hNoise2D_.first);
192 
193  // Make sanity checks about pointers
194  if (not histoPeds) {
196  return;
197  }
198 
199  if (not histoNoiseMean) {
201  return;
202  }
203 
204  if (not histoNoise) {
206  return;
207  }
208 
209  // check the binning --> each x-axis bin is 1 strip -> 2APV per lldChannel -> 256 strips
210  if (histoPeds->GetNbinsX() != 256) {
212  return;
213  }
214 
215  //check the binning --> each x-axis bin is 1 strip -> 2APV per lldChannel -> 256 strips
216  if (histoNoiseMean->GetNbinsX() != 256) {
218  return;
219  }
220 
221  //check the binning --> each y-axis bin is 1 strip -> 2APV per lldChannel -> 256 strips
222  if (histoNoise->GetNbinsY() != 256) {
224  return;
225  }
226 
227  //Reset values
228  reset(ana);
229 
230  // loop on each strip
231  uint32_t apvID = -1;
232 
233  // Save basic information at strip / APV level
234  vector<float> ped_max;
235  vector<float> ped_min;
236  vector<float> raw_max;
237  vector<float> raw_min;
238  vector<float> noise_max;
239  vector<float> noise_min;
240 
241  // loop on each strip in the lldChannel
242  for (int iStrip = 0; iStrip < histoPeds->GetNbinsX(); iStrip++) {
243  if (iStrip < histoPeds->GetNbinsX() / 2)
244  apvID = 0;
245  else
246  apvID = 1;
247 
248  int stripBin = 0;
249  if (iStrip >= 128)
250  stripBin = iStrip - 128;
251  else
252  stripBin = iStrip;
253 
254  ana->peds_[apvID][stripBin] = histoPeds->GetBinContent(iStrip + 1); // pedestal value
255  ana->noise_[apvID][stripBin] = histoNoiseMean->GetBinContent(iStrip + 1); // noise value
256  ana->raw_[apvID][stripBin] = histoPeds->GetBinError(iStrip + 1); // raw noise value
257 
258  ana->pedsMean_[apvID] += ana->peds_[apvID][stripBin]; // mean pedestal
259  ana->rawMean_[apvID] += ana->raw_[apvID][stripBin]; // mean raw noise
260  ana->noiseMean_[apvID] += ana->noise_[apvID][stripBin]; // mean noise
261 
262  // max pedestal
263  if (ped_max.size() < apvID + 1)
264  ped_max.push_back(ana->peds_[apvID][stripBin]);
265  else {
266  if (ana->peds_[apvID][stripBin] > ped_max.at(apvID))
267  ped_max.at(apvID) = ana->peds_[apvID][stripBin];
268  }
269 
270  // min pedestal
271  if (ped_min.size() < apvID + 1)
272  ped_min.push_back(ana->peds_[apvID][stripBin]);
273  else {
274  if (ana->peds_[apvID][stripBin] < ped_min.at(apvID))
275  ped_min.at(apvID) = ana->peds_[apvID][stripBin]; // min pedestal
276  }
277 
278  // max noise
279  if (noise_max.size() < apvID + 1)
280  noise_max.push_back(ana->noise_[apvID][stripBin]);
281  else {
282  if (ana->noise_[apvID][stripBin] > noise_max.at(apvID))
283  noise_max.at(apvID) = ana->noise_[apvID][stripBin];
284  }
285 
286  // min noise
287  if (noise_min.size() < apvID + 1)
288  noise_min.push_back(ana->noise_[apvID][stripBin]);
289  else {
290  if (ana->noise_[apvID][stripBin] < noise_min.at(apvID))
291  noise_min.at(apvID) = ana->noise_[apvID][stripBin];
292  }
293 
294  // max raw
295  if (raw_max.size() < apvID + 1)
296  raw_max.push_back(ana->raw_[apvID][stripBin]);
297  else {
298  if (ana->raw_[apvID][stripBin] > raw_max.at(apvID))
299  raw_max.at(apvID) = ana->raw_[apvID][stripBin];
300  }
301 
302  // min raw
303  if (raw_min.size() < apvID + 1)
304  raw_min.push_back(ana->raw_[apvID][stripBin]);
305  else {
306  if (ana->raw_[apvID][stripBin] < raw_min.at(apvID))
307  raw_min.at(apvID) = ana->raw_[apvID][stripBin];
308  }
309  }
310 
311  // Mean values
312  for (unsigned int iApv = 0; iApv < ana->pedsMean_.size(); iApv++) {
313  ana->pedsMean_.at(iApv) /= (ana->peds_[iApv].size()); // calculate mean pedestal per APV
314  ana->rawMean_.at(iApv) /= (ana->raw_[iApv].size()); // calculate mean raw noise per APV
315  ana->noiseMean_.at(iApv) /= (ana->noise_[iApv].size()); // calculate mean noise per APV
316  }
317 
318  // Min and Max
319  for (unsigned int iApv = 0; iApv < ped_max.size(); iApv++) {
320  if (ped_max.at(iApv) > sistrip::maximum_)
321  ana->pedsMax_.at(iApv) = sistrip::maximum_;
322  else if (ped_max.at(iApv) < -1. * sistrip::maximum_)
323  ana->pedsMax_.at(iApv) = -1. * sistrip::maximum_;
324  else
325  ana->pedsMax_.at(iApv) = ped_max.at(iApv);
326 
327  if (ped_min.at(iApv) > sistrip::maximum_)
328  ana->pedsMin_.at(iApv) = sistrip::maximum_;
329  else if (ped_min.at(iApv) < -1. * sistrip::maximum_)
330  ana->pedsMin_.at(iApv) = -1. * sistrip::maximum_;
331  else
332  ana->pedsMin_.at(iApv) = ped_min.at(iApv);
333 
334  if (noise_max.at(iApv) > sistrip::maximum_)
335  ana->noiseMax_.at(iApv) = sistrip::maximum_;
336  else if (noise_max.at(iApv) < -1. * sistrip::maximum_)
337  ana->noiseMax_.at(iApv) = -1. * sistrip::maximum_;
338  else
339  ana->noiseMax_.at(iApv) = noise_max.at(iApv);
340 
341  if (noise_min.at(iApv) > sistrip::maximum_)
342  ana->noiseMin_.at(iApv) = sistrip::maximum_;
343  else if (noise_min.at(iApv) < -1. * sistrip::maximum_)
344  ana->noiseMin_.at(iApv) = -1. * sistrip::maximum_;
345  else
346  ana->noiseMin_.at(iApv) = noise_min.at(iApv);
347 
348  if (raw_max.at(iApv) > sistrip::maximum_)
349  ana->rawMax_.at(iApv) = sistrip::maximum_;
350  else if (raw_max.at(iApv) < -1. * sistrip::maximum_)
351  ana->rawMax_.at(iApv) = -1. * sistrip::maximum_;
352  else
353  ana->rawMax_.at(iApv) = raw_max.at(iApv);
354 
355  if (raw_min.at(iApv) > sistrip::maximum_)
356  ana->rawMin_.at(iApv) = sistrip::maximum_;
357  else if (raw_min.at(iApv) < -1. * sistrip::maximum_)
358  ana->rawMin_.at(iApv) = -1. * sistrip::maximum_;
359  else
360  ana->rawMin_.at(iApv) = raw_min.at(iApv);
361  }
362 
363  // Calculate the spread for noise and pedestal
364  apvID = -1;
365 
366  for (int iStrip = 0; iStrip < histoNoiseMean->GetNbinsX(); iStrip++) {
367  if (iStrip < histoNoiseMean->GetNbinsX() / 2)
368  apvID = 0;
369  else
370  apvID = 1;
371  ana->pedsSpread_[apvID] += pow(histoPeds->GetBinContent(iStrip + 1) - ana->pedsMean_.at(apvID), 2);
372  ana->noiseSpread_[apvID] += pow(histoNoiseMean->GetBinContent(iStrip + 1) - ana->noiseMean_.at(apvID), 2);
373  ana->rawSpread_[apvID] += pow(histoPeds->GetBinError(iStrip + 1) - ana->rawMean_.at(apvID), 2);
374  }
375 
376  for (unsigned int iApv = 0; iApv < ana->pedsSpread_.size(); iApv++) {
377  ana->pedsSpread_[iApv] = sqrt(ana->pedsSpread_[iApv]) / sqrt(ana->peds_[iApv].size() - 1);
378  ana->noiseSpread_[iApv] = sqrt(ana->noiseSpread_[iApv]) / sqrt(ana->noise_[iApv].size() - 1);
379  ana->rawSpread_[iApv] = sqrt(ana->rawSpread_[iApv]) / sqrt(ana->raw_[iApv].size() - 1);
380  }
381 
382  // loop on each strip in the lldChannel
383  apvID = 0;
384  TH1S* histoResidualStrip = new TH1S("histoResidualStrip",
385  "",
386  histoNoise->GetNbinsX(),
387  histoNoise->GetXaxis()->GetXmin(),
388  histoNoise->GetXaxis()->GetXmax());
389  histoResidualStrip->Sumw2();
390  histoResidualStrip->SetDirectory(nullptr);
391  TF1* fitFunc = new TF1("fitFunc", "gaus(0)", histoNoise->GetXaxis()->GetXmin(), histoNoise->GetXaxis()->GetXmax());
392  TF1* fit2Gaus = nullptr;
393  TH1F* randomHisto = nullptr;
394  TFitResultPtr result;
395 
396  for (int iStrip = 0; iStrip < histoNoise->GetNbinsY(); iStrip++) {
397  // tell which APV
398  if (iStrip < histoNoise->GetNbinsY() / 2)
399  apvID = 0;
400  else
401  apvID = 1;
402  histoResidualStrip->Reset();
403 
404  int stripBin = 0;
405  if (iStrip >= 128)
406  stripBin = iStrip - 128;
407  else
408  stripBin = iStrip;
409 
410  for (int iBinX = 0; iBinX < histoNoise->GetNbinsX(); iBinX++) {
411  histoResidualStrip->SetBinContent(iBinX + 1, histoNoise->GetBinContent(iBinX + 1, iStrip + 1));
412  histoResidualStrip->SetBinError(iBinX + 1, histoNoise->GetBinError(iBinX + 1, iStrip + 1));
413  }
414 
415  if (histoResidualStrip->Integral() == 0) { // dead strip --> i.e. no data
416 
417  // set default values
418  ana->adProbab_[apvID][stripBin] = 0;
419  ana->ksProbab_[apvID][stripBin] = 0;
420  ana->jbProbab_[apvID][stripBin] = 0;
421  ana->chi2Probab_[apvID][stripBin] = 0;
422  ana->noiseSignificance_[apvID][stripBin] = 0;
423  ana->residualMean_[apvID][stripBin] = 0;
424  ana->residualRMS_[apvID][stripBin] = 0;
425  ana->residualSigmaGaus_[apvID][stripBin] = 0;
426  ana->residualSkewness_[apvID][stripBin] = 0;
427  ana->residualKurtosis_[apvID][stripBin] = 0;
428  ana->residualIntegralNsigma_[apvID][stripBin] = 0;
429  ana->residualIntegral_[apvID][stripBin] = 0;
430  ana->deadStrip_[apvID].push_back(stripBin);
431  ana->deadStripBit_[apvID][stripBin] = 1;
432  ana->badStripBit_[apvID][stripBin] = 0;
433 
434  SiStripFecKey fec_key(ana->fecKey());
435  LogTrace(mlDqmClient_) << "DeadStrip: fecCrate "
436  << " " << fec_key.fecCrate() << " fecSlot " << fec_key.fecSlot() << " fecRing "
437  << fec_key.fecRing() << " ccuAddr " << fec_key.ccuAddr() << " ccChan "
438  << fec_key.ccuChan() << " lldChan " << fec_key.lldChan() << " apvID " << apvID
439  << " stripID " << iStrip;
440 
441  continue;
442  }
443 
444  // set / calculated basic quantities
445  ana->residualMean_[apvID][stripBin] = histoResidualStrip->GetMean();
446  ana->residualRMS_[apvID][stripBin] = histoResidualStrip->GetRMS();
447  ana->residualSkewness_[apvID][stripBin] = histoResidualStrip->GetSkewness();
448  ana->residualKurtosis_[apvID][stripBin] = histoResidualStrip->GetKurtosis();
449  ana->noiseSignificance_[apvID][stripBin] =
450  (ana->noise_[apvID][stripBin] - ana->noiseMean_[apvID]) / ana->noiseSpread_[apvID];
451  ana->residualIntegral_[apvID][stripBin] = histoResidualStrip->Integral();
452  ana->residualIntegralNsigma_[apvID][stripBin] =
453  (histoResidualStrip->Integral(histoResidualStrip->FindBin(ana->residualMean_[apvID][stripBin] +
454  ana->residualRMS_[apvID][stripBin] * integralNsigma_),
455  histoResidualStrip->GetNbinsX() + 1) +
456  histoResidualStrip->Integral(
457  0,
458  histoResidualStrip->FindBin(ana->residualMean_[apvID][stripBin] -
459  ana->residualRMS_[apvID][stripBin] * integralNsigma_))) /
460  ana->residualIntegral_[apvID][stripBin];
461 
462  // performing a Gaussian fit of the residual distribution
463  fitFunc->SetRange(histoNoise->GetXaxis()->GetXmin(), histoNoise->GetXaxis()->GetXmax());
464  fitFunc->SetParameters(ana->residualIntegral_[apvID][stripBin],
465  ana->residualMean_[apvID][stripBin],
466  ana->residualRMS_[apvID][stripBin]);
467  result = histoResidualStrip->Fit(fitFunc, "QSRN");
468 
469  // Good gaussian fit
470  if (result.Get()) {
471  ana->residualSigmaGaus_[apvID][stripBin] = fitFunc->GetParameter(2);
472  ana->chi2Probab_[apvID][stripBin] = result->Prob();
473 
474  // jacque bera probability
475  float jbVal =
476  (ana->residualIntegral_[apvID][stripBin] / 6) *
477  (pow(ana->residualSkewness_[apvID][stripBin], 2) + pow(ana->residualKurtosis_[apvID][stripBin], 2) / 4);
478  ana->jbProbab_[apvID][stripBin] = ROOT::Math::chisquared_cdf_c(jbVal, 2);
479 
480  //Kolmogorov Smirnov and Anderson Darlong
481  if (randomHisto == nullptr)
482  randomHisto = (TH1F*)histoResidualStrip->Clone("randomHisto");
483  randomHisto->Reset();
484  randomHisto->SetDirectory(nullptr);
485 
486  if (generateRandomHisto_) {
487  randomHisto->FillRandom("fitFunc", histoResidualStrip->Integral());
488  if (randomHisto->Integral() != 0) {
489  ana->ksProbab_[apvID][stripBin] = histoResidualStrip->KolmogorovTest(randomHisto, "N");
490  ana->adProbab_[apvID][stripBin] = histoResidualStrip->AndersonDarlingTest(randomHisto);
491  } else {
492  ana->ksProbab_[apvID][stripBin] = 0;
493  ana->adProbab_[apvID][stripBin] = 0;
494  }
495 
496  } else {
497  randomHisto->Add(fitFunc);
498  if (randomHisto->Integral() != 0) {
499  ana->ksProbab_[apvID][stripBin] = histoResidualStrip->KolmogorovTest(randomHisto, "N");
500  ROOT::Fit::BinData data1;
501  ROOT::Fit::BinData data2;
502  ROOT::Fit::FillData(data1, histoResidualStrip, nullptr);
503  data2.Initialize(randomHisto->GetNbinsX() + 1, 1);
504  for (int ibin = 0; ibin < randomHisto->GetNbinsX(); ibin++) {
505  if (histoResidualStrip->GetBinContent(ibin + 1) != 0 or randomHisto->GetBinContent(ibin + 1) >= 1)
506  data2.Add(randomHisto->GetBinCenter(ibin + 1),
507  randomHisto->GetBinContent(ibin + 1),
508  randomHisto->GetBinError(ibin + 1));
509  }
510 
511  double probab, value;
512  ROOT::Math::GoFTest::AndersonDarling2SamplesTest(data1, data2, probab, value);
513  ana->adProbab_[apvID][stripBin] = probab;
514  } else {
515  ana->ksProbab_[apvID][stripBin] = 0;
516  ana->adProbab_[apvID][stripBin] = 0;
517  }
518  }
519  }
520 
521  // start applying selections storing output
522  bool badStripFlag = false;
523  ana->deadStripBit_[apvID][stripBin] = 0; // is not dead if the strip has data
524 
525  if (fabs(ana->residualMean_[apvID][stripBin]) > maxDriftResidualCut_ and not badStripFlag) { //mean value
526  ana->shiftedStrip_[apvID].push_back(stripBin);
527  badStripFlag = true;
528  }
529 
530  if (ana->residualRMS_[apvID][stripBin] < minStripNoiseCut_ and not badStripFlag) { // low noise
531  ana->lowNoiseStrip_[apvID].push_back(stripBin);
532  badStripFlag = true;
533  }
534 
535  if (ana->residualRMS_[apvID][stripBin] > maxStripNoiseCut_ and not badStripFlag) { // large noise
536  ana->largeNoiseStrip_[apvID].push_back(stripBin);
537  badStripFlag = true;
538  }
539 
540  if (fabs(ana->noiseSignificance_[apvID][stripBin]) > maxStripNoiseSignificanceCut_ and
541  not badStripFlag) { // large noise significance
542  ana->largeNoiseSignificance_[apvID].push_back(stripBin);
543  badStripFlag = true;
544  }
545 
546  if (result.Get() and result->Status() != 0) // bad fit status
547  ana->badFitStatus_[apvID].push_back(stripBin);
548 
549  if (ana->adProbab_[apvID][stripBin] < adProbabCut_ and not badStripFlag) // bad AD p-value --> store the strip-id
550  ana->badADProbab_[apvID].push_back(stripBin);
551 
552  if (ana->ksProbab_[apvID][stripBin] < ksProbabCut_ and not badStripFlag) // bad KS p-value --> store the strip-id
553  ana->badKSProbab_[apvID].push_back(stripBin);
554 
555  if (ana->jbProbab_[apvID][stripBin] < jbProbabCut_ and not badStripFlag) // bad JB p-value --> store the strip-id
556  ana->badJBProbab_[apvID].push_back(stripBin);
557 
558  if (ana->chi2Probab_[apvID][stripBin] < chi2ProbabCut_ and
559  not badStripFlag) // bad CHI2 p-value --> store the strip-id
560  ana->badChi2Probab_[apvID].push_back(stripBin);
561 
562  if (ana->adProbab_[apvID][stripBin] < adProbabCut_ and ana->ksProbab_[apvID][stripBin] < ksProbabCut_ and
563  ana->jbProbab_[apvID][stripBin] < jbProbabCut_ and ana->chi2Probab_[apvID][stripBin] < chi2ProbabCut_)
564  badStripFlag = true; // bad strip is flagged as bad by all the methods
565 
566  if (ana->residualKurtosis_[apvID][stripBin] > kurtosisCut_ and
567  ana->residualIntegralNsigma_[apvID][stripBin] > integralTailCut_ and not badStripFlag) { // bad tails
568  ana->badTailStrip_[apvID].push_back(stripBin);
569  badStripFlag = true;
570  }
571 
572  if (badStripFlag) { // loop for double peaked
573 
574  fit2Gaus = new TF1("dgaus",
575  "[0]*exp(-((x-[1])*(x-[1]))/(2*[2]*[2]))+[3]*exp(-((x-[4])*(x-[4]))/(2*[5]*[5]))",
576  histoNoise->GetXaxis()->GetXmin(),
577  histoNoise->GetXaxis()->GetXmax());
578  fit2Gaus->SetParameter(0, fitFunc->GetParameter(0) / 2);
579  fit2Gaus->SetParameter(3, fitFunc->GetParameter(0) / 2);
580  fit2Gaus->SetParameter(1, 1.);
581  fit2Gaus->SetParameter(4, -1.);
582  fit2Gaus->SetParameter(2, fitFunc->GetParameter(2));
583  fit2Gaus->SetParameter(5, fitFunc->GetParameter(2));
584  fit2Gaus->SetParLimits(1, 0., histoNoise->GetXaxis()->GetXmax());
585  fit2Gaus->SetParLimits(4, histoNoise->GetXaxis()->GetXmin(), 0);
586  result = histoResidualStrip->Fit(fit2Gaus, "QSR");
587 
588  // ashman distance
589  float ashman = TMath::Power(2, 0.5) * abs(fit2Gaus->GetParameter(1) - fit2Gaus->GetParameter(4)) /
590  (sqrt(pow(fit2Gaus->GetParameter(2), 2) + pow(fit2Gaus->GetParameter(5), 2)));
591  // amplitude
592  float amplitudeRatio = std::min(fit2Gaus->GetParameter(0), fit2Gaus->GetParameter(3)) /
593  std::max(fit2Gaus->GetParameter(0), fit2Gaus->GetParameter(3));
594 
595  if (ashman > ashmanDistance_ and amplitudeRatio > amplitudeRatio_)
596  ana->badDoublePeakStrip_[apvID].push_back(stripBin);
597  }
598 
599  if (badStripFlag) { // save the final bit
600 
601  ana->badStrip_[apvID].push_back(stripBin);
602  ana->badStripBit_[apvID][stripBin] = 1;
603 
604  SiStripFecKey fec_key(ana->fecKey());
605  LogTrace(mlDqmClient_) << "BadStrip: fecCrate "
606  << " " << fec_key.fecCrate() << " fecSlot " << fec_key.fecSlot() << " fecRing "
607  << fec_key.fecRing() << " ccuAddr " << fec_key.ccuAddr() << " ccChan "
608  << fec_key.ccuChan() << " lldChan " << fec_key.lldChan() << " apvID " << apvID
609  << " stripID " << stripBin;
610 
611  } else
612  ana->badStripBit_[apvID][stripBin] = 0;
613  }
614 
615  ped_max.clear();
616  ped_min.clear();
617  raw_max.clear();
618  raw_min.clear();
619  noise_max.clear();
620  noise_min.clear();
621  if (histoResidualStrip)
622  delete histoResidualStrip;
623  if (fitFunc)
624  delete fitFunc;
625  if (randomHisto)
626  delete randomHisto;
627  if (fit2Gaus)
628  delete fit2Gaus;
629 }
PedsFullNoiseAnalysis::jbProbab_
VVFloat jbProbab_
Definition: PedsFullNoiseAnalysis.h:109
PedsFullNoiseAnalysis::badKSProbab_
VVInt badKSProbab_
Definition: PedsFullNoiseAnalysis.h:131
sistrip::extrainfo::commonMode_
static const char commonMode_[]
Definition: ConstantsForDqm.h:48
sistrip::extrainfo::noise2D_
static const char noise2D_[]
Definition: ConstantsForDqm.h:51
electrons_cff.bool
bool
Definition: electrons_cff.py:372
MessageLogger.h
sistrip::PEDS_FULL_NOISE
Definition: ConstantsForRunType.h:92
PedsFullNoiseAnalysis::rawMean_
VFloat rawMean_
Definition: PedsFullNoiseAnalysis.h:142
PedsFullNoiseAnalysis::deadStripBit_
VVInt deadStripBit_
Definition: PedsFullNoiseAnalysis.h:120
PedsFullNoiseAnalysis::chi2Probab_
VVFloat chi2Probab_
Definition: PedsFullNoiseAnalysis.h:110
PedsFullNoiseAnalysis::badFitStatus_
VVInt badFitStatus_
Definition: PedsFullNoiseAnalysis.h:129
PedsFullNoiseAnalysis::residualMean_
VVFloat residualMean_
Definition: PedsFullNoiseAnalysis.h:114
CommissioningAlgorithm::extractFedKey
uint32_t extractFedKey(const TH1 *const)
Definition: CommissioningAlgorithm.cc:29
sistrip::unexpectedTask_
static const char unexpectedTask_[]
Definition: ConstantsForCommissioningAnalysis.h:21
PedsFullNoiseAnalysis::badJBProbab_
VVInt badJBProbab_
Definition: PedsFullNoiseAnalysis.h:132
PedsFullNoiseAlgorithm::maxDriftResidualCut_
float maxDriftResidualCut_
Definition: PedsFullNoiseAlgorithm.h:47
min
T min(T a, T b)
Definition: MathUtil.h:58
PedsFullNoiseAnalysis::ksProbab_
VVFloat ksProbab_
Definition: PedsFullNoiseAnalysis.h:108
PedsFullNoiseAlgorithm::hNoise2D_
Histo hNoise2D_
Definition: PedsFullNoiseAlgorithm.h:44
PedsFullNoiseAnalysis::residualSkewness_
VVFloat residualSkewness_
Definition: PedsFullNoiseAnalysis.h:115
PedsFullNoiseAnalysis::residualIntegralNsigma_
VVFloat residualIntegralNsigma_
Definition: PedsFullNoiseAnalysis.h:117
CommissioningAnalysis::fedKey
const uint32_t & fedKey() const
Definition: CommissioningAnalysis.h:134
PedsFullNoiseAnalysis::rawSpread_
VFloat rawSpread_
Definition: PedsFullNoiseAnalysis.h:143
PedsFullNoiseAnalysis::noiseSignificance_
VVFloat noiseSignificance_
Definition: PedsFullNoiseAnalysis.h:113
CommissioningAnalysis::addErrorCode
virtual void addErrorCode(const std::string &error)
Definition: CommissioningAnalysis.h:148
sistrip::numberOfHistos_
static const char numberOfHistos_[]
Definition: ConstantsForCommissioningAnalysis.h:16
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
tools.TF1
TF1
Definition: tools.py:23
PedsFullNoiseAnalysis::badChi2Probab_
VVInt badChi2Probab_
Definition: PedsFullNoiseAnalysis.h:133
sistrip::mlDqmClient_
static const char mlDqmClient_[]
Definition: ConstantsForLogger.h:19
PedsFullNoiseAnalysis::residualSigmaGaus_
VVFloat residualSigmaGaus_
Definition: PedsFullNoiseAnalysis.h:112
PedsFullNoiseAnalysis
Histogram-based analysis for pedestal run.
Definition: PedsFullNoiseAnalysis.h:16
sistrip::unexpectedExtraInfo_
static const char unexpectedExtraInfo_[]
Definition: ConstantsForCommissioningAnalysis.h:22
PedsFullNoiseAlgorithm::analyse
void analyse() override
Definition: PedsFullNoiseAlgorithm.cc:154
PedsFullNoiseAlgorithm::integralNsigma_
int integralNsigma_
Definition: PedsFullNoiseAlgorithm.h:58
sistrip::mlCommissioning_
static const char mlCommissioning_[]
Definition: ConstantsForLogger.h:15
PedsFullNoiseAnalysis::lowNoiseStrip_
VVInt lowNoiseStrip_
Definition: PedsFullNoiseAnalysis.h:126
CommissioningAlgorithm::anal
CommissioningAnalysis *const anal() const
Definition: CommissioningAlgorithm.h:50
PedsFullNoiseAnalysis::noiseMin_
VFloat noiseMin_
Definition: PedsFullNoiseAnalysis.h:147
PedsFullNoiseAlgorithm.h
PedsFullNoiseAnalysis::noise_
VVFloat noise_
Definition: PedsFullNoiseAnalysis.h:104
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
PedsFullNoiseAnalysis::pedsMin_
VFloat pedsMin_
Definition: PedsFullNoiseAnalysis.h:145
PedsFullNoiseAnalysis::noiseMax_
VFloat noiseMax_
Definition: PedsFullNoiseAnalysis.h:146
PedsFullNoiseAnalysis::adProbab_
VVFloat adProbab_
Definition: PedsFullNoiseAnalysis.h:107
sistrip::numberOfBins_
static const char numberOfBins_[]
Definition: ConstantsForCommissioningAnalysis.h:18
sistrip::extrainfo::pedestals_
static const char pedestals_[]
Definition: ConstantsForDqm.h:45
PedsFullNoiseAnalysis::residualIntegral_
VVFloat residualIntegral_
Definition: PedsFullNoiseAnalysis.h:118
SiStripFecKey
Utility class that identifies a position within the strip tracker control structure,...
Definition: SiStripFecKey.h:45
PedsFullNoiseAnalysis::rawMax_
VFloat rawMax_
Definition: PedsFullNoiseAnalysis.h:148
PedsFullNoiseAlgorithm::kurtosisCut_
float kurtosisCut_
Definition: PedsFullNoiseAlgorithm.h:56
edm::LogWarning
Definition: MessageLogger.h:141
PedsFullNoiseAnalysis::badDoublePeakStrip_
VVInt badDoublePeakStrip_
Definition: PedsFullNoiseAnalysis.h:135
PedsFullNoiseAnalysis::pedsSpread_
VFloat pedsSpread_
Definition: PedsFullNoiseAnalysis.h:139
PedsFullNoiseAnalysis::noiseMean_
VFloat noiseMean_
Definition: PedsFullNoiseAnalysis.h:140
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
edm::ParameterSet
Definition: ParameterSet.h:36
PedsFullNoiseAlgorithm::maxStripNoiseSignificanceCut_
float maxStripNoiseSignificanceCut_
Definition: PedsFullNoiseAlgorithm.h:50
PedsFullNoiseAlgorithm::generateRandomHisto_
bool generateRandomHisto_
Definition: PedsFullNoiseAlgorithm.h:53
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
PedsFullNoiseAlgorithm::jbProbabCut_
float jbProbabCut_
Definition: PedsFullNoiseAlgorithm.h:54
sistrip::maximum_
static const uint16_t maximum_
Definition: Constants.h:20
PedsFullNoiseAnalysis::residualKurtosis_
VVFloat residualKurtosis_
Definition: PedsFullNoiseAnalysis.h:116
PedsFullNoiseAlgorithm::reset
void reset(PedsFullNoiseAnalysis *)
Definition: PedsFullNoiseAlgorithm.cc:115
PedsFullNoiseAlgorithm::ksProbabCut_
float ksProbabCut_
Definition: PedsFullNoiseAlgorithm.h:52
createfilelist.int
int
Definition: createfilelist.py:10
value
Definition: value.py:1
PedsFullNoiseAnalysis::badADProbab_
VVInt badADProbab_
Definition: PedsFullNoiseAnalysis.h:130
sistrip::extrainfo::roughPedestals_
static const char roughPedestals_[]
Definition: ConstantsForDqm.h:49
PedsFullNoiseAlgorithm::ashmanDistance_
float ashmanDistance_
Definition: PedsFullNoiseAlgorithm.h:59
overlapproblemtsosanalyzer_cfi.title
title
Definition: overlapproblemtsosanalyzer_cfi.py:7
combine.histos
histos
Definition: combine.py:4
CommissioningAnalysis
Abstract base for derived classes that provide analysis of commissioning histograms.
Definition: CommissioningAnalysis.h:18
PedsFullNoiseAnalysis::badTailStrip_
VVInt badTailStrip_
Definition: PedsFullNoiseAnalysis.h:134
PedsFullNoiseAnalysis::largeNoiseStrip_
VVInt largeNoiseStrip_
Definition: PedsFullNoiseAnalysis.h:127
std
Definition: JetResolutionObject.h:76
PedsFullNoiseAlgorithm::minStripNoiseCut_
float minStripNoiseCut_
Definition: PedsFullNoiseAlgorithm.h:48
CommissioningAnalysis::fecKey
const uint32_t & fecKey() const
Definition: CommissioningAnalysis.h:133
PedsFullNoiseAnalysis::rawMin_
VFloat rawMin_
Definition: PedsFullNoiseAnalysis.h:149
PedsFullNoiseAnalysis::largeNoiseSignificance_
VVInt largeNoiseSignificance_
Definition: PedsFullNoiseAnalysis.h:128
relativeConstraints.value
value
Definition: relativeConstraints.py:53
SiStripEnumsAndStrings.h
PedsFullNoiseAnalysis::pedsMax_
VFloat pedsMax_
Definition: PedsFullNoiseAnalysis.h:144
SiStripHistoTitle.h
PedsFullNoiseAnalysis::pedsMean_
VFloat pedsMean_
Definition: PedsFullNoiseAnalysis.h:138
PedsFullNoiseAnalysis::badStrip_
VVInt badStrip_
Definition: PedsFullNoiseAnalysis.h:124
CommissioningAlgorithm
Definition: CommissioningAlgorithm.h:17
PedsFullNoiseAnalysis::peds_
VVFloat peds_
Quantitles that are always filled for every strip.
Definition: PedsFullNoiseAnalysis.h:103
SiStripHistoTitle
Utility class that holds histogram title.
Definition: SiStripHistoTitle.h:20
or
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
PedsFullNoiseAlgorithm::integralTailCut_
float integralTailCut_
Definition: PedsFullNoiseAlgorithm.h:57
PedsFullNoiseAlgorithm::chi2ProbabCut_
float chi2ProbabCut_
Definition: PedsFullNoiseAlgorithm.h:55
PedsFullNoiseAnalysis::residualRMS_
VVFloat residualRMS_
Definition: PedsFullNoiseAnalysis.h:111
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:30
mps_fire.result
result
Definition: mps_fire.py:303
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:671
PedsFullNoiseAnalysis::deadStrip_
VVInt deadStrip_
Quantities filled only for bad strips i.e. vectors of strip-id.
Definition: PedsFullNoiseAnalysis.h:123
PedsFullNoiseAnalysis::badStripBit_
VVInt badStripBit_
Definition: PedsFullNoiseAnalysis.h:119
PedsFullNoiseAlgorithm::extract
void extract(const std::vector< TH1 * > &) override
Definition: PedsFullNoiseAlgorithm.cc:62
sistrip
sistrip classes
Definition: SiStripQualityHelpers.h:14
conversion_template_cfg.anal
anal
Definition: conversion_template_cfg.py:16
PedsFullNoiseAnalysis::shiftedStrip_
VVInt shiftedStrip_
Definition: PedsFullNoiseAnalysis.h:125
PedsFullNoiseAlgorithm::PedsFullNoiseAlgorithm
PedsFullNoiseAlgorithm()
Definition: PedsFullNoiseAlgorithm.h:28
sistrip::nullPtr_
static const char nullPtr_[]
Definition: ConstantsForCommissioningAnalysis.h:17
PedsFullNoiseAnalysis::raw_
VVFloat raw_
Definition: PedsFullNoiseAnalysis.h:105
PedsFullNoiseAnalysis::noiseSpread_
VFloat noiseSpread_
Definition: PedsFullNoiseAnalysis.h:141
PedsFullNoiseAlgorithm::amplitudeRatio_
float amplitudeRatio_
Definition: PedsFullNoiseAlgorithm.h:60
PedsFullNoiseAlgorithm::hPeds_
Histo hPeds_
Definition: PedsFullNoiseAlgorithm.h:41
PedsFullNoiseAnalysis.h
PedsFullNoiseAlgorithm::adProbabCut_
float adProbabCut_
Definition: PedsFullNoiseAlgorithm.h:51
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
PedsFullNoiseAlgorithm::hNoise_
Histo hNoise_
Definition: PedsFullNoiseAlgorithm.h:43
PedsFullNoiseAlgorithm::maxStripNoiseCut_
float maxStripNoiseCut_
Definition: PedsFullNoiseAlgorithm.h:49
sistrip::extrainfo::noiseProfile_
static const char noiseProfile_[]
Definition: ConstantsForDqm.h:50