For completeness and future reference, your snippet would look like the following with TTreeReader
(modulo typos ):
// the two repeated snippets should be made into a single function called twice
void read() {
TFile fsig("susysignal_total.root");
TTreeReader rsignal("signal_Tree", &fsig);
TTreeReaderValue<double> energytop_sig(rsignal, "energytop1");
auto histo_sig = new TH1D("histo", "", 100, 0., 2200.);
while(rsignal.Next())
histo_sig->Fill(*energytop_sig);
TFile fbg("susybackground_total.root");
TTreeReader rbg("susybg_Tree", &fbg);
TTreeReaderValue<double> energytop_bg(rbg, "energytop1");
auto histo_bg = new TH1D("histo", "", 100, 0., 2200.);
while(rbg.Next())
histo_bg->Fill(*energytop_bg);
histo_sig->Draw();
histo_bg->Draw("same");
}
and like the following with TDataFrame
:
// the two repeated snippets should be made into a single function called twice
using namespace ROOT::Experimental;
void read() {
TDataFrame dfsig("signal_Tree", "susysignal_total.root");
auto histo_sig = dfsig.Histo1D("energytop1");
histo_sig->Draw();
TDataFrame dfbg("susybg_Tree", "susybackground_total.root");
auto histo_bg = dfbg.Histo1D("energytop1");
histo_bg->Draw("same");
}