3 #include <fwk/CentralConfig.h>
5 #include <utl/Reader.h>
6 #include <utl/ErrorLogger.h>
7 #include <utl/TimeStamp.h>
8 #include <utl/TimeInterval.h>
9 #include <utl/TraceAlgorithm.h>
12 #include <evt/Event.h>
14 #include <revt/REvent.h>
15 #include <revt/StationRecData.h>
16 #include <revt/Channel.h>
17 #include <revt/Station.h>
32 Branch topBranch = CentralConfig::GetInstance()->
GetTopBranch(
"RdChannelRiseTimeCalculator");
36 ERROR(
"this window should be narrower: short window around the main pulse");
49 WARNING(
"No radio event found!");
53 REvent& rEvent =
event.GetREvent();
78 Noisefinder(trace, noiseRMS, noiseWindowStart, noiseWindowStop);
81 double peakAmplitude = 0;
83 double peakTimeError = 0;
84 unsigned int maxPosition = 0;
85 Pulsefinder(trace, peakAmplitude, peakTime, peakTimeError, signalSearchWindowStart, signalSearchWindowStop, maxPosition);
92 const double samplingFrequency = 1. / trace.
GetBinning();
93 const double riseTimeWindowFrequency = fRiseTimeWindow * samplingFrequency;
94 int startRiseTimeWindow = 0;
95 int stopRiseTimeWindow = 0;
96 if (maxPosition != 0) {
97 const int half = 0.5 * riseTimeWindowFrequency;
98 startRiseTimeWindow = int(maxPosition) - half;
99 stopRiseTimeWindow = int(maxPosition) + half;
102 if (startRiseTimeWindow < 0) {
103 WARNING(
"RiseTimeWindowStart outside of trace, RiseTimeWindow adjusted to start of trace");
104 startRiseTimeWindow = 0;
105 stopRiseTimeWindow = riseTimeWindowFrequency;
110 double cumulativeSum = 0;
112 std::vector<double> cumulative;
113 MakeCumulative(trace, startRiseTimeWindow, stopRiseTimeWindow, cumulative, cumulativeSum);
116 std::vector<double> normalizedCumulative;
117 for (
const auto &value : cumulative)
118 normalizedCumulative.push_back(value / cumulativeSum);
122 GetRiseTime(startRiseTimeWindow, stopRiseTimeWindow, normalizedCumulative, riseTime, samplingFrequency);
133 double& rmsNoise,
const double noiseWindowStart,
const double noiseWindowStop)
136 const unsigned int start = noiseWindowStart / channeltrace.
GetBinning();
137 const unsigned int stop = noiseWindowStop / channeltrace.
GetBinning();
138 rmsNoise = TraceAlgorithm::RootMeanSquare(channeltrace, start, stop);
144 double& peakAmplitude,
double& peakTime,
double& peakTimeError,
145 const double signalSearchWindowStart,
const double signalSearchWindowStop,
146 unsigned int& sample)
150 unsigned int start = signalSearchWindowStart / channeltrace.
GetBinning();
151 unsigned int stop = signalSearchWindowStop / channeltrace.
GetBinning();
152 for (
unsigned int i = start; i < stop; ++i) {
153 if (channeltrace.
At(i) > peakAmplitude) {
154 peakAmplitude = channeltrace.
At(i);
165 const unsigned int startRiseTimeWindow,
const unsigned int stopRiseTimeWindow,
166 std::vector<double>& cumulative,
double &cumulativeSum)
169 for (
unsigned int k = startRiseTimeWindow; k < stopRiseTimeWindow + 1; ++k) {
170 cumulativeSum +=
Sqr(channeltrace.
At(k));
171 cumulative.push_back(cumulativeSum);
177 RdChannelRiseTimeCalculator::GetRiseTime(
const unsigned int startCumulative,
const unsigned int stopCumulative,
178 std::vector<double>& normalizedCumulative,
double &riseTime,
179 const double samplingFrequency)
182 bool foundmin =
false;
183 bool foundmax =
false;
184 unsigned int minCumulative = 0;
185 unsigned int maxCumulative = 0;
186 double lowerCumulativeLimit = 0.2;
187 double upperCumulativeLimit = 0.6;
189 for (
unsigned int k = startCumulative; k < stopCumulative + 1; ++k) {
191 if (normalizedCumulative.at(k - startCumulative) < lowerCumulativeLimit)
199 if (normalizedCumulative.at(k - startCumulative) < upperCumulativeLimit)
206 if (foundmin && foundmax)
209 riseTime = (maxCumulative - minCumulative) / samplingFrequency;
Branch GetTopBranch() const
void MakeRecData()
Make channel reconstructed data object.
T & At(const SizeType i)
trace entry with checked address
constexpr T Sqr(const T &x)
boost::filter_iterator< CandidateStationFilter, AllStationIterator > CandidateStationIterator
Iterator over all CandidateStations (i.e., HasSignal, HasNoSignal)
boost::indirect_iterator< InternalChannelIterator, Channel & > ChannelIterator
Iterator over station for read/write.
StationRecData & GetRecData()
Get station level reconstructed data.
CandidateStationIterator CandidateStationsEnd()
Interface class to access to the Radio part of an event.
void SetParameter(Parameter i, double value, bool lock=true)
double GetBinning() const
size of one slot
ChannelRecData & GetRecData()
Get channel level reconstructed data.
void Init()
Initialise the registry.
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
ChannelIterator ChannelsBegin()
begin Channel iterator for read/write
bool HasRecData() const
Check whether channel reconstructed data exists.
ChannelTimeSeries & GetChannelTimeSeries()
retrieve Channel Time Series (write access, only use this if you intend to change the data) ...
ChannelIterator ChannelsEnd()
end Channel iterator for read/write
Class representing a document branch.
class to hold data at the radio Station level.
constexpr double nanosecond
CandidateStationIterator CandidateStationsBegin()
#define WARNING(message)
Macro for logging warning messages.
void GetData(bool &b) const
Overloads of the GetData member template function.
double GetParameter(const Parameter i) const
ResultFlag
Flag returned by module methods to the RunController.
Class that holds the data associated to an individual radio channel.
#define ERROR(message)
Macro for logging error messages.