#include "hgeantsource.h"
#include "TROOT.h"
#include "hgeantreader.h"
#include "hrecevent.h"
#include "hpartialevent.h"
#include "hcategory.h"
HGeantSource::HGeantSource(void) {
}
HGeantSource::HGeantSource(HGeantSource &s) {
fReaderList.Delete();
fReaderList.AddAll(&s.fReaderList);
fFileTable.Delete();
fFileTable.AddAll(&s.fFileTable);
}
HGeantSource::~HGeantSource(void) {
fReaderList.Delete();
}
Bool_t HGeantSource::addGeantReader(HGeantReader *r,const Text_t *inputFile) {
TFile *f=(TFile *)fFileTable.FindObject(inputFile);
if (f==NULL) {
f=new TFile(inputFile);
if (f==NULL) Error("HGeantSource::addGeantReader","Specified file doesn't exist");
fFileTable.Add(f);
gROOT->cd();
}
r->setInput(f);
fReaderList.Add(r);
return kTRUE;
}
Bool_t HGeantSource::init(void) {
TIter next(&fReaderList);
HGeantReader *fReader;
if (!(*fEventAddr)) {
(*fEventAddr) = new HRecEvent;
}
HRecEvent* fEv = (HRecEvent*)(*fEventAddr);
HPartialEvent* fSimul = fEv->getPartialEvent(catSimul);
if(fSimul == NULL) {
fEv->addPartialEvent(catSimul,"Simul","Simulated event");
fSimul = fEv->getPartialEvent(catSimul);
}
while ( (fReader=(HGeantReader*)next())!=NULL) {
if (!fReader->init()) return kFALSE;
}
fSimul = ((HRecEvent*)(*fEventAddr))->getPartialEvent(catSimul);
TObjArray* fCategories = fSimul->getCategories();
Int_t nCategories = fCategories->GetEntriesFast();
for (Int_t i=0; i<nCategories; i++) {
HCategory* cat = (HCategory*)(fCategories->At(i));
if(cat) {
if(cat->getCategory() != catGeantKine) cat->setPersistency(kFALSE);
}
}
return kTRUE;
}
Bool_t HGeantSource::finalize(void) {
TIterator *iter=0;
HGeantReader *reader=0;
iter=fReaderList.MakeIterator();
while ( (reader=(HGeantReader *)iter->Next()) != 0 ) {
if (!reader->finalize()) return kFALSE;
}
return kTRUE;
}
EDsState HGeantSource::getNextEvent(void) {
TIter next(&fReaderList);
HGeantReader *reader;
Int_t returnCode;
while ( (reader=(HGeantReader *)next())!=NULL) {
returnCode = reader->execute();
if(returnCode != kTRUE) return kDsEndData;
}
return kDsOk;
}
ClassImp(HGeantSource)
Last change: Sat May 22 12:56:07 2010
Last generated: 2010-05-22 12:56
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.