RdLDFFitter.cc
Go to the documentation of this file.
1 #include "RdLDFFitter.h"
2 
3 #include <cmath>
4 #include <sstream>
5 #include <fstream>
6 #include <iostream>
7 #include <iomanip> // std::setprecision
8 #include <utility> // for pair
9 #include <string>
10 #include <vector>
11 
12 #include <boost/filesystem/operations.hpp>
13 
14 #include <fwk/CentralConfig.h>
15 #include <fwk/MagneticFieldModel.h>
16 
17 #include <utl/config.h>
18 #include <utl/ErrorLogger.h>
19 #include <utl/Reader.h>
20 #include <utl/RectangleFilter.h>
21 
22 #include <utl/Vector.h>
23 #include <utl/Point.h>
24 #include <utl/BasicVector.h>
25 #include <utl/GeometryUtilities.h>
26 #include <utl/RadioGeometryUtilities.h>
27 #include <utl/CoordinateSystemPtr.h>
28 #include <utl/RadioGeometryUtilities.h>
29 #include <utl/Probability.h>
30 
31 #include <evt/Event.h>
32 #include <evt/ShowerRecData.h>
33 #include <evt/ShowerSRecData.h>
34 #include <evt/ShowerRRecData.h>
35 #include <evt/ShowerFRecData.h>
36 #include <evt/ShowerSimData.h>
37 
38 #include <revt/REvent.h>
39 #include <revt/Station.h>
40 #include <revt/Header.h>
41 #include <revt/StationRecData.h>
42 
43 #include <det/Detector.h>
44 #include <rdet/RDetector.h>
45 
46 // include root stuff
47 #include "TGraphErrors.h"
48 #include "TF1.h"
49 #include "TH2D.h" // for plotting of Likelihood scan
50 #include "TCanvas.h"
51 #include "TLegend.h"
52 #include "TEllipse.h"
53 #include "TMath.h"
54 #include "TLatex.h"
55 #include "TLine.h"
56 #include "TStyle.h"
57 #include "TAxis.h"
58 
59 
60 #include "Minuit2/Minuit2Minimizer.h"
61 #include "Minuit2/MnUserParameters.h"
62 #include "Minuit2/MnMigrad.h"
63 #include "Minuit2/MnContours.h"
64 #include "Minuit2/FunctionMinimum.h"
65 #include "Minuit2/MinimumParameters.h"
66 #include "Minuit2/MnPrint.h"
67 #include "Minuit2/MnPlot.h"
68 #include "Minuit2/MnUserCovariance.h"
69 //#include "TFitterMinuit.h"
70 
71 #include "LikelihoodFunction.h"
72 
73 using namespace revt;
74 using namespace fwk;
75 //using namespace utl;
76 
77 #define OUT(x) if ((x) <= fInfoLevel) std::cerr << " "
78 #define INFO2(x,y) if ((x) <= fInfoLevel) INFO(y)
79 
80 namespace RdLDFFitter {
81 
83  fFitConfig(),
84  fInfoLevel(eNone),
85  fSaveContour(false),
86  fPerformScan(false),
87  fPlotSigmaContours(true),
88  fNStepsX(11),
89  fNStepsY(11),
90  fStepWidthX(10*utl::meter),
91  fStepWidthY(10*utl::meter),
92  fScanCenter(),
93  fMCUncertaintyOnEFieldVector(0.),
94  fPlotStyle(0),
95  fREvent(NULL),
96  fConstEvent(NULL),
97  fEvent(NULL),
98  fShowerAxis(),
99  fMagneticFieldAxis()
100 {
101 }
102 
103 RdLDFFitter::~RdLDFFitter()
104 {
105 }
106 
108 {
109  // Initialize your module here. This method
110  // is called once at the beginning of the run.
111  // The eSuccess flag indicates the method ended
112  // successfully. For other possible return types,
113  // see the VModule documentation.
114 
115  INFO("RdLDFFitter::Init()");
116 
117  // Read in the configurations of the xml file
118  utl::Branch topBranch = CentralConfig::GetInstance()->GetTopBranch("RdLDFFitter");
119 
120  topBranch.GetChild("InfoLevel").GetData(fInfoLevel);
121  topBranch.GetChild("SaveContour").GetData(fSaveContour);
122  topBranch.GetChild("performScan").GetData(fPerformScan);
123  topBranch.GetChild("nStepsX").GetData(fNStepsX);
124  topBranch.GetChild("nStepsY").GetData(fNStepsY);
125  topBranch.GetChild("stepWidthX").GetData(fStepWidthX);
126  topBranch.GetChild("stepWidthY").GetData(fStepWidthY);
127  topBranch.GetChild("outputFolder").GetData(fOutputFolder);
128  topBranch.GetChild("MCUncertaintyOnEFieldVector").GetData(fMCUncertaintyOnEFieldVector);
129 
130  std::string temp;
131  topBranch.GetChild("scanCenter").GetData(temp);
132  if(temp == "Radio")
133  { fScanCenter = eRadio; }
134  if(temp == "SD")
135  { fScanCenter = eSD; }
136  if(temp == "FD")
137  { fScanCenter = eFD; }
138  if(temp == "MC")
139  { fScanCenter = eMC; }
140 
141 
142 // int tmp = 0;
143 // topBranch.GetChild("LDFModel").GetData(tmp);
144 // fFitConfig.LDFModel = tmp;
145  utl::Branch bFitConfig = topBranch.GetChild("FitConfig");
146  bFitConfig.GetChild("LDFModel").GetData(fFitConfig.LDFModel);
147  bFitConfig.GetChild("chargeExcessStrength").GetData(fFitConfig.chargeExcessStrength);
148  bFitConfig.GetChild("fitChargeExcess").GetData(fFitConfig.fitChargeExcess);
149  bFitConfig.GetChild("useChargeExcessCorrectionInLDFFit").GetData(
151  bFitConfig.GetChild("usePolarisation").GetData(fFitConfig.usePolarisation);
152  bFitConfig.GetChild("useSDCoreToImproveRadioCore").GetData(
154  bFitConfig.GetChild("useStationsWithoutSignal").GetData(fFitConfig.useStationsWithoutSignal);
155  bFitConfig.GetChild("useScintillator").GetData(fFitConfig.useScintillator);
156 
157  return eSuccess;
158 }
159 
160 VModule::ResultFlag RdLDFFitter::Run(evt::Event& event)
161 {
162 
163  // Check if there are events at all
164  if (!event.HasREvent()) {
165  WARNING("No radio event found!");
166  return eSuccess;
167  }
168  std::stringstream info;
169  fConstEvent = & event; // setting pointers to event structure to access it from other functions
170  fEvent = & event; // setting pointers to event structure to access it from other functions
171  fREvent = &event.GetREvent();
172 
173  revt::REvent& rEvent = event.GetREvent();
174  const unsigned int runNumber = fREvent->GetHeader().GetRunNumber();
175  const unsigned int eventId = fREvent->GetHeader().GetId();
176 
177  evt::ShowerRRecData& showerrrec = event.GetRecShower().GetRRecShower();
178 
179  if(!(showerrrec.HasParameter(eRecStage) and showerrrec.GetParameter(eRecStage) >= evt::ShowerRRecData::kPlaneFit3d)) {
180  WARNING("The reconstruction stage is not set or smaller that kPlaneFit3d. LDF Fit can not be performed.");
181  return eSuccess;
182  }
183 
184  //Get Radio detector for station loop
185  const det::Detector& detector = det::Detector::GetInstance();
186  const rdet::RDetector& rDetector = detector.GetRDetector();
187 
188  fShowerAxis = showerrrec.GetAxis();
189  utl::Point coordinateOrigin = showerrrec.GetCoordinateOrigin();
190  fLocalCS = LocalCoordinateSystem::Create(coordinateOrigin);
191 
192  fMagneticFieldAxis = event.GetRecShower().GetRRecShower().GetMagneticFieldVector();
193  // use magnetic field from simulations if present
194  if(event.HasSimShower()) {
195  if(fInfoLevel > eFinal) {
196  INFO("Using magnetic field from simulated air shower.");
197  }
198  const double magFieldAzimuth = event.GetSimShower().GetMagneticFieldAzimuth();
199  const double magFieldZenith = event.GetSimShower().GetMagneticFieldZenith();
200  info.str("");
201  info << "Difference in MC and Offline magnetic field:\n"
202  << fMagneticFieldAxis.GetPhi(fLocalCS)/utl::deg << " vs. " << magFieldAzimuth / utl::deg << "\n"
203  << fMagneticFieldAxis.GetTheta(fLocalCS)/utl::deg << " vs. " << magFieldZenith / utl::deg;
204  INFO2(eDebug, info.str());
205  fMagneticFieldAxis = utl::Vector(1., magFieldZenith, magFieldAzimuth, fLocalCS,
207  fShowerAxis = -1. * event.GetSimShower().GetDirection();
208  }
209 
210  // set EventFitData
211  EventFitData eventFitData;
212  eventFitData.fShowerAxis = fShowerAxis;
213  eventFitData.fLocalCS = fLocalCS;
214 
215  if (event.GetRecShower().HasSRecShower()) {
216  evt::ShowerSRecData& showersrec = event.GetRecShower().GetSRecShower(); // get reconstructed SD shower for SD core position
217  eventFitData.SDCore = showersrec.GetCorePosition();
218  eventFitData.SDCoreXError = showersrec.GetCoreError().GetX(fLocalCS);
219  eventFitData.SDCoreYError = showersrec.GetCoreError().GetY(fLocalCS);
220  eventFitData.SDCoreXYCorrelation = showersrec.GetCorrelationXY();
221  }
222 
224  if (not event.GetRecShower().HasSRecShower()) {
225  WARNING(
226  "RdLDFFitter: No reconstructed SD shower found. SD core position can't be used to improve radio core. This option will be deactivated for this event.");
228  }
229  }
230 
231  std::vector<StationFitData> vStationFitData;
232 
233  INFO2(eDebug, "starting station loop");
234 
235  // loop through stations and fill all relevant parameters into the StationFitData struct
236  info.str("");
238  sIt != rEvent.SignalStationsEnd(); ++sIt) {
239  Station& station = *sIt;
240  StationFitData tmpStationFitData;
241  const StationRecData& sRec = station.GetRecData();
242  const utl::Point sPos = rDetector.GetStation(station).GetPosition();
243  tmpStationFitData.antennaPosition = sPos;
244  tmpStationFitData.signal = sRec.GetParameter(revt::eSignal);
245  tmpStationFitData.signalError = sRec.GetParameterError(revt::eSignal);
246  utl::Vector efield = utl::Vector(sRec.GetParameter(revt::eEFieldVectorEW),
247  sRec.GetParameter(revt::eEFieldVectorNS),
248  sRec.GetParameter(revt::eEFieldVectorV), fLocalCS);
250  efield = utl::Probability::GetInstance().GetRandomFisher(
252  info << "smeer out efield by " << fMCUncertaintyOnEFieldVector / utl::deg << " degree, ";
253  }
254  tmpStationFitData.efield = efield;
255  if (sRec.HasParameterError(revt::eAngleToLorentzVector)) {
256 // tmpStationFitData.lorentzAngleError = fMCUncertaintyOnEFieldVector;
257  tmpStationFitData.lorentzAngleError = sqrt(pow(1 * utl::degree, 2) +
259  info << "setting uncertainty to " << tmpStationFitData.lorentzAngleError/utl::deg << " degree\n";
260  } else {
261  WARNING(
262  "RdLDFFitter: Parameter eAngleToLorentzVector not set. Please run the RdStationEFieldReconstructor Module before the LDF Fitter. This event will be skipped!");
263  return eFailure;
264  }
265 
266  vStationFitData.push_back(tmpStationFitData);
267  }
268  INFO2(eDebug, info.str());
269 
270  bool hasScintillator =
271  showerrrec.HasParameter(revt::eNumberOfAERATopScintWithPulseFound)
272  && (showerrrec.GetParameter(revt::eNumberOfAERATopScintWithPulseFound) >= 3) ?
273  true : false;
274  ParameterScintillatorLDFModel preScintillatorFit;
275  std::vector<ScintillatorFitData> vScintillatorFitData;
276  if(hasScintillator) {
277  // fill scintillator fit data
278  int nSignalScintiallators = 0;
279  for (REvent::StationIterator sIt = rEvent.StationsBegin();
280  sIt != rEvent.StationsEnd(); ++sIt) {
281  Station& station = *sIt;
282  const StationRecData& sRec = station.GetRecData();
283  ScintillatorFitData tmpScintillatorData;
284  if(sRec.HasParameter(revt::eAERAScintStationVEM) and sRec.GetParameter(revt::eAERAScintStationVEM) > 1.) {
285  tmpScintillatorData.signal = sRec.GetParameter(revt::eAERAScintStationVEM);
286  tmpScintillatorData.silent = false;
287  nSignalScintiallators++;
288  } else {
289  tmpScintillatorData.silent = true;
290  }
291  const utl::Point sPos = rDetector.GetStation(station).GetPosition();
292  tmpScintillatorData.scintillatorPosition = sPos;
293  vScintillatorFitData.push_back(tmpScintillatorData);
294  }
295  if(nSignalScintiallators < 3) {
296  hasScintillator = false;
297  INFO2(eIntermediate, "number of scintillators is less than three, no scintillator LDF will be fitted");
298  } else {
299  // perform pre fit
300  preScintillatorFit = PreScintillatorLDFFit(vScintillatorFitData, fShowerAxis, coordinateOrigin);
301  info.str("");
302 
303  if(preScintillatorFit.status == 0 or preScintillatorFit.status >= 1000) {
304  info << "Pre scintillator LDF fit was successful. N_e = " << preScintillatorFit.N_e
305  << " +/- " << preScintillatorFit.N_eError;
306  } else {
307  info << "Pre scintillator LDF fit was not successful. Error code is " << preScintillatorFit.status;
308  }
309  INFO2(eIntermediate, info.str());
310  }
311  }
312 
313  ParameterLDFModel PreFitResult;
314  if (fFitConfig.LDFModel) {
315  INFO2(eDebug, "performing pre LDF fit");
316  // perform a pre LDF fit with core = coordinate-origin (barycenter of the antennas)
317  PreFitResult = PreLDFFit(fFitConfig.LDFModel, vStationFitData, fShowerAxis, coordinateOrigin);
318  }
319 
320  // the FIT
321 
322  info.str("");
323  info << "Creating LDF fit function with the following parameters: \n " << "LDF Model:\t"
324  << fFitConfig.LDFModel << "\n" << "usePolarisation:\t" << fFitConfig.usePolarisation << "\n"
325  << "chargeExcessStrength:\t" << fFitConfig.chargeExcessStrength << "\n"
326  << "useChargeExcessCorrectionInLDFFit:\t" << fFitConfig.useChargeExcessCorrectionInLDFFit
327  << "\n" << "useSDCoreToImproveRadioCore:\t" << fFitConfig.useSDCoreToImproveRadioCore
328  << "\n" << "useScintillator:\t" << fFitConfig.useScintillator
329  << std::endl;
330  INFO2(eDebug, info.str());
331 
332  LDFLikelihoodFunction fitFunction = LDFLikelihoodFunction(fFitConfig, eventFitData,
333  vStationFitData,
334  vScintillatorFitData,
336 
337  INFO2(eDebug, "setting fit parameters");
338 
339  ROOT::Minuit2::MnUserParameters upar;
340  upar.Add("coreX", 0., 20);
341  upar.Add("coreY", 0., 20);
342  upar.Add("coreZ", 0., 10);
343 
344  upar.Add("a", fFitConfig.chargeExcessStrength, 0.01);
345  upar.Fix("a");
346 
347  // add scintillator fit variable
348  upar.Add("N_e", preScintillatorFit.N_e, 1.e5); // number of charged particles
349  upar.Add("s", 1.7, .1); // shower age
350  upar.Add("Rm", 35., 1.); // moliere radius
351  upar.Fix("s");
352  upar.Fix("Rm");
353  if(!hasScintillator) {
354  upar.Fix("N_e"); // fix all scintialltor LDF parameters if not enough scnintillators are present
355  }
356 
357  // please add parameters for different LDF models here
358  if (fFitConfig.LDFModel == 1) {
359  upar.Add("A", PreFitResult.A, PreFitResult.AError);
360  upar.Add("R0", PreFitResult.R0, PreFitResult.R0Error);
361  }
362 
363  ROOT::Minuit2::MnMigrad migrad(fitFunction, upar);
364  INFO2(eDebug, "fixing parameter 2 (coreZ)");
365  migrad.Fix("coreZ");
366 
367  // fix LDF parameters for first minimization step
368  if (fFitConfig.LDFModel) {
369  if (fFitConfig.LDFModel == 1) {
370  upar.Fix("A");
371  upar.Fix("R0");
372  migrad(); // perform minimization
373  upar.Release("A");
374  upar.Release("R0");
375  }
376  }
377 
378  // perform minimization
379  ROOT::Minuit2::FunctionMinimum minimum = migrad(); // minimize calles migrad algorithm. If migrad fails it calls simplex and then migrad again.
380  info.str("");
381  info << "minimum: " << minimum;
382  INFO2(eIntermediate, info.str());
383 
384  ROOT::Minuit2::MnUserParameterState minUstate_tmp = minimum.UserState();
385  utl::Point core_tmp(minUstate_tmp.Value("coreX"), minUstate_tmp.Value("coreY"), minUstate_tmp.Value("coreZ"), fLocalCS);
386  if(event.HasSimShower()) {
387  info.str("");
388  double distance = (event.GetSimShower().GetPosition() - core_tmp).GetMag();
389  info << "distance to MC core is " << distance / utl::m << " m";
390  INFO2(eIntermediate, info.str());
391  }
392  if(event.GetRecShower().HasSRecShower()) {
393  info.str("");
394  double distance = (event.GetRecShower().GetSRecShower().GetCorePosition() - core_tmp).GetMag();
395  info << "distance to SD core is " << distance / utl::m << " m";
396  INFO2(eIntermediate, info.str());
397  }
398 
399  // abort if fit was not successful
400  if (!minimum.IsValid()) {
401  WARNING("Core position fit not converged.");
402  info.str("");
403  info << "current rec stage is " << showerrrec.GetParameter(eRecStage) << std::endl;
404  INFO2(eIntermediate, info.str());
405  return eSuccess;
406  }
407  showerrrec.SetParameter(eRecStage, 2.0);
408 
409  double optimalChargeExcessStrength = fFitConfig.chargeExcessStrength;
410 
412  INFO2(eIntermediate, "charge excess strength will be fitted.");
413  migrad.Release("a");
414  ROOT::Minuit2::FunctionMinimum minimum2 = migrad();
415  if (!minimum2.IsValid()) {
416  WARNING("Core position fit with free charge excess strength not converged. Saving result without variation of a");
417  } else {
418  INFO2(eIntermediate, "fit of charge excess strength was successful.");
419  minimum = minimum2;
420  info.str("");
421  info << "minimum: " << minimum;
422  INFO2(eIntermediate, info.str());
423 
424  showerrrec.SetParameter(revt::eChargeExcessStrength, minimum2.UserState().Value("a"));
425  showerrrec.SetParameter(eRecStage, 2.1);
426  optimalChargeExcessStrength = minimum2.UserState().Value("a");
427  }
428  }
429 
430 
431  // get the minimal parameters
432  ROOT::Minuit2::MnUserParameterState minUstate = minimum.UserState();
433  ROOT::Minuit2::MnUserCovariance cov = minUstate.Covariance();
434 
435  std::cout << "covariance matrix \n" << cov << std::endl;
436 
437  // get probabilty that SD core is correct
438  const double arr[] = {eventFitData.SDCore.GetX(fLocalCS),eventFitData.SDCore.GetY(fLocalCS), eventFitData.SDCore.GetZ(fLocalCS)};
439  std::vector<double> params (arr, arr + sizeof(arr) / sizeof(arr[0]) );
440  const double likelihoodValueAtSDCore = fitFunction(params);
441  showerrrec.SetParameter(revt::eProbSDCore, TMath::Prob(likelihoodValueAtSDCore, 2));
442 
443  // save fit result
444  // get reference coordinate system of detector (usually PampaAmarilla)
445  const utl::CoordinateSystemPtr referenceCS = detector.GetReferenceCoordinateSystem();
446  INFO2(eDebug, "save fit results");
447  utl::Point core(minUstate.Value("coreX"), minUstate.Value("coreY"), minUstate.Value("coreZ"),
448  fLocalCS);
449 
450  showerrrec.SetParameter(revt::eCoreX, core.GetX(referenceCS));
451  showerrrec.SetParameter(revt::eCoreY, core.GetY(referenceCS));
452  showerrrec.SetParameter(revt::eCoreZ, core.GetZ(referenceCS));
453 
454  showerrrec.SetParameterCovariance(revt::eCoreX, revt::eCoreY, cov(0, 1));
455  showerrrec.SetParameterCovariance(revt::eCoreX, revt::eCoreZ, 0);
456  showerrrec.SetParameterCovariance(revt::eCoreY, revt::eCoreZ, 0);
457  showerrrec.SetParameterCovariance(revt::eCoreX, revt::eCoreX, cov(0, 0));
458  showerrrec.SetParameterCovariance(revt::eCoreY, revt::eCoreY, cov(1, 1));
459  showerrrec.SetParameterCovariance(revt::eCoreZ, revt::eCoreZ, 0);
460 
461  info.str("");
462  info << "core (local CS) = (" << minUstate.Value("coreX") << ","
463  << minUstate.Value("coreY") << "," << minUstate.Value("coreZ") << ")";
464  INFO2(eIntermediate, info.str());
465  info.str("");
466  info << "core (reference CS) = (" << core.GetX(referenceCS) << ","
467  << core.GetY(referenceCS) << "," << core.GetZ(referenceCS) << ")";
468  INFO2(eIntermediate, info.str());
469  info.str("");
470  info << "optimal charge excess is " << minUstate.Value("a")*100. << "%";
471  INFO2(eIntermediate, info.str());
472  if(event.GetRecShower().HasSRecShower()) {
473  info.str("");
474  double distance = (event.GetRecShower().GetSRecShower().GetCorePosition() - core).GetMag();
475  info << "distance to SD core is " << distance / utl::m << " m";
476  INFO2(eIntermediate, info.str());
477  }
478  if(event.HasSimShower()) {
479  info.str("");
480  double distance = (event.GetSimShower().GetPosition() - core).GetMag();
481  info << "distance to MC core is " << distance / utl::m << " m";
482  INFO2(eIntermediate, info.str());
483  }
484 
485 
486 
487  // save LDF
488  if(fFitConfig.LDFModel){
489  showerrrec.SetParameter(revt::eLDFParameter1, minUstate.Value("A"));
490  showerrrec.SetParameter(revt::eLDFParameter2, minUstate.Value("R0"));
491  showerrrec.SetParameterCovariance(revt::eLDFParameter1, revt::eLDFParameter1, cov(2, 2));
492  showerrrec.SetParameterCovariance(revt::eLDFParameter2, revt::eLDFParameter2, cov(3, 3));
493  showerrrec.SetParameterCovariance(revt::eLDFParameter1, revt::eLDFParameter2, cov(2, 3));
494  // correlation with core position
495  showerrrec.SetParameterCovariance(revt::eCoreX, revt::eLDFParameter1, cov(0, 2));
496  showerrrec.SetParameterCovariance(revt::eCoreY, revt::eLDFParameter1, cov(1, 2));
497  showerrrec.SetParameterCovariance(revt::eCoreX, revt::eLDFParameter2, cov(0, 3));
498  showerrrec.SetParameterCovariance(revt::eCoreY, revt::eLDFParameter2, cov(1, 3));
499  OUT(eIntermediate) << "LDF parameters at minimum: A = " << minUstate.Value("A") << "+/-"
500  << minUstate.Error("A") << "R0 = " << minUstate.Value("R0") << "+/-"
501  << minUstate.Error("R0") << std::endl;
502  }
503 
504  if(fFitConfig.useScintillator and hasScintillator) {
505  TF1 NKG = TF1("NKG","[0]*TMath::Gamma(4.5-[1])/(2.*TMath::Pi()*[2]*[2]*TMath::Gamma([1])*TMath::Gamma(4.5-(2.*[1])))*TMath::Power((x/[2]),([1]-2.))*TMath::Power((1+(x/[2])),[1]-4.5)");
506  NKG.SetParameter(0, minUstate.Value("N_e"));
507  NKG.SetParameter(1, minUstate.Value("s"));
508  NKG.SetParameter(2, minUstate.Value("Rm"));
509  showerrrec.SetScintLDF(NKG);
510  }
511 
512  // scan
513  utl::Point scanCenter;
514  if(fScanCenter == eRadio) {
515  scanCenter = showerrrec.GetCorePosition();
516  }
517  if(fScanCenter == eSD) {
518  if (not event.GetRecShower().HasSRecShower()) {
519  WARNING(
520  "RdLDFFitter: No reconstructed SD shower found. SD core position can't be used as center of scan. Scan will not be performed.");
521  fPerformScan = false;
522  } else {
523  evt::ShowerSRecData& showersrec = event.GetRecShower().GetSRecShower(); // get reconstructed SD shower for SD core position
524  scanCenter = showersrec.GetCorePosition();
525  }
526  }
527  if(fScanCenter == eFD) {
528  if (not event.GetRecShower().HasFRecShower()) {
529  WARNING(
530  "RdLDFFitter: No reconstructed FD shower found. FD core position can't be used as center of scan. Scan will not be performed.");
531  fPerformScan = false;
532  } else {
533  evt::ShowerFRecData& showerfrec = event.GetRecShower().GetFRecShower(); // get reconstructed SD shower for SD core position
534  scanCenter = showerfrec.GetCorePosition();
535  }
536  }
537  if(fScanCenter == eMC) {
538  if (not event.HasSimShower()) {
539  WARNING(
540  "RdLDFFitter: No reconstructed MC shower found. MC core position can't be used as center of scan. Scan will not be performed.");
541  fPerformScan = false;
542  } else {
543  scanCenter = event.GetSimShower().GetPosition();
544  }
545  }
546  utl::Point coreScan;
547  if(fPerformScan) {
548  upar.Fix("a");
549  fNStepsX = (fNStepsX % 2) == 0 ? fNStepsX + 1 : fNStepsX; // make n-steps odd
550  fNStepsY = (fNStepsY % 2) == 0 ? fNStepsY + 1 : fNStepsY;
551  std::vector< std::vector<double> > scanResult(fNStepsX, std::vector<double>(fNStepsY));
552  coreScan = Scan(scanResult, fitFunction, scanCenter, fNStepsX, fNStepsY,
553  fStepWidthX, fStepWidthY, optimalChargeExcessStrength);
554  showerrrec.SetParameter(revt::eCoreScanX, coreScan.GetX(referenceCS));
555  showerrrec.SetParameter(revt::eCoreScanY, coreScan.GetY(referenceCS));
556  showerrrec.SetParameter(revt::eCoreScanZ, coreScan.GetZ(referenceCS));
557 
558  std::stringstream filename;
559  filename << fOutputFolder << "/scan_" << std::setfill('0') << std::setw(6) << runNumber << "_"
560  << std::setfill('0') << std::setw(7) << eventId << ".png";
561  SaveScan(scanResult, filename.str(), scanCenter.GetX(referenceCS),
562  scanCenter.GetY(referenceCS), fNStepsX, fNStepsY, fStepWidthX, fStepWidthY);
563  filename.str("");
564  filename << fOutputFolder << "/scan_" << std::setfill('0') << std::setw(6) << runNumber << "_"
565  << std::setfill('0') << std::setw(7) << eventId << ".png";
566  PlotScan(scanResult, filename.str(),
567  scanCenter, fLocalCS,
568  scanCenter, core,
570  vStationFitData, eventFitData, optimalChargeExcessStrength);
571  filename.str("");
572  filename << std::setfill('0') << std::setw(6) << runNumber << "_" << std::setfill('0')
573  << std::setw(7) << eventId;
574  PlotGoodnessOfFit(fOutputFolder, filename.str(), core);
575  }
576 
577  // save polarization angles for different cores
578  std::vector<std::pair<double, double> > anglesCore = GetAnglesToEFieldExpectation(core, optimalChargeExcessStrength);
579  std::vector<std::pair<double, double> > anglesCoreScan = GetAnglesToEFieldExpectation(coreScan, optimalChargeExcessStrength);
580  std::vector<std::pair<double, double> > anglesReferenceCore = GetAnglesToEFieldExpectation(scanCenter, optimalChargeExcessStrength);
581  unsigned int i = 0;
582  info.str("");
583  info << "betas at fit optimum are: ";
585  sIt != rEvent.SignalStationsEnd(); ++sIt) {
586  Station& station = *sIt;
587  StationRecData& sRec = station.GetRecData();
588  sRec.SetParameter(revt::eBetaFit, anglesCore[i].first);
589  info << anglesCore[i].first / utl::deg << "deg ";
590  // probability to measure the deviation beta or something greater
591  sRec.SetParameter(
592  revt::eProbBetaFit,1 - utl::Probability::GetFisherCDF(anglesCore[i].first,
593  1 / (anglesCore[i].second * anglesCore[i].second)));
594 
595  if(fPerformScan) {
596  sRec.SetParameter(revt::eBetaScan, anglesCoreScan[i].first);
597  // probability to measure the deviation beta or something greater
598  sRec.SetParameter(
599  revt::eProbBetaScan, 1 - utl::Probability::GetFisherCDF(anglesCoreScan[i].first,
600  1 / (anglesCoreScan[i].second * anglesCoreScan[i].second)));
601  }
602 
603  sRec.SetParameter(revt::eBetaReferenceCore, anglesReferenceCore[i].first);
604  // probability to measure the deviation beta or something greater
605  sRec.SetParameter(
606  revt::eProbBetaReferenceCore, 1 - utl::Probability::GetFisherCDF(anglesReferenceCore[i].first,
607  1 / (anglesReferenceCore[i].second * anglesReferenceCore[i].second)));
608  ++i;
609  }
610  INFO2(eDebug, info.str());
611 
612 
613 
614  if(fFitConfig.LDFModel) {
615  // compute cosmic ray energy
616  TF1 fLDF = TF1("fLDF", "[0]*exp(-x/[1])");
617  fLDF.SetParameter(0, minUstate.Value("A"));
618  fLDF.SetParameter(1, minUstate.Value("R0"));
619  double energy_estimator = fLDF.Eval(110);
620  double energy = GetEnergy(energy_estimator);
621  showerrrec.SetParameter(revt::eEnergy, energy);
622 
623  std::stringstream sstr;
624  sstr << "energy = " << energy << " eV";
625  INFO2(eIntermediate, sstr.str());
626  }
627 
628  if (fSaveContour) {
629  // get uncertainty and plot confidence contour
630  ROOT::Minuit2::MnContours contours(fitFunction, minimum);
631  fitFunction.SetErrorDef(2.3); // 68% confidence
632  std::vector<std::pair<double, double> > cont = contours(0, 1, 40);
633 
634  fitFunction.SetErrorDef(5.99); // 95% confidence
635  std::vector<std::pair<double, double> > cont2 = contours(0, 1, 40);
636 
637  // save contour
638  VModule::ResultFlag result = SaveContours(runNumber, eventId, cont, cont2, cov,
639  minUstate.Value("coreX"), minUstate.Value("coreY"));
640  if (result != eSuccess) {
641  return result;
642  }
643 
644 // ROOT::Minuit2::MnPlot plot;
645 // plot(minimum.UserState().Value("coreX"), minimum.UserState().Value("coreY"), cont);
646  }
647 
648  return eSuccess;
649 }
650 
651 
652 VModule::ResultFlag RdLDFFitter::Finish()
653 {
654  // Put any termination or cleanup code here.
655  // This method is called once at the end of the run.
656 
657  INFO("RdLDFFitter::Finish()");
658 
659  return eSuccess;
660 }
661 
662 
663 
665 utl::Point RdLDFFitter::Scan(std::vector< std::vector<double> >& scanResult, const LDFLikelihoodFunction L,
666  const utl::Point core,
667  const unsigned int nStepsX, const unsigned int nStepsY,
668  const double widthX, const double widthY, const double a)
669 {
670  const double coreX = core.GetX(fLocalCS);
671  const double coreY = core.GetY(fLocalCS);
672  const double coreZ = core.GetZ(fLocalCS);
673 
674  std::stringstream msg;
675  msg.str("");
676  msg << "Scan of Likelihood function around " << coreX << ", " << coreY << " will be performed\n"
677  << nStepsX << " steps in x direction with width " << widthX << "\n"
678  << nStepsY << " steps in y direction with width " << widthY;
679  INFO2(eIntermediate, msg.str().c_str());
680 
681  double Lmin = 9999999999;
682  double xmin(0), ymin(0);
683 
684  msg.str("");
685  msg << "loop from " << - (int) (nStepsX / 2) << " to " << nStepsX / 2;
686  INFO2(eDebug, msg.str().c_str());
687  msg.str("");
688  for (unsigned int iX = 0; iX < nStepsX; ++iX) {
689  const double x = coreX + static_cast<int>(iX - nStepsX/2) * widthX;
690  for (unsigned int iY = 0; iY < nStepsY; ++iY) {
691  const double y = coreY + static_cast<int>(iY - nStepsY/2) * widthY;
692  const double arr[] = {x, y, coreZ, a};
693  std::vector<double> params (arr, arr + sizeof(arr) / sizeof(arr[0]) );
694  double temp = L(params);
695  msg << temp << " ";
696  scanResult[iX][iY] = temp;
697  if(temp < Lmin) {
698  Lmin = temp;
699  xmin = x;
700  ymin = y;
701  }
702  }
703  }
704  msg << "\bLmin is " << Lmin;
705  INFO2(eDebug, msg.str());
706 
707  msg.str("");
708  msg << "Scan result: delta -2*logLikelihood at given core position is "
709  << scanResult[nStepsX/2+1][nStepsY/2+1]<< "\n"
710  << "this corresponds to a probability of " << TMath::Prob(scanResult[nStepsX/2+1][nStepsY/2+1], 2) << "\n"
711  << "this corresponds to sigma = " << TMath::NormQuantile(TMath::Prob(scanResult[nStepsX/2+1][nStepsY/2+1], 2));
712  INFO2(eIntermediate, msg.str());
713 
714  for(std::vector< std::vector<double> >::iterator it = scanResult.begin(); it != scanResult.end(); ++it) {
715  for(std::vector<double>::iterator it2 = it->begin(); it2 != it->end(); ++it2) {
716  *it2 = *it2 - Lmin;
717  }
718  }
719  return utl::Point(xmin, ymin, coreZ, fLocalCS);
720 }
721 
722 
723 std::string GetFormattedNumber(const double number) {
724  std::stringstream msg;
725  msg.str("");
726  if(number >= 0.01) {
727  msg << std::setprecision(2) << std::fixed << number;
728  } else {
729  msg << std::setprecision(1) << std::scientific << number;
730  }
731  return msg.str();
732 }
733 
734 fwk::VModule::ResultFlag RdLDFFitter::PlotScan(const std::vector<std::vector<double> >& scanResult,
735  const std::string filename,
736  const utl::Point scanCenter, const utl::CoordinateSystemPtr cs,
737  const utl::Point referenceCore, const utl::Point coreRd,
738  const unsigned int nStepsX, const unsigned int nStepsY,
739  const double widthX, const double widthY,
740  const std::vector<StationFitData>& vStationFitData,
741  const EventFitData& eventFitData, const double a)
742 {
743  bool plotDebug = false;
744  const det::Detector& detector = det::Detector::GetInstance();
745  const rdet::RDetector& rDetector = detector.GetRDetector();
746  const double coreX = scanCenter.GetX(cs);
747  const double coreY = scanCenter.GetY(cs);
748  // define sigma contours in 2D
749 
750  TH2D h = TH2D("h", "", nStepsX,
751  coreX - static_cast<int>(nStepsX / 2) * widthX - 0.5 * widthX,
752  coreX + static_cast<int>(nStepsX / 2) * widthX + 0.5 * widthX, nStepsY,
753  coreY - static_cast<int>(nStepsY / 2) * widthY - 0.5 * widthY,
754  coreY + static_cast<int>(nStepsY / 2) * widthY + 0.5 * widthY);
755  double minimum = 9999999.;
756  std::pair<double, double> minimum_bin (0,0);
757  std::stringstream msg;
758  msg.str("");
759  for (unsigned int iY = 0; iY < nStepsY; ++iY) {
760  const double y = coreY + static_cast<int>(iY - nStepsY/2) * widthY;
761  for (unsigned int iX = 0; iX < nStepsX; ++iX) {
762  const double x = coreX + static_cast<int>(iX - nStepsX/2) * widthX;
763  msg << scanResult[iX][iY] << " ";
764  h.Fill(x, y, scanResult[iX][iY]);
765  if(scanResult[iX][iY] < minimum) {
766  minimum = scanResult[iX][iY];
767  minimum_bin.first = x;
768  minimum_bin.second = y;
769  }
770  }
771  }
772  INFO2(eDebug, msg.str());
773 
774  TCanvas c1("c1", "", 1000,822);
775  c1.cd();
776  c1.GetPad(0)->SetTopMargin(0.02);
777  c1.GetPad(0)->SetLeftMargin(0.10);
778  c1.GetPad(0)->SetBottomMargin(0.08);
779  c1.GetPad(0)->SetRightMargin(0.16);
780  h.GetXaxis()->SetTitle("x [m]");
781  h.GetYaxis()->SetTitle("y [m]");
782  h.GetYaxis()->SetTitleOffset(1.2);
783  h.GetZaxis()->SetTitle("-2 ln(L)");
784  h.GetZaxis()->SetTitleOffset(1.3);
785  if(fPlotSigmaContours) {
786  const unsigned int nContours = 9;
787  const double contours[nContours] = { -0.00001, 2.29574893, 6.18007431, 11.82915808, 19.33390861, 28.74370243,
788  40.08724343, 53.3822385, 68.50378784};
789  h.SetContour(nContours, contours);
790  h.GetZaxis()->SetRangeUser(-0.00001, 1.1*68.50378784);
791  }
792  h.SetStats(false);
793  h.Draw("COLZ");
794 
795  TLegend leg = TLegend(0.6,0.8,0.84,0.98);
796 
797 
798  // plot radio stations
799  if(plotDebug) {
800  const std::vector<int>& stationList = rDetector.GetFullStationList();
801  TGraph gPosAll = TGraph(stationList.size());
802  for(unsigned int i = 0; i< stationList.size(); ++i) {
803  const utl::Point position = rDetector.GetStation(stationList[i]).GetPosition();
804  gPosAll.SetPoint(i, position.GetX(cs), position.GetY(cs));
805  }
806  gPosAll.SetMarkerColor(1);
807  gPosAll.SetMarkerStyle(8);
808  gPosAll.SetMarkerSize(2);
809  gPosAll.Draw("Psame");
810  leg.AddEntry(&gPosAll,"RDS", "P");
811  }
812 
813  TGraph gPos = TGraph(vStationFitData.size());
814  for(unsigned int i = 0; i< vStationFitData.size(); ++i) {
815  gPos.SetPoint(i, vStationFitData[i].antennaPosition.GetX(cs), vStationFitData[i].antennaPosition.GetY(cs));
816  }
817  if(plotDebug) {
818  gPos.SetMarkerColor(1);
819  gPos.SetMarkerStyle(22);
820  gPos.SetMarkerSize(2);
821  } else {
822  gPos.SetMarkerColor(1);
823  gPos.SetMarkerStyle(8);
824  gPos.SetMarkerSize(2);
825  }
826  gPos.Draw("Psame");
827  leg.AddEntry(&gPos,"Rd station", "P");
828 
829 
830  // compute distance of SD core position to likelihood minima in terms of sigma
831  const double sigma = TMath::Prob(scanResult[nStepsX/2][nStepsY/2], 2);
832 
833  // plot SD core
834  TGraph gSDCore(1);
835  gSDCore.SetPoint(0, referenceCore.GetX(cs), referenceCore.GetY(cs));
836  gSDCore.SetMarkerStyle(29);
837  gSDCore.SetMarkerColor(6);
838  gSDCore.SetMarkerSize(4);
839  gSDCore.Draw("Psame");
840  msg.str("");
842  msg << "SD";
843  }
844  if(fConstEvent->HasSimShower()) {
845  msg << "MC";
846  }
847  msg << " core";
848  if(plotDebug) {
849  msg << "(p=" << GetFormattedNumber(sigma) << ")";
850  }
851  leg.AddEntry(&gSDCore, msg.str().c_str(), "P");
852 
853  // draw incoming azimuth direction
854  TLine line = TLine();
855  line.SetLineWidth(2);
856  const double azimuth = fConstEvent->GetRecShower().GetRRecShower().GetAxis().GetPhi(fLocalCS);
857  const double length = nStepsX * widthX * 0.25;
858  line.DrawLine(referenceCore.GetX(cs), referenceCore.GetY(cs), referenceCore.GetX(cs) + cos(azimuth) * length,
859  referenceCore.GetY(cs) + sin(azimuth) * length);
860 
861  // plot improved SD core
862 // utl::Point coreSdImproved;
863 // if(fConstEvent->GetRecShower().HasSRecShower()) {
864 // coreSdImproved = fConstEvent->GetRecShower().GetSRecShower().GetCorrectedCorePosition();
865 // TGraph gSDCoreImproved(1); // graph needs to be defined to make it variable available in other if clauses
866 // if(fPlotStyle > 0) {
867 // gSDCoreImproved.SetPoint(0, coreSdImproved.GetX(cs), coreSdImproved.GetY(cs));
868 // gSDCoreImproved.SetMarkerStyle(29);
869 // gSDCoreImproved.SetMarkerColor(2);
870 // gSDCoreImproved.SetMarkerSize(4);
871 // gSDCoreImproved.Draw("Psame");
872 // msg.str("");
873 // msg << "SD core improved (" << std::setprecision(0) << std::fixed
874 // << coreSdImproved.GetX(cs) / utl::m << "m," << coreSdImproved.GetY(cs) / utl::m << "m)";
875 // leg.AddEntry(&gSDCoreImproved, msg.str().c_str(), "P");
876 // }
877 // }
878 
879  // plot Rd core
880  TGraph gRdCore(1);
881  gRdCore.SetPoint(0, coreRd.GetX(cs), coreRd.GetY(cs));
882  gRdCore.SetMarkerStyle(23);
883  gRdCore.SetMarkerColor(6);
884  gRdCore.SetMarkerSize(3);
885  gRdCore.Draw("Psame");
886 
887  msg.str("");
888  msg << "Rd core";
889  if(plotDebug) {
890  msg << "(" << std::setprecision(0) << std::fixed << coreRd.GetX(cs) / utl::m << "m," << coreRd.GetY(cs) / utl::m << "m)";
891  }
892  leg.AddEntry(&gRdCore, msg.str().c_str(), "P");
893 
895  double sizeFactor = 1.51; // to get 68 % coverage for one sigma intervals in 2D
896  double sx2 = eventFitData.SDCoreXError * eventFitData.SDCoreXError;
897  double sy2 = eventFitData.SDCoreYError * eventFitData.SDCoreYError;
898  double sxy = eventFitData.SDCoreXError * eventFitData.SDCoreYError * eventFitData.SDCoreXYCorrelation;
899  double errorEllipseAngle = 0.5 * atan2(2 * sxy, sx2 - sy2);
900  double sa = sin(errorEllipseAngle);
901  double ca = cos(errorEllipseAngle);
902  double ru = sizeFactor * sqrt(sx2 * ca * ca + 2 * sxy * sa * ca + sy2 * sa * sa);
903  double rv = sizeFactor * sqrt(sx2 * sa * sa - 2 * sxy * sa * ca + sy2 * ca * ca);
904  TEllipse cc = TEllipse(referenceCore.GetX(cs), referenceCore.GetY(cs), ru, rv, 0., 360.,
905  errorEllipseAngle / utl::deg);
906  msg.str("");
907  msg << "plotting SD error ellipse with " << referenceCore.GetX(cs) << ", "
908  << referenceCore.GetY(cs) << ", " << ru << ", " << rv << ", " << errorEllipseAngle / utl::deg;
909  INFO2(eDebug, msg.str());
910  cc.SetFillColor(16);
911  cc.SetLineColor(15);
912  cc.SetFillStyle(3017);
913  cc.Draw("F");
914  }
915 
916  msg.str("");
917  msg << "scan min (" << std::setprecision(0) << std::fixed << minimum_bin.first << "m,"
918  << minimum_bin.second << "m)";
919  if(plotDebug) {
920  leg.AddEntry(&gRdCore, msg.str().c_str(), "");
921  }
922  leg.Draw();
923 
924  // rd core from fit
925  std::vector<std::pair<double, double> > angles = GetAnglesToEFieldExpectation(coreRd, a);
926  double meanAngle(0.);
927  //double meanAngleSigma(0.);
928  unsigned int n = angles.size();
929  double p_value_combined(0.);
930  double p_Likelihood = 0.;
931  for(unsigned int i = 0; i < n; ++i) {
932  meanAngle += angles[i].first;
933  //meanAngleSigma += angles[i].first/angles[i].second;
934  const double p_value = 1 - utl::Probability::GetFisherCDF(angles[i].first,
935  1 / (angles[i].second * angles[i].second));
936  p_value_combined += log(p_value);
937  p_Likelihood += -2 * log(utl::Probability::GetFisherPDF(angles[i].first,
938  1 / (angles[i].second * angles[i].second)));
939  }
940  p_value_combined *= -2.;
941  meanAngle /= n;
942  //meanAngleSigma /= n;
943 
944  TLatex text;
945  text.SetNDC(true);
946  msg.str("");
947  msg << "#bar{#beta}_{fit} = " << std::setprecision(1) << std::fixed << TMath::RadToDeg() * meanAngle
948  << "#circ, p=" << GetFormattedNumber(TMath::Prob(p_value_combined, 2 * n));
949  if(fPlotStyle > 0) {
950  msg << ", L=" << p_Likelihood;
951  }
952  text.SetTextSize(0.030);
953  double yy = 0.77;
954  double xx = 0.6;
955  if(plotDebug) {
956  yy = 0.67;
957  xx = 0.68;
958  }
959  const double dy = 0.035;
960  // text.DrawLatex(xx, yy, msg.str().c_str());
961  // yy -= dy;
962  fEvent->GetRecShower().GetRRecShower().SetParameter(revt::eProbRdCorePol, TMath::Prob(p_value_combined, 2 * n));
963 
964 
965  // scan minima
967  utl::Point(minimum_bin.first, minimum_bin.second, coreRd.GetZ(cs), cs), a);
968  meanAngle = 0.;
969  //meanAngleSigma = 0.;
970  n = angles.size();
971  p_value_combined = 0.;
972  p_Likelihood = 0.;
973  for(unsigned int i = 0; i < n; ++i) {
974  meanAngle += angles[i].first;
975  //meanAngleSigma += angles[i].first/angles[i].second;
976  const double p_value = 1 - utl::Probability::GetFisherCDF(angles[i].first,
977  1 / (angles[i].second * angles[i].second));
978  p_value_combined += log(p_value);
979  p_Likelihood += -2 * log( utl::Probability::GetFisherPDF(angles[i].first,
980  1 / (angles[i].second * angles[i].second)));
981  }
982  p_value_combined *= -2.;
983  meanAngle /= n;
984  //meanAngleSigma /= n;
985  msg.str("");
986  msg << "#bar{#beta}_{scan} = " << std::setprecision(1) << std::fixed << TMath::RadToDeg() * meanAngle
987  << "#circ, p=" << GetFormattedNumber(TMath::Prob(p_value_combined, 2 * n));
988  if(fPlotStyle > 0) {
989  msg << ", L=" << p_Likelihood;
990  }
991  // text.DrawLatex(xx, yy, msg.str().c_str());
992  // yy -= dy;
993  fEvent->GetRecShower().GetRRecShower().SetParameter(revt::eProbRdCoreScanPol, TMath::Prob(p_value_combined, 2 * n));
994 
995  // SD core
996  angles = GetAnglesToEFieldExpectation(referenceCore, a);
997  meanAngle = 0.;
998  //meanAngleSigma = 0.;
999  n = angles.size();
1000  p_value_combined = 0.;
1001  p_Likelihood = 0.;
1002  for(unsigned int i = 0; i < n; ++i) {
1003  meanAngle += angles[i].first;
1004  //meanAngleSigma += angles[i].first/angles[i].second;
1005  const double p_value = 1
1006  - utl::Probability::GetFisherCDF(angles[i].first,
1007  1 / (angles[i].second * angles[i].second));
1008  p_value_combined += log(p_value);
1009  p_Likelihood += -2
1010  * log(
1011  utl::Probability::GetFisherPDF(angles[i].first,
1012  1 / (angles[i].second * angles[i].second)));
1013  }
1014  p_value_combined *= -2.;
1015  meanAngle /= n;
1016  //meanAngleSigma /= n;
1017  msg.str("");
1018  msg << "#bar{#beta}_{SD} = " << std::setprecision(1) << std::fixed << TMath::RadToDeg() * meanAngle
1019  << "#circ, p=" << GetFormattedNumber(TMath::Prob(p_value_combined, 2 * n));
1020  if(fPlotStyle > 0) {
1021  msg << ", L=" << p_Likelihood;
1022  }
1023 // text.DrawLatex(xx, yy, msg.str().c_str());
1024 // yy -= dy;
1025  fEvent->GetRecShower().GetRRecShower().SetParameter(revt::eProbSdCorePol, TMath::Prob(p_value_combined, 2 * n));
1026 
1027 // // improved SD core
1028 // if(fConstEvent->GetRecShower().HasSRecShower() and fPlotStyle > 0) {
1029 // angles = GetAnglesToEFieldExpectation(coreSdImproved);
1030 // meanAngle = 0.;
1031 // meanAngleSigma = 0.;
1032 // n = angles.size();
1033 // p_value_combined = 0.;
1034 // p_Likelihood = 0.;
1035 // for(unsigned int i = 0; i < n; ++i) {
1036 // meanAngle += angles[i].first;
1037 // meanAngleSigma += angles[i].first/angles[i].second;
1038 // const double p_value = 1
1039 // - utl::Probability::GetFisherCDF(angles[i].first,
1040 // 1 / (angles[i].second * angles[i].second));
1041 // p_value_combined += log(p_value);
1042 // p_Likelihood += -2
1043 // * log(
1044 // utl::Probability::GetFisherPDF(angles[i].first,
1045 // 1 / (angles[i].second * angles[i].second)));
1046 // }
1047 // p_value_combined *= -2.;
1048 // meanAngle /= n;
1049 // meanAngleSigma /= n;
1050 // msg.str("");
1051 // msg << "#bar{#beta}_{SD+} = " << std::setprecision(1) << std::fixed << TMath::RadToDeg() * meanAngle
1052 // << "#circ, p=" << GetFormattedNumber(TMath::Prob(p_value_combined, 2 * n));
1053 // if(fPlotStyle > 0) {
1054 // msg << ", L=" << p_Likelihood;
1055 // }
1056 // text.DrawLatex(xx, yy, msg.str().c_str());
1057 // yy -= dy;
1058 // }
1059 // fEvent->GetRecShower().GetRRecShower().SetParameter(revt::eProbSdCoreImprovedPol, TMath::Prob(p_value_combined, 2 * n));
1060 
1061  // angel to Lorentz
1062  angles = GetAnglesToLorentzVector();
1063  meanAngle = 0.;
1064  double meanSigma = 0.;
1065  double minSigma = 999.;
1066  n = angles.size();
1067  for(unsigned int i = 0; i < n; ++i) {
1068  meanAngle += angles[i].first;
1069  meanSigma += angles[i].second;
1070  if(angles[i].second < minSigma) {
1071  minSigma = angles[i].second;
1072  }
1073  }
1074  meanAngle /= n;
1075  meanSigma /= n;
1076  msg.str("");
1077  msg << "#delta = " << std::setprecision(1) << std::fixed << TMath::RadToDeg() * meanAngle
1078  << "#circ"
1079  << " #sigma_{min}=" << minSigma * TMath::RadToDeg() << "#circ #bar{#sigma}=" << meanSigma * TMath::RadToDeg() << "#circ";
1080 // text.DrawLatex(xx, yy, msg.str().c_str());
1081 // yy -= dy;
1082 
1083 
1085  msg.str("");
1086  const double energy = fConstEvent->GetRecShower().GetSRecShower().GetEnergy();
1087  msg << "E = " << std::setprecision(2) << std::fixed << energy / utl::EeV << "EeV";
1088  text.DrawLatex(xx, yy, msg.str().c_str());
1089  yy -= dy;
1090  // plot zenith
1091  msg.str("");
1092  const double zenith = fConstEvent->GetRecShower().GetSRecShower().GetAxis().GetTheta(fLocalCS);
1093  msg << "#Theta = " << std::setprecision(1) << std::fixed << zenith / utl::deg << "#circ";
1094  text.DrawLatex(xx, yy, msg.str().c_str());
1095  yy -= dy;
1096  }
1097  if(fConstEvent->HasSimShower()) {
1098  msg.str("");
1099  const double energy = fConstEvent->GetSimShower().GetEnergy();
1100  msg << "E = " << std::setprecision(2) << std::fixed << energy / utl::EeV << "EeV";
1101  text.DrawLatex(xx, yy, msg.str().c_str());
1102  yy -= dy;
1103  // plot zenith
1104  msg.str("");
1106  const double zenith = (-fConstEvent->GetSimShower().GetDirection()).GetTheta(localCS);
1107  msg << "#Theta = " << std::setprecision(1) << std::fixed << zenith / utl::deg << "#circ";
1108  text.DrawLatex(xx, yy, msg.str().c_str());
1109  yy -= dy;
1110  }
1111 
1112  msg.str("");
1113  msg << "a = " << std::setprecision(2) << a;
1114  text.DrawLatex(xx, yy, msg.str().c_str());
1115  yy -= dy;
1116 
1117  double distance = (referenceCore - coreRd).GetMag();
1118  msg.str("");
1119  msg << "D_{to SD} = " << std::setprecision(1) << distance / utl::m << " m";
1120  text.DrawLatex(xx, yy, msg.str().c_str());
1121  // yy -= dy; // not useful here
1122 
1123 
1124 
1125  c1.SaveAs(filename.c_str());
1126  c1.SaveAs((filename+".C").c_str());
1127 
1128  return eSuccess;
1129 }
1130 
1131 std::vector<std::pair<double, double> > RdLDFFitter::GetAnglesToEFieldExpectation(const utl::Point core, const double a)
1132 {
1133  const det::Detector& detector = det::Detector::GetInstance();
1134  const rdet::RDetector& rDetector = detector.GetRDetector();
1135  std::vector<std::pair<double, double> > angles;
1137  sIt != fREvent->SignalStationsEnd(); ++sIt) {
1138  const StationRecData& sRec = sIt->GetRecData();
1139  utl::Vector currentEField = utl::Normalized(
1140  utl::Vector(sRec.GetParameter(revt::eEFieldVectorEW),
1141  sRec.GetParameter(revt::eEFieldVectorNS),
1142  sRec.GetParameter(revt::eEFieldVectorV), fLocalCS));
1143  const utl::Point stationPosition = rDetector.GetStation(*sIt).GetPosition();
1144  double angleToExpectedEField= utl::RadioGeometryUtilities::GetAngleToEFieldExpectation2D(currentEField,
1145  core, fShowerAxis, stationPosition, fMagneticFieldAxis, a, fLocalCS);
1146  if (angleToExpectedEField > TMath::Pi() / 2.) {
1147  angleToExpectedEField = TMath::Pi() - angleToExpectedEField;
1148  }
1149  angles.push_back(std::pair<double, double>(angleToExpectedEField,
1150  sRec.GetParameterError(revt::eAngleToLorentzVector)));
1151  }
1152  return angles;
1153 }
1154 
1155 std::vector<std::pair<double, double> > RdLDFFitter::GetAnglesToLorentzVector()
1156 {
1157  const det::Detector& detector = det::Detector::GetInstance();
1158  const rdet::RDetector& rDetector = detector.GetRDetector();
1159  std::vector<std::pair<double, double> > angles;
1161  sIt != fREvent->SignalStationsEnd(); ++sIt) {
1162  const StationRecData& sRec = sIt->GetRecData();
1163  utl::Vector currentEField = utl::Normalized(
1164  utl::Vector(sRec.GetParameter(revt::eEFieldVectorEW),
1165  sRec.GetParameter(revt::eEFieldVectorNS),
1166  sRec.GetParameter(revt::eEFieldVectorV), fLocalCS));
1167  const utl::Point stationPosition = rDetector.GetStation(*sIt).GetPosition();
1169  double angleToExpectedEField = utl::Angle(expectedEField, currentEField);
1170  if (angleToExpectedEField > TMath::Pi() / 2.) {
1171  angleToExpectedEField = TMath::Pi() - angleToExpectedEField;
1172  }
1173  if(fabs(angleToExpectedEField - sRec.GetParameter(revt::eAngleToLorentzVector)) < 0.0001) {
1174  std::cout << "angle to Lorentz angle unequal " << std::endl;
1175  }
1176  angles.push_back(
1177  std::pair<double, double>(angleToExpectedEField,
1178  sRec.GetParameterError(revt::eAngleToLorentzVector)));
1179  }
1180  return angles;
1181 }
1182 
1183 fwk::VModule::ResultFlag RdLDFFitter::PlotGoodnessOfFit(const std::string folder,
1184  const std::string eventIdentifier,
1185  const utl::Point core)
1186 {
1187  const det::Detector& detector = det::Detector::GetInstance();
1188  const rdet::RDetector& rDetector = detector.GetRDetector();
1189  TH1D hAngleToExpectedEField = TH1D("hAngleToExpectedEField", "", 18,0,90);
1190  hAngleToExpectedEField.GetXaxis()->SetTitle("#angle(#vec{E}_{exp}, #vec{E}_{measured})");
1191  hAngleToExpectedEField.GetYaxis()->SetTitle("entries");
1192 
1193  TH1D hAngleToExpectedEFieldSigma = TH1D("hAngleToExpectedEFieldSigma", "", 20,0,10);
1194  hAngleToExpectedEFieldSigma.GetXaxis()->SetTitle("#angle(#vec{E}_{exp}, #vec{E}_{measured})/#sigma_{#vec{E}_{measured}}");
1195  hAngleToExpectedEFieldSigma.GetYaxis()->SetTitle("entries");
1196 
1198  sIt != fREvent->SignalStationsEnd(); ++sIt) {
1199 // Station& station = *sIt;
1200  const StationRecData& sRec = sIt->GetRecData();
1201  utl::Vector currentEField = utl::Normalized(
1202  utl::Vector(sRec.GetParameter(revt::eEFieldVectorEW),
1203  sRec.GetParameter(revt::eEFieldVectorNS),
1204  sRec.GetParameter(revt::eEFieldVectorV), fLocalCS));
1205  const utl::Point stationPosition = rDetector.GetStation(*sIt).GetPosition();
1208  double angleToExpectedEField = utl::Angle(expectedEField, currentEField);
1209  if (angleToExpectedEField > TMath::Pi() / 2) {
1210  angleToExpectedEField = TMath::Pi() - angleToExpectedEField;
1211  }
1212  hAngleToExpectedEField.Fill(angleToExpectedEField*TMath::RadToDeg());
1213  hAngleToExpectedEFieldSigma.Fill(angleToExpectedEField/sRec.GetParameterError(revt::eAngleToLorentzVector));
1214  }
1215  TCanvas c1("c1", "", 800,800);
1216  c1.cd();
1217  hAngleToExpectedEField.SetLineWidth(2);
1218  hAngleToExpectedEField.Draw();
1219  c1.SaveAs((folder+"/hAngleToEFieldExectation_"+eventIdentifier+".png").c_str());
1220 
1221  TCanvas c2("c2", "", 800,800);
1222  c2.cd();
1223  hAngleToExpectedEFieldSigma.SetLineWidth(2);
1224  hAngleToExpectedEFieldSigma.Draw();
1225  c2.SaveAs((folder+"/hAngleToEFieldExectation_"+eventIdentifier+"_sigma.png").c_str());
1226  return eSuccess;
1227 }
1228 
1229 VModule::ResultFlag RdLDFFitter::SaveScan(const std::vector< std::vector<double> >& scanResult,
1230  const std::string filename,
1231  const double coreX, const double coreY,
1232  const unsigned int nStepsX, const unsigned int nStepsY,
1233  const double widthX, const double widthY) {
1234  std::ofstream myfile (filename.c_str());
1235  if (myfile.is_open()) {
1236  for (unsigned int iX = 0; iX < nStepsX; ++iX) {
1237  const double x = coreX + static_cast<int>(iX - nStepsX/2) * widthX;
1238  myfile << "\t" << x;
1239  }
1240  myfile << "\n";
1241 
1242  for (unsigned int iY = 0; iY < nStepsY; ++iY) {
1243  const double y = coreY + static_cast<int>(iY - nStepsY/2) * widthY;
1244  myfile << y;
1245  for (unsigned int iX = 0; iX < nStepsX; ++iX) {
1246  myfile << "\t" << scanResult[iX][iY];
1247  }
1248  myfile << "\n";
1249  }
1250  myfile.close();
1251  return eSuccess;
1252  }
1253  else WARNING("Unable to open file");
1254  return eFailure;
1255 }
1256 
1257 double RdLDFFitter::GetEnergy(const double energy_estimator)
1258 {
1259  return 1.35e15 * pow(energy_estimator / utl::micro / utl::volt * utl::meter, 0.98) * utl::eV;
1260 }
1261 
1262 VModule::ResultFlag RdLDFFitter::SaveContours(
1263  unsigned int runNumber, const int eventId,
1264  const std::vector<std::pair<double, double> > contour,
1265  const std::vector<std::pair<double, double> > contour2, ROOT::Minuit2::MnUserCovariance cov,
1266  const double coreX, const double coreY)
1267 {
1268  if (!boost::filesystem::exists("output")) {
1269  WARNING(
1270  "folder \"output\" does not exist. Can't save confidence contours of radio core position fit. Please create the output folder first.");
1271  return eFailure;
1272  }
1273  std::stringstream sstr("");
1274 
1275  sstr << fOutputFolder << "/contour_" << std::setfill('0') << std::setw(6) << runNumber << "_"
1276  << std::setfill('0') << std::setw(7) << eventId << ".dat";
1277  std::fstream fout;
1278  fout.open(sstr.str().c_str(), std::ios::out);
1279  // save fit result
1280  fout << "# fir result: coreX coreY \n" << coreX << "\t" << coreY << "\n";
1281  // save covariance matrix
1282  fout << "# covariance matrix \n" << cov(0, 0) << "\t" << cov(0, 1) << "\n" << cov(1, 0) << "\t"
1283  << cov(1, 1) << "\n";
1284  fout << "# 68% confidence region: x [m]\t y[m] in local coordinates \n";
1285  for (std::vector<std::pair<double, double> >::const_iterator it = contour.begin();
1286  it != contour.end(); ++it) {
1287  fout << it->first << "\t" << it->second << "\n";
1288  }
1289  fout << "# 95% confidence region: x [m]\t y[m] in local coordinates \n";
1290  for (std::vector<std::pair<double, double> >::const_iterator it = contour2.begin();
1291  it != contour2.end(); ++it) {
1292  fout << it->first << "\t" << it->second << "\n";
1293  }
1294  fout.close();
1295  return eSuccess;
1296 }
1297 
1298 ParameterLDFModel RdLDFFitter::PreLDFFit(int LDFModel, const std::vector<StationFitData>& vStationFitData,
1299  utl::Vector ShowerAxis, utl::Point CorePosition) {
1300  switch (LDFModel) {
1301  case 1: {
1302  TGraphErrors gLDF = TGraphErrors();
1303  for (unsigned int i = 0; i < vStationFitData.size(); ++i) {
1304  StationFitData data = vStationFitData[i];
1306  ShowerAxis, CorePosition, data.antennaPosition);
1307  gLDF.SetPoint(i, distance, data.signal);
1308  gLDF.SetPointError(i, 0., data.signalError);
1309  }
1310  TF1 fLDF = TF1("fLDF", "[0]*exp(-x/[1])");
1311  fLDF.SetParNames("A_0", "R_0");
1312  fLDF.SetParameters(0.1, 100);
1313  gLDF.Fit(&fLDF);
1314 
1315  ParameterLDFModel par;
1316  par.A = fLDF.GetParameter(0);
1317  par.R0 = fLDF.GetParameter(1);
1318  par.AError = fLDF.GetParError(0);
1319  par.R0Error = fLDF.GetParError(1);
1320  return par;
1321  }
1322  default: {
1323  WARNING("Using default LDF model, as chosen model is not implemented\n");
1324  TGraphErrors gLDF = TGraphErrors();
1325  for (unsigned int i = 0; i < vStationFitData.size(); ++i) {
1326  StationFitData data = vStationFitData[i];
1328  ShowerAxis, CorePosition, data.antennaPosition);
1329  gLDF.SetPoint(i, distance, data.signal);
1330  gLDF.SetPointError(i, 0., data.signalError);
1331  }
1332  TF1 fLDF = TF1("fLDF", "[0]*exp(-x/[1])");
1333  fLDF.SetParNames("A_0", "R_0");
1334  fLDF.SetParameters(0.1, 100);
1335  gLDF.Fit(&fLDF);
1336 
1337  ParameterLDFModel par;
1338  par.A = fLDF.GetParameter(0);
1339  par.R0 = fLDF.GetParameter(1);
1340  par.AError = fLDF.GetParError(0);
1341  par.R0Error = fLDF.GetParError(1);
1342  return par;
1343  }
1344  }
1345 }
1346 
1347 ParameterScintillatorLDFModel RdLDFFitter::PreScintillatorLDFFit(
1348  const std::vector<ScintillatorFitData>& vScintillatorData, utl::Vector ShowerAxis,
1349  utl::Point CorePosition)
1350 {
1351  ParameterScintillatorLDFModel tmpFitData;
1352  TGraphErrors g = TGraphErrors();
1353  for (std::vector<ScintillatorFitData>::const_iterator sIt = vScintillatorData.begin(), end =
1354  vScintillatorData.end(); sIt != end; ++sIt) {
1355  double distanceToShowerAxis = utl::RadioGeometryUtilities::GetDistanceToAxis(
1356  ShowerAxis, CorePosition, sIt->scintillatorPosition);
1357  g.SetPoint(g.GetN(), distanceToShowerAxis, sIt->signal);
1358  g.SetPointError(g.GetN() - 1, 0, sqrt(sIt->signal));
1359  }
1360  TF1 *NKG_first_stage = new
1361  TF1("NKG_first_stage",
1362  "[0]*TMath::Gamma(4.5-[1])/(2.*TMath::Pi()*[2]*[2]*TMath::Gamma([1])*TMath::Gamma(4.5-(2.*[1])))*TMath::Power((x/[2]),([1]-2.))*TMath::Power((1+(x/[2])),[1]-4.5)",
1363  0, 1000);
1364 
1365  NKG_first_stage->SetParameter(0, 1. * 1e6);
1366  NKG_first_stage->SetParLimits(0, 100000, 100000000000);
1367 
1368  NKG_first_stage->FixParameter(1, 1.7);
1369  NKG_first_stage->SetParameter(2, 35);
1370  NKG_first_stage->SetParLimits(2, 5, 300);
1371  NKG_first_stage->FixParameter(2, 35);
1372  Int_t fitStatus = g.Fit(NKG_first_stage, "NM");
1373  tmpFitData.status = fitStatus;
1374  tmpFitData.N_e = NKG_first_stage->GetParameter(0);
1375  tmpFitData.N_eError = NKG_first_stage->GetParError(0);
1376  return tmpFitData;
1377 }
1378 } // namespace RdLDFFitter
Branch GetTopBranch() const
Definition: Branch.cc:63
utl::CoordinateSystemPtr GetLocalCoordinateSystem() const
Get the Auger coordinate system associated to the shower core position.
double GetCorrelationXY() const
Class to access station level reconstructed data.
void SetParameter(Parameter i, double value, bool lock=true)
constexpr double eV
Definition: AugerUnits.h:185
bool HasParameter(const Parameter i) const
utl::Vector GetAxis() const
Returns vector of the shower axis.
Point object.
Definition: Point.h:32
constexpr double EeV
Definition: AugerUnits.h:190
static double GetDistanceToAxis(const utl::Vector &ShowerAxis, const utl::Point &CorePosition, const utl::Point &AntennaPosition)
computes the distance from the antenna position to the shower &quot;line&quot; defined by the core position and...
double GetPhi(const CoordinateSystemPtr &coordinateSystem) const
azimuth (phi) angle in spherical and cylindrical coordinates
Definition: BasicVector.h:254
Report success to RunController.
Definition: VModule.h:62
ParameterScintillatorLDFModel PreScintillatorLDFFit(const std::vector< ScintillatorFitData > &vScintillatorData, utl::Vector ShowerAxis, utl::Point CorePosition)
Interface class to access to the SD Reconstruction of a Shower.
static double GetAngleToEFieldExpectation2D(const utl::Vector &measuredEField, const utl::Point &core, const utl::Vector &showeraxis, const utl::Point &stationPosition, const utl::Vector &vMagField, const double chargeExcessStrength, const utl::CoordinateSystemPtr localCS)
StationRecData & GetRecData()
Get station level reconstructed data.
Interface class to access to the Radio part of an event.
Definition: REvent.h:42
double GetTheta(const CoordinateSystemPtr &coordinateSystem) const
zenith (theta) angle in spherical coordinates
Definition: BasicVector.h:248
ShowerRecData & GetRecShower()
Interface class to access to the RD Reconstruction of a Shower.
bool HasSimShower() const
fwk::VModule::ResultFlag PlotScan(const std::vector< std::vector< double > > &scanResult, const std::string filename, const utl::Point scanCenter, const utl::CoordinateSystemPtr cs, const utl::Point coreSd, const utl::Point coreRd, const unsigned int nStepsX, const unsigned int nStepsY, const double widthX, const double widthY, const std::vector< StationFitData > &vStationFitData, const EventFitData &eventFitData, const double a)
Definition: RdLDFFitter.cc:734
double GetParameterError(const Parameter i) const
const std::vector< int > & GetFullStationList() const
Get list of ID&#39;s for all stations available in the database or configuration file.
Definition: RDetector.cc:84
bool HasParameterError(const Parameter i1) const
#define INFO2(x, y)
Definition: RdLDFFitter.cc:78
const double meter
Definition: GalacticUnits.h:29
const utl::Vector & GetCoreError() const
#define INFO(message)
Macro for logging informational messages.
Definition: ErrorLogger.h:161
std::vector< std::pair< double, double > > GetAnglesToEFieldExpectation(const utl::Point core, const double a)
StationIterator StationsEnd()
Definition: REvent.h:130
StationIterator StationsBegin()
Definition: REvent.h:128
void Init()
Initialise the registry.
vector< t2list > out
output of the algorithm: a list of clusters
Definition: XbAlgo.cc:32
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)
boost::filter_iterator< StationFilter, AllStationIterator > StationIterator
Iterator over all (non-exculded) stations.
Definition: REvent.h:125
fwk::VModule::ResultFlag SaveScan(const std::vector< std::vector< double > > &scanResult, const std::string filename, const double coreX, const double coreY, const unsigned int nStepsX, const unsigned int nStepsY, const double widthX, const double widthY)
bool HasREvent() const
ShowerRRecData & GetRRecShower()
ShowerSRecData & GetSRecShower()
double GetEnergy(const double energy_estimator)
fwk::VModule::ResultFlag PlotGoodnessOfFit(const std::string folder, const std::string eventIdentifier, const utl::Point core)
reconstructs the core position and LDF
Detector description interface for RDetector-related data.
Definition: RDetector.h:46
constexpr double deg
Definition: AugerUnits.h:140
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
char * exists
Definition: XbArray.cc:12
Class representing a document branch.
Definition: Branch.h:107
utl::Point GetCoordinateOrigin() const
class to hold data at the radio Station level.
const utl::Vector & GetDirection() const
Get the direction of the shower axis. This is the true direction of shower movement.
double GetX(const CoordinateSystemPtr &coordinateSystem) const
Definition: BasicVector.h:206
std::string GetFormattedNumber(const double number)
Definition: RdLDFFitter.cc:723
const Data result[]
utl::Point Scan(std::vector< std::vector< double > > &scanResult, const LDFLikelihoodFunction L, const utl::Point core, const unsigned int nStepsX, const unsigned int nStepsY, const double widthX, const double widthY, const double a)
nSteps is considered to be odd. If it is even, nSteps will be increased by 1 to be odd...
Definition: RdLDFFitter.cc:665
static utl::Vector GetLorentzVector(const utl::Vector &showeraxis, const utl::Vector &vMagField)
returns the Lorentz force vector normalized to length = 1 for maximal emission (showeraxis vertical t...
bool HasFRecShower() const
Header & GetHeader()
access to REvent Header
Definition: REvent.h:239
Top of the hierarchy of the detector description interface.
Definition: Detector.h:81
const double second
Definition: GalacticUnits.h:32
constexpr double meter
Definition: AugerUnits.h:81
ShowerSimData & GetSimShower()
constexpr double degree
constexpr double g
Definition: AugerUnits.h:200
double GetEnergy() const
Get the energy of the shower primary particle.
Definition: ShowerSimData.h:89
const utl::Vector & GetAxis() const
static const CSpherical kSpherical
Definition: BasicVector.h:335
static double GetFisherPDF(const double x, const double kappa)
Definition: Probability.cc:67
#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 OUT(x)
Definition: RdLDFFitter.cc:77
fwk::VModule::ResultFlag SaveContours(unsigned int runNumber, const int eventId, const std::vector< std::pair< double, double > > contour, const std::vector< std::pair< double, double > > contour2, ROOT::Minuit2::MnUserCovariance cov, const double coreX, const double coreY)
AxialVector Normalized(const AxialVector &v)
Definition: AxialVector.h:81
double GetEnergy() const
const revt::REvent * fREvent
Definition: RdLDFFitter.h:155
double GetParameter(const Parameter i) const
double GetY(const CoordinateSystemPtr &coordinateSystem) const
Definition: BasicVector.h:209
std::vector< std::pair< double, double > > GetAnglesToLorentzVector()
ResultFlag
Flag returned by module methods to the RunController.
Definition: VModule.h:60
bool HasParameter(const Parameter i) const
int GetRunNumber() const
Event id in the run (Start at zero at the beginning of each run) /provided by the daq...
Definition: REvent/Header.h:22
static utl::Vector GetExpectedEFieldVector(const utl::Point &core, const utl::Vector &showeraxis, const utl::Point &stationPosition, const utl::Vector &vMagField, const double chargeExcessStrength)
constexpr double volt
Definition: AugerUnits.h:229
utl::CoordinateSystemPtr GetReferenceCoordinateSystem() const
Get the reference coordinate system used for analysis (usually PampaAmarilla for Auger) ...
Definition: Detector.h:141
uint16_t * data
Definition: dump1090.h:228
utl::CoordinateSystemPtr fLocalCS
Definition: RdLDFFitter.h:143
ParameterLDFModel PreLDFFit(int LDFModel, const std::vector< StationFitData > &vStationFitData, utl::Vector ShowerAxis, utl::Point CorePosition)
void SetParameter(Parameter i, double value, bool lock=true)
double Angle(const Vector &left, const Vector &right)
Definition: OperationsVV.h:82
Vector object.
Definition: Vector.h:30
Interface class to access to Fluorescence reconstruction of a Shower.
Report failure to RunController, causing RunController to terminate execution.
Definition: VModule.h:64
const utl::Point & GetCorePosition() const
utl::Point GetCorePosition() const
returns pointer of the position vector of the core in the reference coor system
constexpr double micro
Definition: AugerUnits.h:65
static double GetFisherCDF(const double x, const double kappa)
Definition: Probability.cc:74
const rdet::RDetector & GetRDetector() const
Definition: Detector.cc:143
double GetParameter(const Parameter i) const
SignalStationIterator SignalStationsEnd()
Definition: REvent.h:114
char * filename
Definition: dump1090.h:266
double GetZ(const CoordinateSystemPtr &coordinateSystem) const
Definition: BasicVector.h:212
utl::Vector fMagneticFieldAxis
Definition: RdLDFFitter.h:159
utl::Point GetPosition() const
Tank position in Site Cartesian Coordinates.
constexpr double m
Definition: AugerUnits.h:121
const Station & GetStation(const int stationId) const
Get station by Station Id.
Definition: RDetector.cc:141
const utl::Point & GetCorePosition() const
Shower core as reconstructed by the FD or FD eye.
bool HasSRecShower() const
int GetId() const
Definition: REvent/Header.h:21
double NKG(const double r, const double n, const double rG, const double s)
Definition: Functions.cc:68
const evt::Event * fConstEvent
Definition: RdLDFFitter.h:156
boost::filter_iterator< SignalStationFilter, AllStationIterator > SignalStationIterator
Iterator over all signal stations.
Definition: REvent.h:109
void SetParameterCovariance(Parameter i1, Parameter i2, double value, bool lock=true)
SignalStationIterator SignalStationsBegin()
Definition: REvent.h:112
boost::filter_iterator< SignalStationFilter, ConstAllStationIterator > ConstSignalStationIterator
Definition: REvent.h:110

, generated on Tue Sep 26 2023.