#include <FirstCompleteAPGenerator.h>
Public Member Functions | |
FirstCompleteAPGenerator (TAPGeneratorOptions *opts) | |
virtual | ~FirstCompleteAPGenerator () |
virtual int | ProcessPulses (const PulseIslandList &, AnalysedPulseList &) |
This method is called on each vector of pulses from a MIDAS event. | |
virtual bool | MayDivideTPIs () |
void | SetPulseList (PulseIslandList *list) |
template<typename TypeOfTAP > | |
TypeOfTAP * | MakeNewTAP (int parent_index) const |
The suggested method for constructing a new TAP. | |
TAnalysedPulse * | MakeNewTAP (int parent_index) const |
bool | Debug () const |
IDs::channel | GetChannel () const |
std::string | GetBank () const |
const IDs::source & | GetSource () const |
Get the source id for this generator being used on the current channel. | |
virtual void | CalibratePulses (AnalysedPulseList &theAnalysedPulses) const |
Static Public Member Functions | |
static const char * | TapType () |
Protected Member Functions | |
virtual void | SetChannel (const std::string &det) |
Set the channel for this generator. Should NOT be called by user code. | |
Private Member Functions | |
void | DrawPulse (int original, int pulse_timestamp, int n_pulse_samples) |
void | MakeTAPsWithPCF (int tpi_ID, const TPulseIsland *tpi, AnalysedPulseList &analysedList) |
void | AnalyseOneTpi (int tpi_ID, const TPulseIsland *tpi, AnalysedPulseList &analysedList) |
Private Attributes | |
const Algorithm::MaxBinAmplitude | fMaxBinAmplitude |
const Algorithm::ConstantFractionTime | fConstantFractionTime |
const Algorithm::SimpleIntegral | fSimpleIntegral |
PulseCandidateFinder * | fPulseCandidateFinder |
PulseIslandList | fSubPulses |
Friends | |
class | MakeAnalysedPulses |
Definition at line 11 of file FirstCompleteAPGenerator.h.
FirstCompleteAPGenerator::FirstCompleteAPGenerator | ( | TAPGeneratorOptions * | opts | ) |
Definition at line 15 of file FirstCompleteAPGenerator.cpp.
References TAPGeneratorOptions::Debug(), fPulseCandidateFinder, modules::options::GetBool(), TVAnalysedPulseGenerator::GetChannel(), and modules::options::SetOption().
00015 : 00016 TVAnalysedPulseGenerator("FirstComplete",opts), 00017 fMaxBinAmplitude(SetupNavigator::Instance()->GetPedestal(GetChannel()), 00018 TSetupData::Instance()->GetTriggerPolarity(TSetupData::Instance()->GetBankName(GetChannel().str()))), 00019 fConstantFractionTime(SetupNavigator::Instance()->GetPedestal(GetChannel()), 00020 TSetupData::Instance()->GetTriggerPolarity(TSetupData::Instance()->GetBankName(GetChannel().str())), 00021 TSetupData::Instance()->GetClockTick(TSetupData::Instance()->GetBankName(GetChannel().str())), 00022 opts->GetBool("no_time_shift", false) ? 0. : SetupNavigator::Instance()->GetCoarseTimeOffset(GetSource()), 00023 opts->GetDouble("constant_fraction")), 00024 fSimpleIntegral(SetupNavigator::Instance()->GetPedestal(GetChannel()), 00025 TSetupData::Instance()->GetTriggerPolarity(TSetupData::Instance()->GetBankName(GetChannel().str()))), 00026 fPulseCandidateFinder(NULL) { 00027 if(opts->GetBool("use_pcf",true)){ 00028 if(opts->Debug()) opts->SetOption("debug","true"); 00029 fPulseCandidateFinder=new PulseCandidateFinder(GetChannel().str(), opts); 00030 } 00031 }
FirstCompleteAPGenerator::~FirstCompleteAPGenerator | ( | ) | [virtual] |
Definition at line 33 of file FirstCompleteAPGenerator.cpp.
References fSubPulses.
00033 { 00034 // delete all sub-pulses 00035 for(PulseIslandList::iterator i_tpi=fSubPulses.begin(); i_tpi!=fSubPulses.end(); ++i_tpi){ 00036 delete *i_tpi; 00037 } 00038 }
void FirstCompleteAPGenerator::AnalyseOneTpi | ( | int | tpi_ID, | |
const TPulseIsland * | tpi, | |||
AnalysedPulseList & | analysedList | |||
) | [private] |
Definition at line 65 of file FirstCompleteAPGenerator.cpp.
References fConstantFractionTime, fMaxBinAmplitude, fSimpleIntegral, TPulseIsland::GetPulseLength(), TVAnalysedPulseGenerator::MakeNewTAP(), TAnalysedPulse::SetAmplitude(), TAnalysedPulse::SetIntegral(), and TAnalysedPulse::SetTime().
Referenced by MakeTAPsWithPCF(), and ProcessPulses().
00065 { 00066 if(tpi->GetPulseLength() < 14) return; 00067 00068 // Analyse each TPI 00069 double amplitude=fMaxBinAmplitude(tpi); 00070 double time=fConstantFractionTime(tpi); 00071 double integral=fSimpleIntegral(tpi); 00072 00073 // Now that we've found the information we were looking for make a TAP to 00074 // hold it. This method makes a TAP and sets the parent TPI info. It needs 00075 // the index of the parent TPI in the container as an argument 00076 TAnalysedPulse* tap = MakeNewTAP(tpi_ID); 00077 tap->SetAmplitude(amplitude); 00078 tap->SetTime(time); 00079 tap->SetIntegral(integral); 00080 00081 // Finally add the new TAP to the output list 00082 analysedList.push_back(tap); 00083 }
void TVAnalysedPulseGenerator::CalibratePulses | ( | AnalysedPulseList & | theAnalysedPulses | ) | const [virtual, inherited] |
Definition at line 23 of file TVAnalysedPulseGenerator.cpp.
References TVAnalysedPulseGenerator::fAdcToEnergyGain, TVAnalysedPulseGenerator::fAdcToEnergyOffset, and TVAnalysedPulseGenerator::fCanCalibrate.
00023 { 00024 if(fCanCalibrate){ 00025 for(AnalysedPulseList::iterator i_tap=theAnalysedPulses.begin(); i_tap != theAnalysedPulses.end(); ++i_tap){ 00026 const double amplitude=(*i_tap)->GetAmplitude(); 00027 (*i_tap)->SetEnergy(fAdcToEnergyGain * amplitude + fAdcToEnergyOffset); 00028 } 00029 } 00030 }
bool TVAnalysedPulseGenerator::Debug | ( | ) | const [inline, inherited] |
Definition at line 77 of file TVAnalysedPulseGenerator.h.
References TVAnalysedPulseGenerator::fDebug.
Referenced by GaussFitAPGenerator::FitPulse(), TemplateConvolveAPGenerator::ProcessPulses(), and IntegralRatioAPGenerator::ProcessPulses().
00077 {return fDebug;};
void FirstCompleteAPGenerator::DrawPulse | ( | int | original, | |
int | pulse_timestamp, | |||
int | n_pulse_samples | |||
) | [private] |
Definition at line 85 of file FirstCompleteAPGenerator.cpp.
References EventNavigator::EntryNo(), fSubPulses, TVAnalysedPulseGenerator::GetChannel(), EventNavigator::Instance(), and modules::parser::ToCppValid().
00085 { 00086 00087 /* if( ExportPulse::Instance()) 00088 ExportPulse::Instance()->AddToExportList(GetChannel().str(), original); 00089 else return; 00090 */ 00091 for (std::vector<TPulseIsland*>::const_iterator subPulseIter = fSubPulses.begin(); 00092 subPulseIter != fSubPulses.end(); ++subPulseIter) { 00093 std::stringstream histname; 00094 histname << "hSubPulse_" << GetChannel() << "_Event" 00095 << EventNavigator::Instance().EntryNo() <<"_Pulse" << original 00096 << "_SubPulse" << subPulseIter - fSubPulses.begin(); 00097 00098 const std::vector<int>& sub_pulse_samples = (*subPulseIter)->GetSamples(); 00099 00100 TH1D* hPulse = new TH1D(modules::parser::ToCppValid(histname.str()).c_str(), 00101 histname.str().c_str(), n_pulse_samples,0,n_pulse_samples); 00102 hPulse->SetLineColor(kMagenta); 00103 00104 int delay = (*subPulseIter)->GetTimeStamp() - pulse_timestamp; 00105 for (std::vector<int>::const_iterator subPulseSampleIter = sub_pulse_samples.begin(); 00106 subPulseSampleIter != sub_pulse_samples.end(); ++subPulseSampleIter) { 00107 hPulse->Fill( (subPulseSampleIter - sub_pulse_samples.begin()) + delay, (*subPulseSampleIter) ); 00108 } 00109 } 00110 }
std::string TVAnalysedPulseGenerator::GetBank | ( | ) | const [inline, inherited] |
A convenience method for analysis to get the channel ID of the channel being analysed
Definition at line 85 of file TVAnalysedPulseGenerator.h.
References TVAnalysedPulseGenerator::fBankName.
00085 {return fBankName;};
IDs::channel TVAnalysedPulseGenerator::GetChannel | ( | ) | const [inline, inherited] |
A convenience method for analysis to get the channel ID of the channel being analysed
Definition at line 81 of file TVAnalysedPulseGenerator.h.
References IDs::source::Channel(), and TVAnalysedPulseGenerator::fSource.
Referenced by DrawPulse(), FirstCompleteAPGenerator(), IntegralRatioAPGenerator::ProcessPulses(), TemplateConvolveAPGenerator::TemplateConvolveAPGenerator(), TemplateFitAPGenerator::TemplateFitAPGenerator(), and TVAnalysedPulseGenerator::TVAnalysedPulseGenerator().
const IDs::source& TVAnalysedPulseGenerator::GetSource | ( | ) | const [inline, inherited] |
Get the source id for this generator being used on the current channel.
Useful for a generator to know the full source much like in the above GetChannel method, but this could also be useful for checking that this generator is the one that made a given TAP in later analysis by comparing this value to that stored in the TAP itself.
Definition at line 94 of file TVAnalysedPulseGenerator.h.
References TVAnalysedPulseGenerator::fSource.
Referenced by TVAnalysedPulseGenerator::MakeNewTAP(), and IntegralRatioAPGenerator::ProcessPulses().
00094 {return fSource;};
TAnalysedPulse* TVAnalysedPulseGenerator::MakeNewTAP | ( | int | parent_index | ) | const [inline, inherited] |
Definition at line 73 of file TVAnalysedPulseGenerator.h.
TypeOfTAP * TVAnalysedPulseGenerator::MakeNewTAP | ( | int | parent_index | ) | const [inline, inherited] |
The suggested method for constructing a new TAP.
In the process of constructing TAP, information that isn't immediately obvious how to get needs to be passed to TAP. This method returns a pointer to a TAP construced for you, and all you need to pass it is the TPulseIslandID.
In the case where a generator wants to add extra information to the standard TAP information, we expect people to derive from TAnalysedPulse. If your generator is one of these, then use the template argument to produce the type of TAP you desire. Note that this forces the constructor of the specialised TAP to be the same as for TAnalysedPulse itself.
For example, for to make a specialied analysed pulse called TSpecialAnalysedPulse (original, huh?) you would do:
TSpecialAnalysedPulse* tsap=MakeNewTAP<TSpecialAnalysedPulse>(parent_index);
[in] | parent_index | The TPulseIslandID of the TPI being used to make the new TAP. |
in] | TypeOfTAP The type of specialisation of TAnalysedPulse that you want to create. |
Definition at line 137 of file TVAnalysedPulseGenerator.h.
References TVAnalysedPulseGenerator::fPulseList, and TVAnalysedPulseGenerator::GetSource().
Referenced by AnalyseOneTpi(), SimpIntAPGenerator::ProcessPulses(), MaxBinAPGenerator::ProcessPulses(), CFTimeMBAmpAPGenerator::ProcessPulses(), and CFTimeAPGenerator::ProcessPulses().
00137 { 00138 TypeOfTAP* pulse=NULL; 00139 TPulseIsland* parent = fPulseList->at(parent_index); 00140 pulse=new TypeOfTAP(GetSource(),parent_index,parent); 00141 return pulse; 00142 }
void FirstCompleteAPGenerator::MakeTAPsWithPCF | ( | int | tpi_ID, | |
const TPulseIsland * | tpi, | |||
AnalysedPulseList & | analysedList | |||
) | [private] |
Definition at line 54 of file FirstCompleteAPGenerator.cpp.
References AnalyseOneTpi(), PulseCandidateFinder::FindPulseCandidates(), fPulseCandidateFinder, fSubPulses, and PulseCandidateFinder::GetPulseCandidates().
Referenced by ProcessPulses().
00054 { 00055 // Look for more than one pulse on the TPI 00056 fPulseCandidateFinder->FindPulseCandidates(original_tpi); 00057 fPulseCandidateFinder->GetPulseCandidates(fSubPulses); 00058 00059 // now loop over all sub-pulses 00060 for(PulseIslandList::const_iterator i_tpi=fSubPulses.begin(); i_tpi!=fSubPulses.end(); ++i_tpi){ 00061 AnalyseOneTpi( tpi_ID, *i_tpi,analysedList); 00062 } 00063 }
virtual bool FirstCompleteAPGenerator::MayDivideTPIs | ( | ) | [inline, virtual] |
Implements TVAnalysedPulseGenerator.
Definition at line 22 of file FirstCompleteAPGenerator.h.
int FirstCompleteAPGenerator::ProcessPulses | ( | const PulseIslandList & | pil, | |
AnalysedPulseList & | apl | |||
) | [virtual] |
This method is called on each vector of pulses from a MIDAS event.
[in] | pil | The vector of TPIs to produce TAPs from. |
[out] | apl | The vector of TAPs to append the new TAPs to. |
Implements TVAnalysedPulseGenerator.
Definition at line 40 of file FirstCompleteAPGenerator.cpp.
References AnalyseOneTpi(), fPulseCandidateFinder, and MakeTAPsWithPCF().
00042 { 00043 00044 // Loop over all the TPIs given to us 00045 for (PulseIslandList::const_iterator i_tpi=pulseList.begin(); 00046 i_tpi!=pulseList.end(); ++i_tpi){ 00047 int tpi_ID = i_tpi - pulseList.begin(); 00048 if(fPulseCandidateFinder) MakeTAPsWithPCF(tpi_ID,*i_tpi,analysedList); 00049 else AnalyseOneTpi(tpi_ID, *i_tpi,analysedList); 00050 } 00051 return 0; 00052 }
virtual void TVAnalysedPulseGenerator::SetChannel | ( | const std::string & | det | ) | [inline, protected, virtual, inherited] |
Set the channel for this generator. Should NOT be called by user code.
Called by MakeAnalysedPulses to tell this generator what channel it is looking at.
Definition at line 108 of file TVAnalysedPulseGenerator.h.
References IDs::source::Channel(), TVAnalysedPulseGenerator::fBankName, TVAnalysedPulseGenerator::fSource, SetupNavigator::GetBank(), and SetupNavigator::Instance().
Referenced by TVAnalysedPulseGenerator::TVAnalysedPulseGenerator().
00108 { 00109 fSource.Channel()=det; 00110 fBankName= SetupNavigator::Instance()->GetBank(det); 00111 };
void TVAnalysedPulseGenerator::SetPulseList | ( | PulseIslandList * | list | ) | [inline, inherited] |
Definition at line 44 of file TVAnalysedPulseGenerator.h.
References TVAnalysedPulseGenerator::fPulseList.
00044 {fPulseList=list;};
static const char* TVAnalysedPulseGenerator::TapType | ( | ) | [inline, static, inherited] |
Reimplemented in GaussFitAPGenerator, IntegralRatioAPGenerator, TemplateConvolveAPGenerator, and TemplateFitAPGenerator.
Definition at line 96 of file TVAnalysedPulseGenerator.h.
friend class MakeAnalysedPulses [friend, inherited] |
Definition at line 101 of file TVAnalysedPulseGenerator.h.
Definition at line 31 of file FirstCompleteAPGenerator.h.
Referenced by AnalyseOneTpi().
const Algorithm::MaxBinAmplitude FirstCompleteAPGenerator::fMaxBinAmplitude [private] |
Definition at line 30 of file FirstCompleteAPGenerator.h.
Referenced by AnalyseOneTpi().
Definition at line 35 of file FirstCompleteAPGenerator.h.
Referenced by FirstCompleteAPGenerator(), MakeTAPsWithPCF(), and ProcessPulses().
const Algorithm::SimpleIntegral FirstCompleteAPGenerator::fSimpleIntegral [private] |
Definition at line 32 of file FirstCompleteAPGenerator.h.
Referenced by AnalyseOneTpi().
Definition at line 39 of file FirstCompleteAPGenerator.h.
Referenced by DrawPulse(), MakeTAPsWithPCF(), and ~FirstCompleteAPGenerator().