21 if (Nevt <0) Nevt=1000000;
28 cout <<
"error could not find jobs" << endl;
35 TDirectory* dir0 = (TDirectory*) (jobDirList.
At(0));
39 if (debug) cout <<
"found targets " << nTargets<<endl;
41 for (
Int_t itrgt = 0 ; itrgt < nTargets; itrgt++){
42 if (debug) cout <<
"loop targets " << itrgt<<endl;
43 TString xtit =
"Method";
44 TString ytit =
"Average Quadratic Deviation";
45 TString ftit = ytit +
" versus " + xtit +
TString::Format(
" for target %d",itrgt);
46 c =
new TCanvas(
TString::Format(
"c%d",itrgt), ftit , 50+20*itrgt, 10*itrgt, 750, 650 );
52 c->SetTopMargin(0.28);
53 c->SetBottomMargin(0.1);
55 TString hNameRef =
TString::Format(
"regression_average_devs_target%d",itrgt);
57 const Int_t maxMethods = 100;
64 TIter next(&jobDirList);
65 Float_t mymax=0., mymin=std::numeric_limits<float>::max();
66 TString mvaNames[maxMethods];
70 while ( (jobDir = (TDirectory*)next()) ) {
73 mvaNames[nMethods]=methodTitle;
74 if (debug) cout <<
"--- Found directory for method: " << methodTitle << endl;
77 while ( (histKey = (TKey*)keyIt()) ) {
80 if( !s.Contains(
"Quadr_Dev") )
continue;
83 if( !s.Contains(
"best90perc") && s.Contains(
"train")) ihist=0;
84 if( s.Contains(
"best90perc") && s.Contains(
"train")) ihist=1;
85 if( !s.Contains(
"best90perc") && s.Contains(
"test")) ihist=2;
86 if( s.Contains(
"best90perc") && s.Contains(
"test")) ihist=3;
87 if (debug) cout <<
"using histogram" << s <<
", ihist="<<ihist<<endl;
88 TH1F*
h = (TH1F*) (histKey->
ReadObj());
89 m[ihist][nMethods] =
sqrt(
h->GetMean());
90 em[ihist][nMethods] =
h->GetRMS()/(
sqrt(
h->GetEntries())*2.*
h->GetMean());
91 x[ihist][nMethods] = nMethods+0.44+0.12*ihist;
92 ex[ihist][nMethods] = 0.001;
93 mymax=
m[ihist][nMethods] > mymax ?
m[ihist][nMethods] : mymax;
94 mymin=
m[ihist][nMethods] < mymin ?
m[ihist][nMethods] : mymin;
95 if (debug) cout <<
"m"<< ihist <<
"="<<
m[ihist][nMethods]<<endl;
100 TH1F* haveragedevs=
new TH1F(
TString::Format(
"haveragedevs%d",itrgt),ftit,nMethods,0.,nMethods);
103 TGraphErrors* graphTrainAv=
new TGraphErrors(nMethods,
x[0],
m[0],
ex[0],em[0]);
104 TGraphErrors* graphTruncTrainAv=
new TGraphErrors(nMethods,
x[1],
m[1],
ex[1],em[1]);
105 TGraphErrors* graphTestAv=
new TGraphErrors(nMethods,
x[2],
m[2],
ex[2],em[2]);
106 TGraphErrors* graphTruncTestAv=
new TGraphErrors(nMethods,
x[3],
m[3],
ex[3],em[3]);
113 if (mymin > 1.e-20 &&
log10(mymax/mymin)>1.5){
115 cout <<
"--- result differ significantly using log scale for display of regression results"<< endl;
120 Float_t x0L = 0.03, y0H = 0.91;
121 Float_t dxL = 0.457-x0L, dyH = 0.14;
123 TLegend *legend =
new TLegend( x0L, y0H-dyH, x0L+dxL, y0H );
128 TH1F *hr =
c->DrawFrame(-1.,0.,nMethods+1,
xmax);
130 cout <<
"Training: Average Deviation between target " << itrgt <<
" and estimate" << endl;
131 cout <<
TString::Format(
"%-15s%-15s%-15s",
"Method",
"Average Dev.",
"trunc. Aver.(90%)") <<endl;
132 for (
int i=0;i<nMethods;i++){
134 (
const char*)mvaNames[i],
m[0][i],
m[1][i])<<endl;
139 cout <<
"Testing: Average Deviation between target " << itrgt <<
" and estimate" << endl;
140 cout <<
TString::Format(
"%-15s%-15s%-15s",
"Method",
"Average Dev.",
"trunc. Aver.(90%)") <<endl;
141 for (
int i=0;i<nMethods;i++){
143 (
const char*)mvaNames[i],
m[2][i],
m[3][i])<<endl;
150 haveragedevs->
SetYTitle(
"Deviation from target");
151 haveragedevs->
Draw();
152 c->GetFrame()->SetFillColor(21);
153 c->GetFrame()->SetBorderSize(12);
157 graphTrainAv->
Draw(
"P");
162 graphTruncTrainAv->
Draw(
"P");
167 graphTestAv->
Draw(
"P");
172 graphTruncTestAv->
Draw(
"P");
173 legend->
AddEntry(graphTrainAv,TString(
"Training Sample, Average Deviation"),
"p");
174 legend->
AddEntry(graphTruncTrainAv,TString(
"Training Sample, truncated Average Dev. (best 90%)"),
"p");
175 legend->
AddEntry(graphTestAv,TString(
"Test Sample, Average Deviation"),
"p");
176 legend->
AddEntry(graphTruncTestAv,TString(
"Test Sample, truncated Average Dev. (best 90%)"),
"p");
183 legHeader.
DrawLatex(xheader, yheader,
"Average Deviation = (#sum (_{ } f_{MVA} - f_{target})^{2} )^{1/2}");
190 TString fname = dataset+
"/plots/" + hNameRef;
int Int_t
Signed integer 4 bytes (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 SetMarkerColor(Color_t mcolor=1)
Set the marker color.
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
virtual void SetMarkerSize(Size_t msize=1)
Set the marker size.
virtual void SetTextAlign(Short_t align=11)
Set the text alignment.
virtual void SetTextSize(Float_t tsize=1)
Set the text size.
virtual void SetBinLabel(Int_t bin, const char *label)
Set label for bin.
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
TDirectory * GetDirectory(const char *apath, Bool_t printError=false, const char *funcname="GetDirectory") override
Find a directory using apath.
virtual TList * GetListOfKeys() const
void Draw(Option_t *chopt="") override
Default Draw method for all objects.
virtual void SetXTitle(const char *title)
virtual void SetMaximum(Double_t maximum=-1111)
void Draw(Option_t *option="") override
Draw this histogram with options.
virtual void SetMinimum(Double_t minimum=-1111)
virtual void SetYTitle(const char *title)
virtual void SetStats(Bool_t stats=kTRUE)
Set statistics option on/off.
virtual TObject * ReadObj()
To read a TObject* from the file.
TLatex * DrawLatex(Double_t x, Double_t y, const char *text)
TLegendEntry * AddEntry(const TObject *obj, const char *label="", Option_t *option="lpf")
void Draw(Option_t *option="") override
Draw this box with its current attributes.
void SetMargin(Float_t margin)
TObject * At(Int_t idx) const override
Returns the object at position idx. Returns 0 if idx is out of range.
virtual const char * GetName() const
Returns name of object.
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
const char * Data() const
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
RVec< PromoteType< T > > log10(const RVec< T > &v)
VecExpr< UnaryOp< Sqrt< T >, VecExpr< A, T, D >, T >, T, D > sqrt(const VecExpr< A, T, D > &rhs)
UInt_t GetListOfJobs(TFile *file, TList &jobdirs)
void Initialize(Bool_t useTMVAStyle=kTRUE)
void GetMethodTitle(TString &name, TKey *ikey)
void plot_logo(Float_t v_scale=1.0, Float_t skew=1.0)
TFile * OpenFile(const TString &fin)
Int_t GetNumberOfTargets(TDirectory *dir)
void imgconv(TCanvas *c, const TString &fname)
void regression_averagedevs(TString dataset, TString fin, Int_t Nevt=-1, Bool_t useTMVAStyle=kTRUE)