Skip to content

Commit 3fc6c70

Browse files
committed
Fix THStack
1 parent ad6810b commit 3fc6c70

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

Tutorial/KinemDistributionTutorial.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,21 +76,20 @@ int main(int argc, char **argv) {
7676
for (size_t iPDF=0; iPDF < mySamples.size(); iPDF++) {
7777
MACH3LOG_INFO("Number of samples: {}", mySamples[iPDF]->GetNSamples());
7878
for(int iSample = 0; iSample < mySamples[iPDF]->GetNSamples(); iSample++){
79-
THStack* Stack = new THStack(*mySamples[iPDF]->ReturnStackedHistBySelection1D(iSample, vecParams[iParam], Selection));
80-
TLegend* Legend = new TLegend(*mySamples[iPDF]->ReturnStackHistLegend());
79+
auto Stack = mySamples[iPDF]->ReturnStackedHistBySelection1D(iSample, vecParams[iParam], Selection);
80+
TLegend* Legend = mySamples[iPDF]->ReturnStackHistLegend();
8181

8282
Canv->cd(1);
8383
Stack->Draw("HIST");
8484
//Due to crappy TStack design, you need to draw THStack first then assign axis titles
85-
Stack->SetTitle(mySamples[iPDF]->GetSampleTitle(iSample).c_str());
85+
std::string title = mySamples[iPDF]->GetSampleTitle(iSample);
86+
Stack->SetTitle(title.c_str());
8687
Stack->GetXaxis()->SetTitle((vecParams[iParam]).c_str());
8788
Canv->cd(2);
8889
Legend->Draw();
8990

9091
Canv->Update();
9192
Canv->Print(OutputName);
92-
delete Stack; Stack = nullptr;
93-
delete Legend; Legend = nullptr;
9493
}
9594
}
9695
}

0 commit comments

Comments
 (0)