#include <MakeDetectorPulses.h>
Classes | |
struct | Detector_t |
Public Member Functions | |
MakeDetectorPulses (modules::options *opts) | |
~MakeDetectorPulses () | |
void | SetDefaultAlgorithm (const TString &algorithm) |
void | SetDetectorPulseMap (StringDetPulseMap &aMap) |
IDs::generator | GetPassThruGeneratorID () const |
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::set< Detector_t > | ChannelPairing_t |
Private Member Functions | |
TVDetectorPulseGenerator * | MakeGenerator (const IDs::source ¤t_source, const IDs::source &partner_source, const std::string &generatorType, TDPGeneratorOptions *opts) |
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 | DumpgAnalysedPulseMap (const SourceAnalPulseMap &aMap) |
bool | ParseGeneratorList (const IDs::source ¤t_source, const IDs::source &partner_source, const std::string &generatorList) |
Private Attributes | |
modules::options * | fOptions |
TVDetectorPulseGenerator * | fPassThruGenerator |
TVDetectorPulseGenerator * | fGenerator |
StringDetPulseMap * | fDetectorPulseMap |
ChannelPairing_t | fFastSlowPairs |
std::string | fDefaultAlgorithm |
std::string | fPassThruName |
std::vector< std::string > | fDetectorsToAnalyse |
Definition at line 18 of file MakeDetectorPulses.h.
typedef std::set<Detector_t > MakeDetectorPulses::ChannelPairing_t [private] |
Definition at line 59 of file MakeDetectorPulses.h.
MakeDetectorPulses::MakeDetectorPulses | ( | modules::options * | opts | ) |
Definition at line 26 of file MakeDetectorPulses.cpp.
References fDefaultAlgorithm, fDetectorsToAnalyse, fPassThruName, modules::options::GetString(), and modules::options::GetVectorStringsByWhiteSpace().
00026 : 00027 BaseModule("MakeDetectorPulses",opts,false),fOptions(opts),fPassThruGenerator(NULL){ 00028 // Get the algorithm option from the modules file 00029 // If nothing was set, use MaxTimeDiff by default 00030 opts->GetVectorStringsByWhiteSpace("analyse_detectors",fDetectorsToAnalyse); 00031 std::sort(fDetectorsToAnalyse.begin(), fDetectorsToAnalyse.end()); 00032 fDefaultAlgorithm=opts->GetString("default_algorithm","MaxTimeDiff"); 00033 fPassThruName=opts->GetString("pass_through_algorithm","PassThrough"); 00034 }
MakeDetectorPulses::~MakeDetectorPulses | ( | ) |
Definition at line 36 of file MakeDetectorPulses.cpp.
virtual int MakeDetectorPulses::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 49 of file MakeDetectorPulses.h.
int MakeDetectorPulses::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 39 of file MakeDetectorPulses.cpp.
References BaseModule::Debug(), IDs::channel::Detector(), fDefaultAlgorithm, fDetectorsToAnalyse, fFastSlowPairs, fOptions, fPassThruName, gAnalysedPulseMap, gDetectorPulseMap, IDs::channel::GetCorrespondingFastSlow(), IDs::channel::GetDetectorString(), modules::options::GetString(), modules::options::HasOption(), ParseGeneratorList(), and IDs::generator::Type().
00039 { 00040 // do we analyse all channels? 00041 bool analyse_all=fDetectorsToAnalyse.empty(); 00042 if(!analyse_all) analyse_all= (std::find(fDetectorsToAnalyse.begin(), fDetectorsToAnalyse.end(), "all")!=fDetectorsToAnalyse.end()); 00043 00044 const IDs::channel* ch; 00045 const IDs::generator* gen; 00046 00047 // Find all fast detectors 00048 for (SourceAnalPulseMap::const_iterator i_source = gAnalysedPulseMap.begin(); 00049 i_source != gAnalysedPulseMap.end(); i_source++) { 00050 ch=&i_source->first.Channel(); 00051 gen=&i_source->first.Generator(); 00052 00053 // Do we need to pair this detector? 00054 if( !analyse_all && 00055 (std::find_if(fDetectorsToAnalyse.begin(), 00056 fDetectorsToAnalyse.end(), 00057 is_equal(*ch))==fDetectorsToAnalyse.end())) continue; 00058 00059 // Find the correct source since the generator options could be different 00060 IDs::source partner =i_source->first; 00061 for (SourceAnalPulseMap::const_iterator j_source = gAnalysedPulseMap.begin(); 00062 j_source != gAnalysedPulseMap.end(); ++j_source) { 00063 00064 if (j_source->first.Generator().Type() == gen->Type() 00065 && j_source->first.Channel() == ch->GetCorrespondingFastSlow()) { 00066 partner = j_source->first; 00067 } 00068 } 00069 00070 // Check whether a specific generator is given for this detector 00071 const std::string detname=IDs::channel::GetDetectorString(ch->Detector()); 00072 if( fOptions->HasOption(detname) ){ 00073 // If this channel is named explicitly, use that generator type 00074 // Get a vector for the generator(s) that we want to use for this detector 00075 bool success=ParseGeneratorList(i_source->first, partner,fOptions->GetString(detname)); 00076 if(! success) return 1; 00077 }else if(partner==i_source->first) { 00078 // if there is no corresponding fast / slow channel then use the pass 00079 // through generator 00080 bool success=ParseGeneratorList(i_source->first, partner,fPassThruName); 00081 if(! success) return 1; 00082 } else { 00083 // Else we use the default pairing algorithm 00084 bool success=ParseGeneratorList(i_source->first, partner,fDefaultAlgorithm); 00085 if(! success) return 1; 00086 } 00087 } 00088 00089 // now make an entry in gAnalysedPulseMap for each generator added 00090 for(ChannelPairing_t::const_iterator i_pair=fFastSlowPairs.begin(); 00091 i_pair!=fFastSlowPairs.end();i_pair++){ 00092 gDetectorPulseMap[i_pair->source]; 00093 if(Debug()){ 00094 std::cout<<"Paired: "<<i_pair->fast<<" with "<<i_pair->slow<<" processed by: "<<i_pair->generator->GetGeneratorID()<<std::endl; 00095 } 00096 } 00097 return 0; 00098 }
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 MakeAnalysedPulses::AddGenerator(), ExportPulse::AddToExportList(), PulseCandidateFinder_InvestigateParameters::AfterLastEntry(), PlotTPI_PedestalAndNoise::AfterLastEntry(), PlotTDPs::AfterLastEntry(), PlotTDP_TDiff::AfterLastEntry(), IslandLength::AfterLastEntry(), IslandAmplitude::AfterLastEntry(), BeforeFirstEntry(), TemplateCreator::BeforeFirstEntry(), PulseCandidateFinder_InvestigateParameters::BeforeFirstEntry(), PlotTPI_PedestalAndNoise::BeforeFirstEntry(), PlotTDPs::BeforeFirstEntry(), PlotTDP_TDiff::BeforeFirstEntry(), IslandLength::BeforeFirstEntry(), IslandAmplitude::BeforeFirstEntry(), PulseViewer::ConsiderDrawing(), MakeAnalysedPulses::MakeAnalysedPulses(), MakeGenerator(), ExportPulse::PlotTPI(), ProcessEntry(), TemplateCreator::ProcessEntry(), PulseCandidateFinder_InvestigateParameters::ProcessEntry(), MakeAnalysedPulses::ProcessEntry(), PulseViewer::ProcessEntry(), PlotTDP_TDiff::ProcessEntry(), and TemplateCreator::StartTemplate().
00071 {return fDebug;};
void MakeDetectorPulses::DumpgAnalysedPulseMap | ( | const SourceAnalPulseMap & | aMap | ) | [private] |
Definition at line 224 of file MakeDetectorPulses.cpp.
Referenced by ProcessEntry().
00224 { 00225 std::cout<<"gAnalysedPulseMap contains:"<<std::endl; 00226 for(SourceAnalPulseMap::const_iterator it=aMap.begin(); 00227 it!=aMap.end(); it++){ 00228 cout<<it->first<<" contains "<<it->second.size()<<" TAPs"<<endl; 00229 } 00230 00231 }
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();};
IDs::generator MakeDetectorPulses::GetPassThruGeneratorID | ( | ) | const [inline] |
Definition at line 41 of file MakeDetectorPulses.h.
References fPassThruGenerator, IDs::source::Generator(), and TVDetectorPulseGenerator::GetSource().
00041 { 00042 return fPassThruGenerator?fPassThruGenerator->GetSource().Generator():IDs::generator(); 00043 }
TVDetectorPulseGenerator * MakeDetectorPulses::MakeGenerator | ( | const IDs::source & | current_source, | |
const IDs::source & | partner_source, | |||
const std::string & | generatorType, | |||
TDPGeneratorOptions * | opts | |||
) | [private] |
Definition at line 190 of file MakeDetectorPulses.cpp.
References IDs::source::Channel(), TemplateFactory< BaseModule, OptionsType >::createModule(), BaseModule::Debug(), fFastSlowPairs, IDs::source::Generator(), TVDetectorPulseGenerator::GetGeneratorID(), TDPGeneratorFactory::Instance(), IDs::channel::isFast(), IDs::kNotApplicable, TVDetectorPulseGenerator::SetDebug(), and TVDetectorPulseGenerator::SetPulseSources().
Referenced by ParseGeneratorList().
00190 { 00191 const IDs::channel& ch=current_source.Channel(); 00192 00193 // Select the generator type 00194 TVDetectorPulseGenerator* generator=TDPGeneratorFactory::Instance()->createModule(generatorType,opts); 00195 if (!generator){ 00196 return NULL; 00197 } 00198 // setup some options on the generator 00199 generator->SetDebug(Debug()); 00200 00201 // Prepare the source ID for the TDP generator 00202 IDs::source tdp_source=current_source; 00203 tdp_source.Channel().SlowFast(IDs::kNotApplicable); 00204 tdp_source.Generator()=generator->GetGeneratorID(); 00205 00206 //if(Debug()) 00207 cout<< "MakeDetectorPulses::BeforeFirstEntry: Making generator '"<<generatorType<<"' with source ID: '"<<tdp_source<<"'" <<endl; 00208 00209 if(ch.isFast()) { 00210 // fast channels go first 00211 generator->SetPulseSources(current_source,partner_source); 00212 fFastSlowPairs.insert(Detector_t(tdp_source, current_source,partner_source,generator)); 00213 }else{ 00214 // slow channels go second 00215 // if both fast and slow are the same then later there will be 00216 // nothing to do. 00217 generator->SetPulseSources(partner_source,current_source); 00218 fFastSlowPairs.insert(Detector_t(tdp_source, partner_source,current_source,generator)); 00219 } 00220 00221 return generator; 00222 }
bool MakeDetectorPulses::ParseGeneratorList | ( | const IDs::source & | current_source, | |
const IDs::source & | partner_source, | |||
const std::string & | generatorList | |||
) | [private] |
Definition at line 158 of file MakeDetectorPulses.cpp.
References TDPGeneratorOptions::AddArgument(), modules::parser::Constructor_t::before, modules::parser::Constructor_t::inside, MakeGenerator(), modules::parser::ParseConstructor(), and modules::parser::TokeniseByDelimiter().
Referenced by BeforeFirstEntry().
00159 { 00160 std::vector<std::string> generatorList; 00161 modules::parser::TokeniseByDelimiter(generator_specs,generatorList,":"); 00162 00163 //scan to next item in the list 00164 std::vector<std::string>::const_iterator gen; 00165 std::string arg; 00166 TDPGeneratorOptions* opts; 00167 modules::parser::Constructor_t generator_request; 00168 bool still_good=true; 00169 for(gen=generatorList.begin();gen!= generatorList.end();gen++){ 00170 // check if we have options for this generator 00171 generator_request=modules::parser::ParseConstructor(*gen,'(',')'); 00172 std::stringstream sstream(generator_request.inside); 00173 opts=new TDPGeneratorOptions(generator_request.before); 00174 for(int count=0; std::getline(sstream, arg,','); count++){ 00175 opts->AddArgument(count,arg); 00176 } 00177 still_good = MakeGenerator(current_source,partner_source, generator_request.before,opts); 00178 // Is everything ok to continue? 00179 if (!still_good) { 00180 return false; 00181 } 00182 // Get ready for next iteration 00183 opts=NULL; 00184 } 00185 // Everything went ok, return true 00186 return true; 00187 }
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 MakeDetectorPulses::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 100 of file MakeDetectorPulses.cpp.
References BaseModule::Debug(), DumpgAnalysedPulseMap(), fFastSlowPairs, gAnalysedPulseMap, gDetectorPulseMap, IDs::kAnyDetector, IDs::kNotApplicable, and IDs::source::source().
00100 { 00101 IDs::channel detector(IDs::kAnyDetector,IDs::kNotApplicable); 00102 IDs::source source; 00103 const AnalysedPulseList *slow_pulses; 00104 const AnalysedPulseList *fast_pulses; 00105 SourceAnalPulseMap::const_iterator current; 00106 //DetectorPulseList *detectorPulses; 00107 00108 // Loop through paired channels 00109 for (ChannelPairing_t::const_iterator i_detector = fFastSlowPairs.begin(); 00110 i_detector != fFastSlowPairs.end(); i_detector++) { 00111 detector=i_detector->fast.Channel(); 00112 00113 // find the list of analyzed pulses for the fast channel 00114 current=gAnalysedPulseMap.find(i_detector->fast); 00115 if(current==gAnalysedPulseMap.end()){ 00116 std::cout<<"Unable to find source for fast channel: "<<i_detector->fast<<std::endl; 00117 DumpgAnalysedPulseMap(gAnalysedPulseMap); 00118 return 1; 00119 } 00120 fast_pulses=&(current->second); 00121 00122 // check if the fast_pulses is empty 00123 if(fast_pulses->empty()) { 00124 if(Debug()) cout<< "List of TAPs for "<<i_detector->fast<<" is empty."<<endl; 00125 continue; 00126 } 00127 00128 // if the fast and slow sources are the same then pass the slow channel 00129 // as NULL 00130 if(i_detector->fast==i_detector->slow) slow_pulses=NULL; 00131 else{ 00132 current=gAnalysedPulseMap.find(i_detector->slow); 00133 if(current==gAnalysedPulseMap.end()){ 00134 std::cout<<"Unable to find source for slow channel: "<<i_detector->slow<<std::endl; 00135 DumpgAnalysedPulseMap(gAnalysedPulseMap); 00136 return 1; 00137 } 00138 slow_pulses=&(current->second); 00139 // check if the fast_pulses is empty 00140 if(slow_pulses->empty()) { 00141 if(Debug()) 00142 cout<< "List of TAPs for "<<i_detector->slow<<" is empty."<<endl; 00143 continue; 00144 } 00145 } 00146 00147 // Set the channel 00148 i_detector->generator->SetChannel(detector); 00149 // Set the pulse lists 00150 i_detector->generator->SetPulseLists(fast_pulses,slow_pulses); 00151 // Process the pulses 00152 source=i_detector->source; 00153 i_detector->generator->ProcessPulses(gDetectorPulseMap.at(source)); 00154 } 00155 return 0; 00156 }
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 MakeDetectorPulses::SetDefaultAlgorithm | ( | const TString & | algorithm | ) | [inline] |
Definition at line 38 of file MakeDetectorPulses.h.
References fDefaultAlgorithm.
00038 {fDefaultAlgorithm=algorithm;};
void MakeDetectorPulses::SetDetectorPulseMap | ( | StringDetPulseMap & | aMap | ) | [inline] |
Definition at line 39 of file MakeDetectorPulses.h.
References fDetectorPulseMap.
00039 {fDetectorPulseMap=&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().
std::string MakeDetectorPulses::fDefaultAlgorithm [private] |
Definition at line 61 of file MakeDetectorPulses.h.
Referenced by BeforeFirstEntry(), MakeDetectorPulses(), and SetDefaultAlgorithm().
Definition at line 58 of file MakeDetectorPulses.h.
Referenced by SetDetectorPulseMap().
std::vector<std::string> MakeDetectorPulses::fDetectorsToAnalyse [private] |
Definition at line 62 of file MakeDetectorPulses.h.
Referenced by BeforeFirstEntry(), and MakeDetectorPulses().
Definition at line 60 of file MakeDetectorPulses.h.
Referenced by BeforeFirstEntry(), MakeGenerator(), and ProcessEntry().
Definition at line 57 of file MakeDetectorPulses.h.
modules::options* MakeDetectorPulses::fOptions [private] |
Definition at line 55 of file MakeDetectorPulses.h.
Referenced by BeforeFirstEntry().
Definition at line 56 of file MakeDetectorPulses.h.
Referenced by GetPassThruGeneratorID().
std::string MakeDetectorPulses::fPassThruName [private] |
Definition at line 61 of file MakeDetectorPulses.h.
Referenced by BeforeFirstEntry(), and MakeDetectorPulses().