Hi there,
I’m trying to write a generic histogramming application that takes a number of ntuples and plots them either layered or stacked with different stats panels for each one.
So far this works fine when I pass “nostack” as an argument via “stackargs” but if I leave this out, the first ntuple histogrammed always ends up with a duplicate stats panel. (see the attached images).
I would like to either prevent the additional stats panel from being drawn in the case of stacking, or to remove it automatically if it does get drawn, prior to writing out the images.
The code snippet I am using to do this is as follows. Is there any way to prevent the duplicate panel being made?
Thanks!
for(UInt_t f=0; f<nFiles; f++){
TH1F *Histo = new TH1F(Vars[nVarsDone]+" "+LegendNames[f],Vars[nVarsDone]+" "+LegendNames[f],VarBins[nVarsDone],VarLower[nVarsDone],VarUpper[nVarsDone]);
Trees[f]->Draw(Vars[nVarsDone]+">>"+Vars[nVarsDone]+" "+LegendNames[f]);
Histo->SetLineColor(Colors[f]);
Histo->SetFillColor(Colors[f]);
Histo->SetFillStyle(FillStyles[f]);
Histo->SetLineWidth(lw[f]);
Histo->SetStats(true);
c->Update();
stats[f] = (TPaveStats*)Histo->GetListOfFunctions()->FindObject("stats");
stats[f]->SetTextColor(Colors[f]);
Histo->Scale(Weights[f]);
hs->Add(Histo);
legend->AddEntry(Histo,LegendNames[f],"f");
}
hs->Draw(*stackargs);
if(Axis[nVarsDone]){
gPad->SetLogy();
}
c->Update();
hs->GetXaxis()->SetTitle(Units[nVarsDone]);
hs->GetYaxis()->SetTitle("Candidates");
hs->Draw(*stackargs);
Double_t x1 = 0.825;
Double_t x2 = 0.975;
Double_t y1 = 0.825;
Double_t y2 = 0.975;
for(UInt_t g=0; g<nFiles; g++){
stats[g]->SetX1NDC(x1); stats[g]->SetX2NDC(x2);
stats[g]->SetY1NDC(y1); stats[g]->SetY2NDC(y2);
y1 = y1 - 0.165;
y2 = y2 - 0.165;
stats[g]->Draw();
}
nVarsDone++;
if(v==0){
legend->SetShadowColor(0);
legend->SetLineColor(0);
legend->SetTextSize(0.05);
legend->SetFillColor(0);
legend->Draw();
}
}