A one line description of what your module does. More...
#include <IslandAmplitude.h>
Public Member Functions | |
IslandAmplitude (modules::options *opts) | |
Constructor description. If necessary, add a details tag like above. | |
~IslandAmplitude () | |
Is anything done in the destructor? | |
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 const std::map < std::string, std::string > | mapSS_t |
typedef mapSS_t::const_iterator | mapSS_iter |
typedef std::map< std::string, TH1F * > | mapSH_t |
typedef PulseIslandList::iterator | PIL_iter |
Private Member Functions | |
virtual int | ProcessEntry (TGlobalData *gData, const TSetupData *gSetup) |
What's calculated for every entry? Don't hesitate to repeat what was said in the class description. | |
virtual int | BeforeFirstEntry (TGlobalData *gData, const TSetupData *setup) |
What needes to be done before each run? Don't hesitate to repeat what was said in the class description. | |
virtual int | AfterLastEntry (TGlobalData *gData, const TSetupData *setup) |
What needs to be done after each run? Don't hesitate to repeat what was said in the class description. | |
Private Attributes | |
mapSH_t | fAmpHist |
Don't forget to forget descirptions for each field... | |
mapSH_t | fAmpHistNorm |
TH1 * | fAmpNorm |
int | fNProcessed |
A one line description of what your module does.
A longer, more descriptive block of text. Specifics like members and methods will be described later. You can add this to other groups instead of rootana_modules or in addition to rootana_modules by adding more of the ingroup tags.
Definition at line 23 of file IslandAmplitude.h.
typedef std::map<std::string, TH1F*> IslandAmplitude::mapSH_t [private] |
Definition at line 39 of file IslandAmplitude.h.
typedef mapSS_t::const_iterator IslandAmplitude::mapSS_iter [private] |
Definition at line 38 of file IslandAmplitude.h.
typedef const std::map<std::string, std::string> IslandAmplitude::mapSS_t [private] |
Definition at line 37 of file IslandAmplitude.h.
typedef PulseIslandList::iterator IslandAmplitude::PIL_iter [private] |
Definition at line 40 of file IslandAmplitude.h.
IslandAmplitude::IslandAmplitude | ( | modules::options * | opts | ) |
Constructor description. If necessary, add a details tag like above.
[in] | opts | Describe the options this module takes. |
Definition at line 20 of file IslandAmplitude.cpp.
00021 : BaseModule("IslandAmplitude",opts) 00022 { 00023 // Do something with opts here. 00024 }
IslandAmplitude::~IslandAmplitude | ( | ) |
int IslandAmplitude::AfterLastEntry | ( | TGlobalData * | gData, | |
const TSetupData * | setup | |||
) | [private, virtual] |
What needs to be done after each run? Don't hesitate to repeat what was said in the class description.
[in] | gData | See BaseModule::AfterLastEntry |
[in] | setup | See BaseModule::AfterLastEntry |
Implements BaseModule.
Definition at line 140 of file IslandAmplitude.cpp.
References BaseModule::Debug(), fAmpHist, fAmpHistNorm, fAmpNorm, and fNProcessed.
00140 { 00141 00142 // Print extra info if we're debugging this module: 00143 if(Debug()){ 00144 cout<<"-----IslandAmplitude::AfterLastEntry(): I'm debugging!"<<endl; 00145 } 00146 00147 double run_norm = fAmpNorm->Integral(0,-1); 00148 for(mapSH_t::iterator it = fAmpHist.begin(); it != fAmpHist.end(); ++it) 00149 { 00150 TH1F* h = it->second; 00151 TObject* obj = h->Clone((std::string(h->GetName()) + "_RunNorm").c_str()); 00152 TH1* hn = static_cast<TH1*>(obj); 00153 hn->SetTitle((std::string(h->GetTitle()) + " (run normalized)").c_str()); 00154 hn->Scale(1.0/run_norm); 00155 } 00156 00157 for(mapSH_t::iterator it = fAmpHistNorm.begin(); it != fAmpHistNorm.end(); ++it) 00158 it->second->Scale(1.0/fNProcessed); 00159 00160 return 0; 00161 }
int IslandAmplitude::BeforeFirstEntry | ( | TGlobalData * | gData, | |
const TSetupData * | setup | |||
) | [private, virtual] |
What needes to be done before each run? Don't hesitate to repeat what was said in the class description.
[in] | gData | See BaseModule::BeforeFirstEntry |
[in] | setup | See BaseModule::BeforeFirstEntry |
Implements BaseModule.
Definition at line 35 of file IslandAmplitude.cpp.
References BaseModule::Debug(), fAmpHist, fAmpHistNorm, fAmpNorm, fNProcessed, TGlobalData::fPulseIslandToChannelMap, TSetupData::GetDetectorName(), and TSetupData::GetNBits().
00036 { 00037 // Print extra info if we're debugging this module: 00038 if(Debug()){ 00039 cout<<"-----IslandAmplitude::BeforeFirstEntry(): I'm debugging!"<<endl; 00040 00041 } 00042 00043 fNProcessed = 0; 00044 00045 StringPulseIslandMap& islands = data->fPulseIslandToChannelMap; 00046 00047 00048 00049 for(StringPulseIslandMap::iterator mIt = islands.begin(); 00050 mIt != islands.end(); ++mIt) 00051 { 00052 std::string bankname = mIt->first; 00053 std::string detname = setup->GetDetectorName(bankname); 00054 int max_adc_value = pow(2, setup->GetNBits(bankname)); 00055 std::string histname = "hDQ_IslandAmplitudes_" + detname + "" + bankname; 00056 std::string histtitle = "Amplitude of Pulses in " + detname; 00057 TH1F* hDQ = new TH1F(histname.c_str(), histtitle.c_str(), 00058 max_adc_value, 0, max_adc_value); 00059 hDQ->GetXaxis()->SetTitle("Amplitude (adc)"); 00060 hDQ->GetYaxis()->SetTitle("Counts"); 00061 fAmpHist[bankname] = hDQ; 00062 00063 if(detname == "muSc") 00064 fAmpNorm=hDQ; 00065 00066 histname += "_EvtNorm"; 00067 histtitle +=" (event normalized)"; 00068 hDQ = new TH1F(histname.c_str(), histtitle.c_str(), 00069 500, 0, 2000); 00070 fAmpHistNorm[bankname] = hDQ; 00071 } 00072 TDirectory::CurrentDirectory()->cd(".."); 00073 00074 00075 return 0; 00076 }
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(), AfterLastEntry(), MakeDetectorPulses::BeforeFirstEntry(), TemplateCreator::BeforeFirstEntry(), PulseCandidateFinder_InvestigateParameters::BeforeFirstEntry(), PlotTPI_PedestalAndNoise::BeforeFirstEntry(), PlotTDPs::BeforeFirstEntry(), PlotTDP_TDiff::BeforeFirstEntry(), IslandLength::BeforeFirstEntry(), 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, 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();};
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 IslandAmplitude::ProcessEntry | ( | TGlobalData * | gData, | |
const TSetupData * | gSetup | |||
) | [private, virtual] |
What's calculated for every entry? Don't hesitate to repeat what was said in the class description.
[in] | gData | See BaseModule::ProcessEntry |
[in] | gSetup | See BaseModule::ProcessEntry |
Implements BaseModule.
Definition at line 82 of file IslandAmplitude.cpp.
References banks, fAmpHist, fAmpHistNorm, fNProcessed, TGlobalData::fPulseIslandToChannelMap, TSetupData::GetDetectorName(), TSetupData::GetPedestal(), and TSetupData::GetTriggerPolarity().
00083 { 00084 ++fNProcessed; 00085 00086 StringPulseIslandMap& banks = data->fPulseIslandToChannelMap; 00087 int entry_norm =-1; 00088 00089 for(StringPulseIslandMap::iterator mIter = banks.begin(); mIter != banks.end(); ++mIter) 00090 { 00091 std::string detname = setup->GetDetectorName(mIter->first); 00092 if(detname == "muSc") 00093 entry_norm = mIter->second.size(); 00094 } 00095 00096 for(StringPulseIslandMap::iterator mIter = banks.begin(); mIter != banks.end(); ++mIter) 00097 { 00098 std::string bankname = mIter->first; 00099 std::string detname = setup->GetDetectorName(bankname); 00100 PulseIslandList& pulses = mIter->second; 00101 00102 TH1F* hist = fAmpHist.find(bankname)->second; 00103 TH1F* histnorm = fAmpHistNorm.find(bankname)->second; 00104 00105 for(PIL_iter pIt = pulses.begin(); pIt != pulses.end(); ++pIt) 00106 { 00107 00108 00109 // 00110 double amp = 0; 00111 std::vector<int> samples = (*pIt)->GetSamples(); 00112 std::vector<int>::iterator pos; 00113 int polarity = setup->GetTriggerPolarity(bankname); 00114 int pedestal = setup->GetPedestal(bankname); 00115 00116 if(polarity == 1) 00117 pos = std::max_element(samples.begin(), samples.end()); 00118 else if(polarity == -1) 00119 pos = std::min_element(samples.begin(), samples.end()); 00120 00121 amp = polarity * (*pos - pedestal); 00122 // 00123 00124 hist->Fill(amp); 00125 if(entry_norm != 0) 00126 histnorm->Fill(amp, 1.0/entry_norm); 00127 } 00128 } 00129 00130 00131 return 0; 00132 }
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;};
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().
mapSH_t IslandAmplitude::fAmpHist [private] |
Don't forget to forget descirptions for each field...
...and don't hesitate to include details.
Definition at line 74 of file IslandAmplitude.h.
Referenced by AfterLastEntry(), BeforeFirstEntry(), and ProcessEntry().
mapSH_t IslandAmplitude::fAmpHistNorm [private] |
Definition at line 75 of file IslandAmplitude.h.
Referenced by AfterLastEntry(), BeforeFirstEntry(), and ProcessEntry().
TH1* IslandAmplitude::fAmpNorm [private] |
Definition at line 77 of file IslandAmplitude.h.
Referenced by AfterLastEntry(), and BeforeFirstEntry().
int IslandAmplitude::fNProcessed [private] |
Definition at line 79 of file IslandAmplitude.h.
Referenced by AfterLastEntry(), BeforeFirstEntry(), and ProcessEntry().