11 #include "TFitResult.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" 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")) {
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_ 65 <<
" NULL pointer to Analysis object!";
80 std::vector<TH1*>::const_iterator ihis =
histos.begin();
81 for (; ihis !=
histos.end(); ihis++) {
98 hPeds_.second = (*ihis)->GetName();
104 hNoise_.second = (*ihis)->GetName();
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.;
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;
158 <<
" NULL pointer to base Analysis object!";
168 <<
" NULL pointer to derived Analysis object!";
189 TProfile* histoPeds =
dynamic_cast<TProfile*
>(
hPeds_.first);
190 TProfile* histoNoiseMean =
dynamic_cast<TProfile*
>(
hNoise_.first);
191 TH2S* histoNoise =
dynamic_cast<TH2S*
>(
hNoise2D_.first);
199 if (not histoNoiseMean) {
204 if (not histoNoise) {
210 if (histoPeds->GetNbinsX() != 256) {
216 if (histoNoiseMean->GetNbinsX() != 256) {
222 if (histoNoise->GetNbinsY() != 256) {
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;
242 for (
int iStrip = 0; iStrip < histoPeds->GetNbinsX(); iStrip++) {
243 if (iStrip < histoPeds->GetNbinsX() / 2)
250 stripBin = iStrip - 128;
254 ana->peds_[apvID][stripBin] = histoPeds->GetBinContent(iStrip + 1);
255 ana->noise_[apvID][stripBin] = histoNoiseMean->GetBinContent(iStrip + 1);
256 ana->raw_[apvID][stripBin] = histoPeds->GetBinError(iStrip + 1);
258 ana->pedsMean_[apvID] +=
ana->peds_[apvID][stripBin];
259 ana->rawMean_[apvID] +=
ana->raw_[apvID][stripBin];
260 ana->noiseMean_[apvID] +=
ana->noise_[apvID][stripBin];
263 if (ped_max.size() < apvID + 1)
264 ped_max.push_back(
ana->peds_[apvID][stripBin]);
266 if (
ana->peds_[apvID][stripBin] > ped_max.at(apvID))
267 ped_max.at(apvID) =
ana->peds_[apvID][stripBin];
271 if (ped_min.size() < apvID + 1)
272 ped_min.push_back(
ana->peds_[apvID][stripBin]);
274 if (
ana->peds_[apvID][stripBin] < ped_min.at(apvID))
275 ped_min.at(apvID) =
ana->peds_[apvID][stripBin];
279 if (noise_max.size() < apvID + 1)
280 noise_max.push_back(
ana->noise_[apvID][stripBin]);
282 if (
ana->noise_[apvID][stripBin] > noise_max.at(apvID))
283 noise_max.at(apvID) =
ana->noise_[apvID][stripBin];
287 if (noise_min.size() < apvID + 1)
288 noise_min.push_back(
ana->noise_[apvID][stripBin]);
290 if (
ana->noise_[apvID][stripBin] < noise_min.at(apvID))
291 noise_min.at(apvID) =
ana->noise_[apvID][stripBin];
295 if (raw_max.size() < apvID + 1)
296 raw_max.push_back(
ana->raw_[apvID][stripBin]);
298 if (
ana->raw_[apvID][stripBin] > raw_max.at(apvID))
299 raw_max.at(apvID) =
ana->raw_[apvID][stripBin];
303 if (raw_min.size() < apvID + 1)
304 raw_min.push_back(
ana->raw_[apvID][stripBin]);
306 if (
ana->raw_[apvID][stripBin] < raw_min.at(apvID))
307 raw_min.at(apvID) =
ana->raw_[apvID][stripBin];
312 for (
unsigned int iApv = 0; iApv <
ana->pedsMean_.size(); iApv++) {
313 ana->pedsMean_.at(iApv) /= (
ana->peds_[iApv].size());
314 ana->rawMean_.at(iApv) /= (
ana->raw_[iApv].size());
315 ana->noiseMean_.at(iApv) /= (
ana->noise_[iApv].size());
319 for (
unsigned int iApv = 0; iApv < ped_max.size(); iApv++) {
325 ana->pedsMax_.at(iApv) = ped_max.at(iApv);
332 ana->pedsMin_.at(iApv) = ped_min.at(iApv);
339 ana->noiseMax_.at(iApv) = noise_max.at(iApv);
346 ana->noiseMin_.at(iApv) = noise_min.at(iApv);
353 ana->rawMax_.at(iApv) = raw_max.at(iApv);
360 ana->rawMin_.at(iApv) = raw_min.at(iApv);
366 for (
int iStrip = 0; iStrip < histoNoiseMean->GetNbinsX(); iStrip++) {
367 if (iStrip < histoNoiseMean->GetNbinsX() / 2)
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);
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);
384 TH1S* histoResidualStrip =
new TH1S(
"histoResidualStrip",
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;
396 for (
int iStrip = 0; iStrip < histoNoise->GetNbinsY(); iStrip++) {
398 if (iStrip < histoNoise->GetNbinsY() / 2)
402 histoResidualStrip->Reset();
406 stripBin = iStrip - 128;
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));
415 if (histoResidualStrip->Integral() == 0) {
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;
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;
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] +
455 histoResidualStrip->GetNbinsX() + 1) +
456 histoResidualStrip->Integral(
458 histoResidualStrip->FindBin(
ana->residualMean_[apvID][stripBin] -
460 ana->residualIntegral_[apvID][stripBin];
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");
471 ana->residualSigmaGaus_[apvID][stripBin] = fitFunc->GetParameter(2);
472 ana->chi2Probab_[apvID][stripBin] =
result->Prob();
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);
481 if (randomHisto ==
nullptr)
482 randomHisto = (TH1F*)histoResidualStrip->Clone(
"randomHisto");
483 randomHisto->Reset();
484 randomHisto->SetDirectory(
nullptr);
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);
492 ana->ksProbab_[apvID][stripBin] = 0;
493 ana->adProbab_[apvID][stripBin] = 0;
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));
511 double probab,
value;
512 ROOT::Math::GoFTest::AndersonDarling2SamplesTest(data1, data2, probab,
value);
513 ana->adProbab_[apvID][stripBin] = probab;
515 ana->ksProbab_[apvID][stripBin] = 0;
516 ana->adProbab_[apvID][stripBin] = 0;
522 bool badStripFlag =
false;
523 ana->deadStripBit_[apvID][stripBin] = 0;
526 ana->shiftedStrip_[apvID].push_back(stripBin);
531 ana->lowNoiseStrip_[apvID].push_back(stripBin);
536 ana->largeNoiseStrip_[apvID].push_back(stripBin);
542 ana->largeNoiseSignificance_[apvID].push_back(stripBin);
547 ana->badFitStatus_[apvID].push_back(stripBin);
549 if (
ana->adProbab_[apvID][stripBin] <
adProbabCut_ and not badStripFlag)
550 ana->badADProbab_[apvID].push_back(stripBin);
552 if (
ana->ksProbab_[apvID][stripBin] <
ksProbabCut_ and not badStripFlag)
553 ana->badKSProbab_[apvID].push_back(stripBin);
555 if (
ana->jbProbab_[apvID][stripBin] <
jbProbabCut_ and not badStripFlag)
556 ana->badJBProbab_[apvID].push_back(stripBin);
560 ana->badChi2Probab_[apvID].push_back(stripBin);
568 ana->badTailStrip_[apvID].push_back(stripBin);
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");
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)));
592 float amplitudeRatio =
std::min(fit2Gaus->GetParameter(0), fit2Gaus->GetParameter(3)) /
593 std::max(fit2Gaus->GetParameter(0), fit2Gaus->GetParameter(3));
596 ana->badDoublePeakStrip_[apvID].push_back(stripBin);
601 ana->badStrip_[apvID].push_back(stripBin);
602 ana->badStripBit_[apvID][stripBin] = 1;
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;
612 ana->badStripBit_[apvID][stripBin] = 0;
621 if (histoResidualStrip)
622 delete histoResidualStrip;
CommissioningAnalysis *const anal() const
static const char unexpectedTask_[]
void extract(const std::vector< TH1 *> &) override
Utility class that holds histogram title.
static const char numberOfHistos_[]
static const char mlDqmClient_[]
static const char unexpectedExtraInfo_[]
static const char numberOfBins_[]
Histogram-based analysis for pedestal run.
Utility class that identifies a position within the strip tracker control structure, down to the level of an APV25.
uint32_t extractFedKey(const TH1 *const)
static const char mlCommissioning_[]
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
static const uint16_t maximum_
Abs< T >::type abs(const T &t)
virtual void addErrorCode(const std::string &error)
const uint32_t & fedKey() const
float maxStripNoiseSignificanceCut_
bool generateRandomHisto_
void reset(PedsFullNoiseAnalysis *)
Abstract base for derived classes that provide analysis of commissioning histograms.
Log< level::Warning, false > LogWarning
Power< A, B >::type pow(const A &a, const B &b)
float maxDriftResidualCut_
static const char nullPtr_[]