Hi,
I’m trying to running the macro readTree_1
to read the file
SimpleTree.root
macro:
void readTree_1(const char* fileNameIn="SimpleTree.root") {
// *******************************************************
// Histogram
// *******************************************************
Int_t NBINS=100; Double_t XMIN=0; Double_t XMAX=10;
TH1F *h1 = new TH1F("h1","Meu espectro de pt",NBINS,XMIN,XMAX);
// *******************************************************
// Open the file with the object Tree
// *******************************************************
TFile *fin = new TFile(fileNameIn,"READ");
// *******************************************************
// take the object TTree in the file .root
// *******************************************************
TTree *tree = (TTree*)fin->Get("tree");
// *******************************************************
// Define the address of the objects inside of the TTree
// *******************************************************
Int_t ev;
TParticle *pa;
tree->SetBranchAddress("Ev",&ev);
tree->SetBranchAddress("Pa",&pa);
// *******************************************************
// The number of line of the TTree
// *******************************************************
Int_t nevents = tree->GetEntries();
// *******************************************************
// Do a loop in all the lines of the TTree
// *******************************************************
for(Int_t i=0;i<nevents;++i) {
tree->GetEntry(i);
Double_t pt=(pa->Pt());
h1->Fill(pt);
}
// *******************************************************
// Windows
// *******************************************************
TCanvas *c1 = new TCanvas("c1","Minha Janela",10,10,700,500);
c1->SetFillColor(18); c1->SetGrid(1,1); c1->SetLogx(0); c1->SetLogy(0);
h1->Draw();
}
The file SimpleTree.root
SimpleTree.root (2.3 MB)
But I get the following error:
root [0]
Processing readTree_1.C...
*** Break *** segmentation violation
===========================================================
There was a crash.
This is the entire stack trace of all threads:
===========================================================
#0 0x00007ff90ab0d07a in __GI___waitpid (pid=15698, stat_loc=stat_loc
entry=0x7ffdf85f7c80, options=options
entry=0) at ../sysdeps/unix/sysv/linux/waitpid.c:29
#1 0x00007ff90aa85fbb in do_system (line=<optimized out>) at ../sysdeps/posix/system.c:148
#2 0x00007ff90b6804ed in TUnixSystem::Exec (shellcmd=<optimized out>, this=0x251f4f0) at /opt/root6/root6_src/core/unix/src/TUnixSystem.cxx:2118
#3 TUnixSystem::StackTrace (this=0x251f4f0) at /opt/root6/root6_src/core/unix/src/TUnixSystem.cxx:2412
#4 0x00007ff90b682adc in TUnixSystem::DispatchSignals (this=0x251f4f0, sig=kSigSegmentationViolation) at /opt/root6/root6_src/core/unix/src/TUnixSystem.cxx:3643
#5 <signal handler called>
#6 0x0000000000000000 in ?? ()
#7 0x00007ff8ebe49bb0 in TClass::Streamer (onfile_class=0x0, b=..., obj=<optimized out>, this=<optimized out>) at /opt/root6/include/TClass.h:537
#8 TBranchElement::ReadLeavesCustomStreamer (this=0x3eb62a0, b=...) at /opt/root6/root6_src/tree/tree/src/TBranchElement.cxx:4141
#9 0x00007ff8ebe3dea6 in TBranch::GetEntry (this=this
entry=0x3eb62a0, entry=entry
entry=0, getall=getall
entry=0) at /opt/root6/root6_src/tree/tree/src/TBranch.cxx:1317
#10 0x00007ff8ebe560c0 in TBranchElement::GetEntry (this=0x3eb62a0, entry=0, getall=0) at /opt/root6/root6_src/tree/tree/src/TBranchElement.cxx:2332
#11 0x00007ff8ebe997da in TTree::<lambda()>::operator() (__closure=<synthetic pointer>) at /opt/root6/root6_src/tree/tree/src/TTree.cxx:5342
#12 TTree::GetEntry (this=0x3ae88a0, entry=0, getall=0) at /opt/root6/root6_src/tree/tree/src/TTree.cxx:5416
#13 0x00007ff90bde81e1 in ?? ()
#14 0x00007ff900000007 in ?? ()
#15 0x00000000025d3bc0 in ?? ()
#16 0x0000000002583110 in ?? ()
#17 0x35fefdb2dd491600 in ?? ()
#18 0x0000000003ba5de0 in ?? ()
#19 0x0000000000000000 in ?? ()
===========================================================
The lines below might hint at the cause of the crash.
You may get help by asking at the ROOT forum http://root.cern.ch/forum.
Only if you are really convinced it is a bug in ROOT then please submit a
report at http://root.cern.ch/bugs. Please post the ENTIRE stack trace
from above as an attachment in addition to anything else
that might help us fixing this issue.
===========================================================
#6 0x0000000000000000 in ?? ()
#7 0x00007ff8ebe49bb0 in TClass::Streamer (onfile_class=0x0, b=..., obj=<optimized out>, this=<optimized out>) at /opt/root6/include/TClass.h:537
#8 TBranchElement::ReadLeavesCustomStreamer (this=0x3eb62a0, b=...) at /opt/root6/root6_src/tree/tree/src/TBranchElement.cxx:4141
#9 0x00007ff8ebe3dea6 in TBranch::GetEntry (this=this
entry=0x3eb62a0, entry=entry
entry=0, getall=getall
entry=0) at /opt/root6/root6_src/tree/tree/src/TBranch.cxx:1317
#10 0x00007ff8ebe560c0 in TBranchElement::GetEntry (this=0x3eb62a0, entry=0, getall=0) at /opt/root6/root6_src/tree/tree/src/TBranchElement.cxx:2332
#11 0x00007ff8ebe997da in TTree::<lambda()>::operator() (__closure=<synthetic pointer>) at /opt/root6/root6_src/tree/tree/src/TTree.cxx:5342
#12 TTree::GetEntry (this=0x3ae88a0, entry=0, getall=0) at /opt/root6/root6_src/tree/tree/src/TTree.cxx:5416
#13 0x00007ff90bde81e1 in ?? ()
#14 0x00007ff900000007 in ?? ()
#15 0x00000000025d3bc0 in ?? ()
#16 0x0000000002583110 in ?? ()
#17 0x35fefdb2dd491600 in ?? ()
#18 0x0000000003ba5de0 in ?? ()
#19 0x0000000000000000 in ?? ()
===========================================================
I think that error is in some place for here in the macro:
for(Int_t i=0;i<nevents;++i) {
tree->GetEntry(i);
Double_t pt=(pa->Pt());
h1->Fill(pt);
}
Someone can help me?
Thanks!
André