Hello,
I’m working on a program in C++ that should graph and save px, py, pz from a tree of generated events. I want to fill TCanvas using arrays and then graph. I’m not sure exactly how to do this, can anybody offer some advice? I’ve copied the code I have so far below. (Please forgive any incorrect terminology or errors- I am a very new beginner!)
#include “TChain.h”
#include “TCanvas.h”
void TChainPractice(){
//creates a chain with tree "T"
TChain chain(“h16”);
//Adds all the files needed
chain.Add(“kstar*.root”);
//Now to get the events:
chain.SetBranchAddress("idhep==211"); //to recognize the mass of pi
chain.SetBranchAddress("px");
chain.SetBranchAddress("py");
chain.SetBranchAddress("pz");
Int_t nevent = chain.GetEntries();
for(Int_t i =0;i<nevent;i++){
if(idhep==211){
chain.GetEvent(i);
abs(idhep)==211
}
//Still need to fill TCanvas...
// ...
h16->Draw("px", "abs(idhep)==211");
c1->SaveAs("px.png");
h16->Draw("py," "abs(idehep)==211");
c1->SaveAs("py.png");
h16->Draw("pz", "abso(idhep)==211");
c1->SaveAs(("pz.png");