#include <BaseModule.h>
Public Member Functions | |
BaseModule (const char *module_name, modules::options *opts=NULL, bool with_directory=true) | |
Constructor of a module class. Provides several virtual methods that should be overloaded in the derived class. Derived classes should hard-code their name as the first argument to the constructor. | |
virtual | ~BaseModule () |
int | ProcessGenericEntry (TGlobalData *gData, const TSetupData *gSetup) |
int | Preprocess (TGlobalData *gData, const TSetupData *gSetup) |
Method called by the main pre-process loop. | |
int | Postprocess (TGlobalData *gData, const TSetupData *gSetup) |
Method called by the main pre-process loop. | |
virtual int | BeforeFirstEntry (TGlobalData *gData, const TSetupData *setup)=0 |
virtual int | AfterLastEntry (TGlobalData *gData, const TSetupData *setup)=0 |
void | SetAlias (const std::string &alias) |
std::string | GetAlias () const |
const char * | GetName () const |
Get the name of this module as given to the constructor of the base class. | |
Protected Member Functions | |
bool | Debug () const |
TDirectory * | GetDirectory () const |
Get the TDirectory for this module. | |
TDirectory * | GetDirectory (const std::string &name="") |
Protected Attributes | |
TDirectory * | dir |
Private Member Functions | |
virtual int | ProcessEntry (TGlobalData *gData, const TSetupData *gSetup)=0 |
The big kahuna. Overload this in the derived class and it will be called for each event. | |
Private Attributes | |
TSetupData * | fSetup |
bool | fDebug |
std::string | fName |
TDirectory * | fDirectory |
std::string | fAlias |
Base class for a generic analysis module. Provides several virtual methods for the derived class to overload. Also sets up a directory where all histograms and other ROOT objects created by the module will be saved in the output root file.
Definition at line 16 of file BaseModule.h.
BaseModule::BaseModule | ( | const char * | module_name, | |
modules::options * | opts = NULL , |
|||
bool | with_directory = true | |||
) |
Constructor of a module class. Provides several virtual methods that should be overloaded in the derived class. Derived classes should hard-code their name as the first argument to the constructor.
module_name | The name of the module | |
opts | Options given to the module from the modules file | |
setup | [To be removed soon] |
Many modules use 'dir' still which was the old protected pointer to the modules directory. To prevent things being broken so soon, we keep this pointer available, but be warned that it will be removed shortly...
Definition at line 7 of file BaseModule.cpp.
References dir, fDebug, fDirectory, fName, GetAlias(), modules::options::GetAlias(), modules::options::GetBool(), modules::options::GetOption(), modules::options::HasOption(), modules::navigator::Instance(), SetAlias(), and modules::options::StringDescription().
00007 : 00008 fSetup(TSetupData::Instance()),fDebug(false),fName(name),fDirectory(NULL){ 00009 // Pass common options 00010 if(opts){ 00011 fDebug=(opts->HasOption("debug") && (opts->GetOption("debug").empty() || opts->GetBool("debug"))); 00012 SetAlias(opts->GetAlias()); 00013 } 00014 // Make a directory for this module if desired 00015 if(with_directory){ 00016 // check if one exists 00017 fDirectory=gDirectory->GetDirectory(fName.c_str()); 00018 // if not create one 00019 if(!fDirectory) fDirectory=gDirectory->mkdir(fName.c_str()); 00020 // now make check if there's more than one instance of this module 00021 if(modules::navigator::Instance()->HowMany(fName)>1) { 00022 // and if there is, make a subdirectory and change into it 00023 fDirectory=fDirectory->mkdir(GetAlias().c_str()); 00024 } 00025 fDirectory->SetTitle(opts->StringDescription().c_str()); 00026 fDirectory->cd(); 00027 // write the config into the file as a string 00028 TObjString *title=new TObjString(opts->StringDescription().c_str()); 00029 title->Write(); 00030 } else { 00031 // Set this module to use the top-level directory of the file 00032 fDirectory=gDirectory->GetDirectory("/"); 00033 } 00037 dir=fDirectory; 00038 }
BaseModule::~BaseModule | ( | ) | [virtual] |
Definition at line 40 of file BaseModule.cpp.
virtual int BaseModule::AfterLastEntry | ( | TGlobalData * | gData, | |
const TSetupData * | setup | |||
) | [pure virtual] |
Optional method which is called once after the main event loop Can be used to dump a summary or finalise a histogram
Implemented in TME_Al50_EvdE, TME_SiArmTDiff, TMEViewer, IslandAmplitude, IslandLength, FastSlowCompare, GeSpectrum, LoadPulses, PlotIntegralRatios, CalcCoarseTimeOffset, CheckTMEs, ExportPulse, PlotAmpVsMuScTDiff, PlotAmpVsTDiff, PlotTAP_Amplitude, PlotTAP_Energy, PlotTAP_Integral, PlotTAP_selfCorrelation, PlotTAP_TDiff, PlotTAP_Time, PlotTDP_TDiff, PlotTDPs, PlotTME_activeSiRmuStops, PlotTPI_PedestalAndNoise, PulseViewer, SavePulses, MakeAnalysedPulses, PulseCandidateFinder_InvestigateParameters, TemplateCreator, MakeDetectorPulses, MakeMuonEvents, and MakeSiliconEvents.
Referenced by Postprocess().
virtual int BaseModule::BeforeFirstEntry | ( | TGlobalData * | gData, | |
const TSetupData * | setup | |||
) | [pure virtual] |
Optional method which is called once before the main event loop Can be used to parse options and setup histograms.
Implemented in TME_Al50_EvdE, TME_SiArmTDiff, TMEViewer, IslandAmplitude, IslandLength, FastSlowCompare, GeSpectrum, LoadPulses, PlotIntegralRatios, CalcCoarseTimeOffset, CheckTMEs, ExportPulse, PlotAmpVsMuScTDiff, PlotAmpVsTDiff, PlotTAP_Amplitude, PlotTAP_Energy, PlotTAP_Integral, PlotTAP_selfCorrelation, PlotTAP_TDiff, PlotTAP_Time, PlotTDP_TDiff, PlotTDPs, PlotTME_activeSiRmuStops, PlotTPI_PedestalAndNoise, PulseViewer, SavePulses, MakeAnalysedPulses, PulseCandidateFinder_InvestigateParameters, TemplateCreator, MakeDetectorPulses, MakeMuonEvents, and MakeSiliconEvents.
Referenced by Preprocess().
bool BaseModule::Debug | ( | ) | const [inline, protected] |
Check whether this module was asked to print extra debug information
Definition at line 71 of file BaseModule.h.
References fDebug.
Referenced by MakeAnalysedPulses::AddGenerator(), ExportPulse::AddToExportList(), PulseCandidateFinder_InvestigateParameters::AfterLastEntry(), PlotTPI_PedestalAndNoise::AfterLastEntry(), PlotTDPs::AfterLastEntry(), PlotTDP_TDiff::AfterLastEntry(), IslandLength::AfterLastEntry(), IslandAmplitude::AfterLastEntry(), MakeDetectorPulses::BeforeFirstEntry(), TemplateCreator::BeforeFirstEntry(), PulseCandidateFinder_InvestigateParameters::BeforeFirstEntry(), PlotTPI_PedestalAndNoise::BeforeFirstEntry(), PlotTDPs::BeforeFirstEntry(), PlotTDP_TDiff::BeforeFirstEntry(), IslandLength::BeforeFirstEntry(), IslandAmplitude::BeforeFirstEntry(), PulseViewer::ConsiderDrawing(), MakeAnalysedPulses::MakeAnalysedPulses(), MakeDetectorPulses::MakeGenerator(), ExportPulse::PlotTPI(), MakeDetectorPulses::ProcessEntry(), TemplateCreator::ProcessEntry(), PulseCandidateFinder_InvestigateParameters::ProcessEntry(), MakeAnalysedPulses::ProcessEntry(), PulseViewer::ProcessEntry(), PlotTDP_TDiff::ProcessEntry(), and TemplateCreator::StartTemplate().
00071 {return fDebug;};
std::string BaseModule::GetAlias | ( | ) | const [inline] |
Returns a string for the alias of this module. May be empty if no alias was given in the modules file.
Definition at line 63 of file BaseModule.h.
References fAlias.
Referenced by BaseModule().
00063 {return fAlias;};
TDirectory * BaseModule::GetDirectory | ( | const std::string & | name = "" |
) | [protected] |
Definition at line 77 of file BaseModule.cpp.
References dir, and fDirectory.
00077 { 00078 if(name.empty()) return fDirectory; 00079 TDirectory* dir=fDirectory->GetDirectory(name.c_str()); 00080 if(dir) return dir; 00081 return fDirectory->mkdir(name.c_str()); 00082 }
TDirectory* BaseModule::GetDirectory | ( | ) | const [inline, protected] |
Get the TDirectory for this module.
Definition at line 74 of file BaseModule.h.
References fDirectory.
Referenced by TemplateCreator::AfterLastEntry(), SavePulses::AfterLastEntry(), TemplateCreator::BeforeFirstEntry(), PlotTDPs::BeforeFirstEntry(), ExportPulse::ExportPulse(), and TemplateCreator::ProcessEntry().
00074 {return fDirectory;}
const char* BaseModule::GetName | ( | ) | const [inline] |
Get the name of this module as given to the constructor of the base class.
Definition at line 66 of file BaseModule.h.
References fName.
Referenced by SavePulses::BeforeFirstEntry(), PlotTDPs::BeforeFirstEntry(), PlotTDP_TDiff::BeforeFirstEntry(), PlotTAP_Time::ProcessEntry(), PlotTAP_Energy::ProcessEntry(), PlotTAP_Amplitude::ProcessEntry(), and LoopSequence::Run().
00066 {return fName.c_str();};
int BaseModule::Postprocess | ( | TGlobalData * | gData, | |
const TSetupData * | gSetup | |||
) |
Method called by the main pre-process loop.
Does some simple work, then hooks into the derived class through AfterLastEntry.
Definition at line 66 of file BaseModule.cpp.
References AfterLastEntry(), and fDirectory.
Referenced by LoopSequence::Postprocess().
00066 { 00067 // This is called by our main routine and would allow later to split into different 00068 // process routines if we have more than one Tree and hence different tpyes of data input. 00069 00070 if(fDirectory) fDirectory->cd(); 00071 int ret = AfterLastEntry(gData, gSetup); 00072 gDirectory->cd("/"); 00073 00074 return ret; 00075 }
int BaseModule::Preprocess | ( | TGlobalData * | gData, | |
const TSetupData * | gSetup | |||
) |
Method called by the main pre-process loop.
Does some simple work, then hooks into the derived class through BeforeFirstEntry.
Definition at line 55 of file BaseModule.cpp.
References BeforeFirstEntry(), and fDirectory.
Referenced by LoopSequence::Preprocess().
00055 { 00056 // This is called by our main routine and would allow later to split into different 00057 // process routines if we have more than one Tree and hence different tpyes of data input. 00058 00059 if(fDirectory) fDirectory->cd(); 00060 int ret = BeforeFirstEntry(gData, gSetup); 00061 gDirectory->cd("/"); 00062 00063 return ret; 00064 }
virtual int BaseModule::ProcessEntry | ( | TGlobalData * | gData, | |
const TSetupData * | gSetup | |||
) | [private, pure virtual] |
The big kahuna. Overload this in the derived class and it will be called for each event.
gData | Pointer to current map of all TPIs [ WILL CHANGE SHORTLY ] | |
gSetup | Pointer to TSetupData for this run [ WILL CHANGE SHORTLY ] |
Implemented in TME_Al50_EvdE, TME_SiArmTDiff, TMEViewer, IslandAmplitude, IslandLength, FastSlowCompare, GeSpectrum, LoadPulses, PlotIntegralRatios, CalcCoarseTimeOffset, CheckTMEs, ExportPulse, PlotAmpVsMuScTDiff, PlotAmpVsTDiff, PlotTAP_Amplitude, PlotTAP_Energy, PlotTAP_Integral, PlotTAP_selfCorrelation, PlotTAP_TDiff, PlotTAP_Time, PlotTDP_TDiff, PlotTDPs, PlotTME_activeSiRmuStops, PlotTPI_PedestalAndNoise, PulseViewer, SavePulses, MakeTemplate, MakeAnalysedPulses, PulseCandidateFinder_InvestigateParameters, TemplateCreator, MakeDetectorPulses, MakeMuonEvents, and MakeSiliconEvents.
Referenced by ProcessGenericEntry().
int BaseModule::ProcessGenericEntry | ( | TGlobalData * | gData, | |
const TSetupData * | gSetup | |||
) |
Method called by the main event loop for each entry in the input root tree. Does some simple work, then hooks into the derived class through ProcessEntry.
Definition at line 44 of file BaseModule.cpp.
References fDirectory, and ProcessEntry().
Referenced by LoopSequence::Process().
00044 { 00045 // This is called by our main routine and would allow later to split into different 00046 // process routines if we have more than one Tree and hence different tpyes of data input. 00047 00048 if(fDirectory) fDirectory->cd(); 00049 int ret = ProcessEntry(gData, gSetup); 00050 gDirectory->cd("/"); 00051 00052 return ret; 00053 }
void BaseModule::SetAlias | ( | const std::string & | alias | ) | [inline] |
Sets the alias for this module, which should be provided in the modules file
Definition at line 59 of file BaseModule.h.
References fAlias.
Referenced by BaseModule().
00059 {fAlias=alias;};
TDirectory* BaseModule::dir [protected] |
Many modules use 'dir' still which was the old protected pointer to the modules directory. To prevent things being broken so soon, we keep this pointer available, but be warned that it will be removed shortly...
Definition at line 98 of file BaseModule.h.
Referenced by BaseModule(), FastSlowCompare::FastSlowCompare(), GeSpectrum::GeSpectrum(), GetDirectory(), MakeMuonEvents::MakeMuonEvents(), and PlotAmpVsTDiff::PlotAmpVsTDiff().
std::string BaseModule::fAlias [private] |
Definition at line 92 of file BaseModule.h.
Referenced by GetAlias(), and SetAlias().
bool BaseModule::fDebug [private] |
Definition at line 89 of file BaseModule.h.
Referenced by BaseModule(), and Debug().
TDirectory* BaseModule::fDirectory [private] |
Definition at line 91 of file BaseModule.h.
Referenced by BaseModule(), GetDirectory(), Postprocess(), Preprocess(), and ProcessGenericEntry().
std::string BaseModule::fName [private] |
Definition at line 90 of file BaseModule.h.
Referenced by BaseModule(), and GetName().
TSetupData* BaseModule::fSetup [private] |
Reimplemented in ExportPulse.
Definition at line 88 of file BaseModule.h.