#include "hrunanalizer.h"
#include "hevent.h"
#include "heventheader.h"
#include "hades.h"
#include "hruntimedb.h"
#include <unistd.h>
ClassImp(HRunAnalizer)
HRunAnalizer::HRunAnalizer(Text_t *name,Text_t *title,Text_t *fileName)
: HReconstructor(name,title) {
Char_t defaultFileName[]="run_info.txt";
fEventHeader=0;
fFirstRun=kTRUE;
fTotEvents=0;
fCalEvents=0;
if (!fileName) fileName=defaultFileName;
if (access(fileName,F_OK)==0) {
fOut=fopen(fileName,"a");
} else {
fOut=fopen(fileName,"w");
writeHeader();
}
}
HRunAnalizer::HRunAnalizer(HRunAnalizer &analizer) {
Error("HRunAnalizer","Copy constructor not defined");
}
HRunAnalizer::~HRunAnalizer(void) {
fclose(fOut);
}
Int_t HRunAnalizer::execute(void) {
UInt_t fId=fEventHeader->getId();
if (fId==65538) {
extractStartInfo();
fFirstEvent=kFALSE;
} else {
fRunStopTime=fEventHeader->getTime();
fRunStopDate=fEventHeader->getDate();
if (fId!=65539) fTotEvents++;
if (fId==4) fCalEvents++;
}
return 0;
}
Bool_t HRunAnalizer::init(void) {
fEventHeader=gHades->getCurrentEvent()->getHeader();
fFirstRun=kTRUE;
fTotEvents=0;
fCalEvents=0;
return kTRUE;
}
Bool_t HRunAnalizer::reinit(void) {
if (fFirstRun)
fFirstRun=kFALSE;
else
writeInfo();
fTotEvents=0;
fCalEvents=0;
fFirstEvent=kTRUE;
return kTRUE;
}
Bool_t HRunAnalizer::finalize(void) {
if (!fFirstRun) writeInfo();
return kTRUE;
}
void HRunAnalizer::extractStartInfo(void) {
fRunStartTime=fEventHeader->getTime();
fRunStartDate=fEventHeader->getDate();
fRunId=fEventHeader->getEventRunNumber();
fFileName=gHades->getRuntimeDb()->getCurrentFileName();
}
void HRunAnalizer::writeHeader(void) {
fprintf(fOut,"########################################################\n");
fprintf(fOut,"#Run Id File name Total nr of events Nr of cal events\n");
fprintf(fOut,"# Run Start Run Stop Time\n");
fprintf(fOut,"########################################################\n");
}
void HRunAnalizer::writeInfo(void) {
UInt_t db=fRunStartDate;
UInt_t tb=fRunStartTime;
UInt_t de=fRunStopDate;
UInt_t te=fRunStopTime;
fprintf(fOut,"%u %s %i %i\n",fRunId,fFileName.Data(),fTotEvents,fCalEvents);
fprintf(fOut," %02i-%02i-%4i::%02i:%02i:%02i %02i-%02i-%4i::%02i:%02i:%02i\n",
(db & 0xFF),1+( (db>>8) & 0xFF),1900+((db>>16) & 0xFF),
((tb>>16) & 0xFF),( (tb>>8) & 0xFF),( tb & 0xFF),
(de & 0xFF),1+( (de>>8) & 0xFF),1900+((de>>16) & 0xFF),
((te>>16) & 0xFF),( (te>>8) & 0xFF),( te & 0xFF));
}
Last change: Sat May 22 13:12:24 2010
Last generated: 2010-05-22 13:12
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.