11 #include "StMuException.hh"
12 #include "StMuDebug.h"
13 #include "StMuDbReader.h"
47 StMuDbReader::~StMuDbReader() {
60 ifstream in(fileName);
62 DEBUGMESSAGE2(
"can not open file");
63 DEBUGVALUE2(fileName);
69 int iret = sscanf(line,
"%s%i",name, &numberOfEvents);
71 pair<string,int> aPair(name,numberOfEvents);
72 mDb.push_back( aPair );
85 for (iter=
mDb.begin(); iter!=
mDb.end(); iter++) {
86 cout << (*iter).first.c_str() << endl;
95 list< pair<string,int> > tmpList;
96 list< pair<string,int> >::iterator tmpIter;
97 for (iter=
mDb.begin(); iter!=
mDb.end(); iter++) {
98 tmpList.push_back( *iter );
103 for (tmpIter=tmpList.begin(); tmpIter!=tmpList.end(); tmpIter++) {
104 mDb.push_back( *tmpIter );
113 string fileName(file);
121 pos = (int) (lo+hi)/2;
123 if (oldPos==pos)
break;
124 if (fileName >
mDb[pos].first) lo=pos;
125 if (fileName <
mDb[pos].first) hi=pos;
126 if (fileName ==
mDb[pos].first) {
127 entries =
mDb[pos].second;
147 ofstream dbFile(dbName, ios::app);
151 ifstream in(inputList);
152 if (!in || !dbFile) {
153 DEBUGVALUE2(
"could not open file");
162 in.getline(line,255);
163 int iret = sscanf(line,
"%s",fileName);
166 cout << fileName <<
" ";
170 TTree *tree =
dynamic_cast<TTree*
>(f1.Get(
"MuDst"));
172 Stat_t nentries = tree->GetEntries();
173 dbFile << fileName <<
" " << nentries << endl;
174 cout <<
" added with " << nentries <<
" entries " << endl;
179 cout <<
" already in data base " << endl;
int addDb(const char *dbFile)
add entries in dbFile to internal data base ( mDb ), will call sortDb(), returns number of entries in...
int entries(const char *file)
scan internal data base for file, if found return number of entries, otherwise return 0; ...
StMuDbReader()
Attention: constructor not public, this is a singleton.
void showDb()
show all entries in internal data base
void sortDb()
sort all entries in internal data base according to file name
vector< pair< string, int > > mDb
the internal database, a vector containing pairs of file names and number of events */ ...
int createDB(const char *dbFile, const char *inputList)
scan the files in inputList for the number of events add add them to the dbFile file. Create dbFile file if not existent returns number of entries in mDb