Skip to content

Commit c357ce2

Browse files
benedikt-voelkelBenedikt Volkel
authored andcommitted
Delete ratio plots after plotting
1 parent 2cacba9 commit c357ce2

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

RelVal/PlotOverlays.C

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ void overlay1D(std::vector<TH1*> hVec, std::vector<std::string> labelVec, TLegen
127127
if (i > 0) {
128128
// no ratio for the first histogram (which would simply be 1)
129129
TH1* hRatio = (TH1*)h->Clone();
130+
hRatio->SetDirectory(0);
130131
hRatio->Divide(h, hVec[0], 1.0, 1.0, "B"); // error option?
131132
ratios.push_back(hRatio);
132133
}
@@ -194,6 +195,10 @@ void overlay1D(std::vector<TH1*> hVec, std::vector<std::string> labelVec, TLegen
194195
auto savePath = outputDir + "/" + hVec[0]->GetName() + ".png";
195196
c.SaveAs(savePath.c_str());
196197
c.Close();
198+
199+
for (auto& r : ratios) {
200+
delete r;
201+
}
197202
}
198203

199204
// overlay 2D histograms
@@ -218,8 +223,12 @@ void overlay2D(std::vector<TH1*> hVec1, std::vector<std::string> labelVec, TLege
218223
t1->Draw();
219224
}
220225

226+
std::vector<TH1*> ratios;
227+
221228
for (int i = 1; i < nHistos; i++){
222229
auto hDiv = (TH2*)hVec[i]->Clone(Form("%s_ratio", hVec[i]->GetName()));
230+
hDiv->SetDirectory(0);
231+
ratios.push_back(hDiv);
223232
hDiv->SetTitle(hVec[i]->GetTitle() + TString("(" + labelVec[i] + "/"+labelVec[0]+")"));
224233
hDiv->SetStats(0);
225234
hDiv->Divide(hVec[0]);
@@ -254,6 +263,10 @@ void overlay2D(std::vector<TH1*> hVec1, std::vector<std::string> labelVec, TLege
254263
auto savePath = outputDir + "/" + hVec[0]->GetName() + ".png";
255264
c.SaveAs(savePath.c_str());
256265
c.Close();
266+
267+
for (auto& r : ratios) {
268+
delete r;
269+
}
257270
}
258271

259272
// entry point for overlay plots from ReleaseValidation.C

0 commit comments

Comments
 (0)