GSI Forum
GSI Helmholtzzentrum für Schwerionenforschung

Home » PANDA » PandaRoot » General » Reading a tree HELP!
Re: Reading a tree HELP! [message #17784 is a reply to message #17783] Thu, 22 January 2015 15:48 Go to previous messageGo to previous message
asanchez is currently offline  asanchez
Messages: 350
Registered: March 2006
first-grade participant
From: *kph.uni-mainz.de
Hi Mamaen,
here you are some lines as example how to get read of
the TParticle Info in a TTree Smile.


TFile *tf1 = new TFile("the file");
TTree *data = (TTree*)tf1->Get("data");
TClonesArray* hit_array=new TClonesArray("TParticle",100);
data->SetBranchAddress("Particles",&hit_array);//Branch names

for (Int_t j=0; j<data->GetEntries(); j++)
{
// if ((j)%100000==0)cout <<"evt: "<<j<<endl;

data->GetEntry(j); // Loop over particles in TClonesArray

for (Int_t iPart=0; iPart < nParts; iPart++) {

TParticle* part = (TParticle*) hit_array->At(iPart);
Int_t pdgType = part->GetPdgCode();


//you can use the member function of TPArticle to get the kinematic information

TLorentzVector lv1;

part->Momentum(lv1);

TVector3 v1;

v1= lv1.Vect();


// Total momentum

Double_t P;

P = part->P();

// theta

Double_t theta;

theta = part->Theta();


}

}
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Howto for eventdisplay
Next Topic: simulation output; sge scripts in macro/prod
Goto Forum:
  


Current Time: Fri Apr 26 22:05:15 CEST 2024

Total time taken to generate the page: 0.01212 seconds