38using std::cout, std::endl;
76 Log() << kERROR <<
"Cannot cal ROC curve etc, as in put mvaS and mvaB have differen #nbins or range "<<Endl;
79 if (!strcmp(
fmvaS->GetXaxis()->GetTitle(),
""))
fmvaS->SetXTitle(
"MVA-value");
80 if (!strcmp(
fmvaB->GetXaxis()->GetTitle(),
""))
fmvaB->SetXTitle(
"MVA-value");
81 if (!strcmp(
fmvaS->GetYaxis()->GetTitle(),
""))
fmvaS->SetYTitle(
"#entries");
82 if (!strcmp(
fmvaB->GetYaxis()->GetTitle(),
""))
fmvaB->SetYTitle(
"#entries");
92 Log() << kERROR <<
"Cannot Rebin Histograms mvaS and mvaB, ROC values will be calculated without Rebin histograms."<<Endl;
94 fmvaSpdf = (TH1*)mvaS->Clone(
"MVA Signal PDF");
95 fmvaBpdf = (TH1*)mvaB->Clone(
"MVA Backgr PDF");
97 fmvaSpdf->SetTitle(
"MVA Signal PDF");
98 fmvaBpdf->SetTitle(
"MVA Backgr PDF");
123 Int_t FillColor__S = c_SignalFill;
124 Int_t FillStyle__S = 1001;
125 Int_t LineColor__S = c_SignalLine;
126 Int_t LineWidth__S = 2;
130 Int_t FillColor__B = c_BackgroundFill;
131 Int_t FillStyle__B = 3554;
132 Int_t LineColor__B = c_BackgroundLine;
133 Int_t LineWidth__B = 2;
150 any->SetLineColor( LineColor__S );
151 any->SetLineWidth( LineWidth__S );
152 any->SetFillStyle( FillStyle__S );
153 any->SetFillColor( FillColor__S );
183 Log() << kERROR <<
"I guess the mva distributions fed into ROCCalc were already normalized, therefore the calculated error on the efficiency will be incorrect !! " <<
Endl;
198 effBvsS->SetXTitle(
"Signal eff" );
199 effBvsS->SetYTitle(
"Backgr eff" );
203 rejBvsS->SetXTitle(
"Signal eff" );
204 rejBvsS->SetYTitle(
"Backgr rejection (1-eff)" );
209 inveffBvsS->SetYTitle(
"Inverse backgr. eff (1/eff)" );
234 effBvsS->SetBinContent( bini, effB );
235 rejBvsS->SetBinContent( bini, 1.0-effB );
236 if (effB>std::numeric_limits<double>::epsilon())
246 Double_t effS = 0., rejB = 0., effS_ = 0., rejB_ = 0.;
248 for (
Int_t bini=1; bini<=nbins; bini++) {
251 effS = (bini - 0.5)/
Float_t(nbins);
255 if ((effS - rejB)*(effS_ - rejB_) < 0)
break;
275 for (
Int_t bini=1; bini<=nbins; bini++) {
278 effS = (bini - 0.5)/
Float_t(nbins);
280 integral += (1.0 - effB);
294 Double_t effS=0., effB, effSOld=1., effBOld=0.;
299 for (
Int_t bini=1; bini<=nbins; bini++) {
301 effS = (bini - 0.5)*step;
305 if ((effB - effBref)*(effBOld - effBref) <= 0)
break;
311 effS = 0.5*(effS + effSOld);
354 Log() << kWARNING <<
"<ROCCalc::Root> initial interval w/o root: "
355 <<
"(a=" <<
a <<
", b=" <<
b <<
"),"
358 <<
"(fa=" << fa <<
", fb=" << fb <<
"), "
359 <<
"refValue = " << refValue <<
Endl;
367 if ((fb < 0 && fc < 0) || (fb > 0 && fc > 0)) {
378 fa = fb; fb = fc; fc = fa;
392 if (ac_equal) { p = 2 *
m * s;
q = 1 - s; }
394 q = fa / fc;
r = fb / fc;
395 p = s * (2 *
m *
q * (
q -
r) - (
b -
a) * (
r - 1));
396 q = (
q - 1) * (
r - 1) * (s - 1);
404 if (2 * p < (min1 < min2 ? min1 : min2)) {
408 else {
d =
m;
e =
m; }
414 else b += (
m > 0 ? +tol : -tol);
421 Log() << kWARNING <<
"<ROCCalc::Root> maximum iterations (" <<
fMaxIter
422 <<
") reached before convergence" <<
Endl;
454 fPurity->SetXTitle(
"mva cut value");
455 fPurity->SetYTitle(
"Purity: S/(S+B)");
475 cout <<
"S="<<S<<
" B="<<B<<
" purity="<<purity<< endl;
476 fPurity->SetBinContent( i, purity );
int Int_t
Signed integer 4 bytes (int).
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
bool Bool_t
Boolean (0=false, 1=true) (bool).
double Double_t
Double 8 bytes.
float Float_t
Float 4 bytes (float).
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
virtual void SetLineColor(Color_t lcolor)
Set the line color.
static Int_t GetColor(const char *hexcolor)
1-D histogram with a double per channel (see TH1 documentation)
TH1 is the base class of all histogram classes in ROOT.
virtual Int_t GetNbinsX() const
virtual TH1 * RebinX(Int_t ngroup=2, const char *newname="")
ostringstream derivative to redirect and format output
Double_t fSignalCut
MVA cut value for last demanded background rejection or signal efficiency.
Double_t Root(Double_t)
Root finding using Brents algorithm; taken from CERNLIB function RZERO.
void ApplySignalAndBackgroundStyle(TH1 *sig, TH1 *bkg, TH1 *any=nullptr)
Double_t GetROCIntegral()
code to compute the area under the ROC ( rej-vs-eff ) curve
Float_t fXmax
min and max of the mva distribution
TSpline * fSplmvaCumB
spline of cumulated mva distributions
Int_t fMaxIter
maximum number of iterations
Bool_t fStatus
false if is found some error in mvaS or mvaB
Int_t fCutOrientation
+1 if larger mva value means more signal like, -1 otherwise
TH1 * GetPurity(Int_t nStot, Int_t nBtot)
Double_t GetEffSForEffBof(Double_t effBref, Double_t &effSerr)
get the signal efficiency for a particular background efficiency that will be the value of the effici...
ROCCalc(TH1 *mvaS, TH1 *mvaB)
TH1 * GetSignificance(Int_t nStot, Int_t nBtot)
TH1D * GetROC()
get the ROC curve
TH1 * fmvaB
the input mva distributions
MsgLogger * fLogger
! message logger
Double_t fAbsTol
absolute tolerance deviation
TH1 * fmvaBpdf
the normalized (and rebinned) input mva distributions
Double_t GetEffForRoot(Double_t theCut)
returns efficiency as function of cut
Double_t fNevtS
number of signal events (used in error calculation)
Linear interpolation of TGraph.
create variable transformations
MsgLogger & Endl(MsgLogger &ml)
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Double_t Sqrt(Double_t x)
Returns the square root of x.
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.