22 #include <Riostream.h>
25 #include <TSystemFile.h>
72 static TFile* nextFile = NULL ;
73 static TNtuple* ntData = NULL ;
74 static Int_t doOnce = 0 ;
75 static Long64_t nextEntry = 0 ;
76 static Long64_t entries = 0 ;
77 static Long64_t fileCounter = 0 ;
83 if ( nextFile == 0 )
return false ;
84 ntData = (TNtuple*) ( nextFile->Get(
"NTtracks") ) ;
85 entries = ntData->GetEntriesFast() ;
86 Int_t columns = ntData->GetNvar() ;
89 cout <<
"Error in reading Ntuple file: no. columns != 15" << endl ;
93 cout <<
"Start New File " << fileCounter << endl ;
98 while ( nextEntry < entries )
100 Float_t* header = NULL;
101 Int_t numberOfParticles = 0 ;
102 Long64_t headerEntry = 0 ;
103 Long64_t skipEvent = 0 ;
109 for ( Long64_t j = nextEntry ; j < entries ; j++ )
111 Long64_t BytesRead = ntData->GetEntry(j) ;
112 if ( BytesRead < 60 )
114 cout <<
"Warning: error in file or EOF " << endl ;
118 header = ntData->GetArgs() ;
119 if ( (
int) header[10] == -1 && (
int) header[11] == -1 && (
int) header[12] == -1 &&
120 (
int) header[13] == -1 && (
int) header[14] == -1 )
124 numberOfParticles = (int) header[9] ;
128 cout <<
"Warning: no header entries found in this file" << endl ;
132 if ( headerEntry == -1 ) break ;
135 for ( Long64_t j = headerEntry + 1 ; j < headerEntry + 1 + numberOfParticles ; j++ )
137 Long64_t BytesRead = ntData->GetEntry(j) ;
138 if ( BytesRead < 60 )
140 cout <<
"Warning: error in file sequence or EOF" << endl ;
144 header = ntData->GetArgs() ;
146 if ( TMath::IsNaN(header[10]) == 1 )
148 cout <<
"IsNan ... dEdx will be zeroed out" << endl ;
154 cout << header[0] <<
" " << header[1] <<
" " << header[2] <<
" " << header[3] <<
" "
155 << header[4] <<
" " << header[5] <<
" " << header[6] <<
" " << header[7] <<
" "
156 << header[8] <<
" " << header[9] <<
" " << header[10] <<
" " << header[11] <<
" "
157 << header[12] <<
" " << header[13] <<
" " << header[14] << endl ;
160 if ( (
int) header[10] == -1 && (
int) header[11] == -1 && (
int) header[12] == -1 &&
161 (
int) header[13] == -1 && (
int) header[14] == -1 )
163 cout <<
"Warning: Header in the wrong place, skipping event" << endl ;
173 if ( nextEntry == -1 ) break ;
174 if ( skipEvent == 1 ) continue ;
179 nextFile = (TFile*)
fFileList->After(nextFile) ;
180 if ( nextFile == 0 ) break ;
181 if (ntData)
delete ntData;
182 ntData = (TNtuple*) ( nextFile->Get(
"NTtracks") ) ;
183 entries = ntData->GetEntriesFast() ;
184 Int_t columns = ntData->GetNvar() ;
187 cout <<
"Error in reading Ntuple file: no. columns != 15" << endl ;
191 cout <<
"Start New File " << fileCounter << endl ;
201 TString inputstring(input);
203 TSystemFile inputfile(inputstring.Data(),
"");
204 if (inputfile.IsDirectory())
215 static Int_t doOnce = 0 ;
217 void* directory =
gSystem->OpenDirectory(inputFileDirectory) ;
218 const char* entry =
gSystem->GetDirEntry(directory) ;
222 cout << endl <<
"Error: \"" << inputFileDirectory <<
"\" does not exist" << endl << endl ;
229 int len = strlen(entry);
230 if( len >= 5 && strcmp( &entry[len - 5],
".root" ) == 0 )
233 fileName = inputFileDirectory ;
234 if( !fileName.EndsWith(
"/") ) fileName +=
"/" ;
236 fFileList->Add ( TFile::Open(fileName) ) ;
239 cout <<
"Add: " << fileName << endl ;
244 entry =
gSystem->GetDirEntry(directory) ;
247 cout <<
"Add: " << Count-1 <<
" more file(s) from this directory for a total of " << Count <<
" files." << endl ;
248 cout <<
"Finished creating file list ... preparing to open first file." << endl << endl ;
258 filein.open(inputFile);
261 printf(
"problem reading the file list \"%s\"\n",inputFile);
265 while (filein.good())
267 printf(
"opening file: ");
268 line.ReadLine(filein);
269 if (line.Length() == 0)
continue;
270 TFile*
file = TFile::Open(line.Data());
273 printf(
"problem opening file \"%s\"\n",line.Data());
277 printf(
"%s\n",line.Data());
279 if (
fFileList->GetEntries()>0)
return kTRUE;
virtual Bool_t MakeFileListFromFile(const char *inputFileName)
ClassImp(AliStarEventReader) AliStarEventReader
virtual ~AliStarEventReader()
void SetParams(const Float_t *params)
virtual Bool_t MakeFileList(const char *inputFileDirectory)
void AddTrack(AliStarTrack *track)
virtual Bool_t GetNextEvent()
virtual Bool_t MakeFileListFromDir(const char *inputFileDirectory)