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"))
47 <<
"[PedsFullNoiseAlgorithm::" << __func__ <<
"]" 52 <<
" Set minimum Anderson-Darling p-value to: " <<
adProbabCut_ 53 <<
" Set minimum Kolmogorov-Smirnov p-value to: " <<
ksProbabCut_ 54 <<
" Set minimum Jacque-Bera p-value to: " <<
jbProbabCut_ 68 <<
"[PedsFullNoiseAlgorithm::" << __func__ <<
"]" 69 <<
" NULL pointer to Analysis object!";
74 if ( histos.size() != 3 ) {
79 if ( !histos.empty() ) {
84 std::vector<TH1*>::const_iterator ihis = histos.begin();
85 for ( ; ihis != histos.end(); ihis++ ) {
88 if ( !(*ihis) ) {
continue; }
102 hPeds_.second = (*ihis)->GetName();
110 hNoise_.second = (*ihis)->GetName();
125 for(
size_t iapv = 0 ; iapv < ana->
peds_.size(); iapv++){
139 for(
size_t istrip = 0; istrip < ana->
peds_[iapv].size(); istrip++){
140 ana->
peds_[iapv][istrip] = 0.;
141 ana->
noise_[iapv][istrip] = 0.;
142 ana->
raw_[iapv][istrip] = 0.;
168 <<
"[PedsFullNoiseAlgorithm::" << __func__ <<
"]" 169 <<
" NULL pointer to base Analysis object!";
179 <<
"[PedsFullNoiseAlgorithm::" << __func__ <<
"]" 180 <<
" NULL pointer to derived Analysis object!";
202 TProfile *histoPeds =
dynamic_cast<TProfile *
>(
hPeds_.first);
203 TProfile *histoNoiseMean =
dynamic_cast<TProfile *
>(
hNoise_.first);
204 TH2S * histoNoise =
dynamic_cast<TH2S*
>(
hNoise2D_.first);
212 if (not histoNoiseMean) {
217 if (not histoNoise) {
223 if (histoPeds->GetNbinsX() != 256 ) {
229 if (histoNoiseMean->GetNbinsX() != 256 ) {
235 if (histoNoise->GetNbinsY() != 256 ) {
248 vector<float> ped_max;
249 vector<float> ped_min;
250 vector<float> raw_max;
251 vector<float> raw_min;
252 vector<float> noise_max;
253 vector<float> noise_min;
256 for(
int iStrip = 0; iStrip < histoPeds->GetNbinsX(); iStrip++){
258 if(iStrip < histoPeds->GetNbinsX()/2) apvID = 0;
262 if(iStrip >= 128) stripBin = iStrip-128;
263 else stripBin = iStrip;
265 ana->
peds_[apvID][stripBin] = histoPeds->GetBinContent(iStrip+1);
266 ana->
noise_[apvID][stripBin] = histoNoiseMean->GetBinContent(iStrip+1);
267 ana->
raw_[apvID][stripBin] = histoPeds->GetBinError(iStrip+1);
274 if(ped_max.size() < apvID+1)
275 ped_max.push_back(ana->
peds_[apvID][stripBin]);
277 if(ana->
peds_[apvID][stripBin] > ped_max.at(apvID))
278 ped_max.at(apvID) = ana->
peds_[apvID][stripBin];
282 if(ped_min.size() < apvID+1)
283 ped_min.push_back(ana->
peds_[apvID][stripBin]);
285 if(ana->
peds_[apvID][stripBin] < ped_min.at(apvID))
286 ped_min.at(apvID) = ana->
peds_[apvID][stripBin];
290 if(noise_max.size() < apvID+1)
291 noise_max.push_back(ana->
noise_[apvID][stripBin]);
293 if(ana->
noise_[apvID][stripBin] > noise_max.at(apvID))
294 noise_max.at(apvID) = ana->
noise_[apvID][stripBin];
298 if(noise_min.size() < apvID+1)
299 noise_min.push_back(ana->
noise_[apvID][stripBin]);
301 if(ana->
noise_[apvID][stripBin] < noise_min.at(apvID))
302 noise_min.at(apvID) = ana->
noise_[apvID][stripBin];
306 if(raw_max.size() < apvID+1)
307 raw_max.push_back(ana->
raw_[apvID][stripBin]);
309 if(ana->
raw_[apvID][stripBin] > raw_max.at(apvID))
310 raw_max.at(apvID) = ana->
raw_[apvID][stripBin];
314 if(raw_min.size() < apvID+1)
315 raw_min.push_back(ana->
raw_[apvID][stripBin]);
317 if(ana->
raw_[apvID][stripBin] < raw_min.at(apvID))
318 raw_min.at(apvID) = ana->
raw_[apvID][stripBin];
323 for(
unsigned int iApv = 0; iApv < ana->
pedsMean_.size(); iApv++){
330 for(
unsigned int iApv = 0; iApv < ped_max.size(); iApv++){
336 ana->
pedsMax_.at(iApv) = ped_max.at(iApv);
343 ana->
pedsMin_.at(iApv) = ped_min.at(iApv);
350 ana->
noiseMax_.at(iApv) = noise_max.at(iApv);
357 ana->
noiseMin_.at(iApv) = noise_min.at(iApv);
364 ana->
rawMax_.at(iApv) = raw_max.at(iApv);
371 ana->
rawMin_.at(iApv) = raw_min.at(iApv);
378 for(
int iStrip = 0; iStrip < histoNoiseMean->GetNbinsX(); iStrip++){
379 if(iStrip < histoNoiseMean->GetNbinsX()/2) apvID = 0;
386 for(
unsigned int iApv = 0; iApv < ana->
pedsSpread_.size(); iApv++){
394 TH1S* histoResidualStrip =
new TH1S(
"histoResidualStrip",
"",histoNoise->GetNbinsX(),histoNoise->GetXaxis()->GetXmin(),histoNoise->GetXaxis()->GetXmax());
395 histoResidualStrip->Sumw2();
396 histoResidualStrip->SetDirectory(
nullptr);
397 TF1* fitFunc =
new TF1 (
"fitFunc",
"gaus(0)",histoNoise->GetXaxis()->GetXmin(),histoNoise->GetXaxis()->GetXmax());
398 TF1* fit2Gaus =
nullptr;
399 TH1F* randomHisto =
nullptr;
402 for(
int iStrip = 0; iStrip < histoNoise->GetNbinsY(); iStrip++){
404 if(iStrip < histoNoise->GetNbinsY()/2) apvID = 0;
406 histoResidualStrip->Reset();
409 if(iStrip >= 128) stripBin = iStrip-128;
410 else stripBin = iStrip;
412 for(
int iBinX = 0; iBinX < histoNoise->GetNbinsX(); iBinX++){
413 histoResidualStrip->SetBinContent(iBinX+1,histoNoise->GetBinContent(iBinX+1,iStrip+1));
414 histoResidualStrip->SetBinError(iBinX+1,histoNoise->GetBinError(iBinX+1,iStrip+1));
417 if(histoResidualStrip->Integral() == 0){
438 <<
" "<<fec_key.fecCrate()
439 <<
" fecSlot "<<fec_key.fecSlot()
440 <<
" fecRing "<<fec_key.fecRing()
441 <<
" ccuAddr "<<fec_key.ccuAddr()
442 <<
" ccChan "<<fec_key.ccuChan()
443 <<
" lldChan "<<fec_key.lldChan()
445 <<
" stripID "<<iStrip;
452 ana->
residualMean_[apvID][stripBin] = histoResidualStrip->GetMean();
453 ana->
residualRMS_[apvID][stripBin] = histoResidualStrip->GetRMS();
463 fitFunc->SetRange(histoNoise->GetXaxis()->GetXmin(),histoNoise->GetXaxis()->GetXmax());
465 result = histoResidualStrip->Fit(fitFunc,
"QSRN");
471 ana->
chi2Probab_[apvID][stripBin] = result->Prob();
475 ana->
jbProbab_[apvID][stripBin] = ROOT::Math::chisquared_cdf_c(jbVal,2);
478 if(randomHisto ==
nullptr)
479 randomHisto = (TH1F*) histoResidualStrip->Clone(
"randomHisto");
480 randomHisto->Reset();
481 randomHisto->SetDirectory(
nullptr);
484 randomHisto->FillRandom(
"fitFunc",histoResidualStrip->Integral());
485 if(randomHisto->Integral() != 0){
486 ana->
ksProbab_[apvID][stripBin] = histoResidualStrip->KolmogorovTest(randomHisto,
"N");
487 ana->
adProbab_[apvID][stripBin] = histoResidualStrip->AndersonDarlingTest(randomHisto);
496 randomHisto->Add(fitFunc);
497 if(randomHisto->Integral() != 0){
498 ana->
ksProbab_[apvID][stripBin] = histoResidualStrip->KolmogorovTest(randomHisto,
"N");
499 ROOT::Fit::BinData data1;
500 ROOT::Fit::BinData data2;
501 ROOT::Fit::FillData(data1,histoResidualStrip,
nullptr);
502 data2.Initialize(randomHisto->GetNbinsX()+1,1);
503 for(
int ibin = 0; ibin < randomHisto->GetNbinsX(); ibin++){
504 if(histoResidualStrip->GetBinContent(ibin+1) != 0
or randomHisto->GetBinContent(ibin+1) >= 1)
505 data2.Add(randomHisto->GetBinCenter(ibin+1),randomHisto->GetBinContent(ibin+1),randomHisto->GetBinError(ibin+1));
508 double probab,
value;
509 ROOT::Math::GoFTest::AndersonDarling2SamplesTest(data1,data2,probab,value);
510 ana->
adProbab_[apvID][stripBin] = probab;
520 bool badStripFlag =
false;
543 if(result.Get() and result->Status() != 0)
569 fit2Gaus =
new TF1(
"dgaus",
"[0]*exp(-((x-[1])*(x-[1]))/(2*[2]*[2]))+[3]*exp(-((x-[4])*(x-[4]))/(2*[5]*[5]))",histoNoise->GetXaxis()->GetXmin(),histoNoise->GetXaxis()->GetXmax());
570 fit2Gaus->SetParameter(0,fitFunc->GetParameter(0)/2);
571 fit2Gaus->SetParameter(3,fitFunc->GetParameter(0)/2);
572 fit2Gaus->SetParameter(1,1.);
573 fit2Gaus->SetParameter(4,-1.);
574 fit2Gaus->SetParameter(2,fitFunc->GetParameter(2));
575 fit2Gaus->SetParameter(5,fitFunc->GetParameter(2));
576 fit2Gaus->SetParLimits(1,0.,histoNoise->GetXaxis()->GetXmax());
577 fit2Gaus->SetParLimits(4,histoNoise->GetXaxis()->GetXmin(),0);
578 result = histoResidualStrip->Fit(fit2Gaus,
"QSR");
581 float ashman = TMath::Power(2,0.5)*
abs(fit2Gaus->GetParameter(1)-fit2Gaus->GetParameter(4))/(
sqrt(
pow(fit2Gaus->GetParameter(2),2)+
pow(fit2Gaus->GetParameter(5),2)));
583 float amplitudeRatio =
std::min(fit2Gaus->GetParameter(0),fit2Gaus->GetParameter(3))/
std::max(fit2Gaus->GetParameter(0),fit2Gaus->GetParameter(3));
591 ana->
badStrip_[apvID].push_back(stripBin);
596 <<
" "<<fec_key.fecCrate()
597 <<
" fecSlot "<<fec_key.fecSlot()
598 <<
" fecRing "<<fec_key.fecRing()
599 <<
" ccuAddr "<<fec_key.ccuAddr()
600 <<
" ccChan "<<fec_key.ccuChan()
601 <<
" lldChan "<<fec_key.lldChan()
603 <<
" stripID "<<stripBin;
617 if(histoResidualStrip)
delete histoResidualStrip;
618 if(fitFunc)
delete fitFunc;
619 if(randomHisto)
delete randomHisto;
620 if(fit2Gaus)
delete fit2Gaus;
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.
static const char mlCommissioning_[]
VVFloat noiseSignificance_
VVFloat residualIntegralNsigma_
uint32_t extractFedKey(const TH1 *const )
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 *)
std::vector< std::vector< double > > tmp
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_[]