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" 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!";
70 if (histos.size() != 3) {
75 if (!histos.empty()) {
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++) {
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.;
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);
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++) {
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)
376 for (
unsigned int iApv = 0; iApv < ana->
pedsSpread_.size(); iApv++) {
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) {
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();
453 (histoResidualStrip->Integral(histoResidualStrip->FindBin(ana->
residualMean_[apvID][stripBin] +
455 histoResidualStrip->GetNbinsX() + 1) +
456 histoResidualStrip->Integral(
458 histoResidualStrip->FindBin(ana->
residualMean_[apvID][stripBin] -
459 ana->
residualRMS_[apvID][stripBin] * integralNsigma_))) /
463 fitFunc->SetRange(histoNoise->GetXaxis()->GetXmin(), histoNoise->GetXaxis()->GetXmax());
467 result = histoResidualStrip->Fit(fitFunc,
"QSRN");
472 ana->
chi2Probab_[apvID][stripBin] = result->Prob();
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);
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;
522 bool badStripFlag =
false;
546 if (result.Get() and result->Status() != 0)
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));
601 ana->
badStrip_[apvID].push_back(stripBin);
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;
621 if (histoResidualStrip)
622 delete histoResidualStrip;
VVFloat peds_
Quantitles that are always filled for every strip.
static const char unexpectedTask_[]
const uint32_t & fedKey() const
VVInt badDoublePeakStrip_
Utility class that holds histogram title.
static const char numberOfHistos_[]
VVFloat residualIntegral_
static const char mlDqmClient_[]
static const char unexpectedExtraInfo_[]
VVInt deadStrip_
Quantities filled only for bad strips i.e. vectors of strip-id.
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_[]
VVFloat noiseSignificance_
VVFloat residualIntegralNsigma_
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
VVFloat residualSkewness_
static const uint16_t maximum_
Abs< T >::type abs(const T &t)
virtual void addErrorCode(const std::string &error)
const uint32_t & fecKey() const
float maxStripNoiseSignificanceCut_
bool generateRandomHisto_
VVFloat residualKurtosis_
void extract(const std::vector< TH1 * > &) override
void reset(PedsFullNoiseAnalysis *)
VVInt largeNoiseSignificance_
Abstract base for derived classes that provide analysis of commissioning histograms.
VVFloat residualSigmaGaus_
Power< A, B >::type pow(const A &a, const B &b)
CommissioningAnalysis *const anal() const
float maxDriftResidualCut_
static const char nullPtr_[]