I tried to build a program that make a chain from this two root files tree.root (11.3 KB) tree2.root (20.1 KB)
and then build a histogram entries vs pt for a specific particle pdg=21. I made this:
{
TFile hfile("hfile.root","recreate"); //create a root file
TChain ch("tree"); //create a chain of tree
TCanvas c1("c1","pt distribution pdg 21",700,500); //create a canvas 700x500
ch.Add("tree.root"); //add tree to chain
ch.Add("tree2.root");
// devo creare un istogramma e riempirlo con quelle variabili
TH1F h("h","pt distribution pdg 21",100,0,8);
//now i need to creare a for in order to fill h
//and choose right particle fpdg="21"
h.GetXaxis().SetTitle("P_t [MeV]"); //set axis names
h.GetYaxis().SetTitle("Entries");
h.SetTitle("pt distribution pdg 21");
h.Draw("((fPx*fPx)+(fPy*fPy))^0.5"); //draw pt
hfile.Write(); //write on root file
hfile.Close(); //close root file
}
How can I make a for cycle and fill my h with the variable ((fPxfPx)+(fPyfPy))^0.5 ? And how can i choose the particle?
Thanks for all!
_ROOT Version: 6.18
_Platform: Xubuntu 19.04
_Compiler: gcc version 7.3.0