[ROOT] problem with chaining ntuples

From: Masoud M.Shafiei (shafiei@kvi.nl)
Date: Thu Nov 28 2002 - 01:08:10 MET


Dear Root users,

        I have 27 ntuple files of  about 6 Mbytes.  When I call them one
by one on a root session everything goes well.
What I want to do is to chain them all, make a class out of them ( using
MakeClass command)
and analyze my data. But, apparently the class made of a chain of more
than 4 ntuples leads to
segmentation violation while looping over the data!!

***********************************************
Compiled for linux with thread support.

CINT/ROOT C/C++ Interpreter version 5.15.50, July 7 2002
Type ? for help. Commands must be C++ statements.
Enclose multiple statements between { }.
root [0] TChain ch("t");
root [1] ch.Add("*.root");
root [2] ch.MakeClass("myfile")
Info in <TTreePlayer::MakeClass>: Files: myfile.h and myfile.C generated
from Tree: t
(Int_t)0
root [0] .L myfile.C
root [1] myfile t
root [2] t.Loop();

 *** Break *** segmentation violation
Root >
******************************************************************

I have attached the  "myfile.C and myfile.h" created by  MakeClass()
command, in case you may have look at them.

any help is appreciated.

Best Regards
Masoud



////////////////////////////////////////////////////////// // This class has been automatically generated // (Wed Nov 27 18:42:31 2002 by ROOT version3.03/07) // from TChain t/ ////////////////////////////////////////////////////////// #ifndef myfile_h #define myfile_h #include <TROOT.h> #include <TChain.h> #include <TFile.h> class myfile { public : TTree *fChain; //!pointer to the analyzed TTree or TChain Int_t fCurrent; //!current Tree number in a TChain //Declaration of leaves types Int_t mul1; Float_t th1; Float_t ph1; Float_t en1[4]; //[mul1] Int_t mul2; Float_t th2; Float_t ph2; Float_t en2[3]; //[mul2] Int_t mulg; Float_t thg[83]; //[mulg] Float_t phg[83]; //[mulg] Float_t delta[83]; //[mulg] Float_t energy[83]; //[mulg] Float_t id[83]; //[mulg] Float_t tdc[83]; //[mulg] Float_t PhgMeas; Float_t ThgMeas; Float_t engm_eng; Float_t engm_delg; Int_t parity; Float_t e1r; Float_t e2r; Float_t egr; Float_t phgr; Float_t nonco; //List of branches TBranch *b_mul1; //! TBranch *b_th1; //! TBranch *b_ph1; //! TBranch *b_en1; //! TBranch *b_mul2; //! TBranch *b_th2; //! TBranch *b_ph2; //! TBranch *b_en2; //! TBranch *b_mulg; //! TBranch *b_thg; //! TBranch *b_phg; //! TBranch *b_delta; //! TBranch *b_energy; //! TBranch *b_id; //! TBranch *b_tdc; //! TBranch *b_PhgMeas; //! TBranch *b_ThgMeas; //! TBranch *b_engm; //! TBranch *b_parity; //! TBranch *b_e1r; //! TBranch *b_e2r; //! TBranch *b_egr; //! TBranch *b_phgr; //! TBranch *b_nonco; //! myfile(TTree *tree=0); ~myfile(); Int_t Cut(Int_t entry); Int_t GetEntry(Int_t entry); Int_t LoadTree(Int_t entry); void Init(TTree *tree); void Loop(); Bool_t Notify(); void Show(Int_t entry = -1); }; #endif #ifdef myfile_cxx myfile::myfile(TTree *tree) { // if parameter tree is not specified (or zero), connect the file // used to generate this class and read the Tree. if (tree == 0) { #ifdef SINGLE_TREE // The following code should be used if you want this class to access // a single tree instead of a chain TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject("Memory Directory"); if (!f) { f = new TFile("Memory Directory"); f->cd("Rint:/"); } tree = (TTree*)gDirectory->Get("t"); #else // SINGLE_TREE // The following code should be used if you want this class to access a chain // of trees. TChain * chain = new TChain("t",""); chain->Add("/home/shafiei/analysis/ntuple20/root3/07ppg4.root/t"); chain->Add("/home/shafiei/analysis/ntuple20/root3/07ppg5.root/t"); chain->Add("/home/shafiei/analysis/ntuple20/root3/07ppg.root/t"); chain->Add("/home/shafiei/analysis/ntuple20/root3/07ppg6.root/t"); chain->Add("/home/shafiei/analysis/ntuple20/root3/07ppg8.root/t"); chain->Add("/home/shafiei/analysis/ntuple20/root3/07ppg7.root/t"); chain->Add("/home/shafiei/analysis/ntuple20/root3/07ppg9.root/t"); chain->Add("/home/shafiei/analysis/ntuple20/root3/07ppgb.root/t"); chain->Add("/home/shafiei/analysis/ntuple20/root3/07ppgc.root/t"); chain->Add("/home/shafiei/analysis/ntuple20/root3/07ppgd.root/t"); chain->Add("/home/shafiei/analysis/ntuple20/root3/07ppge.root/t"); chain->Add("/home/shafiei/analysis/ntuple20/root3/07ppg2.root/t"); chain->Add("/home/shafiei/analysis/ntuple20/root3/07ppg3.root/t"); chain->Add("/home/shafiei/analysis/ntuple20/root3/10ppg10.root/t"); chain->Add("/home/shafiei/analysis/ntuple20/root3/10ppg11.root/t"); chain->Add("/home/shafiei/analysis/ntuple20/root3/10ppg12.root/t"); chain->Add("/home/shafiei/analysis/ntuple20/root3/10ppg13.root/t"); chain->Add("/home/shafiei/analysis/ntuple20/root3/02ppg142.root/t"); chain->Add("/home/shafiei/analysis/ntuple20/root3/02ppg14.root/t"); chain->Add("/home/shafiei/analysis/ntuple20/root3/04ppg18.root/t"); chain->Add("/home/shafiei/analysis/ntuple20/root3/04ppg19.root/t"); chain->Add("/home/shafiei/analysis/ntuple20/root3/04ppg2.root/t"); chain->Add("/home/shafiei/analysis/ntuple20/root3/04ppg.root/t"); chain->Add("/home/shafiei/analysis/ntuple20/root3/05ppg15.root/t"); chain->Add("/home/shafiei/analysis/ntuple20/root3/05ppg14.root/t"); chain->Add("/home/shafiei/analysis/ntuple20/root3/05ppg2.root/t"); chain->Add("/home/shafiei/analysis/ntuple20/root3/05ppg.root/t"); tree = chain; #endif // SINGLE_TREE } Init(tree); } myfile::~myfile() { if (!fChain) return; delete fChain->GetCurrentFile(); } Int_t myfile::GetEntry(Int_t entry) { // Read contents of entry. if (!fChain) return 0; return fChain->GetEntry(entry); } Int_t myfile::LoadTree(Int_t entry) { // Set the environment to read one entry if (!fChain) return -5; Int_t centry = fChain->LoadTree(entry); if (centry < 0) return centry; if (fChain->IsA() != TChain::Class()) return centry; TChain *chain = (TChain*)fChain; if (chain->GetTreeNumber() != fCurrent) { fCurrent = chain->GetTreeNumber(); Notify(); } return centry; } void myfile::Init(TTree *tree) { // Set branch addresses if (tree == 0) return; fChain = tree; fCurrent = -1; fChain->SetMakeClass(1); fChain->SetBranchAddress("mul1",&mul1); fChain->SetBranchAddress("th1",&th1); fChain->SetBranchAddress("ph1",&ph1); fChain->SetBranchAddress("en1",en1); fChain->SetBranchAddress("mul2",&mul2); fChain->SetBranchAddress("th2",&th2); fChain->SetBranchAddress("ph2",&ph2); fChain->SetBranchAddress("en2",en2); fChain->SetBranchAddress("mulg",&mulg); fChain->SetBranchAddress("thg",thg); fChain->SetBranchAddress("phg",phg); fChain->SetBranchAddress("delta",delta); fChain->SetBranchAddress("energy",energy); fChain->SetBranchAddress("id",id); fChain->SetBranchAddress("tdc",tdc); fChain->SetBranchAddress("PhgMeas",&PhgMeas); fChain->SetBranchAddress("ThgMeas",&ThgMeas); fChain->SetBranchAddress("engm",&engm_eng); fChain->SetBranchAddress("parity",&parity); fChain->SetBranchAddress("e1r",&e1r); fChain->SetBranchAddress("e2r",&e2r); fChain->SetBranchAddress("egr",&egr); fChain->SetBranchAddress("phgr",&phgr); fChain->SetBranchAddress("nonco",&nonco); Notify(); } Bool_t myfile::Notify() { // Called when loading a new file. // Get branch pointers. b_mul1 = fChain->GetBranch("mul1"); b_th1 = fChain->GetBranch("th1"); b_ph1 = fChain->GetBranch("ph1"); b_en1 = fChain->GetBranch("en1"); b_mul2 = fChain->GetBranch("mul2"); b_th2 = fChain->GetBranch("th2"); b_ph2 = fChain->GetBranch("ph2"); b_en2 = fChain->GetBranch("en2"); b_mulg = fChain->GetBranch("mulg"); b_thg = fChain->GetBranch("thg"); b_phg = fChain->GetBranch("phg"); b_delta = fChain->GetBranch("delta"); b_energy = fChain->GetBranch("energy"); b_id = fChain->GetBranch("id"); b_tdc = fChain->GetBranch("tdc"); b_PhgMeas = fChain->GetBranch("PhgMeas"); b_ThgMeas = fChain->GetBranch("ThgMeas"); b_engm = fChain->GetBranch("engm"); b_parity = fChain->GetBranch("parity"); b_e1r = fChain->GetBranch("e1r"); b_e2r = fChain->GetBranch("e2r"); b_egr = fChain->GetBranch("egr"); b_phgr = fChain->GetBranch("phgr"); b_nonco = fChain->GetBranch("nonco"); return kTRUE; } void myfile::Show(Int_t entry) { // Print contents of entry. // If entry is not specified, print current entry if (!fChain) return; fChain->Show(entry); } Int_t myfile::Cut(Int_t entry) { // This function may be called from Loop. // returns 1 if entry is accepted. // returns -1 otherwise. return 1; } #endif // #ifdef myfile_cxx



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:21 MET