15 IO::
IO(const
char* dir, const
char* match, const
char* ext)
16 : mNFile(0), mDir(dir), mMatch(match), mExt(ext) {
22 void IO::chain(TChain* chain)
25 void *pDir = gSystem->OpenDirectory(mDir.Data());
27 std::cerr <<
"##Cannot open directory " << mDir.Data() << endl;
28 std::cerr <<
"##Goodbye" << endl;
32 cout <<
"\tUsing directory : " << mDir.Data() << endl;
33 cout <<
"\tMatch string : " << mMatch.Data() << endl;
34 cout <<
"\tMatch extension : " << mExt.Data() << endl;
35 if(mNFile) cout <<
"\tMaximum # files : " << mNFile << endl;
41 const char* fileName(0);
44 while((fileName = gSystem->GetDirEntry(pDir))){
45 if(strcmp(fileName,
".")==0 || strcmp(fileName,
"..")==0)
continue;
47 if(strstr(fileName,mExt.Data()) && strstr(fileName,mMatch.Data())){
48 char* fullFile = gSystem->ConcatFileName(mDir.Data(),fileName);
64 TFile *f1 =
new TFile(fullFile);
65 TTree *tree = (TTree*)f1->Get(
"StHiMicroTree");
66 if (tree) events = (int)tree->GetEntries();
71 chain->Add(fullFile,events);
72 if (count%100==0) cout <<
"File # " << count << endl <<
"\tAdding " <<
73 fullFile <<
" with " << events <<
" events to the chain" << endl;
77 if(mNFile && count > mNFile)
break;
81 cout <<
"Added " << count <<
" files to the chain" << endl;
85 void IO::createDb(
const char *dbName)
89 ofstream dbFile(dbName, std::ios::app);
91 void *pDir = gSystem->OpenDirectory(mDir.Data());
93 std::cerr <<
"##Cannot open directory " << mDir.Data() << endl;
94 std::cerr <<
"##Goodbye" << endl;
98 cout <<
"\tUsing directory : " << mDir.Data() << endl;
99 cout <<
"\tMatch string : " << mMatch.Data() << endl;
100 cout <<
"\tMatch extension : " << mExt.Data() << endl;
105 const char* fileName(0);
108 while((fileName = gSystem->GetDirEntry(pDir))){
109 if(strcmp(fileName,
".")==0 || strcmp(fileName,
"..")==0)
continue;
111 if(strstr(fileName,mExt.Data()) && strstr(fileName,mMatch.Data())){
112 char* fullFile = gSystem->ConcatFileName(mDir.Data(),fileName);
118 TFile *f1 =
new TFile(fullFile);
119 TTree *tree = (TTree*)f1->Get(
"StHiMicroTree");
120 if (tree) events = (int)tree->GetEntries();
124 dbFile << fullFile <<
" " << events << endl;
125 cout <<
"\tAdding " << fullFile <<
" with " << events <<
" events to the Database" << endl;