I’m trying to create a 1D histogram but getting this error “Replacing existing TH1: Energy (Potential memory leak)”. Some ideas would be highly appreciated.
GENIAnalysis.C (1.9 KB)
ROOT Version:6.24
Platform:_ Not Provided
Compiler:_ Not Provided
I’m trying to create a 1D histogram but getting this error “Replacing existing TH1: Energy (Potential memory leak)”. Some ideas would be highly appreciated.
GENIAnalysis.C (1.9 KB)
ROOT Version:6.24
Platform:_ Not Provided
Compiler:_ Not Provided
You need:
// ...
TH1D *h = new TH1D("Energy", "Final Energy; Protons; Frequency", 50, 0., 2.);
for (Long64_t jentry = 0; jentry < nentries; jentry++) {
// ...
if (pdgf[pdgindex] == 2212) {
h->Fill(Your_Particle_Final_Energy_Value); // maybe (Ef[pdgindex])
}
// ...
}
h->Draw();
// ...
BTW. If this is the same tree as in the “InteractionsII.root” file, instead of:
for (Long64_t pdgindex=0; pdgindex<28;pdgindex++)
you need:
for (Int_t pdgindex = 0; pdgindex < nf; pdgindex++) // if you use the "pdgf[nf]/I " branch inside
or:
for (Int_t pdgindex = 0; pdgindex < ni; pdgindex++) // if you use the "pdgi[ni]/I " branch inside
Thanks Wile! It worked. I really appreciate it.
Hany
