63 #include "Stl3CounterMaker.h"
64 #include "St_DataSetIter.h"
65 #include "StMessMgr.h"
66 #include "StIOMaker/StIOMaker.h"
67 #include "StDAQMaker/StDAQReader.h"
68 #include "StDaqLib/L3/L3_Reader.hh"
69 #include "tables/St_l3RunSummary_Table.h"
70 #include "tables/St_l3AlgorithmInfo_Table.h"
71 #include "tables/St_l3AlgorithmCount_Table.h"
72 #include "tables/St_l3GlobalCounter_Table.h"
84 Stl3CounterMaker::~Stl3CounterMaker(){
89 Int_t Stl3CounterMaker::Init(){
97 mStoreDbTables = kTRUE;
103 if(!IOMaker) IOMaker = (
StIOMaker*)GetMaker(
"inputStream");
105 IOMaker->SetNotify(
"OpenFile",
this);
106 IOMaker->SetNotify(
"CloseFile",
this);
109 cout <<
"Stl3CounterMaker::Init(): Could not SetNotify for IOMaker." << endl;
116 mAlgorithmCounterTable =
new St_l3AlgorithmCount(
"l3AlgorithmCount", 1);
117 mGlobalCounterTable =
new St_l3GlobalCounter(
"l3GlobalCounter", 1);
120 l3GlobalCounter_st totalCounterRow;
121 totalCounterRow.runNumber = 0;
122 totalCounterRow.fileNumber = 0;
123 totalCounterRow.nProcessed = 0;
124 totalCounterRow.nReconstructed = 0;
125 mGlobalCounterTable->AddAt(&totalCounterRow);
127 for (
int i=0; i<MaxNumberOfAlgorithms; i++) {
128 l3AlgorithmCount_st totalAlgCounterRow;
129 totalAlgCounterRow.runNumber = 0;
130 totalAlgCounterRow.algId = 0;
131 totalAlgCounterRow.fileNumber = 0;
132 totalAlgCounterRow.nProcessed = 0;
133 totalAlgCounterRow.nAccept = 0;
134 totalAlgCounterRow.nBuild = 0;
135 mAlgorithmCounterTable->AddAt(&totalAlgCounterRow);
138 mNumberOfGl3Nodes = 0;
139 mNumberOfAlgorithms = 0;
143 for (
int i=0; i<MaxNumberOfGl3Nodes; i++) {
144 mGlobalCounter[i].nProcessed = 0;
145 mGlobalCounter[i].nReconstructed = 0;
146 for (
int j=0; j<MaxNumberOfAlgorithms; j++) {
147 mAlgorithmCounter[i][j].algId = 0;
148 mAlgorithmCounter[i][j].nProcessed = 0;
149 mAlgorithmCounter[i][j].nAccept = 0;
150 mAlgorithmCounter[i][j].nBuild = 0;
155 return StMaker::Init();
160 void Stl3CounterMaker::NotifyMe(
const char *about,
const void *info)
165 if (strcmp(
"CloseFile", about)==0) {
166 if (!mStoreDbTables)
return;
169 if (strcmp(
"OpenFile", about)==0) {
170 mDaqFileName =((
char*)info);
177 Int_t Stl3CounterMaker::InitTable()
182 TString seq(mDaqFileName(mDaqFileName.Index(
"_physics_"), 30));
183 if (seq.Contains(
".daq")) {
184 TString fileNo = seq(21,4);
185 TString rowNo = seq(9,7);
186 mDaqFileSequenceNumber = atoi(fileNo.Data());
187 mRunNumber = atoi(rowNo.Data());
190 mDaqFileSequenceNumber = 999;
191 mRunNumber = 9999999;
192 cout <<
"Stl3CounterMaker::InitTable(): Could not extract daq file run/sequence number." << endl;
194 if (Debug()) cout <<
"run number: " << mRunNumber <<
", sequence number: " << mDaqFileSequenceNumber << endl;
198 l3GlobalCounter_st* totalCounter = (l3GlobalCounter_st*) mGlobalCounterTable->GetTable();
199 mAlgorithmCounterTable->SetNRows(MaxNumberOfAlgorithms);
200 l3AlgorithmCount_st* totalAlgCounter = (l3AlgorithmCount_st*) mAlgorithmCounterTable->GetTable();
202 totalCounter->runNumber = mRunNumber;
203 totalCounter->fileNumber = mDaqFileSequenceNumber;
204 totalCounter->nProcessed = 0;
205 totalCounter->nReconstructed = 0;
207 for (
int i=0; i<MaxNumberOfAlgorithms; i++) {
208 totalAlgCounter[i].runNumber = mRunNumber;
209 totalAlgCounter[i].fileNumber = mDaqFileSequenceNumber;
210 totalAlgCounter[i].algId = 0;
211 totalAlgCounter[i].nProcessed = 0;
212 totalAlgCounter[i].nAccept = 0;
213 totalAlgCounter[i].nBuild = 0;
217 for (
int i=0; i<MaxNumberOfGl3Nodes; i++) {
218 mGlobalCounter[i].nProcessed = 0;
219 mGlobalCounter[i].nReconstructed = 0;
220 for (
int j=0; j<MaxNumberOfAlgorithms; j++) {
221 mAlgorithmCounter[i][j].algId = 0;
222 mAlgorithmCounter[i][j].nProcessed = 0;
223 mAlgorithmCounter[i][j].nAccept = 0;
224 mAlgorithmCounter[i][j].nBuild = 0;
238 cout <<
"Now we start l3Counter Maker. \n" ;
243 DAQReaderSet = GetDataSet(
"StDAQReader");
245 gMessMgr->Error() <<
"Stl3CounterMaker::Make(): no DaqReader found!" << endm;
250 ml3reader = daqReader->getL3Reader();
259 if (ml3reader->getGlobalTrackReader())
260 cout << ml3reader->getGlobalTrackReader()->getNumberOfTracks()
261 <<
" global tracks found.\n";
265 gMessMgr->Error(
"Stl3CounterMaker: problems getting l3 counters.");
275 cout <<
"ERROR: L3 is ON, but no l3 data found in this event." << endl;
282 cout <<
"WARNING: no l3 data found." << endl;
297 Int_t Stl3CounterMaker::GetCounters()
303 cout <<
"ERROR: L3 is ON, but L3 summary data is missing!" << endl;
310 if (ml3reader->getL3_Summary()->on == 0) {
311 cout <<
"Warning: L3 crashed online on this event, no usefull information."
317 mDbSet = GetDataBase(
"RunLog/l3");
323 if (l3runSummaryTable) {
324 l3RunSummary_st*
data = (l3RunSummary_st* )l3runSummaryTable->GetArray();
325 mNumberOfGl3Nodes = data->nGl3Nodes;
327 cout <<
"database: runNumber = " << data->runNumber << endl;
328 cout <<
"database: nGl3Nodes = " << data->nGl3Nodes << endl;
331 if (mNumberOfGl3Nodes>MaxNumberOfGl3Nodes) {
332 cout <<
" ERROR: number of gl3 nodes too high: db -> " << mNumberOfGl3Nodes
333 <<
" max -> " << MaxNumberOfGl3Nodes << endl;
338 mNumberOfGl3Nodes = MaxNumberOfGl3Nodes;
339 cout <<
" no table entry for this run in 'l3RunSummary' found!" << endl;
340 cout <<
" using default values." << endl;
344 mNumberOfGl3Nodes = MaxNumberOfGl3Nodes;
345 cout <<
" no database 'Runlog/l3' found!" << endl;
346 cout <<
" using default values." << endl;
350 int gl3Id = ml3reader->getGl3Id();
353 mNumberOfAlgorithms = gl3Reader->getNumberofAlgorithms();
356 if (mNumberOfAlgorithms >= MaxNumberOfAlgorithms) {
357 cout <<
"ERROR: number of algorithms exceeds limit: found "
358 << mNumberOfAlgorithms <<
", limit " << MaxNumberOfAlgorithms
362 if (gl3Id<=0 || gl3Id>= MaxNumberOfGl3Nodes) {
363 cout <<
"ERROR: gl3 id exceeds limit: found "
364 << gl3Id <<
", limit " << MaxNumberOfGl3Nodes
379 mGlobalCounter[gl3Id-1].nProcessed = gl3Reader->getNumberOfProcessedEvents();
380 mGlobalCounter[gl3Id-1].nReconstructed = gl3Reader->getNumberOfReconstructedEvents();
383 for (
int i=0; i<mNumberOfAlgorithms; i++) {
384 mAlgorithmCounter[gl3Id-1][i].algId = algData[i].algId;
385 mAlgorithmCounter[gl3Id-1][i].nProcessed = algData[i].nProcessed;
386 mAlgorithmCounter[gl3Id-1][i].nAccept = algData[i].nAccept;
387 mAlgorithmCounter[gl3Id-1][i].nBuild = algData[i].nBuild;
392 l3GlobalCounter_st* totalCounter = (l3GlobalCounter_st*) mGlobalCounterTable->GetTable();
393 mAlgorithmCounterTable->SetNRows(mNumberOfAlgorithms);
394 l3AlgorithmCount_st* totalAlgCounter = (l3AlgorithmCount_st*) mAlgorithmCounterTable->GetTable();
396 totalCounter->nProcessed = 0;
397 totalCounter->nReconstructed = 0;
399 for (
int i=0; i<mNumberOfAlgorithms; i++) {
400 totalAlgCounter[i].algId = 0;
401 totalAlgCounter[i].nProcessed = 0;
402 totalAlgCounter[i].nAccept = 0;
403 totalAlgCounter[i].nBuild = 0;
407 for (
int i=0; i<mNumberOfGl3Nodes; i++) {
410 if (mGlobalCounter[i].nProcessed==0 && mEventCounter<(2*mNumberOfGl3Nodes)) {
411 totalCounter->nProcessed = -1;
412 totalCounter->nReconstructed = -1;
413 for (
int j=0; j<mNumberOfAlgorithms; j++) {
414 totalAlgCounter[j].algId = mAlgorithmCounter[gl3Id-1][j].algId;
415 totalAlgCounter[j].nProcessed = -1;
416 totalAlgCounter[j].nAccept = -1;
417 totalAlgCounter[j].nBuild = -1;
423 totalCounter->nProcessed += mGlobalCounter[i].nProcessed;
424 totalCounter->nReconstructed += mGlobalCounter[i].nReconstructed;
425 for (
int k=0; k<mNumberOfAlgorithms; k++) {
426 totalAlgCounter[k].algId = mAlgorithmCounter[gl3Id-1][k].algId;
427 totalAlgCounter[k].nProcessed += mAlgorithmCounter[i][k].nProcessed;
428 totalAlgCounter[k].nAccept += mAlgorithmCounter[i][k].nAccept;
429 totalAlgCounter[k].nBuild += mAlgorithmCounter[i][k].nBuild;
435 cout <<
" Global counters: nProcessed = " << totalCounter->nProcessed
436 <<
", nReconstructed = " << totalCounter->nReconstructed << endl;
437 cout <<
" algId\tnProcessed\tnAccept\tnBuild" << endl;
438 for (
int k=0; k<mNumberOfAlgorithms; k++) {
439 cout << totalAlgCounter[k].algId <<
"\t"
440 << totalAlgCounter[k].nProcessed <<
"\t"
441 << totalAlgCounter[k].nAccept <<
"\t"
442 << totalAlgCounter[k].nBuild << endl;
444 cout <<
" ------------------------------------ " << endl;
458 if (!mStoreDbTables)
return 0;
466 Int_t Stl3CounterMaker::WriteTable()
473 sprintf(filename,
"./StarDb/RunLog_l3/l3counters_glob.%08d.%06d.C",GetDate(),GetTime());
474 TString dirname = gSystem->DirName(filename);
476 if (Debug()) cout <<
"Stl3CounterMaker::WriteTable(): output dir: " << dirname.Data() << endl;
478 if (gSystem->OpenDirectory(dirname.Data())==0) {
479 if (gSystem->mkdir(dirname.Data())) {
480 cout <<
"Stl3CounterMaker::WriteTable(): Directory " << dirname <<
" creation failed" << endl;
481 cout <<
"Stl3CounterMaker::WriteTable(): Putting l3counters_glob.C in current directory" << endl;
482 for (
int i=0;i<80;i++) filename[i]=0;
483 sprintf(filename,
"l3counters_glob.%08d.%06d.C",GetDate(),GetTime());
486 ofstream *out =
new ofstream(filename);
487 mGlobalCounterTable->SavePrimitive(*out,
"");
491 sprintf(filename,
"./StarDb/RunLog_l3/l3counters_algo.%08d.%06d.C",GetDate(),GetTime());
492 dirname = gSystem->DirName(filename);
494 if (Debug()) cout <<
"Stl3CounterMaker::WriteTable(): output dir: " << dirname.Data() << endl;
496 if (gSystem->OpenDirectory(dirname.Data())==0) {
497 if (gSystem->mkdir(dirname.Data())) {
498 cout <<
"Stl3CounterMaker::WriteTable(): Directory " << dirname <<
" creation failed" << endl;
499 cout <<
"Stl3CounterMaker::WriteTable(): Putting l3counters_algo.C in current directory" << endl;
500 for (
int i=0;i<80;i++) filename[i]=0;
501 sprintf(filename,
"l3counters_algo.%08d.%06d.C",GetDate(),GetTime());
504 out =
new ofstream(filename);
505 mAlgorithmCounterTable->SavePrimitive(*out,
"");
virtual TObject * GetObject() const
The depricated method (left here for the sake of the backward compatibility)
virtual TDataSet * Find(const char *path) const