Hi Bertrand,
sorry for answering too late. I solved my problem by use of what you suggested me in your first reply. It was more suitable for what I needed to do.
But now the problem of “glib detected” rises again in another code.
As usual, I have to read some files and take the same variable from all of them. This variable is actually an array.
This time I use no for loops, but something like this (sorry for its length) :
#include “TTree.h”
#include “TFile.h”
…
void function()
{
gROOT->SetStyle(“Plain”) ;
Int_t var1, var2 ,var3 ;
Float_t Pt[2] ; // array
Double_t fs = (Double_t) 43.2/500 ; //scale factor
TFile *f1 = new TFile(“file1.root”)
TTree f1 = (TTree)f1->Get(“tree”)
t1->SetBranchAddress(“var1”,&var1) ;
t1->SetBranchAddress(“var2”,&var2) ;
t1->SetBranchAddress(“Pt”,Pt) ;
TH1F *h1 = new TH1F(“h1”,“h1”,100,0,300) ;
Int_t nentries = (Int_t)t1->GetEntries();
for (Int_t i = 0 ; i<nentries ; i++)
{
t1->GetEntry(i);
if(var1>0 && var2==2) h1->Fill(Pt[0]) ; //fill with the first element of the array
}
TFile *f1 = new TFile(“file1.root”)
TTree f1 = (TTree)f1->Get(“tree”)
t1->SetBranchAddress(“var1”,&var1) ;
t1->SetBranchAddress(“var2”,&var2) ;
t1->SetBranchAddress(“Pt”,Pt) ;
TH1F *h2 = new TH1F(“h1”,“h2”,100,0,300) ;
Int_t nentries = (Int_t)t2->GetEntries();
for (Int_t i = 0 ; i<nentries ; i++)
{
t2->GetEntry(i);
if(var1>0 && var2==2) h2->Fill(Pt[0]) ; //fill with the first element of the array
}
…
TFile *f10 = new TFile(“file1.root”)
TTree f10 = (TTree)f10->Get(“tree”)
t10->SetBranchAddress(“var1”,&var1) ;
t10->SetBranchAddress(“var2”,&var2) ;
t10->SetBranchAddress(“Pt”,Pt) ;
TH1D *h10 = new TH1D(“h10”,“h10”,100,0,300) ;
Int_t nentries = (Int_t)t10->GetEntries();
for (Int_t i = 0 ; i<nentries ; i++)
{
t10->GetEntry(i);
if(var1>0 && var2==2) h10->Fill(Pt[0]) ; //fill with the first element of the array
}
TCanvas *c1 = new TCanvas(“c1”,“c1”,1)
THStack *hs = new THStack(“hs”,“hs”) ;
h1->Scale(fs) ;
h1->SetFillColor(2)
h2->Scale(fs) ;
h2->SetFillColor(3) ;
…
…
hs->Add(h1) ;
hs->Add(h2) ;
…
…
…
hs->Draw() ;
TLegend *leg = new TLegend(0.45,0.45,0.9,0.9)
leg->AddEntry(h1, “title1”, “f” );
leg->AddEntry(h2, “title2”, “f” );
leg->Draw() ;
}
The unbelievable thing is that the crash comes when I put 9 or more files to read, while everything works when adding a maximum of 8 files !!
Is there any explanation ?
PS: the root version I use is 5.18/00b.
Thanks in advance!
Manuel