#include <MaxTimeDiffDPGenerator.h>
Public Member Functions | |
MaxTimeDiffDPGenerator (TDPGeneratorOptions *opts) | |
virtual | ~MaxTimeDiffDPGenerator () |
virtual bool | ChecksForPileUp () const |
virtual int | ProcessPulses (DetectorPulseList &output) |
void | SetPulseSources (const IDs::source &fast, const IDs::source &slow) |
void | SetPulseLists (const AnalysedPulseList *fast, const AnalysedPulseList *slow) |
void | SetDebug (const bool &val=true) |
bool | Debug () |
TDetectorPulse * | MakeTDP (int fast_parent, int slow_parent) const |
IDs::source | GetSource () const |
IDs::source | GetFastSource () const |
IDs::source | GetSlowSource () const |
void | SetChannel (const IDs::channel &ch) |
IDs::generator | GetGeneratorID () const |
const AnalysedPulseList * | FastPulseList () const |
const AnalysedPulseList * | SlowPulseList () const |
const AnalysedPulseList * | PulseList (bool getFast) const |
Private Attributes | |
double | fTimeDifference |
Definition at line 6 of file MaxTimeDiffDPGenerator.h.
MaxTimeDiffDPGenerator::MaxTimeDiffDPGenerator | ( | TDPGeneratorOptions * | opts | ) |
Definition at line 10 of file MaxTimeDiffDPGenerator.cpp.
References fTimeDifference, and modules::options::GetDouble().
00010 : 00011 TVDetectorPulseGenerator("MaxTimeDiff",opts),fTimeDifference(0.1){ 00012 fTimeDifference=opts->GetDouble("time_difference",fTimeDifference); 00013 }
virtual MaxTimeDiffDPGenerator::~MaxTimeDiffDPGenerator | ( | ) | [inline, virtual] |
Definition at line 10 of file MaxTimeDiffDPGenerator.h.
virtual bool MaxTimeDiffDPGenerator::ChecksForPileUp | ( | ) | const [inline, virtual] |
Implements TVDetectorPulseGenerator.
Definition at line 11 of file MaxTimeDiffDPGenerator.h.
bool TVDetectorPulseGenerator::Debug | ( | ) | [inline, inherited] |
Definition at line 34 of file TVDetectorPulseGenerator.h.
References TVDetectorPulseGenerator::fDebug.
Referenced by ProcessPulses().
00034 {return fDebug;};
const AnalysedPulseList* TVDetectorPulseGenerator::FastPulseList | ( | ) | const [inline, inherited] |
Definition at line 53 of file TVDetectorPulseGenerator.h.
References TVDetectorPulseGenerator::fFastPulses.
Referenced by ProcessPulses().
00053 {return fFastPulses;}
IDs::source TVDetectorPulseGenerator::GetFastSource | ( | ) | const [inline, inherited] |
Definition at line 48 of file TVDetectorPulseGenerator.h.
References TVDetectorPulseGenerator::fFastSource.
Referenced by ProcessPulses().
00048 {return fFastSource;};
IDs::generator TVDetectorPulseGenerator::GetGeneratorID | ( | ) | const [inline, inherited] |
Definition at line 51 of file TVDetectorPulseGenerator.h.
References TVDetectorPulseGenerator::fSource, and IDs::source::Generator().
Referenced by MakeDetectorPulses::MakeGenerator().
IDs::source TVDetectorPulseGenerator::GetSlowSource | ( | ) | const [inline, inherited] |
Definition at line 49 of file TVDetectorPulseGenerator.h.
References TVDetectorPulseGenerator::fSlowSource.
Referenced by ProcessPulses().
00049 {return fSlowSource;};
IDs::source TVDetectorPulseGenerator::GetSource | ( | ) | const [inline, inherited] |
Definition at line 47 of file TVDetectorPulseGenerator.h.
References TVDetectorPulseGenerator::fSource.
Referenced by MakeDetectorPulses::GetPassThruGeneratorID(), and TVDetectorPulseGenerator::MakeTDP().
00047 {return fSource;};
TDetectorPulse* TVDetectorPulseGenerator::MakeTDP | ( | int | fast_parent, | |
int | slow_parent | |||
) | const [inline, inherited] |
Definition at line 36 of file TVDetectorPulseGenerator.h.
References TVDetectorPulseGenerator::fFastPulses, TVDetectorPulseGenerator::fSlowPulses, and TVDetectorPulseGenerator::GetSource().
Referenced by PassThroughDPGenerator::ProcessPulses(), and ProcessPulses().
00036 { 00037 TDetectorPulse* pulse=NULL; 00038 const TAnalysedPulse* fast=NULL; 00039 if(fFastPulses && fast_parent>=0) fast=fFastPulses->at(fast_parent); 00040 const TAnalysedPulse* slow=NULL; 00041 if(fSlowPulses && slow_parent>=0) slow=fSlowPulses->at(slow_parent); 00042 if(fast || slow) { 00043 pulse=new TDetectorPulse(GetSource(),fast_parent,fast,slow_parent,slow); 00044 } 00045 return pulse; 00046 }
int MaxTimeDiffDPGenerator::ProcessPulses | ( | DetectorPulseList & | output | ) | [virtual] |
Implements TVDetectorPulseGenerator.
Definition at line 15 of file MaxTimeDiffDPGenerator.cpp.
References TVDetectorPulseGenerator::Debug(), TVDetectorPulseGenerator::FastPulseList(), fTimeDifference, TVDetectorPulseGenerator::GetFastSource(), TVDetectorPulseGenerator::GetSlowSource(), TAnalysedPulse::GetSource(), TDetectorPulse::GetTime(), TAnalysedPulse::GetTime(), GetTime(), IDs::source::isFast(), IDs::source::isSlow(), TDetectorPulse::kFast, TDetectorPulse::kSlow, TVDetectorPulseGenerator::MakeTDP(), TVDetectorPulseGenerator::SlowPulseList(), and IDs::source::str().
00015 { 00016 00017 if(!SlowPulseList()) { 00018 cout<<"Error: No pulse list for slow channel, "<<GetFastSource()<<" with MaxTimeDiffDPGenerator"<<endl; 00019 return 1; 00020 } else if(!FastPulseList()) { 00021 cout<<"Error: No pulse list for fast channel, "<<GetSlowSource()<<" with MaxTimeDiffDPGenerator"<<endl; 00022 return 2; 00023 } 00024 00025 AnalysedPulseList::const_iterator fastPulseIter = FastPulseList()->begin(); 00026 AnalysedPulseList::const_iterator slowPulseIter = SlowPulseList()->begin(); 00027 AnalysedPulseList::const_iterator finalFastPulseIter = FastPulseList()->end(); 00028 AnalysedPulseList::const_iterator finalSlowPulseIter = SlowPulseList()->end(); 00029 00030 std::vector< std::pair< 00031 AnalysedPulseList::const_iterator, 00032 AnalysedPulseList::const_iterator> > pulseIters; 00033 pulseIters.push_back(std::make_pair(fastPulseIter,finalFastPulseIter)); 00034 pulseIters.push_back(std::make_pair(slowPulseIter,finalSlowPulseIter)); 00035 00036 // Loop through both TAnalysedPulse vectors until they are both finished 00037 // NB with this alogirthm this can be extended to more than 2 00038 double min_time = 999999; // something large 00039 double pulse_time; 00040 //int count=0; 00041 int fast_pulse, slow_pulse; 00042 while (pulseIters.size() > 0) { 00043 fast_pulse=-1.; 00044 slow_pulse=-1.; 00045 min_time = 999999e9; 00046 00047 // Find out which of the next fast or slow pulses happened next 00048 for (unsigned int b = 0; b < pulseIters.size(); ++b) { 00049 pulse_time = (*pulseIters.at(b).first)->GetTime() * 1e-6; // convert to ms 00050 min_time = std::min(min_time, pulse_time); 00051 00052 } 00053 00054 // Now go through and find all the pulses that are within a certain time of this 00055 for (unsigned int b = 0; b < pulseIters.size(); ++b) { 00056 00057 TAnalysedPulse* pulse = *(pulseIters[b].first); 00058 double pulse_time = pulse->GetTime() * 1e-6; // convert to ms 00059 00060 if (std::fabs(pulse_time - min_time) < fTimeDifference) { 00061 if ( pulse->GetSource().isFast()) { 00062 if(Debug()) cout<<"Fast? " << pulse->GetSource().str() << std::endl; 00063 fast_pulse = pulseIters[b].first - FastPulseList()->begin(); 00064 } else if ( pulse->GetSource().isSlow()) { 00065 if(Debug()) cout<<"Slow? " << pulse->GetSource().str() << std::endl; 00066 slow_pulse = pulseIters[b].first - SlowPulseList()->begin(); 00067 } 00068 00069 ++(pulseIters[b].first); // increment the iterator because we used the pulse 00070 } 00071 } 00072 TDetectorPulse* det_pulse = MakeTDP( fast_pulse, slow_pulse); // Create the TDetectorPulse 00073 if(det_pulse){ 00074 output.push_back(det_pulse); 00075 if(Debug()){ 00076 cout<<"Created a TDetectorPulse with:\n"; 00077 cout<<"Fast Pulse: " << det_pulse->GetTime(TDetectorPulse::kFast) * 1e-6 << std::endl; 00078 cout<< "Slow Pulse: " << det_pulse->GetTime(TDetectorPulse::kSlow) * 1e-6 << std::endl; 00079 cout<< std::endl; 00080 } 00081 } 00082 00083 //Delete the iterators to finished banks. Go through in reverse to 00084 //avoid invalidation problems 00085 for (int b = pulseIters.size()-1; b >= 0; --b) { 00086 if (pulseIters[b].first == pulseIters[b].second){ 00087 pulseIters.erase(pulseIters.begin() + b); 00088 } 00089 } // for (int b -reversed) 00090 } // end for 00091 return 0; 00092 }
const AnalysedPulseList* TVDetectorPulseGenerator::PulseList | ( | bool | getFast | ) | const [inline, inherited] |
Definition at line 55 of file TVDetectorPulseGenerator.h.
References TVDetectorPulseGenerator::fFastPulses, and TVDetectorPulseGenerator::fSlowPulses.
Referenced by PassThroughDPGenerator::ProcessPulses().
00055 {return getFast?fFastPulses:fSlowPulses;}
void TVDetectorPulseGenerator::SetChannel | ( | const IDs::channel & | ch | ) | [inline, inherited] |
Definition at line 50 of file TVDetectorPulseGenerator.h.
References IDs::source::Channel(), and TVDetectorPulseGenerator::fSource.
void TVDetectorPulseGenerator::SetDebug | ( | const bool & | val = true |
) | [inline, inherited] |
Definition at line 33 of file TVDetectorPulseGenerator.h.
References TVDetectorPulseGenerator::fDebug.
Referenced by MakeDetectorPulses::MakeGenerator().
00033 {fDebug=val;};
void TVDetectorPulseGenerator::SetPulseLists | ( | const AnalysedPulseList * | fast, | |
const AnalysedPulseList * | slow | |||
) | [inline, inherited] |
Definition at line 28 of file TVDetectorPulseGenerator.h.
References TVDetectorPulseGenerator::fFastPulses, and TVDetectorPulseGenerator::fSlowPulses.
Referenced by PassThroughDPGenerator::ProcessPulses().
00028 { 00029 fFastPulses=fast; 00030 fSlowPulses=slow; 00031 }
void TVDetectorPulseGenerator::SetPulseSources | ( | const IDs::source & | fast, | |
const IDs::source & | slow | |||
) | [inline, inherited] |
Definition at line 24 of file TVDetectorPulseGenerator.h.
References TVDetectorPulseGenerator::fFastSource, and TVDetectorPulseGenerator::fSlowSource.
Referenced by MakeDetectorPulses::MakeGenerator().
00024 { 00025 fFastSource=fast; 00026 fSlowSource=slow; 00027 }
const AnalysedPulseList* TVDetectorPulseGenerator::SlowPulseList | ( | ) | const [inline, inherited] |
Definition at line 54 of file TVDetectorPulseGenerator.h.
References TVDetectorPulseGenerator::fSlowPulses.
Referenced by ProcessPulses().
00054 {return fSlowPulses;}
double MaxTimeDiffDPGenerator::fTimeDifference [private] |
Definition at line 17 of file MaxTimeDiffDPGenerator.h.
Referenced by MaxTimeDiffDPGenerator(), and ProcessPulses().