#include <FixedWindowMEGenerator.h>
Classes | |
struct | Detector_t |
Public Member Functions | |
FixedWindowMEGenerator (TMEGeneratorOptions *opts) | |
virtual | ~FixedWindowMEGenerator () |
virtual int | ProcessPulses (MuonEventList &muonEventsOut, const SourceDetPulseMap &detectorPulsesIn) |
const IDs::generator & | GetGenerator () const |
Protected Member Functions | |
bool | Debug () const |
Private Types | |
typedef std::vector< Detector_t > | SourceList |
Private Member Functions | |
int | Init (const SourceDetPulseMap &) |
void | Reset () |
void | AddPulsesInWindow (TMuonEvent *tme, double window, Detector_t &detector) |
Private Attributes | |
bool | fInit |
double | fEventWindow |
Detector_t | fMuSc |
SourceList | fDetectors |
Definition at line 8 of file FixedWindowMEGenerator.h.
typedef std::vector<Detector_t> FixedWindowMEGenerator::SourceList [private] |
Definition at line 29 of file FixedWindowMEGenerator.h.
FixedWindowMEGenerator::FixedWindowMEGenerator | ( | TMEGeneratorOptions * | opts | ) |
Definition at line 12 of file FixedWindowMEGenerator.cpp.
References fEventWindow, and modules::options::GetDouble().
00012 : 00013 TVMuonEventGenerator("FixedWindow",opts),fInit(true){ 00014 fEventWindow=opts->GetDouble("event_window",1e4); 00015 }
virtual FixedWindowMEGenerator::~FixedWindowMEGenerator | ( | ) | [inline, virtual] |
Definition at line 33 of file FixedWindowMEGenerator.h.
void FixedWindowMEGenerator::AddPulsesInWindow | ( | TMuonEvent * | tme, | |
double | window, | |||
Detector_t & | detector | |||
) | [private] |
Definition at line 77 of file FixedWindowMEGenerator.cpp.
References TMuonEvent::AddPulses(), TMuonEvent::AllPulsesUsed(), FixedWindowMEGenerator::Detector_t::end_window, TMuonEvent::GetTime(), TDetectorPulse::kFast, FixedWindowMEGenerator::Detector_t::pulses, FixedWindowMEGenerator::Detector_t::source, and FixedWindowMEGenerator::Detector_t::start_window.
Referenced by ProcessPulses().
00078 { 00079 // Get the central time for this event; 00080 double central_time=tme->GetTime(); 00081 double early_edge=central_time-window; 00082 double late_edge=central_time+window; 00083 00084 // advance the start and stop iterators that define the range of pulses 00085 // contained in the window 00086 DetectorPulseList::const_iterator& start=detector.start_window; 00087 DetectorPulseList::const_iterator& stop=detector.end_window; 00088 const DetectorPulseList::const_iterator& end=detector.pulses->end(); 00089 //const DetectorPulseList::const_iterator& begin=detector.pulses->begin(); 00090 00091 // skip empty lists 00092 if(start==end) return; 00093 00094 // Move the iterator for the start of the window 00095 DetectorPulseList::const_iterator i_tmp=start; 00096 while( (i_tmp !=end)){ 00097 // skip over bad TDPs 00098 while( (i_tmp!=end) && !(*i_tmp)->IsGood() ) ++i_tmp; 00099 // if there are no TDPs left we can finish already 00100 if(i_tmp==end) return; 00101 double time=(*i_tmp)->GetTime(TDetectorPulse::kFast); 00102 if(time<early_edge) ++i_tmp; 00103 else break; 00104 } 00105 start=i_tmp; 00106 // Move the iteator for the end of the window 00107 while( (i_tmp !=end)){ 00108 // skip over bad TDPs 00109 while( (i_tmp!=end) && !(*i_tmp)->IsGood() ) ++i_tmp; 00110 // if there are no TDPs left we can finish already 00111 if(i_tmp==end) break; 00112 double time=(*i_tmp)->GetTime(TDetectorPulse::kFast); 00113 if(time<late_edge) ++i_tmp; 00114 else break; 00115 } 00116 stop=i_tmp; 00117 00118 // Add all pulses in the current window to the tme 00119 tme->AddPulses(*detector.source,start,stop); 00120 00121 // Flag if we've used all of a channels pulses 00122 if(stop==detector.pulses->end()) tme->AllPulsesUsed(*detector.source); 00123 }
bool TVMuonEventGenerator::Debug | ( | ) | const [inline, protected, inherited] |
Definition at line 25 of file TVMuonEventGenerator.h.
Referenced by MaxTimeDiffMEGenerator::ProcessPulses().
00025 {return fDebug;};
const IDs::generator& TVMuonEventGenerator::GetGenerator | ( | ) | const [inline, inherited] |
Definition at line 22 of file TVMuonEventGenerator.h.
References TVMuonEventGenerator::fGenerator.
00022 {return fGenerator;}
int FixedWindowMEGenerator::Init | ( | const SourceDetPulseMap & | detectorPulsesIn | ) | [private] |
Definition at line 17 of file FixedWindowMEGenerator.cpp.
References fDetectors, fMuSc, IDs::source::isWildCardChannel(), IDs::kMuSc, and FixedWindowMEGenerator::Detector_t::source.
Referenced by ProcessPulses().
00017 { 00018 for(SourceDetPulseMap::const_iterator i_source=detectorPulsesIn.begin(); 00019 i_source!=detectorPulsesIn.end();++i_source){ 00020 // if i_source->source is muSc then 00021 if(i_source->first.matches(IDs::channel(IDs::kMuSc))){ 00022 // if source is wildcard then select fMuSc 00023 if(!fMuSc.source || fMuSc.source->isWildCardChannel()){ 00024 fMuSc=Detector_t(i_source); 00025 }else{ 00026 cout<<"FixedWindowMEGenerator: Error: Multiple muSc TDP sources found"<<endl; 00027 return 1; 00028 } 00029 }else{ 00030 fDetectors.push_back(Detector_t(i_source)); 00031 } 00032 } 00033 return 0; 00034 }
int FixedWindowMEGenerator::ProcessPulses | ( | MuonEventList & | muonEventsOut, | |
const SourceDetPulseMap & | detectorPulsesIn | |||
) | [virtual] |
Implements TVMuonEventGenerator.
Definition at line 44 of file FixedWindowMEGenerator.cpp.
References AddPulsesInWindow(), fDetectors, fEventWindow, fInit, fMuSc, Init(), FixedWindowMEGenerator::Detector_t::pulses, and Reset().
00045 { 00046 if(fInit) { 00047 int error=Init(detectorPulsesIn); 00048 if(error) return error; 00049 fInit=false; 00050 }else{ 00051 Reset(); 00052 } 00053 00054 // Loop over all muons 00055 for(DetectorPulseList::const_iterator i_muSc=fMuSc.pulses->begin(); 00056 i_muSc!=fMuSc.pulses->end(); ++i_muSc){ 00057 // Make a TME centred on this muon 00058 TMuonEvent* tme=new TMuonEvent(*i_muSc, fEventWindow); 00059 00060 // Add all muon pulses in the event window to this TME 00061 AddPulsesInWindow(tme,fEventWindow,fMuSc); 00062 00063 for(SourceList::iterator i_det=fDetectors.begin(); 00064 i_det!=fDetectors.end(); ++i_det){ 00065 // Add all pulses in the event window to this TME 00066 AddPulsesInWindow(tme,fEventWindow,*i_det); 00067 } 00068 //if(Debug()) cout<<"FixedWindowMEGenerator::ProcessPulses:" 00069 // " Created TME with "<<tme->TotalNumPulses()<<" pulses" <<endl; 00070 00071 // Add TME to list of event 00072 muonEventsOut.push_back(tme); 00073 } 00074 return 0; 00075 }
void FixedWindowMEGenerator::Reset | ( | ) | [private] |
Definition at line 36 of file FixedWindowMEGenerator.cpp.
References fDetectors, fMuSc, and FixedWindowMEGenerator::Detector_t::Reset().
Referenced by ProcessPulses().
00036 { 00037 fMuSc.Reset(); 00038 for(SourceList::iterator i_det=fDetectors.begin(); 00039 i_det!=fDetectors.end(); ++i_det){ 00040 i_det->Reset(); 00041 } 00042 }
SourceList FixedWindowMEGenerator::fDetectors [private] |
Definition at line 48 of file FixedWindowMEGenerator.h.
Referenced by Init(), ProcessPulses(), and Reset().
double FixedWindowMEGenerator::fEventWindow [private] |
Definition at line 46 of file FixedWindowMEGenerator.h.
Referenced by FixedWindowMEGenerator(), and ProcessPulses().
bool FixedWindowMEGenerator::fInit [private] |
Definition at line 45 of file FixedWindowMEGenerator.h.
Referenced by ProcessPulses().
Detector_t FixedWindowMEGenerator::fMuSc [private] |
Definition at line 47 of file FixedWindowMEGenerator.h.
Referenced by Init(), ProcessPulses(), and Reset().