#include "FastMC.h"
#include "TCollection.h"
#include "TObjArray.h"
#include "Event.h"
#include <stdio.h>
#include "GetParameters.h"
//______________________________________________________________________
//
// FastMC
//
// Manager class for Fast MC. Creates instances of specific
// modules (processors) at constructor time. Then may fetch
// events one at a time from event source and invoke the modules
ClassImp(FastMC)
FastMC::FastMC(EventSource* eventSource,
char* parameterFileName,
char* outputFileName
) {
// Constructor for FastMC. Modules can use parameterFile
// to set up and will write to outputFile (if non-null outputFileName
// has been supplied.)
// If running interactively in Root, may not have an output file
// so do something sensible whether or not there is one.
m_ofile = 0;
if (outputFileName) m_ofile = fopen(outputFileName,"w");
m_parfile = fopen(parameterFileName,"r");
GetParameters* gp = new GetParameters(m_parfile);
// create list of modules to run
// add modules to list. They inherit from RecModule and must have
// doit, cleanup and spew functions defined.
m_eventMarker = new EventMarker(0,0);
m_ModuleList.Add(m_eventMarker);
m_mcPartPrint = new MCPartPrint();
m_ModuleList.Add(m_mcPartPrint);
m_trackFullSmear = new TrackFullSmear(gp);
m_ModuleList.Add(m_trackFullSmear);
m_calRecon = new CalRecon(*(gp->getDetectorName()));
m_ModuleList.Add(m_calRecon);
m_iter = new TObjArrayIter(&m_ModuleList);
m_source = eventSource;
};
FastMC::~FastMC() {
// Destructor (but there is almost nothing to do)
int parfileStatus = fclose(m_parfile);
int ofileStatus;
if (m_ofile) ofileStatus = fclose(m_ofile);
};
Int_t FastMC::DoEventBatch() {
// Full batch-like processing for a single event.
Event* event = 0;
// translate to Root event format
event = new Event();
int ierr = m_source->getEvent(event);
if (!ierr) return ierr;
Cleanup(); // All modules get ready
Doit(event); // All modules process
Spew(); // All modules output
// clean up event
event->Clear();
delete event;
event = 0;
return 1;
}
Int_t FastMC::FetchEvent(Event *evt) {
// Get single event from source
return m_source->getEvent(evt);
}
void FastMC::Doit(Event *event) {
// Invoke each module to process event
m_iter->Reset();
while (m_module = (RecModule*) (*m_iter)()) {
m_module->doit(event);
}
}
void FastMC::Spew() {
// Invoke each module to do its spew (if have an output file to spew to)
if (m_ofile) {
m_iter->Reset();
while (m_module = (RecModule*)(*m_iter)()) {
m_module->spew(m_ofile);
}
}
}
void FastMC::Cleanup() {
// Invoke each module's cleanup method
m_iter->Reset();
while (m_module = (RecModule*) (*m_iter)()) {
m_module->cleanup();
}
}
ROOT page - Class index - Top of the page
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.