12 using std::stringstream;
13 using namespace Diana;
20 GetBool(
"SkipEvents",
false,
false);
22 if (GetIteration() == 1) {
24 fExpectedTimeInterval = GetDouble(
"ExpectedTimeInterval", -1);
25 if (fExpectedTimeInterval <= 0) {
26 fExpectedTimeInterval = 305.536;
29 fTimeIntervalUncertainty = GetDouble(
"TimeIntervalUncertainty", 0.500);
30 fTimeIntervalStepSize = GetDouble(
"TimeIntervalStepSize", 0.008);
32 int numberOfTimeAdjustments = GetInt(
"NumberOfTimeAdjustments", 0);
33 for (
int i = 1; i <= numberOfTimeAdjustments; ++i) {
34 stringstream parameterName;
35 parameterName <<
"TimeAdjustment_" << i << flush;
36 double timeAdjustment = GetDouble(parameterName.str(), 0.0);
37 fTimeAdjustments.push_back(timeAdjustment);
40 fTimeTolerance = GetDouble(
"TimeTolerance", 1.0);
41 fFalsePositiveRate = GetDouble(
"FalsePositiveRate", 0.001);
43 fUseCoincidences = GetBool(
"UseCoincidences",
false);
45 if (fUseCoincidences) {
46 fNecessaryCoincidentEvents = GetInt(
"NecessaryCoincidentEvents", 2);
47 fSufficientCoincidentEvents = GetInt(
"SufficientCoincidentEvents", 5);
48 fMaxRandomCoincidentEvents = GetInt(
"MaxRandomCoincidentEvents", 2);
52 ev.Add<
QBool>(
"IsPulser");
53 ev.Add<
QInt>(
"Goodness");
54 ev.Add<
QInt>(
"GoodnessThreshold");
55 if(fUseCoincidences) ev.Require<
QCoincidenceTiming>(
"CoincidenceTiming_PulserFlag",
"Timing");
58 ev.Require<
QHeader>(
"DAQ",
"Header");
67 const int&
channel = pulseInfo.GetChannelId();
69 const double time = header.
GetTime().GetFromStartRunNs() / 1e9;
72 if (GetIteration() == 1 && ev.
Get<
QBool>(
"SkipEvent")==
false) {
73 fTimingAnalyzer[
channel].AddValue(time);
75 else if (GetIteration() == 2) {
77 unsigned int goodness = 0;
78 unsigned int goodnessThreshold = 0;
80 if (fTimingAnalyzer.count(
channel) != 0) {
81 goodness = fTimingAnalyzer[
channel].GetGoodness(time);
82 goodnessThreshold = fTimingAnalyzer[
channel].GetGoodnessThreshold();
85 bool isPulser = (goodness > goodnessThreshold);
87 if (fUseCoincidences) {
94 && numberOfCoincidentEvents_SamePulserGroup
95 >= fNecessaryCoincidentEvents;
101 numberOfCoincidentEvents_SamePulserGroup
102 >= fSufficientCoincidentEvents
104 numberOfCoincidentEvents
105 <= numberOfCoincidentEvents_SamePulserGroup
106 + fMaxRandomCoincidentEvents
110 ev.
Get<
QBool>(
"IsPulser") = isPulser;
111 ev.
Get<
QInt>(
"Goodness") = goodness;
112 ev.
Get<
QInt>(
"GoodnessThreshold") = goodnessThreshold;
121 if (GetIteration() == 1) {
123 for (map<int, QTimingAnalyzer>::iterator channelIter
124 = fTimingAnalyzer.begin();
125 channelIter != fTimingAnalyzer.end();
128 Debug(
"Operating on channel %d", channelIter->first);
136 timingAnalyzer.
FindPeriod(fTimeIntervalUncertainty,
137 fTimeIntervalStepSize);
139 Info(
"Best time interval for channel %d: %f",
#define REGISTER_MODULE(clazz)
Flag heater events by their regular timing.
void Do(Diana::QEvent &ev)
Do method.
base types wrapped into a QObject. Currently implemented types are QInt QDouble and QFloat....
bool wrapped into a QObject
int fNumberOfCoincidentEvents_SameHeaterGroup
int fNumberOfCoincidentEvents
void Get(const char *owner, ReadHandle< Q > &handle) const
Get a QObject Handle in read mode.
Raw event: bolometer channel, trigger positions and types.
Analyzes a list of values for the occurance of elements separated by regular intervals.
void SetExpectedPeriod(const double period)
Set period for repetition of values.
void SetAdjustments(const std::vector< double > &adjustments)
Set adjustments.
void SetTolerance(const double tolerance)
Set size of window in which to look for event.
void ComputeGoodnessThreshold(const double falseRate)
Compute goodness threshold at given false positive rate.
double GetPeriod() const
Get period.
void FindPeriod(const double uncertainty, const double stepSize=0.008)
Find period by searching within 'uncertainty' of fPeriod.
the Diana namespace is needed because sometimes we use Qt libraries, that use same class names of our...