MaxTimeDiffMEGenerator Class Reference

#include <MaxTimeDiffMEGenerator.h>

Inheritance diagram for MaxTimeDiffMEGenerator:
TVMuonEventGenerator

List of all members.

Public Member Functions

 MaxTimeDiffMEGenerator (TMEGeneratorOptions *opts)
virtual ~MaxTimeDiffMEGenerator ()
virtual int ProcessPulses (MuonEventList &muonEventsOut, const SourceDetPulseMap &detectorPulsesIn)
const IDs::generatorGetGenerator () const

Protected Member Functions

bool Debug () const

Detailed Description

Definition at line 6 of file MaxTimeDiffMEGenerator.h.


Constructor & Destructor Documentation

MaxTimeDiffMEGenerator::MaxTimeDiffMEGenerator ( TMEGeneratorOptions opts  )  [inline]

Definition at line 9 of file MaxTimeDiffMEGenerator.h.

00009 : TVMuonEventGenerator("MaxTimeDiff",opts){};

virtual MaxTimeDiffMEGenerator::~MaxTimeDiffMEGenerator (  )  [inline, virtual]

Definition at line 10 of file MaxTimeDiffMEGenerator.h.

00010 {};


Member Function Documentation

bool TVMuonEventGenerator::Debug (  )  const [inline, protected, inherited]

Definition at line 25 of file TVMuonEventGenerator.h.

Referenced by 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 MaxTimeDiffMEGenerator::ProcessPulses ( MuonEventList muonEventsOut,
const SourceDetPulseMap detectorPulsesIn 
) [virtual]

Implements TVMuonEventGenerator.

Definition at line 9 of file MaxTimeDiffMEGenerator.cpp.

References TMuonEvent::AddPulse(), TVMuonEventGenerator::Debug(), TDetectorPulse::GetSource(), TDetectorPulse::GetTime(), GetTime(), and TMuonEvent::TotalNumPulses().

00010                                                           {
00011 
00012           std::vector<DetectorPulseList::const_iterator> pulseIters;
00013           std::vector<DetectorPulseList::const_iterator> finalIters;
00014           for(SourceDetPulseMap::const_iterator i_detector=detectorPulsesIn.begin();
00015                           i_detector!=detectorPulsesIn.end(); i_detector++){
00016                           pulseIters.push_back(i_detector->second.begin());
00017                           finalIters.push_back(i_detector->second.end());
00018           }
00019 
00020           // Loop through both TAnalysedPulse vectors until they are both finished
00021           double min_time = 999999; // something large
00022           double pulse_time;
00023           while (pulseIters.size() > 0) {
00024 
00025             // Find out which of the next fast or slow pulsees happened next
00026             for (unsigned int b = 0; b < pulseIters.size(); ++b) {
00027               pulse_time = (*pulseIters[b])->GetTime() * 1e-6; // convert to ms       
00028               min_time = std::min(min_time, pulse_time);
00029 
00030             }
00031 
00032             // Now go through and find all the pulses that are within a certain time of this
00033             double time_difference = 0.1; // 0.1 ms
00034             TMuonEvent* muon_event=new TMuonEvent();
00035             for (unsigned int b = 0; b < pulseIters.size(); ++b) {
00036 
00037               TDetectorPulse* pulse = *(pulseIters[b]);
00038               double pulse_time = pulse->GetTime() * 1e-6; // convert to ms
00039 
00040               if (std::fabs(pulse_time - min_time) < time_difference) {
00041                  if(Debug()) cout<<"Using pulse from: " << pulse->GetSource() << std::endl;
00042                  muon_event->AddPulse(pulse->GetSource(), pulse);
00043                 ++(pulseIters[b]); // increment the iterator because we used the pulse
00044               }
00045             }
00046             muonEventsOut.push_back(muon_event);
00047             if(Debug()){
00048                 cout<<"Created a TMuonEvent with "<<muon_event->TotalNumPulses();
00049                 cout<< std::endl;
00050             }
00051 
00052             //Delete the iterators to finished banks. Go through in reverse to
00053             //avoid invalidation problems
00054             for (int b = pulseIters.size()-1; b >= 0; --b) {
00055               if (pulseIters[b] == finalIters[b]){
00056                 pulseIters.erase(pulseIters.begin() + b);
00057                 finalIters.erase(finalIters.begin() + b);
00058               }  
00059             } // for (int b -reversed)        
00060           } // end for
00061 
00062           return 0;
00063 }


The documentation for this class was generated from the following files:

Generated on 15 Jun 2016 for AlcapDAQ by  doxygen 1.6.1