RdStationSignalReconstructor/RdStationSignalReconstructor.cc
Go to the documentation of this file.
2 
3 #include <fwk/CentralConfig.h>
4 #include <fwk/LocalCoordinateSystem.h>
5 
6 #include <utl/ErrorLogger.h>
7 #include <utl/Trace.h>
8 #include <utl/AugerUnits.h>
9 #include <utl/FFTDataContainerAlgorithm.h>
10 #include <utl/RadioGeometryUtilities.h>
11 #include <utl/RadioTraceUtilities.h>
12 #include <utl/PhysicalConstants.h>
13 
14 #include <evt/Event.h>
15 #include <evt/ShowerRecData.h>
16 #include <evt/ShowerRRecData.h>
17 
18 #include <revt/REvent.h>
19 #include <revt/Station.h>
20 #include <revt/StationRecData.h>
21 #include <revt/StationTriggerData.h>
22 #include <revt/Channel.h>
23 
24 #include <det/Detector.h>
25 #include <rdet/RDetector.h>
26 #include <rdet/Station.h>
27 #include <rdet/Channel.h>
28 
29 #include <boost/algorithm/string/case_conv.hpp>
30 
31 #include <string>
32 
33 
34 using namespace revt;
35 using namespace fwk;
36 using namespace utl;
37 using namespace std;
38 
39 
41 
44  {
45  Branch topBranch = CentralConfig::GetInstance()->GetTopBranch("RdStationSignalReconstructor");
46  topBranch.GetChild("InfoLevel").GetData(fInfoLevel);
47 
48  topBranch.GetChild("VectorialComponent").GetData(fVectorialComponent);
49  topBranch.GetChild("useEnvelope").GetData(fUseEnvelope);
50  topBranch.GetChild("SignalIntegrationWindowSize").GetData(fSignalIntegrationWindowSize);
51  topBranch.GetChild("AddNoiseToUncertainty").GetData(fAddNoiseToUncertainty);
52  topBranch.GetChild("MinSignal").GetData(fMinSignal);
53  topBranch.GetChild("MinSignalToNoise").GetData(fMinSignalToNoise);
54  topBranch.GetChild("SelfTriggeredSNcut").GetData(fSelfTriggeredSNcut);
55  topBranch.GetChild("AdjustSignalAmplitude").GetData(fAdjustSignalAmplitude);
56 
57  topBranch.GetChild("AmplitudeUncertainty").GetData(fAmplitudeUncertainty);
58  topBranch.GetChild("DefaultAntennaUncertainty").GetData(fDefaultAntennaUncertainty);
59  topBranch.GetChild("ButterflyAntennaUncertainty").GetData(fButterflyAntennaUncertainty);
60  topBranch.GetChild("BlackSpiderAntennaUncertainty").GetData(fBlackSpiderAntennaUncertainty);
61  topBranch.GetChild("SallaRDAntennaUncertainty").GetData(fSallaRDAntennaUncertainty);
62 
63  const string yesnostr = topBranch.GetChild("allowMultipleCalls").Get<string>();
64  fLockParameterStorage = (yesnostr == "no");
65 
66  ostringstream info;
67  info << "\n\t Vectorial component : " << fVectorialComponent
68  << "\n\t Use Envelope : " << fUseEnvelope
69  << "\n\t Min. SNR : " << fMinSignalToNoise
70  << "\n\t Signal inegration window : " << fSignalIntegrationWindowSize << "ns"
71  << "\n\t Add Noise to uncertainty : " << fAddNoiseToUncertainty
72  << "\n\t Ampl. uncertainty / % : " << fAmplitudeUncertainty
73  << "\n\t Rel. antenna pattern uncertainty / %"
74  << "\n\t (LPDA / BF / Salla_RD / Default): (" << fBlackSpiderAntennaUncertainty
75  << " / " << fButterflyAntennaUncertainty
76  << " / " << fSallaRDAntennaUncertainty
77  << " / " << fDefaultAntennaUncertainty << ")\n";
78 
79  INFO(info);
80  return eSuccess;
81  }
82 
83 
85  RdStationSignalReconstructor::Run(evt::Event& event)
86  {
87  // Check if there are events at all
88  if (!event.HasREvent()) {
89  WARNING("No radio event found!");
90  return eContinueLoop;
91  }
92 
93  REvent& rEvent = event.GetREvent();
94 
95  ostringstream info;
96  int numberOfStationsWithPulseFound = 0;
97 
98  // loop through candidate stations
99  for (auto& station : rEvent.StationsRange()) {
100 
101  // RRecStation event should have been generated by RdEventInitializer
102  if (!station.HasRecData()) {
103  WARNING("Station has no RecData! Please call RdEventInitializer first!");
104  return eFailure;
105  }
106  StationRecData& recStation = station.GetRecData();
107 
108  const double signalSearchWindowStart = recStation.GetParameter(eSignalSearchWindowStart);
109  const double signalSearchWindowStop = recStation.GetParameter(eSignalSearchWindowStop);
110 
111  info.str("");
112  info << "Signal search window: " << signalSearchWindowStart << " to " << signalSearchWindowStop;
113  INFODebug(info);
114 
115  if (station.HasRejectedReason(eSignalSearchWindowInvalid)) {
116  info.str();
117  info << "Station " << station.GetId() << " has invalid signal search window from "
118  << signalSearchWindowStart << " to " << signalSearchWindowStop
119  << ". Skipping station.";
120  WARNING(info);
121 
122  continue;
123  }
124 
125  // time that is added to all times determined in a trace in ns
126  const double relTime = recStation.GetParameter(eTraceStartTime);
127 
128  info.str("");
129  info << "Apply pulse finder on station " << station.GetId();
130  INFOIntermediate(info);
131 
132  // Read the time trace of this station
133  // getting a local copy of the electric field data
134  StationFFTDataContainer efieldData = station.GetFFTDataContainer();
135  if (fUseEnvelope)
136  FFTDataContainerAlgorithm::HilbertEnvelope(efieldData);
137 
138  info.str("");
139  info << "size of efield trace = " << efieldData.GetConstTimeSeries().GetSize();
140  INFODebug(info);
141 
142  const StationTimeSeries& stationtrace = efieldData.GetConstTimeSeries();
143  // get a fresh copy without the envelope
144  const StationTimeSeries& stationTraceNoEnvelope = station.GetFFTDataContainer().GetConstTimeSeries();
145 
146  // temporary channel trace to which the selected station data is copied
147  ChannelTimeSeries channeltrace;
148  channeltrace.SetBinning(stationtrace.GetBinning());
149  ChannelTimeSeries channelTraceNoEnvelope;
150  channelTraceNoEnvelope.SetBinning(stationTraceNoEnvelope.GetBinning());
151 
152  // are not const because clipped when outside the trace
153  double noiseWindowStart = recStation.GetParameter(eNoiseWindowStart);
154  double noiseWindowStop = recStation.GetParameter(eNoiseWindowStop);
155 
156  const double signalIntegrationWindowSize = fSignalIntegrationWindowSize;
157  recStation.SetParameter(eSignalIntegrationTime, fSignalIntegrationWindowSize, fLockParameterStorage);
158 
159  bool pulseFound = false;
160 
161  double signalWindowStart = 0;
162  double signalWindowStop = 0;
163 
164  double noiseMean = 0;
165  double noiseRMS = 0;
166 
167  unsigned int peakBin = 0;
168  unsigned int sample = 0;
169 
170  double peakAmplitude = 0;
171  double peakTime = 0;
172  double peakTimeError = 0;
173 
174  /* The following loop calculates the signal quantities for the different polarisations/components
175  of the electric field. The VectorialComponent defined in the config defines which compenent is
176  used for, among other things, the definition of the signal to noise ratio.
177  component = 0 is absolute value of vectorial sum of station vector data
178  component = 1 is x, 2 is y, 3 is z
179  component = 4 is xy-plane
180  component 5-6 is vxB and vxvxB plane
181  */
182  const unsigned int numComponents = 7;
183  for (unsigned int iterator = 0; iterator < numComponents; ++iterator) {
184  // loop has to start at fVectorialComponent so that start time is set correctly
185  const unsigned int component = (iterator + fVectorialComponent) % numComponents;
186 
187  // fixme TH: it would be nice to reserve the appropriate space in the trace here,
188  // but utl::Trace does not offer that functionality (yet)
189  channeltrace.Clear();
190  channelTraceNoEnvelope.Clear();
191 
192  // Absolute value of vectorial sum of station vector data
193  if (component == 0) {
194  for (StationTimeSeries::SizeType i = 0; i < stationtrace.GetSize(); ++i) {
195  channeltrace.PushBack(stationtrace[i].GetMag());
196  channelTraceNoEnvelope.PushBack(stationTraceNoEnvelope[i].GetMag());
197 
198  if (isnan(stationtrace[i].GetMag()) || isnan(stationTraceNoEnvelope[i].GetMag())) {
199  info.str("");
200  info << "sample " << i << " of efield trace is nan";
201  WARNING(info);
202  }
203  }
204  } else if (component == 1 || component == 2 || component == 3) {
205  // 1 is x, 2 is y, 3 is z
206  for (StationTimeSeries::SizeType i = 0; i < stationtrace.GetSize(); ++i) {
207  channeltrace.PushBack(abs(stationtrace[i][component - 1]));
208  channelTraceNoEnvelope.PushBack(abs(stationTraceNoEnvelope[i][component - 1]));
209  }
210  } else if (component == 4) {
211  // xy-plane
212  for (StationTimeSeries::SizeType i = 0; i < stationtrace.GetSize(); ++i) {
213  channeltrace.PushBack(sqrt(Sqr(stationtrace[i][0]) + Sqr(stationtrace[i][1])));
214  channelTraceNoEnvelope.PushBack(sqrt(Sqr(stationTraceNoEnvelope[i][0]) +
215  Sqr(stationTraceNoEnvelope[i][1])));
216  }
217  } else if (component == 5 || component == 6) {
218  // vxB and vxvxB plane
219  evt::ShowerRRecData& recShower = event.GetRecShower().GetRRecShower();
220 
221  if (!(recShower.HasReferenceCorePosition(event) && recShower.HasReferenceAxis(event))) {
222  WARNING("Reference direction or core position not set. "
223  "The electric-field can not be rotated into the vxB, vx(vxB) system. "
224  "The calculation will be skipped");
225  continue;
226  }
227 
228  // rotate trace to shower xy-plane
229  const CoordinateSystemPtr coreCS =
230  LocalCoordinateSystem::Create(recShower.GetReferenceCorePosition(event));
231  Vector showerAxis = recShower.GetReferenceAxis(event);
232 
233  RadioGeometryUtilities csTrans =
234  RadioGeometryUtilities(showerAxis, coreCS, recShower.GetMagneticFieldVector());
235 
236  TraceV3D traceShowerPlane = csTrans.GetTraceInShowerPlaneVxB(stationtrace);
237  TraceV3D traceShowerPlaneNoEnvelope = csTrans.GetTraceInShowerPlaneVxB(stationTraceNoEnvelope);
238 
239  for (unsigned int i = 0; i < traceShowerPlane.GetSize(); ++i) {
240  channeltrace.PushBack(traceShowerPlane[i][component - 5]);
241  channelTraceNoEnvelope.PushBack(traceShowerPlaneNoEnvelope[i][component - 5]);
242  }
243  } else {
244  // should never reach that
245  ERROR("This component does not exist!");
246  return eFailure;
247  }
248 
249  // clip windows at trace boundaries
250  const double traceStop = (channeltrace.GetSize() - 1) * channeltrace.GetBinning();
251  noiseWindowStart = min(max(0., noiseWindowStart), traceStop);
252  noiseWindowStop = max(min(noiseWindowStop, traceStop), noiseWindowStart);
253 
254  // calculate noise and find pulse
255  RadioTraceUtilities::Noisefinder(channeltrace, noiseRMS, noiseMean, noiseWindowStart, noiseWindowStop);
256  RadioTraceUtilities::Pulsefinder(channeltrace, peakAmplitude, peakTime, peakTimeError,
257  signalSearchWindowStart, signalSearchWindowStop, sample);
258 
259  if (component == fVectorialComponent)
260  peakBin = sample;
261 
262  // calculate signal energy fluence
263  double signalEnergyFluence = 0;
264  RadioTraceUtilities::PulseFixedWindowIntegrator(channelTraceNoEnvelope, peakBin, signalIntegrationWindowSize,
265  signalEnergyFluence, signalWindowStart, signalWindowStop, true);
266 
267  // calculate noise energy fluence
268  double noiseEnergyFluence = 0;
269  double integratedNoisePowerFixedWidthStartTime = 0;
270  double integratedNoisePowerFixedWidthStopTime = 0;
271  const double noiseWindowSize = noiseWindowStop - noiseWindowStart;
272  const unsigned int meanNoiseSample = (noiseWindowStart + noiseWindowSize * 0.5) / channelTraceNoEnvelope.GetBinning();
273  RadioTraceUtilities::PulseFixedWindowIntegrator(channelTraceNoEnvelope, meanNoiseSample, noiseWindowSize,
274  noiseEnergyFluence, integratedNoisePowerFixedWidthStartTime,
275  integratedNoisePowerFixedWidthStopTime, true);
276 
277  // normalize noise integral to size of integration window
278  noiseEnergyFluence *= signalIntegrationWindowSize / noiseWindowSize;
279  signalEnergyFluence = signalEnergyFluence - noiseEnergyFluence;
280 
281  double signalEnergyFluenceError = sqrt(
282  2 * Sqr(noiseRMS) * channelTraceNoEnvelope.GetBinning() *
283  (2 * abs(signalEnergyFluence) + signalIntegrationWindowSize * Sqr(noiseRMS))
284  );
285 
286  // convert to energy fluence
287  signalEnergyFluence *= kConversionRadioSignalToEnergyFluence;
288  noiseEnergyFluence *= kConversionRadioSignalToEnergyFluence;
289  signalEnergyFluenceError *= kConversionRadioSignalToEnergyFluence;
290 
291  const double antennaToAntennaUncertainty = GetAntennaToAntennaUncertainty(station);
292 
293  info.str("");
294  info << "Station " << station.GetId() << " component " << component << " signaltime (sample) "
295  << peakTime << "(" << sample << ") Integrating f around sample " << peakBin
296  << " f = " << signalEnergyFluence << " f noise = " << noiseEnergyFluence
297  << " sigma_f = " << signalEnergyFluenceError
298  << " AmplitudeUncertainty = " << fAmplitudeUncertainty
299  << " antennaToAntennaUncertainty = " << antennaToAntennaUncertainty;
300  INFODebug(info);
301 
302  // add relative uncertainty (a factor "2" is used because the energy fluence scales with amplitude squared)
303  signalEnergyFluenceError = sqrt(
304  Sqr(signalEnergyFluenceError) +
305  Sqr(fAmplitudeUncertainty * 2 * signalEnergyFluence) +
306  Sqr(antennaToAntennaUncertainty * 2 * signalEnergyFluence)
307  );
308 
309  // calculate signal to noise ratio
310  double signalToNoise = nan("");
311  if (noiseRMS > 0)
312  signalToNoise = peakAmplitude / noiseRMS;
313 
314  // fill the generic variables using the options selected in the xml file
315  if (component == fVectorialComponent) {
316  info.str("");
317  info << "Pulsefinder startsample = " << signalWindowStart << " lastsample = " << signalWindowStop;
318  INFODebug(info);
319 
320  const auto signalToNoise2 = Sqr(signalToNoise);
321 
322  peakTimeError = sqrt(Sqr(peakTimeError) + Sqr(GetSignalTimeUncertainty(signalToNoise2)));
323 
324  recStation.SetParameter(eSignalTime, relTime + peakTime, fLockParameterStorage);
325  recStation.SetParameterError(eSignalTime,
326  sqrt(Sqr(peakTimeError) + Sqr(recStation.GetParameterError(eTraceStartTime))),
327  fLockParameterStorage
328  );
329 
330  if (fAdjustSignalAmplitude)
331  peakAmplitude = GetAdjustedSignalAmplitude(peakAmplitude, signalToNoise2);
332 
333  const auto sigUnc = GetSignalUncertainty(peakAmplitude, signalToNoise2);
334  info.str("");
335  info << "SNR = " << signalToNoise2 << "\t"
336  "signal amplitude = " << peakAmplitude << "\t"
337  "Uncertainty of SignalAmplitude = " << sigUnc;
338  INFODebug(info);
339 
340  const double tempUncertainty = sqrt(
341  Sqr(sigUnc) +
342  Sqr(peakAmplitude * fAmplitudeUncertainty) +
343  Sqr(peakAmplitude * antennaToAntennaUncertainty)
344  );
345 
346  recStation.SetParameter(eSignalToNoise, signalToNoise2, fLockParameterStorage);
347  recStation.SetParameter(eNoise, noiseRMS, fLockParameterStorage);
348  recStation.SetParameter(eSignal, peakAmplitude, fLockParameterStorage);
349 
350  recStation.SetParameterError(eSignal, tempUncertainty, fLockParameterStorage);
351 
352  recStation.SetParameter(eSignalWindowStart, signalWindowStart, fLockParameterStorage);
353  recStation.SetParameter(eSignalWindowStop, signalWindowStop, fLockParameterStorage);
354  recStation.SetParameter(eMinSignal, fMinSignal, fLockParameterStorage);
355  recStation.SetParameter(eMinSignalToNoise, fMinSignalToNoise, fLockParameterStorage);
356  }
357 
358  /* Add noise level to uncertainty. This factor is not well motivated,
359  however the uncertainty of weak signals seems underestimated otherwise.
360  Previously this has been done by the LDFFitter modules individually. */
361  if (fAddNoiseToUncertainty)
362  signalEnergyFluenceError = sqrt(Sqr(signalEnergyFluenceError) + Sqr(noiseEnergyFluence));
363 
364  // fill the variables
365  if (component == 0) {
366  recStation.SetParameter(ePeakAmplitudeMag, peakAmplitude, fLockParameterStorage);
367  recStation.SetParameter(ePeakTimeMag, relTime + peakTime, fLockParameterStorage);
368  recStation.SetParameter(eNoiseRmsMag, noiseRMS, fLockParameterStorage);
369  recStation.SetParameter(eNoiseMeanMag, noiseMean, fLockParameterStorage);
370  recStation.SetParameter(eSignalEnergyFluenceMag, signalEnergyFluence, fLockParameterStorage);
371  recStation.SetParameterError(eSignalEnergyFluenceMag, signalEnergyFluenceError, fLockParameterStorage);
372  recStation.SetParameter(eNoiseEnergyFluenceMag, noiseEnergyFluence, fLockParameterStorage);
373  } else if (component == 1) {
374  recStation.SetParameter(ePeakAmplitudeEW, peakAmplitude, fLockParameterStorage);
375  recStation.SetParameter(ePeakTimeEW, relTime + peakTime, fLockParameterStorage);
376  recStation.SetParameter(eNoiseRmsEW, noiseRMS, fLockParameterStorage);
377  recStation.SetParameter(eNoiseMeanEW, noiseMean, fLockParameterStorage);
378  recStation.SetParameter(eSignalEnergyFluenceEW, signalEnergyFluence, fLockParameterStorage);
379  recStation.SetParameterError(eSignalEnergyFluenceEW, signalEnergyFluenceError, fLockParameterStorage);
380  recStation.SetParameter(eNoiseEnergyFluenceEW, noiseEnergyFluence, fLockParameterStorage);
381  } else if (component == 2) {
382  recStation.SetParameter(ePeakAmplitudeNS, peakAmplitude, fLockParameterStorage);
383  recStation.SetParameter(ePeakTimeNS, relTime + peakTime, fLockParameterStorage);
384  recStation.SetParameter(eNoiseRmsNS, noiseRMS, fLockParameterStorage);
385  recStation.SetParameter(eNoiseMeanNS, noiseMean, fLockParameterStorage);
386  recStation.SetParameter(eSignalEnergyFluenceNS, signalEnergyFluence, fLockParameterStorage);
387  recStation.SetParameterError(eSignalEnergyFluenceNS, signalEnergyFluenceError, fLockParameterStorage);
388  recStation.SetParameter(eNoiseEnergyFluenceNS, noiseEnergyFluence, fLockParameterStorage);
389  } else if (component == 3) {
390  recStation.SetParameter(ePeakAmplitudeV, peakAmplitude, fLockParameterStorage);
391  recStation.SetParameter(ePeakTimeV, relTime + peakTime, fLockParameterStorage);
392  recStation.SetParameter(eNoiseRmsV, noiseRMS, fLockParameterStorage);
393  recStation.SetParameter(eNoiseMeanV, noiseMean, fLockParameterStorage);
394  recStation.SetParameter(eSignalEnergyFluenceV, signalEnergyFluence, fLockParameterStorage);
395  recStation.SetParameterError(eSignalEnergyFluenceV, signalEnergyFluenceError, fLockParameterStorage);
396  recStation.SetParameter(eNoiseEnergyFluenceV, noiseEnergyFluence, fLockParameterStorage);
397  } else if (component == 4) {
398  recStation.SetParameter(ePeakAmplitudeNSEWPlane, peakAmplitude, fLockParameterStorage);
399  recStation.SetParameter(ePeakTimeNSEWPlane, relTime + peakTime, fLockParameterStorage);
400  recStation.SetParameter(eNoiseRmsNSEWPlane, noiseRMS, fLockParameterStorage);
401  recStation.SetParameter(eNoiseMeanNSEWPlane, noiseMean, fLockParameterStorage);
402  recStation.SetParameter(eSignalEnergyFluenceNSEWPlane, signalEnergyFluence, fLockParameterStorage);
403  recStation.SetParameterError(eSignalEnergyFluenceNSEWPlane, signalEnergyFluenceError, fLockParameterStorage);
404  recStation.SetParameter(eNoiseEnergyFluenceNSEWPLane, noiseEnergyFluence, fLockParameterStorage);
405  } else if (component == 5) {
406  recStation.SetParameter(ePeakAmplitudeVxB, peakAmplitude, fLockParameterStorage);
407  recStation.SetParameter(ePeakTimeVxB, relTime + peakTime, fLockParameterStorage);
408  recStation.SetParameter(eNoiseRmsVxB, noiseRMS, fLockParameterStorage);
409  recStation.SetParameter(eNoiseMeanVxB, noiseMean, fLockParameterStorage);
410  recStation.SetParameter(eSignalEnergyFluenceVxB, signalEnergyFluence, fLockParameterStorage);
411  recStation.SetParameterError(eSignalEnergyFluenceVxB, signalEnergyFluenceError, fLockParameterStorage);
412  recStation.SetParameter(eNoiseEnergyFluenceVxB, noiseEnergyFluence, fLockParameterStorage);
413  recStation.SetParameter(eSignalToNoiseVxB, signalToNoise, fLockParameterStorage);
414  } else if (component == 6) {
415  recStation.SetParameter(ePeakAmplitudeVxVxB, peakAmplitude, fLockParameterStorage);
416  recStation.SetParameter(ePeakTimeVxVxB, relTime + peakTime, fLockParameterStorage);
417  recStation.SetParameter(eNoiseRmsVxVxB, noiseRMS, fLockParameterStorage);
418  recStation.SetParameter(eNoiseMeanVxVxB, noiseMean, fLockParameterStorage);
419  recStation.SetParameter(eSignalEnergyFluenceVxVxB, signalEnergyFluence, fLockParameterStorage);
420  recStation.SetParameterError(eSignalEnergyFluenceVxVxB, signalEnergyFluenceError, fLockParameterStorage);
421  recStation.SetParameter(eNoiseEnergyFluenceVxVxB, noiseEnergyFluence, fLockParameterStorage);
422  recStation.SetParameter(eSignalToNoiseVxVxB, signalToNoise, fLockParameterStorage);
423  }
424 
425  if (component == fVectorialComponent) {
426  info.str("");
427 
428  if ((recStation.GetParameter(eSignalToNoise) > fMinSignalToNoise ||
429  (station.GetTriggerData().GetTriggerSource() == StationTriggerData::eSelf &&
430  !fSelfTriggeredSNcut)) &&
431  recStation.GetParameter(eSignal) > fMinSignal) {
432 
433  info << "pulse found for station " << station.GetId();
434  ++numberOfStationsWithPulseFound;
435  pulseFound = true;
436 
437  // if the station is already rejected (eg. due to saturation) it can not be set to signal station here
438  if (station.IsRejected()) {
439  info << ", but station is already rejected.";
440  } else {
441  info << ", setting station to signal station";
442  station.SetSignal();
443  }
444  } else {
445  info << "no pulse found for station " << station.GetId();
446  pulseFound = false;
447  station.SetNoSignal();
448  }
449 
450  INFOIntermediate(info);
451  recStation.SetPulseFound(pulseFound);
452  }
453  } // end of component loop
454  } // end station loop
455 
456  if (!event.HasRecShower())
457  event.MakeRecShower();
458 
459  evt::ShowerRecData& shower = event.GetRecShower();
460  if (!shower.HasRRecShower())
461  shower.MakeRRecShower();
462 
463  info.str("");
464  info << "Found " << numberOfStationsWithPulseFound << " stations with signal pulse";
465  INFOFinal(info);
466 
467  if (fLockParameterStorage)
468  fNumberOfStationsInEvents[numberOfStationsWithPulseFound]++;
469 
470  return eSuccess;
471  }
472 
473 
475  RdStationSignalReconstructor::Finish()
476  {
477  ostringstream info;
478 
479  const auto totalEvents =
480  accumulate(fNumberOfStationsInEvents.begin(), fNumberOfStationsInEvents.end(), 0,
481  [](const size_t sum, const auto& p){ return sum + p.second; });
482 
483  info << "Event statistics:\n\t" << totalEvents << " event(s) total:";
484 
485  if (!totalEvents) {
486  info << "\nNo events stored in the map. "
487  "This can happen if the parameter storage is kept unlocked, "
488  "e.g. for the iterative geometry reconstruction";
489  } else {
490  if (fInfoLevel == eInfoFinal) {
491  const auto eventsMoreThanFiveStations = totalEvents -
492  fNumberOfStationsInEvents[0] - fNumberOfStationsInEvents[1] -
493  fNumberOfStationsInEvents[2] - fNumberOfStationsInEvents[3] -
494  fNumberOfStationsInEvents[4] - fNumberOfStationsInEvents[5];
495 
496  info << "\n\t" << fNumberOfStationsInEvents[1] << " event(s) with 1 signal station"
497  << "\n\t" << fNumberOfStationsInEvents[2] << " event(s) with 2 signal stations"
498  << "\n\t" << fNumberOfStationsInEvents[3] << " event(s) with 3 signal stations"
499  << "\n\t" << fNumberOfStationsInEvents[4] << " event(s) with 4 signal stations"
500  << "\n\t" << fNumberOfStationsInEvents[5] << " event(s) with 5 signal stations"
501  << "\n\t" << eventsMoreThanFiveStations << " events with more than 5 signal stations";
502  }
503 
504  if (fInfoLevel == eInfoIntermediate) {
505  for (const auto& sn : fNumberOfStationsInEvents)
506  info << "\n\t" << sn.second << " event(s) with " << sn.first << " station(s)";
507  }
508  }
509 
510  INFO(info);
511 
512  return eSuccess;
513  }
514 
515 
516  double
517  RdStationSignalReconstructor::GetAdjustedSignalAmplitude(const double signalAmpitude, const double snr)
518  const
519  {
520  const double factor = 1 / (1 + 1.55 / pow(snr, 2.43/2));
521  ostringstream info;
522  info << "adjusting signal amplitude with a factor of " << factor;
523  INFODebug(info);
524 
525  return signalAmpitude * factor;
526  }
527 
528 
529  double
530  RdStationSignalReconstructor::GetSignalUncertainty(const double signalAmplitude, const double snr)
531  const
532  {
533  return (0.423 / sqrt(snr) - 0.501 / snr + 3.395 / pow(snr, 1.5)) * signalAmplitude;
534  }
535 
536 
537  double
538  RdStationSignalReconstructor::GetSignalTimeUncertainty(const double snr)
539  const
540  {
541  return 11.7*ns * pow(snr, -0.71);
542  }
543 
544 
545  double
546  RdStationSignalReconstructor::GetAntennaToAntennaUncertainty(const Station& station)
547  const
548  {
549  double antennaToAntennaUncertainty = 0;
550  const auto& rDet = det::Detector::GetInstance().GetRDetector();
551  for (const auto& channel : station.ChannelsRange()) {
552  const auto cid = channel.GetId();
553  const auto& antennaName = rDet.GetStation(station).GetChannel(cid).GetAntennaTypeName();
554  const auto& an = boost::algorithm::to_lower_copy(antennaName);
555  if (an.find("butterfly") != string::npos) {
556  if (antennaToAntennaUncertainty < fButterflyAntennaUncertainty)
557  antennaToAntennaUncertainty = fButterflyAntennaUncertainty;
558  } else if (an.find("blackspider") != string::npos) {
559  if (antennaToAntennaUncertainty < fBlackSpiderAntennaUncertainty)
560  antennaToAntennaUncertainty = fBlackSpiderAntennaUncertainty;
561  } else if (an.find("salla_rd") != string::npos) {
562  if (antennaToAntennaUncertainty < fSallaRDAntennaUncertainty)
563  antennaToAntennaUncertainty = fSallaRDAntennaUncertainty;
564  } else {
565  if (antennaToAntennaUncertainty < fDefaultAntennaUncertainty)
566  antennaToAntennaUncertainty = fDefaultAntennaUncertainty;
567  }
568  }
569  return antennaToAntennaUncertainty;
570  }
571 
572 }
Branch GetTopBranch() const
Definition: Branch.cc:63
Class to access station level reconstructed data.
void SetParameterError(Parameter i, double value, bool lock=true)
utl::Point GetReferenceCorePosition(const Event &event) const
Returning the reference core position depending on the corresponding flag.
constexpr T Sqr(const T &x)
void SetPulseFound(const bool pulsefound)
Interface class to access Shower Reconstructed parameters.
Definition: ShowerRecData.h:33
bool HasRecShower() const
Interface class to access to the Radio part of an event.
Definition: REvent.h:42
Interface class to access to the RD Reconstruction of a Shower.
double GetParameterError(const Parameter i) const
bool HasReferenceAxis(const Event &event) const
Return always true for SD and FD if RecShower exsist, asking for min. rec stage could fix this...
double GetBinning() const
size of one slot
Definition: Trace.h:138
#define INFO(message)
Macro for logging informational messages.
Definition: ErrorLogger.h:161
void Init()
Initialise the registry.
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
Definition: Branch.cc:211
double pow(const double x, const unsigned int i)
bool HasREvent() const
T Get() const
Definition: Branch.h:271
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
#define INFOIntermediate(y)
Definition: VModule.h:162
#define max(a, b)
Class representing a document branch.
Definition: Branch.h:107
class to hold data at the radio Station level.
std::vector< T >::size_type SizeType
Definition: Trace.h:58
const double ns
double abs(const SVector< n, T > &v)
bool HasRRecShower() const
void Clear()
Definition: Trace.h:158
SizeType GetSize() const
Definition: Trace.h:156
#define WARNING(message)
Macro for logging warning messages.
Definition: ErrorLogger.h:163
void GetData(bool &b) const
Overloads of the GetData member template function.
Definition: Branch.cc:644
#define INFODebug(y)
Definition: VModule.h:163
PulseFinder searches for maximum in the trace. Choose vectorial component in the xml file...
double GetParameter(const Parameter i) const
void SetBinning(const double binning)
Definition: Trace.h:139
Template class for a data container that offers and takes both time series and corresponding frequenc...
ResultFlag
Flag returned by module methods to the RunController.
Definition: VModule.h:60
bool HasReferenceCorePosition(const Event &event) const
Return always true for SD and FD if RecShower exsist, asking for min. rec stage could fix this...
Template class for a FADC data or calibrated data container. Use the typedefs (TraceD, TraceI, etc.) defined in Trace-fwd.h.
Definition: Trace-fwd.h:19
void SetParameter(Parameter i, double value, bool lock=true)
Vector object.
Definition: Vector.h:30
constexpr double kConversionRadioSignalToEnergyFluence
utl::Vector GetReferenceAxis(const Event &event) const
Returning the referencedirection depending on the corresponding flag.
#define INFOFinal(y)
Definition: VModule.h:161
void PushBack(const T &value)
Insert a single value at the end.
Definition: Trace.h:119
utl::Vector GetMagneticFieldVector() const
returns the magnetic field vector from the components stored in the parameter storage ...
#define ERROR(message)
Macro for logging error messages.
Definition: ErrorLogger.h:165
utl::TraceV3D GetTraceInShowerPlaneVxB(const utl::TraceV3D &trace) const

, generated on Tue Sep 26 2023.