12 #include "dqm_core/exceptions.h"
13 #include "dqm_core/AlgorithmManager.h"
14 #include "dqm_core/AlgorithmConfig.h"
15 #include "dqm_core/Result.h"
17 #include <TGraphErrors.h>
18 #include <TFitResult.h>
35 message +=
"Description: Calculates the mean of the LB dependence\n";
36 message +=
"A constant fit is performed, for bins with minimum statistics, and outliers are reported. Yellow is for any 5 sigma deviations, red is for 10 or more\n";
37 message +=
" Overflow (and Underflow) bins are not included\n";
45 : m_name(
"ZDCTestConstantVsLB")
67 execute(
const std::string&
name,
const TObject&
object,
const dqm_core::AlgorithmConfig&
config)
74 if(
object.
IsA()->InheritsFrom(
"TH2" ) ) {
77 throw dqm_core::BadConfig( ERS_HERE,
name,
"dimension > 2 " );
80 throw dqm_core::BadConfig( ERS_HERE,
name,
"does not inherit from TH2" );
84 TH1 *projection =
histogram->ProjectionX(
"projection");
85 int Xbins =
histogram->GetXaxis()->GetNbins();
92 bool yellowflag =
false;
93 bool greenflag =
true;
95 TGraphErrors* ge =
new TGraphErrors;
99 if (projection->GetBinContent(
ilb+1) >= minstat)
107 TFitResultPtr fit_res = ge->Fit(
"pol0",
"QNS0");
110 result->status_ = dqm_core::Result::Yellow;
114 double mean = fit_res->Value(0);
116 std::vector<int> yellowLBs;
117 std::vector<double> yellowR;
118 for (
int ip = 0;
ip<ge->GetN() ;
ip++)
121 ge->GetPoint(
ip,
x,
y);
122 double ey = ge->GetErrorY(
ip);
123 double r = TMath::Abs((
y -
mean ) / ey);
127 yellowLBs.push_back(
x);
128 yellowR.push_back(
r);
132 for (
size_t iy=0;iy<yellowLBs.size();iy++)
134 int LB = yellowLBs.at(iy);
135 double R = yellowR.at(iy);
137 sprintf(ctag,
"Bad LB %d with R", LB);
141 if (yellowLBs.size() > NsigMultRed)
152 result->status_ = dqm_core::Result::Yellow;