#include <MakeAnalysedPulses.h>
Public Member Functions | |
MakeAnalysedPulses (modules::options *opts) | |
~MakeAnalysedPulses () | |
bool | AddGenerator (const std::string &detector, std::string generatorType, TAPGeneratorOptions *opts=NULL) |
bool | ParseGeneratorList (std::string generatorList, const std::vector< std::string > &) |
void | SetAnalysedPulseMap (StringAnalPulseMap &aMap) |
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. | |
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 Types | |
typedef std::vector < TVAnalysedPulseGenerator * > | ChannelGenerators_t |
Private Member Functions | |
virtual int | ProcessEntry (TGlobalData *gData, const TSetupData *gSetup) |
The big kahuna. Overload this in the derived class and it will be called for each event. | |
virtual int | BeforeFirstEntry (TGlobalData *gData, const TSetupData *setup) |
virtual int | AfterLastEntry (TGlobalData *gData, const TSetupData *setup) |
void | CalibratePulses (const TVAnalysedPulseGenerator *generator, AnalysedPulseList &theAnalysedPulses) const |
Private Attributes | |
ChannelGenerators_t | fGenerators |
StringAnalPulseMap * | fAnalysedPulseMap |
std::string | fSlowGeneratorType |
std::string | fFastGeneratorType |
std::vector< std::string > | fChannelsToAnalyse |
modules::options * | fOptions |
TAPGeneratorOptions * | fDefaultOpts |
Definition at line 19 of file MakeAnalysedPulses.h.
typedef std::vector<TVAnalysedPulseGenerator*> MakeAnalysedPulses::ChannelGenerators_t [private] |
Definition at line 20 of file MakeAnalysedPulses.h.
MakeAnalysedPulses::MakeAnalysedPulses | ( | modules::options * | opts | ) |
Definition at line 21 of file MakeAnalysedPulses.cpp.
References BaseModule::Debug(), fChannelsToAnalyse, fDefaultOpts, modules::options::GetVectorStringsByWhiteSpace(), and modules::options::SetOption().
00021 : 00022 BaseModule("MakeAnalysedPulses",opts,false), 00023 fSlowGeneratorType(opts->GetString("default_slow_generator","MaxBin")), 00024 fFastGeneratorType(opts->GetString("default_fast_generator","MaxBin")), 00025 fChannelsToAnalyse(), 00026 fOptions(opts), 00027 fDefaultOpts(new TAPGeneratorOptions("default generator options")){ 00028 opts->GetVectorStringsByWhiteSpace("analyse_channels",fChannelsToAnalyse); 00029 if(Debug()) fDefaultOpts->SetOption("debug","true"); 00030 }
MakeAnalysedPulses::~MakeAnalysedPulses | ( | ) |
Definition at line 32 of file MakeAnalysedPulses.cpp.
bool MakeAnalysedPulses::AddGenerator | ( | const std::string & | detector, | |
std::string | generatorType, | |||
TAPGeneratorOptions * | opts = NULL | |||
) |
Definition at line 192 of file MakeAnalysedPulses.cpp.
References TemplateFactory< BaseModule, OptionsType >::createModule(), BaseModule::Debug(), TAPGeneratorOptions::Debug(), fDefaultOpts, fFastGeneratorType, fGenerators, fSlowGeneratorType, modules::options::GetNumOptions(), TAPGeneratorFactory::Instance(), IDs::kFast, IDs::kSlow, and TAPGeneratorOptions::SetChannel().
Referenced by ParseGeneratorList().
00192 { 00193 // If generatorType is '!FAST!' or '!SLOW!' replace with default value 00194 enum {kFast, kSlow, kArbitrary} requestType; 00195 if(generatorType=="!FAST!") { 00196 generatorType=fFastGeneratorType; 00197 requestType=kFast; 00198 }else if(generatorType=="!SLOW!"){ 00199 generatorType=fSlowGeneratorType; 00200 requestType=kSlow; 00201 }else requestType=kArbitrary; 00202 00203 // Make sure opts is not null 00204 if(!opts) opts=new TAPGeneratorOptions(*fDefaultOpts); 00205 opts->SetChannel(detector); 00206 opts->Debug(Debug()); 00207 00208 // Get the requested generator 00209 TVAnalysedPulseGenerator* generator= 00210 TAPGeneratorFactory::Instance()->createModule(generatorType,opts); 00211 if(!generator) return false; 00212 00213 // print something 00214 if(Debug()) { 00215 cout<<detector<<": using "; 00216 if (requestType ==kFast) cout<<"default fast: "; 00217 else if (requestType ==kSlow) cout<<"default slow: "; 00218 else cout<<"generator: "; 00219 cout<<generatorType ; 00220 if(opts) cout<<" with "<<opts->GetNumOptions()<<" option(s)."; 00221 cout<<endl; 00222 } 00223 00224 // Add this generator to the list for the required detector 00225 fGenerators.push_back(generator); 00226 return true; 00227 }
virtual int MakeAnalysedPulses::AfterLastEntry | ( | TGlobalData * | gData, | |
const TSetupData * | setup | |||
) | [inline, private, virtual] |
Optional method which is called once after the main event loop Can be used to dump a summary or finalise a histogram
Implements BaseModule.
Definition at line 33 of file MakeAnalysedPulses.h.
int MakeAnalysedPulses::BeforeFirstEntry | ( | TGlobalData * | gData, | |
const TSetupData * | setup | |||
) | [private, virtual] |
Optional method which is called once before the main event loop Can be used to parse options and setup histograms.
Implements BaseModule.
Definition at line 35 of file MakeAnalysedPulses.cpp.
References detectors, fChannelsToAnalyse, fGenerators, fOptions, gAnalysedPulseMap, TSetupData::GetAllDetectors(), modules::options::GetVectorStringsByDelimiter(), modules::options::HasOption(), modules::parser::iequals(), TSetupData::IsFast(), and ParseGeneratorList().
00035 { 00036 // Loop over every named detector channel in TSetupData 00037 std::vector<std::string> detectors; 00038 setup->GetAllDetectors(detectors); 00039 00040 // do we analyse all channels? 00041 bool analyse_all=fChannelsToAnalyse.empty(); 00042 if(!analyse_all){ 00043 for(unsigned i=0;i<fChannelsToAnalyse.size();i++){ 00044 if (fChannelsToAnalyse[i]=="all"){ 00045 analyse_all=true; 00046 break; 00047 } 00048 } 00049 } 00050 std::cout<<"MakeAnalysedPulses::BeforeFirstEntry: Will analyse "; 00051 if(analyse_all) std::cout<<"all "; 00052 else std::cout<<fChannelsToAnalyse.size()<<" of "; 00053 std::cout<<detectors.size()<<" channels"<<std::endl; 00054 00055 // For each channel: 00056 bool skip_detector=false; 00057 std::string des_gen; 00058 for(std::vector<std::string>::const_iterator det=detectors.begin(); 00059 det!=detectors.end(); det++){ 00060 // if we should not analyse det, leave generator as NULL 00061 skip_detector=false; 00062 if(! analyse_all ){ 00063 std::vector<std::string>::const_iterator it_chan; 00064 for(it_chan=fChannelsToAnalyse.begin(); 00065 it_chan!=fChannelsToAnalyse.end(); 00066 it_chan++){ 00067 if(modules::parser::iequals((*it_chan), (*det)) )break; 00068 } 00069 if(it_chan== fChannelsToAnalyse.end() ) skip_detector=true; 00070 } 00071 if(skip_detector) 00072 continue; 00073 // else find the right generator to build 00074 if(fOptions->HasOption(*det)){ 00075 // If this channel is named explicitly, use that generator type 00076 // Get a vector for the generator(s) that we want to use for this detector 00077 std::vector<std::string> generatorList; 00078 fOptions->GetVectorStringsByDelimiter(*det,generatorList); 00079 bool success=ParseGeneratorList(*det,generatorList); 00080 if(! success) return 1; 00081 } else{ 00082 // else use default value for this type of channel (fast or slow) 00083 if(TSetupData::IsFast(*det)){ 00084 std::vector<std::string> generatorList; 00085 fOptions->GetVectorStringsByDelimiter("default_fast_generator",generatorList); 00086 bool success=ParseGeneratorList(*det,generatorList); 00087 if(!success) return 1; 00088 } else { 00089 std::vector<std::string> generatorList; 00090 fOptions->GetVectorStringsByDelimiter("default_slow_generator",generatorList); 00091 bool success=ParseGeneratorList(*det,generatorList); 00092 if(!success) return 1; 00093 } 00094 } 00095 } 00096 00097 // now make an entry in gAnalysedPulseMap for each generator added 00098 for(ChannelGenerators_t::const_iterator i_gen=fGenerators.begin(); 00099 i_gen!=fGenerators.end();i_gen++){ 00100 gAnalysedPulseMap[(*i_gen)->GetSource()]; 00101 } 00102 return 0; 00103 }
void MakeAnalysedPulses::CalibratePulses | ( | const TVAnalysedPulseGenerator * | generator, | |
AnalysedPulseList & | theAnalysedPulses | |||
) | const [private] |
bool BaseModule::Debug | ( | ) | const [inline, protected, inherited] |
Check whether this module was asked to print extra debug information
Definition at line 71 of file BaseModule.h.
References BaseModule::fDebug.
Referenced by 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(), MakeDetectorPulses::MakeGenerator(), ExportPulse::PlotTPI(), MakeDetectorPulses::ProcessEntry(), TemplateCreator::ProcessEntry(), PulseCandidateFinder_InvestigateParameters::ProcessEntry(), ProcessEntry(), PulseViewer::ProcessEntry(), PlotTDP_TDiff::ProcessEntry(), and TemplateCreator::StartTemplate().
00071 {return fDebug;};
std::string BaseModule::GetAlias | ( | ) | const [inline, inherited] |
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 BaseModule::fAlias.
Referenced by BaseModule::BaseModule().
00063 {return fAlias;};
TDirectory * BaseModule::GetDirectory | ( | const std::string & | name = "" |
) | [protected, inherited] |
Definition at line 77 of file BaseModule.cpp.
References BaseModule::dir, and BaseModule::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, inherited] |
Get the TDirectory for this module.
Definition at line 74 of file BaseModule.h.
References BaseModule::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, inherited] |
Get the name of this module as given to the constructor of the base class.
Definition at line 66 of file BaseModule.h.
References BaseModule::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();};
bool MakeAnalysedPulses::ParseGeneratorList | ( | std::string | generatorList, | |
const std::vector< std::string > & | generatorList | |||
) |
Definition at line 155 of file MakeAnalysedPulses.cpp.
References TAPGeneratorOptions::AddArgument(), AddGenerator(), and modules::parser::GetOneWord().
Referenced by BeforeFirstEntry().
00156 { 00157 00158 //scan to next item in the list 00159 size_t start_br=0; 00160 size_t end_br=std::string::npos; 00161 std::vector<std::string>::const_iterator gen; 00162 std::string arg,generator; 00163 TAPGeneratorOptions* opts; 00164 bool still_good=true; 00165 for(gen=generatorList.begin();gen!= generatorList.end();gen++){ 00166 // check if we have options for this generator 00167 start_br=gen->find('('); 00168 generator=GetOneWord(*gen,0,start_br); 00169 if(start_br!=std::string::npos){ 00170 std::stringstream sstream; 00171 // There are options for this generator 00172 ++start_br; // Move to first character after '(' 00173 end_br=gen->find(')'); 00174 sstream.str(gen->substr(start_br,end_br-start_br)); 00175 opts=new TAPGeneratorOptions(generator); 00176 for(int count=0; std::getline(sstream, arg,','); count++){ 00177 opts->AddArgument(count,arg); 00178 } 00179 } 00180 still_good = AddGenerator(detector,generator,opts); 00181 // Is everything ok to continue? 00182 if (!still_good) { 00183 return false; 00184 } 00185 // Get ready for next iteration 00186 opts=NULL; 00187 } 00188 // Everything went ok, return true 00189 return true; 00190 }
int BaseModule::Postprocess | ( | TGlobalData * | gData, | |
const TSetupData * | gSetup | |||
) | [inherited] |
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 BaseModule::AfterLastEntry(), and BaseModule::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 | |||
) | [inherited] |
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 BaseModule::BeforeFirstEntry(), and BaseModule::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 }
int MakeAnalysedPulses::ProcessEntry | ( | TGlobalData * | gData, | |
const TSetupData * | gSetup | |||
) | [private, 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 ] |
Implements BaseModule.
Definition at line 105 of file MakeAnalysedPulses.cpp.
References BaseModule::Debug(), EventNavigator::EntryNo(), fGenerators, TGlobalData::fPulseIslandToChannelMap, gAnalysedPulseMap, EventNavigator::Instance(), and IDs::channel::str().
00105 { 00106 // Generator just receives a bunch of TPIs and must return a list of TAPs 00107 00108 // Loop over each generator 00109 IDs::channel detector; 00110 PulseIslandList* thePulseIslands; 00111 ChannelGenerators_t::iterator generator; 00112 AnalysedPulseList theAnalysedPulses; 00113 int retVal=0; 00114 for(generator = fGenerators.begin(); generator != fGenerators.end(); generator++){ 00115 // Get the bank name 00116 detector = (*generator)->GetChannel().str(); 00117 00118 // Get the TPIs 00119 thePulseIslands=&gData->fPulseIslandToChannelMap[(*generator)->GetBank()]; 00120 if(thePulseIslands->empty() ){ 00121 if( Debug()) cout << "Event No: " 00122 << EventNavigator::Instance().EntryNo() 00123 <<": List of TPIs for '"<< detector 00124 <<"' was empty "<< endl; 00125 continue; 00126 } 00127 00128 // clear the list of analyse_pulses from the last iteration 00129 theAnalysedPulses.clear(); 00130 00131 // generate the new list of analyse_pulses 00132 (*generator)->SetPulseList(thePulseIslands); 00133 retVal=(*generator)->ProcessPulses( *thePulseIslands,theAnalysedPulses); 00134 if(retVal!=0) return retVal; 00135 00136 // find the pulse list in gAnalysedPulseMap 00137 SourceAnalPulseMap::iterator it=gAnalysedPulseMap.find((*generator)->GetSource()); 00138 if(it==gAnalysedPulseMap.end()){ 00139 // source doesn't seem to exist in gAnalysedPulseMap 00140 cout <<"Error: New TAP source \"" << (*generator)->GetSource() 00141 <<"\" seems to have been created during processing of pulses." 00142 <<endl; 00143 return 1; 00144 } 00145 // add the pulses into the map 00146 it->second=theAnalysedPulses; 00147 00148 (*generator)->CalibratePulses(it->second); 00149 } 00150 return 0; 00151 }
int BaseModule::ProcessGenericEntry | ( | TGlobalData * | gData, | |
const TSetupData * | gSetup | |||
) | [inherited] |
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 BaseModule::fDirectory, and BaseModule::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, inherited] |
Sets the alias for this module, which should be provided in the modules file
Definition at line 59 of file BaseModule.h.
References BaseModule::fAlias.
Referenced by BaseModule::BaseModule().
00059 {fAlias=alias;};
void MakeAnalysedPulses::SetAnalysedPulseMap | ( | StringAnalPulseMap & | aMap | ) | [inline] |
Definition at line 29 of file MakeAnalysedPulses.h.
References fAnalysedPulseMap.
00029 {fAnalysedPulseMap=&aMap;}
TDirectory* BaseModule::dir [protected, inherited] |
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::BaseModule(), FastSlowCompare::FastSlowCompare(), GeSpectrum::GeSpectrum(), BaseModule::GetDirectory(), MakeMuonEvents::MakeMuonEvents(), and PlotAmpVsTDiff::PlotAmpVsTDiff().
Definition at line 38 of file MakeAnalysedPulses.h.
Referenced by SetAnalysedPulseMap().
std::vector<std::string> MakeAnalysedPulses::fChannelsToAnalyse [private] |
Definition at line 41 of file MakeAnalysedPulses.h.
Referenced by BeforeFirstEntry(), and MakeAnalysedPulses().
Definition at line 43 of file MakeAnalysedPulses.h.
Referenced by AddGenerator(), and MakeAnalysedPulses().
std::string MakeAnalysedPulses::fFastGeneratorType [private] |
Definition at line 40 of file MakeAnalysedPulses.h.
Referenced by AddGenerator().
Definition at line 37 of file MakeAnalysedPulses.h.
Referenced by AddGenerator(), BeforeFirstEntry(), and ProcessEntry().
modules::options* MakeAnalysedPulses::fOptions [private] |
Definition at line 42 of file MakeAnalysedPulses.h.
Referenced by BeforeFirstEntry().
std::string MakeAnalysedPulses::fSlowGeneratorType [private] |
Definition at line 39 of file MakeAnalysedPulses.h.
Referenced by AddGenerator().