3 #include <fwk/CentralConfig.h>
4 #include <fwk/LocalCoordinateSystem.h>
6 #include <utl/ErrorLogger.h>
7 #include <utl/Reader.h>
8 #include <utl/config.h>
10 #include <utl/TraceAlgorithm.h>
11 #include <utl/TimeStamp.h>
12 #include <utl/TimeInterval.h>
13 #include <utl/AugerUnits.h>
14 #include <utl/AugerException.h>
15 #include <utl/FFTDataContainerAlgorithm.h>
17 #include <utl/RadioGeometryUtilities.h>
18 #include <utl/HannWindow.h>
19 #include <utl/AnalyticCoordinateTransformator.h>
20 #include <utl/AxialVector.h>
21 #include <utl/Vector.h>
23 #include <evt/Event.h>
24 #include <evt/ShowerRecData.h>
25 #include <evt/ShowerRRecData.h>
26 #include <evt/ShowerRRecDataQuantities.h>
27 #include <revt/REvent.h>
28 #include <revt/Header.h>
29 #include <revt/Station.h>
30 #include <revt/StationRecData.h>
31 #include <revt/StationHeader.h>
32 #include <revt/StationTriggerData.h>
33 #include <revt/Channel.h>
35 #include <det/Detector.h>
36 #include <rdet/RDetector.h>
37 #include <rdet/Station.h>
38 #include <rdet/Channel.h>
41 #include "Minuit2/Minuit2Minimizer.h"
42 #include "Minuit2/MnMigrad.h"
43 #include "Minuit2/FunctionMinimum.h"
44 #include "Minuit2/MinimumParameters.h"
45 #include "Minuit2/MnPrint.h"
47 #include <boost/algorithm/string/case_conv.hpp>
51 #include "TGraphErrors.h"
53 #include "simuroutine.C"
59 using std::stringstream;
60 using std::ostringstream;
68 #define OUT(x) if ((x) <= fInfoLevel) cerr << " "
76 INFO(
"RdStationSignalReconstructorWithBgSubtraction::Init()");
79 Branch topBranch = CentralConfig::GetInstance()->
GetTopBranch(
"RdStationSignalReconstructorWithBgSubtraction");
82 topBranch.
GetChild(
"SignalIntegrationWindowSize").
GetData(fSignalIntegrationWindowSize);
83 topBranch.
GetChild(
"EnergyFluenceIntegrationWindowStart").
GetData(fEnergyFluenceIntegrationWindowStart);
84 topBranch.
GetChild(
"EnergyFluenceIntegrationWindowStop").
GetData(fEnergyFluenceIntegrationWindowStop);
87 topBranch.
GetChild(
"RelativeWindowWidthOnEachSide").
GetData(fWindowSizeOnEachSide);
89 topBranch.
GetChild(
"BackGroundSubtraction").
GetData(fBackGroundSubtraction);
90 topBranch.
GetChild(
"DefaultAntennaUncertainty").
GetData(fDefaultAntennaUncertainty);
91 topBranch.
GetChild(
"ButterflyAntennaUncertainty").
GetData(fButterflyAntennaUncertainty);
92 topBranch.
GetChild(
"BlackSpiderAntennaUncertainty").
GetData(fBlackSpiderAntennaUncertainty);
93 topBranch.
GetChild(
"RelativeAmplitudeUncertainty").
GetData(fRelativeAmplitudeUncertainty);
97 fWindow =
new HannWindow(fWindowSizeOnEachSide);
99 f_sigmoind =
new TF1(
"f_sigmoind",
"[0]*(-(TMath::Pi()*0.5)+TMath::ATan([1]*(x-1)+TMath::Tan((-1./[0])+(TMath::Pi()*0.5))))",0, 10);
100 f_sigmoind->FixParameter(0, 4.);
101 f_sigmoind->FixParameter(1, 0.3);
104 info <<
"\n\t Vectorial component: " << fVectorialComponent
105 <<
"\n\t Signal inegration window: " << fSignalIntegrationWindowSize <<
"ns";
112 RdStationSignalReconstructorWithBgSubtraction::Run(
evt::Event& event)
114 if (fInfoLevel >= eInfoIntermediate)
115 INFO(
"RdStationSignalReconstructorWithBgSubtraction::Run()");
119 WARNING(
"No radio event found!");
120 return eContinueLoop;
123 ++fTotalNumberOfEvents;
125 ostringstream message;
127 REvent& rEvent =
event.GetREvent();
130 int numberOfStationsWithPulseFound = 0;
132 time_t timeAllStation = time(
nullptr);
137 time_t timeStation = time(
nullptr);
143 WARNING(
"Station has no RecData! Please call RdEventInitializer first!");
152 info <<
"Apply pulse finder on station " << station.
GetId();
160 FFTDataContainerAlgorithm::HilbertEnvelope(efieldData);
161 OUT(eInfoDebug) <<
"size of efield trace = " << efieldData.GetConstTimeSeries().GetSize() << endl;
183 double NoiseWindowStart = recStation.
GetParameter(eNoiseWindowStart);
184 double NoiseWindowStop = recStation.
GetParameter(eNoiseWindowStop);
185 double SignalSearchWindowStart = recStation.
GetParameter(eSignalSearchWindowStart);
186 double SignalSearchWindowStop = recStation.
GetParameter(eSignalSearchWindowStop);
187 double SignalWindowStart = 0;
188 double SignalWindowStop = 0;
189 double SignalIntegrationWindowSize = fSignalIntegrationWindowSize;
190 double Integral_lowerLimit = fEnergyFluenceIntegrationWindowStart;
191 double Integral_upperLimit = fEnergyFluenceIntegrationWindowStop;
193 recStation.
SetParameter(revt::eSignalIntegrationTime, fSignalIntegrationWindowSize);
195 bool PulseFound =
false;
196 double MeanNoise = 0;
198 unsigned int sampleNSEW = 0;
199 unsigned int sample = 0;
200 double PeakAmplitude = 0;
201 double IntegratedSignal = 0;
202 double SignalTimeFWHM = 0;
204 double PeakTimeError = 0;
205 double SignalToNoise = 0;
206 unsigned int binsSignal = 0;
207 unsigned int nBinFreq = 0;
208 double freqBinning = 0;
215 channeltrace.
Clear();
216 channeltrace_noenvelope.
Clear();
219 channeltrace_noenvelope.
PushBack(
sqrt(
Sqr(stationtrace_noenvelope[i][0]) +
Sqr(stationtrace_noenvelope[i][1])));
221 Pulsefinder(channeltrace, PeakAmplitude, PeakTime, PeakTimeError,
222 SignalSearchWindowStart, SignalSearchWindowStop, sampleNSEW);
224 unsigned int NumComponents = 7;
225 std::vector<double> UncertantySignalSpectrum[NumComponents];
226 std::vector<double> UncertantyBackGroundSpectrum[NumComponents];
230 for (
unsigned int component = 0; component < NumComponents; ++component) {
231 channel_spectrum[component].
Clear();
232 channel_spectrum_bg[component].
Clear();
233 channeltrace.
Clear();
234 channeltrace_noenvelope.
Clear();
238 UncertantySignalSpectrum[component].clear();
239 UncertantyBackGroundSpectrum[component].clear();
242 if (component == 0 || component == 1 || component == 2) {
244 channeltrace.
PushBack(stationtrace[i][component]);
245 channeltrace_noenvelope.
PushBack(stationtrace_noenvelope[i][component]);
247 }
else if (component == 3) {
249 channeltrace.
PushBack(stationtrace[i].GetMag());
250 if (std::isnan(stationtrace[i].GetMag())) {
252 message <<
"sample " << i <<
" of efield trace is nan";
255 channeltrace_noenvelope.
PushBack(stationtrace_noenvelope[i].GetMag());
256 if (std::isnan(stationtrace_noenvelope[i].GetMag())) {
258 message <<
"sample " << i <<
" of efield trace is nan";
262 }
else if (component == 4) {
265 channeltrace_noenvelope.
PushBack(
sqrt(
Sqr(stationtrace_noenvelope[i][0]) +
Sqr(stationtrace_noenvelope[i][1])));
267 }
else if (component == 5 || component == 6) {
271 WARNING(
"Reference direction or core position not set. "
272 "The electric-field can not be rotated into the vxB, vx(vxB) system. "
273 "The calculation will be skipped");
281 utl::TraceV3D traceShowerPlane = csTrans.GetTraceInShowerPlaneVxB(stationtrace);
282 utl::TraceV3D traceShowerPlane_noenvelope = csTrans.GetTraceInShowerPlaneVxB(stationtrace_noenvelope);
283 for (
unsigned int i = 0; i < traceShowerPlane.GetSize(); ++i) {
284 channeltrace.
PushBack(traceShowerPlane[i][component - 5]);
285 channeltrace_noenvelope.
PushBack(traceShowerPlane_noenvelope[i][component - 5]);
289 ERROR(
"This component does not exist!");
294 double TraceStop = (channeltrace.
GetSize() - 1) * channeltrace_noenvelope.
GetBinning();
295 NoiseWindowStart = min(
max(0.0, NoiseWindowStart), TraceStop);
296 NoiseWindowStop =
max(min(NoiseWindowStop, TraceStop), NoiseWindowStart);
299 Noisefinder(channeltrace, RMSNoise, MeanNoise, NoiseWindowStart, NoiseWindowStop);
300 Pulsefinder(channeltrace, PeakAmplitude, PeakTime, PeakTimeError,
301 SignalSearchWindowStart, SignalSearchWindowStop, sample);
304 PulseFWHMIntegrator(channeltrace, sample, PeakAmplitude, SignalTimeFWHM, IntegratedSignal,
305 SignalWindowStart, SignalWindowStop);
307 SignalToNoise = RMSNoise > 0 ? PeakAmplitude/RMSNoise : 0;
310 if (component == 0 || component == 1) {
312 unsigned int start = int(
max(0., round(sampleNSEW*1. - SignalIntegrationWindowSize * 0.5 / channeltrace_noenvelope.
GetBinning())));
313 unsigned int stop = int(min(channeltrace_noenvelope.
GetSize() * 1., round(sampleNSEW*1. + SignalIntegrationWindowSize * 0.5 / channeltrace_noenvelope.
GetBinning())));
314 binsSignal = stop - start;
315 fWindow->SetTraceLength(binsSignal+1);
317 for (
unsigned int i = start; i <=stop; ++i) {
323 double U_1 = (start > 2*binsSignal) ?
double(start - 2*binsSignal) / double(binsSignal) : 0;
324 double U_2 = (channeltrace_noenvelope.
GetSize() > (stop + 2*binsSignal + 2*binsSignal)) ? double(channeltrace_noenvelope.
GetSize() - (stop + 2*binsSignal + 2*binsSignal)) / double(binsSignal) : 0;
325 unsigned int numberofnoisewindows =
std::max(U_1, U_2);
326 if (numberofnoisewindows > 50)
327 numberofnoisewindows = 50;
328 unsigned int startBG = U_1 > U_2 ? 2*binsSignal : stop + 2*binsSignal;
331 for (
unsigned int i = startBG; i <= startBG+numberofnoisewindows*binsSignal; ++i) {
332 if (i > (startBG + (numberofnoisewindows/2)*binsSignal) &&
333 i <= (startBG + (numberofnoisewindows/2)*binsSignal) + binsSignal) {
347 channel_spectrum[component].
SetBinning(freqBinning);
348 channel_spectrum_bg[component].
SetBinning(freqBinning);
349 unsigned int startBin = meas_FFTDataContainer.GetBinOfFrequency(Integral_lowerLimit);
350 unsigned int stopBin = meas_FFTDataContainer.GetBinOfFrequency(Integral_upperLimit);
351 double sigmaM[nBinFreq];
352 double meanB[nBinFreq];
353 for (
unsigned int i=0; i < nBinFreq; ++i) {
357 if (fBackGroundSubtraction && sampleNSEW) {
358 CalculateTheBGAverage(avgBgFFTDataContainer, numberofnoisewindows-1, nBinFreq, binsSignal, sigmaM, meanB);
360 for (
unsigned int i = startBin; i <=stopBin; ++i) {
361 double varSignal = 0;
365 double sigmaB = (fBackGroundSubtraction && sampleNSEW!=0)? sigmaM[i]/
sqrt(numberofnoisewindows-1) : 0;
366 if (fBackGroundSubtraction && sampleNSEW) {
368 mean_and_sigma(
sqrt(2./(
double)binsSignal)*
std::abs(meas_FFTDataContainer.
GetFrequencySpectrum()[i]), sigmaM[i], meanB[i], sigmaB, 0.01, signal, varSignal);
372 UncertantySignalSpectrum[component].push_back(varSignal);
373 UncertantyBackGroundSpectrum[component].push_back(varBg);
377 }
else if (component == 2) {
381 WARNING(
"Reference direction or core position not set. "
382 "The electric-field can not be rotated into the vxB, vx(vxB) system. "
383 "The calculation will be skipped");
389 double th = AnalyticCoordinateTransformator::GetZenithFromCartesianCoordinates(showerAxis.
GetX(coreCS), showerAxis.
GetY(coreCS), showerAxis.
GetZ(coreCS));
390 double phi = AnalyticCoordinateTransformator::GetAzimuthFromCartesianCoordinates(showerAxis.
GetX(coreCS), showerAxis.
GetY(coreCS));
391 channel_spectrum[component].
SetBinning(freqBinning);
392 channel_spectrum_bg[component].
SetBinning(freqBinning);
394 channel_spectrum[component].
PushBack((-(channel_spectrum[0][i]* cos(phi) + channel_spectrum[1][i] *sin(phi))*tan(th)));
395 channel_spectrum_bg[component].
PushBack((-(channel_spectrum_bg[0][i]* cos(phi) + channel_spectrum_bg[1][i] *sin(phi))*tan(th)));
396 UncertantySignalSpectrum[component].push_back(
sqrt(
Sqr(UncertantySignalSpectrum[0].at(i)*cos(phi)*tan(th)) +
Sqr(UncertantySignalSpectrum[1].at(i)*sin(phi)*tan(th))));
397 UncertantyBackGroundSpectrum[component].push_back(
sqrt(
Sqr(UncertantyBackGroundSpectrum[0].at(i)*cos(phi)*tan(th)) +
Sqr(UncertantyBackGroundSpectrum[1].at(i)*sin(phi)*tan(th))));
399 }
else if (component == 3) {
402 WARNING(
"Reference direction or core position not set. "
403 "The electric-field can not be rotated into the vxB, vx(vxB) system. "
404 "The calculation will be skipped");
410 double th = AnalyticCoordinateTransformator::GetZenithFromCartesianCoordinates(showerAxis.
GetX(coreCS), showerAxis.
GetY(coreCS), showerAxis.
GetZ(coreCS));
411 double phi = AnalyticCoordinateTransformator::GetAzimuthFromCartesianCoordinates(showerAxis.
GetX(coreCS), showerAxis.
GetY(coreCS));
412 double factorEW_tot = 2*(1 +
pow(cos(phi)*tan(th),2));
413 double factotNS_tot = 2*(1 +
pow(sin(phi)*tan(th),2));
414 double factorNSEW_tot = sin(2*phi)*
pow(tan(th),2);
415 channel_spectrum[component].
SetBinning(freqBinning);
416 channel_spectrum_bg[component].
SetBinning(freqBinning);
420 double u =
pow((
std::abs(channel_spectrum[0][i])*factorEW_tot+
std::abs(channel_spectrum[1][i])*factorNSEW_tot)*UncertantySignalSpectrum[0].at(i)/(2*
std::abs(channel_spectrum[component][i])),2) +
pow((factotNS_tot*
std::abs(channel_spectrum[1][i])+
std::abs(channel_spectrum[0][i])*factorNSEW_tot)*UncertantySignalSpectrum[1].at(i)/(2*
std::abs(channel_spectrum[component][i])),2);
421 UncertantySignalSpectrum[component].push_back(
sqrt(u));
422 double uBg =
pow((
std::abs(channel_spectrum_bg[0][i])*factorEW_tot+
std::abs(channel_spectrum_bg[1][i])*factorNSEW_tot)*UncertantyBackGroundSpectrum[0].at(i),2) +
pow((factotNS_tot*
std::abs(channel_spectrum_bg[1][i])+
std::abs(channel_spectrum_bg[0][i])*factorNSEW_tot)*UncertantyBackGroundSpectrum[1].at(i),2);
423 UncertantyBackGroundSpectrum[component].push_back(
sqrt(uBg/(4*
std::norm(channel_spectrum_bg[component][i]))));
425 }
else if (component == 4) {
426 channel_spectrum[component].
SetBinning(freqBinning);
427 channel_spectrum_bg[component].
SetBinning(freqBinning);
433 UncertantySignalSpectrum[component].push_back(
sqrt(
Sqr(
std::abs(channel_spectrum[0][i])*UncertantySignalSpectrum[0].at(i))+
Sqr(
std::abs(channel_spectrum[1][i])*UncertantySignalSpectrum[1].at(i)))/(norm));
434 UncertantyBackGroundSpectrum[component].push_back(
sqrt(
Sqr(
std::abs(channel_spectrum_bg[0][i])*UncertantyBackGroundSpectrum[0].at(i))+
Sqr(
std::abs(channel_spectrum_bg[1][i])*UncertantyBackGroundSpectrum[1].at(i)))/(normBg));
436 }
else if (component == 5 || component == 6) {
437 channel_spectrum[component].
SetBinning(freqBinning);
438 channel_spectrum_bg[component].
SetBinning(freqBinning);
441 WARNING(
"Reference direction or core position not set. "
442 "The electric-field can not be rotated into the vxB, vx(vxB) system. "
443 "The calculation will be skipped");
449 double th = AnalyticCoordinateTransformator::GetZenithFromCartesianCoordinates(showerAxis.
GetX(coreCS), showerAxis.
GetY(coreCS), showerAxis.
GetZ(coreCS));
450 double phi = AnalyticCoordinateTransformator::GetAzimuthFromCartesianCoordinates(showerAxis.
GetX(coreCS), showerAxis.
GetY(coreCS));
458 if (component == 5) {
459 factorNS = vxB.GetY(coreCS)-vxB.GetZ(coreCS)*sin(phi)*tan(th);
460 factorEW = vxB.GetX(coreCS)-vxB.GetZ(coreCS)*cos(phi)*tan(th);
462 if (component == 6) {
463 factorNS = vxvxB.
GetY(coreCS)-vxvxB.
GetZ(coreCS)*sin(phi)*tan(th);
464 factorEW = vxvxB.
GetX(coreCS)-vxvxB.
GetZ(coreCS)*cos(phi)*tan(th);
467 channel_spectrum[component].
PushBack(channel_spectrum[0][i]*factorEW+channel_spectrum[1][i]*factorNS);
468 channel_spectrum_bg[component].
PushBack(channel_spectrum_bg[0][i]*factorEW+channel_spectrum_bg[1][i]*factorNS);
469 UncertantySignalSpectrum[component].push_back(
sqrt(
Sqr(UncertantySignalSpectrum[0].at(i)*factorEW) +
Sqr(UncertantySignalSpectrum[1].at(i)*factorNS)));
470 UncertantyBackGroundSpectrum[component].push_back(
sqrt(
Sqr(UncertantyBackGroundSpectrum[0].at(i)*factorEW) +
Sqr(UncertantyBackGroundSpectrum[1].at(i)*factorNS)));
474 ERROR(
"This component does not exist!");
478 double signalEnergyFluence = 0;
479 double signalEnergyFluenceError = 0;
481 EnergyFluenceIntegral(channel_spectrum[component], UncertantySignalSpectrum[component], signalEnergyFluence, signalEnergyFluenceError,
true);
484 double noiseEnergyFluence = 0;
485 double noiseEnergyFluenceError = 0;
487 if (fBackGroundSubtraction && sampleNSEW) {
488 EnergyFluenceIntegral(channel_spectrum_bg[component], UncertantyBackGroundSpectrum[component], noiseEnergyFluence, noiseEnergyFluenceError,
true);
489 double signalEnergyFluence_bg=(f_sigmoind->Eval(signalEnergyFluence/noiseEnergyFluence))*noiseEnergyFluence+signalEnergyFluence;
490 double noiseSignalEnergyFluence_bg =
sqrt(
pow((f_sigmoind->Eval(signalEnergyFluence/noiseEnergyFluence)*noiseEnergyFluenceError),2)+signalEnergyFluenceError*signalEnergyFluenceError);
491 signalEnergyFluence=signalEnergyFluence_bg;
492 signalEnergyFluenceError=noiseSignalEnergyFluence_bg;
495 signalEnergyFluence *= (fConversionSignalToEnergyFluence * channeltrace_noenvelope.
GetBinning());
496 noiseEnergyFluence *= (fConversionSignalToEnergyFluence * channeltrace_noenvelope.
GetBinning());
497 signalEnergyFluenceError *= (fConversionSignalToEnergyFluence * channeltrace_noenvelope.
GetBinning());
498 noiseEnergyFluenceError *= (fConversionSignalToEnergyFluence * channeltrace_noenvelope.
GetBinning());
501 info <<
"station " << station.
GetId() <<
" "
502 "component " << component <<
" "
503 "signaltime (sample) " << PeakTime <<
"(" << sample <<
") "
504 "Integrating f around sample " << sample <<
" "
505 "f = " << signalEnergyFluence+noiseEnergyFluence <<
" +/- " << signalEnergyFluenceError <<
" "
506 "f noise = " << noiseEnergyFluence <<
" +/- " << noiseEnergyFluenceError;
509 double antennaToAntennaUncertainty = 0;
512 if (boost::algorithm::to_lower_copy(
513 det::Detector::GetInstance().GetRDetector().GetStation(station).GetChannel(channel.
GetId()).GetAntennaTypeName()
514 ).find(
"butterfly") != std::string::npos) {
515 if (antennaToAntennaUncertainty < fButterflyAntennaUncertainty)
516 antennaToAntennaUncertainty = fButterflyAntennaUncertainty;
517 }
else if (boost::algorithm::to_lower_copy(
518 det::Detector::GetInstance().GetRDetector().GetStation(station).GetChannel(channel.
GetId()).GetAntennaTypeName()
519 ).find(
"blackspider") != std::string::npos) {
520 if (antennaToAntennaUncertainty < fBlackSpiderAntennaUncertainty)
521 antennaToAntennaUncertainty = fBlackSpiderAntennaUncertainty;
523 if (antennaToAntennaUncertainty < fDefaultAntennaUncertainty)
524 antennaToAntennaUncertainty = fDefaultAntennaUncertainty;
529 signalEnergyFluenceError =
531 signalEnergyFluenceError * signalEnergyFluenceError +
532 fRelativeAmplitudeUncertainty * 2 * signalEnergyFluence * fRelativeAmplitudeUncertainty * 2 * signalEnergyFluence +
533 antennaToAntennaUncertainty * 2 * signalEnergyFluence * antennaToAntennaUncertainty * 2 * signalEnergyFluence
537 if (component == fVectorialComponent) {
547 <<
"SNR = " <<
Sqr(SignalToNoise) <<
"\t"
548 "signal amplitude = " << PeakAmplitude <<
"\t"
549 "Uncertainty of SignalAmplitude = " << GetSignalUncertainty(PeakAmplitude,
Sqr(SignalToNoise))
552 double tempUncertainty =
554 GetSignalUncertainty(PeakAmplitude,
Sqr(SignalToNoise)) * GetSignalUncertainty(PeakAmplitude,
Sqr(SignalToNoise)) +
555 PeakAmplitude * fRelativeAmplitudeUncertainty * PeakAmplitude * fRelativeAmplitudeUncertainty +
556 PeakAmplitude * antennaToAntennaUncertainty * PeakAmplitude * antennaToAntennaUncertainty
563 OUT(eInfoDebug) <<
"Filling the primary parameters..." << endl;
572 if (component == 3) {
582 }
else if (component == 0) {
592 }
else if (component == 1) {
603 }
else if (component == 2) {
613 }
else if (component == 4) {
623 }
else if (component == 5) {
633 }
else if (component == 6) {
645 if (component == fVectorialComponent) {
649 ++numberOfStationsWithPulseFound;
654 message <<
"no signal pulse found for station " << station.
GetId();
668 message <<
"needed " << difftime(time(
nullptr), timeStation) <<
" seconds for Station " << station.
GetId();
673 message <<
"needed " << difftime(time(
nullptr), timeAllStation) <<
" seconds for all stations";
684 message <<
"Found " << numberOfStationsWithPulseFound <<
" stations with signal pulse with energy fluence";
687 if (numberOfStationsWithPulseFound == 1)
688 ++fNumberOfEvents1SignalStations;
689 else if (numberOfStationsWithPulseFound == 2)
690 ++fNumberOfEvents2SignalStations;
691 else if (numberOfStationsWithPulseFound == 3)
692 ++fNumberOfEvents3SignalStations;
693 else if (numberOfStationsWithPulseFound == 4)
694 ++fNumberOfEvents4SignalStations;
695 else if (numberOfStationsWithPulseFound == 5)
696 ++fNumberOfEvents5SignalStations;
697 else if (numberOfStationsWithPulseFound >= 5)
698 ++fNumberOfEvents5plusSignalStations;
705 RdStationSignalReconstructorWithBgSubtraction::Finish()
708 sstr <<
"Event statistics:\n"
709 <<
"\t" << fTotalNumberOfEvents <<
" events\n"
710 <<
"\t" << fNumberOfEvents1SignalStations <<
" = "
711 << 100. * fNumberOfEvents1SignalStations/fTotalNumberOfEvents <<
"% events with 1 signal station\n"
712 <<
"\t" << fNumberOfEvents2SignalStations <<
" = "
713 << 100. * fNumberOfEvents2SignalStations/fTotalNumberOfEvents <<
"% events with 2 signal stations\n"
714 <<
"\t" << fNumberOfEvents3SignalStations <<
" = "
715 << 100. * fNumberOfEvents3SignalStations/fTotalNumberOfEvents <<
"% events with 3 signal stations\n"
716 <<
"\t" << fNumberOfEvents4SignalStations <<
" = "
717 << 100. * fNumberOfEvents4SignalStations/fTotalNumberOfEvents <<
"% events with 4 signal stations\n"
718 <<
"\t" << fNumberOfEvents5SignalStations <<
" = "
719 << 100. * fNumberOfEvents5SignalStations/fTotalNumberOfEvents <<
"% events with 5 signal stations\n"
720 <<
"\t" << fNumberOfEvents5plusSignalStations <<
" = "
721 << 100. * fNumberOfEvents5plusSignalStations/fTotalNumberOfEvents <<
"% events "
722 "with more than 5 signal stations\n";
729 f_sigmoind =
nullptr;
737 double& RMSNoise,
double& MeanNoise,
double NoiseWindowStart,
738 double NoiseWindowStop)
741 unsigned int start = NoiseWindowStart / channeltrace.
GetBinning();
742 unsigned int stop = NoiseWindowStop / channeltrace.
GetBinning();
743 RMSNoise = TraceAlgorithm::RootMeanSquare(channeltrace, start, stop);
750 double& PeakAmplitude,
double& PeakTime,
double& PeakTimeError,
751 double SignalSearchWindowStart,
double SignalSearchWindowStop,
752 unsigned int& sample)
756 unsigned int start = SignalSearchWindowStart / channeltrace.
GetBinning();
757 unsigned int stop = SignalSearchWindowStop / channeltrace.
GetBinning();
759 OUT(eInfoDebug) <<
" Pulsefinder startsample = " << start <<
" lastsample = " << stop << endl;
761 for (
unsigned int i = start; i < stop; ++i) {
762 if (channeltrace[i] > PeakAmplitude) {
763 PeakAmplitude = channeltrace[i];
775 RdStationSignalReconstructorWithBgSubtraction::GetSignalUncertainty(
const double signalAmplitude,
const double SNR)
778 return (0.423/
sqrt(SNR) - 0.501/SNR + 3.395/
pow(SNR,1.5) ) * signalAmplitude;
783 RdStationSignalReconstructorWithBgSubtraction::GetSignalTimeUncertainty(
const double snr)
792 const std::vector<double>& uncertainty,
793 double& integratedSignal,
double& energyFluenceUncertainty,
797 integratedSignal = 0;
798 energyFluenceUncertainty = 0;
799 for (
unsigned int i = 0; i < channeltrace.
GetSize(); ++i) {
801 integratedSignal +=
std::norm(channeltrace[i]);
802 energyFluenceUncertainty += 4*
std::norm(channeltrace[i])*
Sqr(uncertainty.at(i));
804 integratedSignal += fabs(
std::abs(channeltrace[i]));
805 energyFluenceUncertainty +=
Sqr(uncertainty.at(i));
808 energyFluenceUncertainty =
sqrt(energyFluenceUncertainty);
814 unsigned int nWindows,
int nBin,
int ntimeBin,
815 double*
const sigmaB,
double*
const meanB)
818 double ampNoise[nBin];
819 for (
int t = 0; t < nBin; ++t) {
820 ampNoise[t] = meanB[t] = sigmaB[t] = 0;
824 double arrayBackground[nWindows][nBin];
825 for (
unsigned int i = 0; i < nWindows; ++i) {
827 for (
unsigned int j = i*ntimeBin; j < (i+1)*ntimeBin; ++j) {
830 for (
int k = 0; k < nBin; ++k) {
831 arrayBackground[i][k] = 0;
836 for (
int t = 0; t < nBin; ++t) {
837 meanB[t] = ampNoise[t]/nWindows;
839 for (
unsigned int inoise = 0; inoise<nWindows; ++inoise) {
840 stdB +=
pow((arrayBackground[inoise][t] - meanB[t]), 2);
842 stdB = nWindows > 3 ?
sqrt(stdB/
double(nWindows-1)) :
sqrt(stdB/
double(nWindows));
850 unsigned int sample,
double PeakAmplitude,
851 double& SignalTimeFWHM,
double& IntegratedSignal,
852 double& SignalWindowStart,
double& SignalWindowStop)
856 IntegratedSignal = 0;
857 unsigned int tmp = sample;
859 while (sample < channeltrace.
GetSize() && channeltrace[sample] > 0.5 * PeakAmplitude) {
861 IntegratedSignal += channeltrace[sample];
864 SignalWindowStop = sample * channeltrace.
GetBinning();
867 while (sample > 0 && channeltrace[sample] > 0.5 * PeakAmplitude) {
869 IntegratedSignal += channeltrace[sample];
872 SignalWindowStart = sample * channeltrace.
GetBinning();
873 SignalTimeFWHM = SignalTimeFWHM * channeltrace.
GetBinning();
Branch GetTopBranch() const
AxialVector Cross(const Vector &l, const Vector &r)
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)
Abstract base class for analytic windows.
int GetId() const
Return Id of the Channel.
StationTriggerData & GetTriggerData()
Get Trigger data for the station.
boost::indirect_iterator< InternalChannelIterator, Channel & > ChannelIterator
Iterator over station for read/write.
void SetPulseFound(const bool pulsefound)
StationRecData & GetRecData()
Get station level reconstructed data.
Interface class to access Shower Reconstructed parameters.
bool HasRecShower() const
Interface class to access to the Radio part of an event.
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
#define INFO(message)
Macro for logging informational messages.
StationIterator StationsEnd()
StationIterator StationsBegin()
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
double pow(const double x, const unsigned int i)
boost::filter_iterator< StationFilter, AllStationIterator > StationIterator
Iterator over all (non-exculded) stations.
ChannelIterator ChannelsEnd()
end Channel iterator for read/write
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
#define INFOIntermediate(y)
Class representing a document branch.
class to hold data at the radio Station level.
C< F > & GetFrequencySpectrum()
read out the frequency spectrum (write access)
double GetX(const CoordinateSystemPtr &coordinateSystem) const
std::vector< T >::size_type SizeType
double abs(const SVector< n, T > &v)
bool HasRRecShower() const
C< T > & GetTimeSeries()
read out the time series (write access)
#define WARNING(message)
Macro for logging warning messages.
void GetData(bool &b) const
Overloads of the GetData member template function.
int GetId() const
Get the station Id.
AxialVector Normalized(const AxialVector &v)
constexpr double microvolt
double GetParameter(const Parameter i) const
void SetBinning(const double binning)
double GetY(const CoordinateSystemPtr &coordinateSystem) const
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.
bool HasReferenceCorePosition(const Event &event) const
Return always true for SD and FD if RecShower exsist, asking for min. rec stage could fix this...
const StationFFTDataContainer & GetFFTDataContainer() const
retrieve Station FFTDataContainer (read access)
Template class for a FADC data or calibrated data container. Use the typedefs (TraceD, TraceI, etc.) defined in Trace-fwd.h.
TriggerSource GetTriggerSource() const
Get the Trigger Source of the station, i.e. if it triggered itself or was triggered by the central st...
void SetParameter(Parameter i, double value, bool lock=true)
Class that holds the data associated to an individual radio channel.
utl::Vector GetReferenceAxis(const Event &event) const
Returning the referencedirection depending on the corresponding flag.
double Mean(const std::vector< double > &v)
bool HasRecData() const
Check whether station reconstructed data exists.
double GetZ(const CoordinateSystemPtr &coordinateSystem) const
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.
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.