3 #include <fwk/CentralConfig.h>
4 #include <fwk/MagneticFieldModel.h>
6 #include <utl/ErrorLogger.h>
7 #include <utl/Reader.h>
8 #include <utl/config.h>
9 #include <utl/RadioGeometryUtilities.h>
10 #include <utl/FFTDataContainer.h>
11 #include <utl/FFTDataContainerAlgorithm.h>
12 #include <utl/RadioTraceUtilities.h>
14 #include <evt/Event.h>
15 #include <evt/ShowerRRecData.h>
16 #include <evt/ShowerRecData.h>
17 #include <evt/ShowerSRecData.h>
18 #include <evt/ShowerFRecData.h>
19 #include <evt/ShowerSimData.h>
21 #include <revt/REvent.h>
22 #include <revt/Header.h>
23 #include <revt/Station.h>
24 #include <revt/Channel.h>
25 #include <revt/StationRecData.h>
26 #include <revt/StationSimData.h>
41 topBranch.
GetChild(
"LowerCutoffFrequency").
GetData(fLowerCutoffFrequency);
42 topBranch.
GetChild(
"UpperCutoffFrequency").
GetData(fUpperCutoffFrequency);
43 topBranch.
GetChild(
"ApplyBandpassFilter").
GetData(fApplyBandpassFilter);
45 topBranch.
GetChild(
"SignalIntegrationWindowSize").
GetData(fSignalIntegrationWindowSize);
48 std::ostringstream info;
49 info <<
"\n\tApply bandpass filter: " << fApplyBandpassFilter
50 <<
" (" << fLowerCutoffFrequency /
MHz <<
" - " << fUpperCutoffFrequency /
MHz <<
") MHz"
51 <<
"\n\tUse hilbert envelope: " << fUseHilbertEnvelope
52 <<
"\n\tSize of the signal integration window: " << fSignalIntegrationWindowSize /
ns <<
" ns"
53 <<
"\n\tUse reference direction for coorindate transformation from: " << fReferenceShower <<
"\n";
63 auto& rEvent =
event.GetREvent();
64 const TimeStamp& rEventTime = rEvent.GetHeader().GetTime();
66 std::ostringstream info;
68 for (
auto& station : rEvent.StationsRange()) {
70 info <<
"Getting StationRecData for station " << station.GetId();
74 if (!station.HasSimData()) {
75 station.MakeSimData();
78 auto& stationSimData = station.GetSimData();
79 auto efieldData = station.GetFFTDataContainer();
80 auto& spectrum = efieldData.GetFrequencySpectrum();
83 if (fApplyBandpassFilter) {
84 for (
unsigned int i = 0; i < spectrum.GetSize(); ++i) {
85 if ((efieldData.GetFrequencyOfBin(i) < fLowerCutoffFrequency) ||
86 (efieldData.GetFrequencyOfBin(i) > fUpperCutoffFrequency)) {
87 spectrum[i][0] = std::complex<double>(0., 0.);
88 spectrum[i][1] = std::complex<double>(0., 0.);
89 spectrum[i][2] = std::complex<double>(0., 0.);
99 if (fUseHilbertEnvelope) {
102 auto efieldDataEnvelope = efieldData;
104 stationTraceForPeakFinding = efieldDataEnvelope.GetConstTimeSeries();
107 stationTraceForPeakFinding = stationTrace;
111 unsigned int peakInt = 0;
112 double peakAmplitude = 0;
114 double peakTimeError = 0;
115 const double windowstart = 0;
116 const double windowstop = stationTraceForPeakFinding.
GetStop() * stationTraceForPeakFinding.
GetBinning();
119 windowstart, windowstop, peakInt);
122 info <<
"Setting SimPulseTime of station " << station.GetId() <<
" to " << peakTime
123 <<
" (sample " << peakInt <<
")" <<
" and SimPulseAmplitude to " << peakAmplitude;
126 if (!peakAmplitude) {
128 info <<
"No sim pulse found for station " << station.GetId();
133 const TimeInterval traceStartTime = station.GetRawTraceStartTime() - rEventTime;
134 stationSimData.SetParameter(revt::eTraceStartTime, traceStartTime);
136 stationSimData.SetParameter(revt::eSignal, peakAmplitude);
137 stationSimData.SetParameter(revt::eSignalTime, peakTime + traceStartTime);
141 unsigned int maxPol = 0;
142 for (
unsigned int j = 0; j <= 2; ++j) {
143 for (
unsigned int i = 0; i < stationTrace.
GetSize(); ++i) {
144 if (fabs(stationTrace[i][j]) > maxPeak) {
145 maxPeak = fabs(stationTrace[i][j]);
152 unsigned int tMaxPos = 0;
153 double peakSearchWindow = 20. *
ns;
154 for (
unsigned int i = peakInt + peakSearchWindow / stationTrace.
GetBinning();
155 i > (peakInt - peakSearchWindow / stationTrace.
GetBinning()); --i) {
156 if (fabs(stationTrace[i][maxPol]) > tMaxAmp) {
157 tMaxAmp = fabs(stationTrace[i][maxPol]);
163 unsigned int FWHMlowerBound = 0;
164 unsigned int FWHMupperBound = 0;
165 for (
unsigned int i = tMaxPos; i > 0; --i) {
166 if (stationTraceForPeakFinding[i].GetMag() < peakAmplitude * .5) {
172 if (FWHMlowerBound == 0) {
173 INFODebug(
"FWHMLowerBound is 0. This may mean that something went wrong");
176 for (
unsigned int i = tMaxPos; i < stationTrace.
GetSize(); ++i) {
177 if (stationTraceForPeakFinding[i].GetMag() < peakAmplitude * .5) {
183 if (FWHMupperBound == stationTrace.
GetSize()) {
184 INFODebug(
"FWHMupperBound is the last entry in the station trace. This may mean that something went wrong");
188 TVector3 initialGuess(stationTrace[peakInt][0], stationTrace[peakInt][1], stationTrace[peakInt][2]);
189 TVector3 meanEField(0, 0, 0);
190 for (
unsigned int i = FWHMlowerBound; i < FWHMupperBound; ++i) {
191 TVector3 currentEField(stationTrace[i][0], stationTrace[i][1], stationTrace[i][2]);
192 if (currentEField.Angle(initialGuess) > 90. *
degree) {
195 meanEField += currentEField;
197 meanEField.SetMag(peakAmplitude);
200 info <<
"Sim E-field vector for this station is (" << meanEField[0] <<
","
201 << meanEField[1] <<
"," << meanEField[2] <<
").";
204 stationSimData.SetParameter(revt::eEFieldVectorEW, meanEField[0]);
205 stationSimData.SetParameter(revt::eEFieldVectorNS, meanEField[1]);
206 stationSimData.SetParameter(revt::eEFieldVectorV, meanEField[2]);
211 if (fReferenceShower ==
"Reference") {
216 if (fReferenceShower ==
"SD") {
219 showerAxis = recShower.
GetAxis();
221 if (fReferenceShower ==
"FD") {
224 showerAxis = recShower.
GetAxis();
226 if (fReferenceShower ==
"MC") {
241 TraceV3D traceShowerPlane = csTrans.GetTraceInShowerPlaneVxB(stationTrace);
244 double integratedSignal = 0;
245 for (
unsigned int i = 0; i <= 2; ++i) {
246 integratedSignal = 0;
247 stationChannel.
Clear();
250 for (
const auto& element : stationTrace) {
251 stationChannel.
PushBack(element.GetMag());
255 stationChannel.
PushBack(traceShowerPlane[j][i - 1]);
260 double integratedNoisePowerFixedWidthStartTime = 0;
261 double integratedNoisePowerFixedWidthStopTime = 0;
263 integratedSignal, integratedNoisePowerFixedWidthStartTime, integratedNoisePowerFixedWidthStopTime,
true);
267 stationSimData.SetParameter(revt::eSignalEnergyFluenceMag, energyFluence);
269 stationSimData.SetParameter(revt::eSignalEnergyFluenceVxB, energyFluence);
271 stationSimData.SetParameter(revt::eSignalEnergyFluenceVxVxB, energyFluence);
281 RdStationSimPulseFinder::Finish()
utl::Point GetReferenceCorePosition(const Event &event) const
Returning the reference core position depending on the corresponding flag.
static void PulseFixedWindowIntegrator(const utl::Trace< double > &channeltrace, unsigned int sample, double integrationTime, double &integratedSignal, double &signalWindowStart, double &signalWindowStop, const bool usePower)
static void HilbertEnvelope(FFTDataContainer< C, T, F > &container)
applies a HilbertEnvelope to the time series data
Interface class to access to the SD Reconstruction of a Shower.
SizeType GetStop() const
Get valid data stop bin.
Interface class to access to the RD Reconstruction of a Shower.
double GetBinning() const
size of one slot
void Init()
Initialise the registry.
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
A TimeStamp holds GPS second and nanosecond for some event.
Interface class to access Shower Simulated parameters.
#define INFOIntermediate(y)
Class representing a document branch.
const utl::Vector & GetDirection() const
Get the direction of the shower axis. This is the true direction of shower movement.
std::vector< T >::size_type SizeType
static MagneticFieldModel & instance()
const utl::Point & GetPosition() const
Get the position of the shower core.
static utl::Vector GetMagneticFieldVector(const utl::Point &position, const utl::TimeStamp &time)
returns the magnetic field at a specific place at a specific time
static void Pulsefinder(const utl::Trace< double > &channeltrace, double &peakAmplitude, double &peakTime, double &peakTimeError, double signalSearchWindowStart, double signalSearchWindowStop, unsigned int &sample)
const utl::Vector & GetAxis() const
void GetData(bool &b) const
Overloads of the GetData member template function.
void SetBinning(const double binning)
A TimeInterval is used to represent time elapsed between two events.
ResultFlag
Flag returned by module methods to the RunController.
unsigned long GetGPSSecond() const
GPS second.
static CentralConfig * GetInstance()
Use this the first time you get an instance of central configuration.
Template class for a FADC data or calibrated data container. Use the typedefs (TraceD, TraceI, etc.) defined in Trace-fwd.h.
Interface class to access to Fluorescence reconstruction of a Shower.
const utl::Point & GetCorePosition() const
constexpr double kConversionRadioSignalToEnergyFluence
utl::Vector GetReferenceAxis(const Event &event) const
Returning the referencedirection depending on the corresponding flag.
static Policy::type Create(const utl::Point &theOrigin)
Create the standard local coordinate system for a Point.
void PushBack(const T &value)
Insert a single value at the end.
const utl::Point & GetCorePosition() const
Shower core as reconstructed by the FD or FD eye.
utl::Branch GetTopBranch(const std::string &id)
Get top branch for moduleConfigLink with given id (XML files)
const utl::Vector & GetAxis() const
Shower Axis as reconstructed by the FD or FD eye.