your sugesstion did the reading very well, but result is the same as before, the variables continue be zero.
The TTree in the file .root there are diferents variables with diferents entries, por example, nPart (entries=1000) and px (entries~280000). I think in this reading the macro is not acess the right leaf from the TTree.
What i need are the variable px, py,pz and E.
I think that px, py, pz and E is not Receiving the data from the TTree.
#include "TROOT.h"
#include "TFile.h"
#include "TTree.h"
#include "TBrowser.h"
#include "TH2.h"
#include "TRandom.h"
void read_root(const char* fileNameIn="crmc_eposlhc_294960099_Pb_p_1600.root")
{
// *******************************************************
// open the file that have the object Tree
// *******************************************************
TFile *fin = new TFile(fileNameIn,"READ");
// *******************************************************
//Take the object TTree that is inside of the file .root
// *******************************************************
TTree *tree = (TTree*)fin->Get("Particle");
// *******************************************************
// Created a windows for show the graph
// *******************************************************
TCanvas *c1 = new TCanvas("c1","Minha Janela",10,10,700,500);
c1->SetFillColor(18);
c1->SetGrid(1,1);
c1->SetLogx(0);
c1->SetLogy(1);
tree->Draw("TMath::Sqrt(px*px+py*py)");
//tree->Print("all");
((TTreePlayer*)(tree->GetPlayer()))->SetScanRedirect(true);
((TTreePlayer*)(tree->GetPlayer()))->SetScanFileName("crmc_eposlhc_294960099_Pb_p_1600.txt");
tree->Scan();
}