Hi everyone,
I am trying to plot a histogram from a root file. This root file contains four tree,0,1,2,3 and each tree has many branches such as px,py,pz etc. The code I used to plot the px is shown below:
{
gROOT->LoadMacro(“AtlasStyle.C”);
gROOT->LoadMacro(“AtlasUtils.C”);
SetAtlasStyle();
TFile *myFile = new TFile(“test.root”);
TTree Tree0 = (TTree)myFile->Get(“Tree0”);
Float_t px;
Tree0->SetBranchAddress(“px”,&px);
TH1F *hpx = new TH1F(“px”,“px”,100,-100,12500);
Int_t nentries = (Int_t)Tree0->GetEntries();
for (Int_t i=0; i<nentries; i++){
Tree0->GetEntry(i);
hpx->Fill(px);
}
TCanvas c1;
c1.SetGridx();
c1.SetGridy();
Tree0->Draw();
if (gROOT->IsBatch()) return;
}
Although there is no error when I run root px.C, no plot is shown. I wonder whether there are any mistakes?
Thanks