:: Unable to read tree :


_ROOT Version: 5.34/34
Platform: Not Provided
Compiler: Not Provided


Hello
I am trying to read a tree but there are errors in getting the branch information. I am unable to find the entries in the “gTrack”.

#include “TROOT.h”
#include “TFile.h”
#include “TTree.h”
#include “TBrowser.h”
#include “TH2.h”
#include “TRandom.h”
#include “TLeaf.h”
const int nn = 10000;
void flow_chargeed_hadrons()
{
TProfile *V2hist = new TProfile("","",100,0,3,-1,1); // V2 Histogram declaration
Int_t gTrack = 0 ;
Double_t gImp = 0.;
Int_t nPid[nn] ={0};
Double_t pt[nn] = {0.};
Double_t nPy[nn] = {0.};
Double_t nPx[nn] = {0.};
Double_t nPz[nn] = {0.};
Double_t v2[nn] = {0.};
Double_t nMass[nn] = {0.};
TFile *readTree = new TFile(“amptTree.root”,“READ”); //Tree reading
TTree t = (TTree)readTree->Get(“t”);
t->SetBranchAddress(“gImp”,&gImp);
t->SetBranchAddress(“gTrack”,&gTrack);
t->SetBranchAddress(“nPx”,&nPx);
t->SetBranchAddress(“nPy”,&nPy);
t->SetBranchAddress(“nPz”,&nPz);
t->SetBranchAddress(“nPid”,&nPid);
t->SetBranchAddress(“nMass”,&nMass);
// TRACKS = 0;
TH1F *PX = new TH1F(“PX”,“px distribution”,100,-3,3);
TH1F *PY = new TH1F(“PY”,“py distribution”,100,-3,3);
TH1F *PT = new TH1F(“PT”,“pt distribution”,100,-3,3);
cout << “========================================== I am HERE =========================================================” << endl;
int TotalEvents = t->GetEntries();
cout << "TOTAL EVENTS : " << TotalEvents << endl;
for (int i = 0; i < TotalEvents; i++)
{
int TRACK = gTrack;
cout << TRACKS << endl;
/*for (int ii = 0; ii < TotalEvents; ii++)
{
PX->Fill(nPx[i]);
PY->Fill(nPy);
pt = sqrt(nPx * nPx + nPy * nPy);
PT->Fill(pt);
}
/
}
PX->Draw();
PY->Draw();
PT->Draw();
readTree->Close();
/

pt = sqrt(px * px + py * py); // v2 evaluation block
if ((px!=0) && (py==0)) v2 = 1.0;
else if ((px==0) && (py!=0)) v2 = -1.0;
else if ((px==0) && (py==0)) v2 = 0.0;
else
v2 = (px * px - py * py)/(px * px + py * py);
V2hist->Fill(pt,v2,1); //Filling Histogram
V2hist->Draw();
*/
}

Here is the tree to be read…
tree

Thank you
:slight_smile:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.