3 #include "QDbDetector.hh"
6 #include "QFiltersData.hh"
7 #include "QMainPulse.hh"
18 const QRawEvent& raw = ev->GetRawEvent();
19 const QMainPulse& pulse = raw.GetPulse();
20 fChannel = pulse.GetChannelId();
21 fEventNumber = raw.GetEventNumber();
23 fPassed = ev->GetFilters().GetPassed();
24 fPulseTimeOffset = ev->GetOB().GetStartTimeOffset();
26 fTimeFromStartRunNs = raw.GetTime().GetFromStartRunNs();
36 :
QModule(
"CoincidenceTiming",s)
58 const QRawEvent& raw = ev->GetRawEvent();
59 int thisRun = raw.GetRun();
67 = QDbDetector::GetPulserId(thisRun, thisEvent.
fChannel,
71 Info(
"%s",
err.GetDescription().c_str());
75 vector<int> relatives;
77 relatives = QDbDetector::GetRelativeChannels(thisRun,
82 Info(
"%s",
err.GetDescription().c_str());
85 if (relatives.size() > 0) {
99 SeqAuxData().GetQObject(
"RunData")) ) {
100 double samplingFrequency = runData->GetSamplingFrequency();
102 if (samplingFrequency != 0) {
115 double timeSinceEvent_SameChannel = -999;
116 double timeSinceEvent_DifferentChannel = -999;
117 double timeUntilEvent_SameChannel = -999;
118 double timeUntilEvent_DifferentChannel = -999;
120 int numberOfCoincidentEvents = 0;
121 int numberOfCoincidentEvents_SameHeaterGroup = 0;
124 int index = thisIndex;
125 double timeDifference = 0;
127 bool previousEventFound_SameChannel =
false;
128 bool previousEventFound_DifferentChannel =
false;
129 bool nextEventFound_SameChannel =
false;
130 bool nextEventFound_DifferentChannel =
false;
131 bool allFound =
false;
134 index = thisIndex - 1;
135 while (index >= 0 && (!allFound || timeDifference <
fTimeWindow)) {
140 if (!previousEventFound_SameChannel
142 timeSinceEvent_SameChannel = timeDifference;
143 previousEventFound_SameChannel =
true;
145 if (!previousEventFound_DifferentChannel
148 timeSinceEvent_DifferentChannel = timeDifference;
149 previousEventFound_DifferentChannel =
true;
154 ++numberOfCoincidentEvents;
157 ++numberOfCoincidentEvents_SameHeaterGroup;
162 allFound = previousEventFound_SameChannel
163 && previousEventFound_DifferentChannel;
167 index = thisIndex + 1;
176 if (!nextEventFound_SameChannel
178 timeUntilEvent_SameChannel = timeDifference;
179 nextEventFound_SameChannel =
true;
181 if (!nextEventFound_DifferentChannel
184 timeUntilEvent_DifferentChannel = timeDifference;
185 nextEventFound_DifferentChannel =
true;
190 ++numberOfCoincidentEvents;
193 ++numberOfCoincidentEvents_SameHeaterGroup;
198 allFound = nextEventFound_SameChannel
199 && nextEventFound_DifferentChannel;
201 ev->AuxData().SetDouble(
203 timeSinceEvent_SameChannel,
"save"
205 ev->AuxData().SetDouble(
207 timeSinceEvent_DifferentChannel,
"save"
209 ev->AuxData().SetDouble(
211 timeUntilEvent_SameChannel,
"save"
213 ev->AuxData().SetDouble(
215 timeUntilEvent_DifferentChannel,
"save"
217 ev->AuxData().SetInt(
219 numberOfCoincidentEvents,
"save"
221 ev->AuxData().SetInt(
223 +
"Events_SameHeaterGroup",
224 numberOfCoincidentEvents_SameHeaterGroup,
"save"
237 for (
unsigned int index = 0; index !=
fEventList.size(); ++index) {
238 int eventNumber =
fEventList[index].fEventNumber;
#define REGISTER_MODULE(clazz)
long long fTimeFromStartRunNs
void ApplyOffset(double samplingPeriod)
Module to identify coincident events.
MCoincidenceTiming(QSequence *s)
constructor
std::string fDetectorSetupFile
detector setup file for DB alternative
std::string fFilteredEventsType
Description of filtered events.
std::vector< EventInfo > fEventList
List of events passing the filter(s)
double fSamplingPeriod
Sampling period from QRunData.
double fTimeWindow
Time interval in which to search for coincident events.
std::map< int, unsigned int > fEventListIndex
Index for fEventList based on event number.
virtual ~MCoincidenceTiming()
destructor
std::map< int, ChannelInfo > fRelatedMap
map of channels with their heater channel and relative channel on the same crystal
bool fIsRunDataLoaded
Whether or not QRunData has been loaded.
QEvent * Do(QEvent *ev)
Do method.
bool fUsePulseStartTimeOffset
Whether or not to adjust time of event based on pulse slewing.
const std::string & GetString(const std::string &parname, const std::string &defVal, bool warnCfg=true) const
Get a string parameter from config file ( see GetDouble() )
unsigned int GetIteration() const
Get Current sequence iteration.
void Info(const char *descr,...) const
Send an info message (information) with printf syntax.
double GetDouble(const std::string &parname, double defVal, bool warnCfg=true) const
Get a double parameter from config file.
bool GetBool(const std::string &parname, bool defVal, bool warnCfg=true) const
Get a bool parameter from config file ( see GetDouble() )
void SetRunAgain(bool b)
Set that the sequence will be reiterated.
error class with error type and description
Base class for diana modules.
Diana Reconstruction program.