Hello,
I have the following simple code just to test my data file.
[code]#include
#include
#include
#include <stdlib.h>
#include <TROOT.h>
#include <TChain.h>
#include <TFile.h>
#include
#include “TROOT.h”
#include “TFile.h”
#include “TTree.h”
#include “TChain.h”
#include “TBranch.h”
#include “TFileCollection.h”
#include “TApplication.h”
#include “TChainElement.h”
#include “TObjArray.h”
#include
#if defined(MAKECINT) || defined(CINT)
#pragma link C++ class vector<vector >+;
#endif
using namespace std;
//using namespace Root;
int main(int argc, char **argv)
{
// TApplication App(argv[0],&argc,argv);
gROOT->ProcessLine("#include “);
const char* physics = “physics”;
TChain chain(physics,”");
const char * dataset = “”;
string datasetstg(argv[1]);
if (argc>1){
cout << " \tDatasets will be read from: " << (argv[1]) << endl;
dataset = (argv[1]);
}
ifstream myfile;
myfile.open( dataset, ios::in);
if (!myfile) {
cout << " Read Datasets: Can’t open input file: " << datasetstg << endl;
exit(1);
} else {
cout << “\n Read data file=” << dataset << “\n”<<endl;
}
string temp;
while (myfile >> temp) {
if (temp.find("#") != -1) continue;
//m_outfile = temp + “.root”;
//cout << temp << endl;
//temp = temp + “/physics”;
cout<<temp.c_str()<<endl;
chain.AddFile( temp.c_str() );
cout<<temp<<endl;
}
TObjArray *fileElements=chain.GetListOfFiles();
TIter next(fileElements);
TChainElement chEl=0;
while (( chEl=(TChainElement)next() )) {
TFile f(chEl->GetTitle());
cout<<f.GetName()<<endl;
}
Int_t el_pt;
TBranch *b_el_pt;
chain.SetBranchAddress(“el_pt”, &el_pt, &b_el_pt);
try
{
// main loop
Long64_t nentries = chain.GetEntries();
cout<<“number of entries”<<nentries<<endl;
for (Long64_t jentry=0; jentry<nentries;jentry++)
{
Long64_t ientry = chain.LoadTree(jentry);
// cout<<“here”<<endl;
cout<<ientry<<endl;
// if (ientry < 0)
// break;
Int_t currentEntry = chain.GetEntry(ientry);
}
}
catch (exception& e)
{
cout << e.what() << endl;
}
}
[/code]
Everything works except when I come to chain.getEntry(ientry). From there I get segmentation fault with the following info:
[code] Datasets will be read from: input.txt
Read data file=input.txt
NTUP_SMWZ.742823._000005.root
NTUP_SMWZ.742823._000005.root
Warning in TClass::TClass: no dictionary for class AttributeListLayout is available
Warning in TClass::TClass: no dictionary for class pair<string,string> is available
NTUP_SMWZ.742823._000005.root
number of entries10000
0
*** Break *** segmentation violation
===========================================================
There was a crash (#6 0x00ab79db in SigHandler(ESignals) () from /home/user/root/lib/libCore.so).
This is the entire stack trace of all threads:
#0 0x008cd416 in __kernel_vsyscall ()
#1 0x0039e3e3 in waitpid () from /lib/i386-linux-gnu/libc.so.6
#2 0x0033e6e3 in ?? () from /lib/i386-linux-gnu/libc.so.6
#3 0x00ab08db in TUnixSystem::Exec(char const*) () from /home/user/root/lib/libCore.so
#4 0x00ab4dc0 in TUnixSystem::StackTrace() () from /home/user/root/lib/libCore.so
#5 0x00ab78c7 in TUnixSystem::DispatchSignals(ESignals) () from /home/user/root/lib/libCore.so
#6 0x00ab79db in SigHandler(ESignals) () from /home/user/root/lib/libCore.so
#7 0x00aaeb12 in sighandler(int) () from /home/user/root/lib/libCore.so
#8
#9 0x00526a21 in TBufferFile::ReadFastArray(float*, int) () from /home/user/root/lib/libRIO.so
#10 0x0055e45e in void TGenCollectionStreamer::ReadBufferVectorPrimitives(TBuffer&, void*) () from /home/user/root/lib/libRIO.so
#11 0x0055a833 in TGenCollectionStreamer::ReadBuffer(TBuffer&, void*) () from /home/user/root/lib/libRIO.so
#12 0x0052c538 in TCollectionClassStreamer::Stream(TBuffer&, void*, TClass const*) () from /home/user/root/lib/libRIO.so
#13 0x00a806d7 in TClass::StreamerExternal(void*, TBuffer&, TClass const*) const () from /home/user/root/lib/libCore.so
#14 0x005273c5 in TBufferFile::ReadFastArray(void*, TClass const*, int, TMemberStreamer*, TClass const*) () from /home/user/root/lib/libRIO.so
#15 0x005793f5 in int TStreamerInfoActions::ReadSTL<&TStreamerInfoActions::ReadSTLMemberWiseSameClass, &TStreamerInfoActions::ReadSTLObjectWiseFastArray>(TBuffer&, void*, TStreamerInfoActions::TConfiguration const*) () from /home/user/root/lib/libRIO.so
#16 0x00526bc9 in TBufferFile::ApplySequence(TStreamerInfoActions::TActionSequence const&, void*) () from /home/user/root/lib/libRIO.so
#17 0x07467204 in ?? ()
The lines below might hint at the cause of the crash.
If they do not help you then please submit a bug 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.
#9 0x00526a21 in TBufferFile::ReadFastArray(float*, int) () from /home/user/root/lib/libRIO.so
#10 0x0055e45e in void TGenCollectionStreamer::ReadBufferVectorPrimitives(TBuffer&, void*) () from /home/user/root/lib/libRIO.so
#11 0x0055a833 in TGenCollectionStreamer::ReadBuffer(TBuffer&, void*) () from /home/user/root/lib/libRIO.so
#12 0x0052c538 in TCollectionClassStreamer::Stream(TBuffer&, void*, TClass const*) () from /home/user/root/lib/libRIO.so
#13 0x00a806d7 in TClass::StreamerExternal(void*, TBuffer&, TClass const*) const () from /home/user/root/lib/libCore.so
#14 0x005273c5 in TBufferFile::ReadFastArray(void*, TClass const*, int, TMemberStreamer*, TClass const*) () from /home/user/root/lib/libRIO.so
#15 0x005793f5 in int TStreamerInfoActions::ReadSTL<&TStreamerInfoActions::ReadSTLMemberWiseSameClass, &TStreamerInfoActions::ReadSTLObjectWiseFastArray>(TBuffer&, void*, TStreamerInfoActions::TConfiguration const*) () from /home/user/root/lib/libRIO.so
#16 0x00526bc9 in TBufferFile::ApplySequence(TStreamerInfoActions::TActionSequence const&, void*) () from /home/user/root/lib/libRIO.so
#17 0x07467204 in ?? ()
[/code]
I have tried everything to make it work but run constantly into segmentation fault at the GetEntry line. Can anyone see what I doing wrong or if I am missing something? Grateful for any help…Thanks.
Donya.