RdREASSimPreparatorNG.h
Go to the documentation of this file.
1 #ifndef RdREASSimPreparatorNG_H
2 #define RdREASSimPreparatorNG_H
3 
4 #include <fwk/VModule.h>
5 #include <utl/TimeStamp.h>
6 #include <utl/Point.h>
7 #include <utl/Vector.h>
8 
9 #include <string>
10 #include <vector>
11 #include <boost/tuple/tuple.hpp>
12 
13 
14 namespace utl {
15  class RandomEngine;
16 }
17 
18 namespace RdREASSimPreparatorNG {
19 
29  enum EPrimary {
30  ePhoton = 1,
31  eProton = 14,
33  eTauNeutrino = 133,
34  eHelium = 402,
35  eNitrogen = 1407,
36  eOxygen = 1608,
37  eIron = 5626
38  };
39  // |
40  // v
41  // UPDATE this code if you add new ePrimary
42  const std::map<std::string, EPrimary> ePrimaryConvertor{
43  {"Photon", ePhoton},
44  {"Proton", eProton},
45  {"ElectronNeutrino", eElectronNeutrino},
46  {"TauNeutrino", eTauNeutrino},
47  {"Helium", eHelium},
48  {"Nitrogen", eNitrogen},
49  {"Oxygen", eOxygen},
50  {"Iron", eIron},
51  };
52 
53 
55  struct Option {
56  std::string fName;
57  std::string fContent;
58  std::string fComment;
59  };
60 
61 
63  struct OptionSet {
64  std::string fName;
65  std::vector<Option> fOptions;
66  };
67 
68 
69  struct Set {
71  std::string fPrimary;
72  };
73 
74 
75  struct SimulationInput {
76  double energy;
80  std::string eventId;
81  int rEventId;
82  int runId;
84  };
85 
86 
88  public:
89  fwk::VModule::ResultFlag Init() override;
92 
93  private:
96  void CreateSimulationInput(const SimulationInput& input);
97 
98  // direction only needed for generic AERA simulations
99  utl::Point GetCore(const double zenith = std::nan("1"), const double azimuth = std::nan("1"));
100 
101  std::string CreateCORSIKAContent(const utl::Vector& theAxis,
102  const float energy,
103  const utl::Point& core,
104  const EPrimary primary);
105 
106  std::string CreateCoREASContent(const utl::Point& thecore,
107  const utl::Vector& theAxis,
108  const float energy,
109  const std::string& corsikaparameterfile,
110  const utl::TimeStamp theTime,
111  const std::string eventId,
112  const int rEventId,
113  const int runId);
114 
115  std::string CreateCoREASListContent(const utl::Point& core,
116  const utl::Vector& axis,
117  const EPrimary primary);
118 
119  std::string CreateBashContent(const std::string& inpfilename);
120  void RecordFile(const std::string& filename, const std::string& buffer);
121 
122  std::string GetEventNumber(const std::string& eventid);
123  std::string AddZero(const int runID, const int numberofdigit); // Return runNumber as 000042
124  std::vector<Option> GetOptionSet(const std::string& SetName);
125  bool HasOptionSet(const std::string &SetName);
126 
127  /* Randomly choose SD station with a full crown around it.
128  (Allows to generate core around this "closest" station with GenerateCoreAroundStation() */
130 
131  // Draw core and check that event geometry can hit AERA
132  void GenerateCoreForAERA(utl::Point& theCore, const double zenith, const double azimuth);
133 
134  // Draw core within the inner hexagon around this station
135  void GenerateCoreAroundStation(const utl::Point& center, const std::vector<utl::Point>& crownStations,
136  utl::Point& theCore);
137 
138  /* Returns the (cherenkov) radius (r_che, first) and the distance to the apex (d_depth, second)
139  of an cone for a given (shower) axis (zenith angle) and depth (default = 750 g/cm2).
140  The cherenkov radius is determined as followed:
141  r_che = tan(arccos(1 / n(h_depth))) * d_depth.
142  A parameterized correction can be applied (default no correction) */
143  std::pair<double, double> CherenkovRadius(const utl::Point &theCore, const utl::Vector &theAxis,
144  const double depth = 750 * utl::g / utl::cm2,
145  const bool useParamCorrection = false);
146 
147  // Returns True if station is to far away from simulated core
148  bool IsStationToFarAway(const utl::Point& core, const utl::Vector& axis, const utl::Point& position,
149  const double maxRadius, const double distanceToApex);
150 
151  // Calculates early late corrected axis distance for a given distance to the source (typically Xmax).
152  // Magnetic field is taken from offline model.
153  double GetEarlyLateCorrectedAxisDistance(const utl::Point& core, const utl::Vector& axis,
154  const utl::Point& position, const double distanceToApex);
155 
156  // Returns the SeaLevelRefractiveIndex specified in XML config
158 
159  // Copied from Modules/FdSimulation/ProfileSimulatorOG/ProfileSimulator.cc
160  double PowerLaw(const double min, const double max, const double index) const;
161 
162  // for GenerateCardsWithoutEvent and WriteAERAlist = 1 check if event can hit AERA
163  bool EventHitsAERA(const utl::Point& core, const utl::Vector& axis, const unsigned int nStation,
164  const unsigned int nCherenkov);
165 
167 
173  };
174 
176  bool fSimulateInfillEvent = false;
177 
186 
187  std::vector<double> fDiscreteZenithAngles;
188  std::vector<double> fDiscreteAzimuthAngles;
189  std::vector<double> fDiscreteEnergies;
191 
192  std::string fEventHeader;
193  int fgsRunNumber = 0;
194  int fSeedAmount = 3;
195 
196  unsigned int fNeutrinoInteractionChannel = 1;
203  double fixhei = 0;
204 
205  std::string fWorkingDir;
207  std::string fCreateDatabase;
208  std::string fUserName;
209  std::string fHostName;
210  std::string fCorsikapath;
211  std::string fCorsikaBin;
212  std::string fFLUPRO;
213  std::string fUseGeometry;
214  std::string fUseEnergy;
215 
216  bool fSimulatedParallel = false;
217  double fParallelWeight = 0;
218 
219  bool fModelMagField = false;
220  double fMagFieldDec = 0;
221  double fMagFieldX = 0;
222  double fMagFieldY = 0;
223 
224  double fThinLevel = 0;
225  bool fWriteAERAlist = false;
227  bool fUseCoreDist = false;
228  double fMaxAntDist = 0;
229 
232  double fCherenkovRadii = 0;
233  double fMinMaxAntDist = 0;
234 
237 
238  std::vector<OptionSet> fOptionSets;
239  std::vector<Set> fSimulationSets;
240 
241  unsigned int fNumberOfSkippedEvents = 0;
242 
243  REGISTER_MODULE("RdREASSimPreparatorNG", RdREASSimPreparatorNG);
244  };
245 
246 }
247 
248 
249 #endif
Point object.
Definition: Point.h:32
std::string CreateCoREASContent(const utl::Point &thecore, const utl::Vector &theAxis, const float energy, const std::string &corsikaparameterfile, const utl::TimeStamp theTime, const std::string eventId, const int rEventId, const int runId)
bool IsStationToFarAway(const utl::Point &core, const utl::Vector &axis, const utl::Point &position, const double maxRadius, const double distanceToApex)
double GetEarlyLateCorrectedAxisDistance(const utl::Point &core, const utl::Vector &axis, const utl::Point &position, const double distanceToApex)
std::string CreateCoREASListContent(const utl::Point &core, const utl::Vector &axis, const EPrimary primary)
void RecordFile(const std::string &filename, const std::string &buffer)
bool EventHitsAERA(const utl::Point &core, const utl::Vector &axis, const unsigned int nStation, const unsigned int nCherenkov)
Prepares stearing cards for CORSIKA/CoREAS simulations and scripts for running the simulations...
void CreateSimulationInput(const SimulationInput &input)
A TimeStamp holds GPS second and nanosecond for some event.
Definition: TimeStamp.h:110
#define max(a, b)
fwk::VModule::ResultFlag Run(evt::Event &event) override
Run: invoked once per event.
std::string CreateBashContent(const std::string &inpfilename)
std::pair< double, double > CherenkovRadius(const utl::Point &theCore, const utl::Vector &theAxis, const double depth=750 *utl::g/utl::cm2, const bool useParamCorrection=false)
Wraps the random number engine used to generate distributions.
Definition: RandomEngine.h:27
Structure holding content to be put in the stearing card.
std::string CreateCORSIKAContent(const utl::Vector &theAxis, const float energy, const utl::Point &core, const EPrimary primary)
constexpr double g
Definition: AugerUnits.h:200
const std::map< std::string, EPrimary > ePrimaryConvertor
std::string GetEventNumber(const std::string &eventid)
Extract Event Number from the Event ID string.
SimulationInput FillEventInput(SimulationInput &input, const evt::Event &theEvent)
Module interface.
Definition: VModule.h:53
void GenerateCoreAroundStation(const utl::Point &center, const std::vector< utl::Point > &crownStations, utl::Point &theCore)
std::vector< Option > GetOptionSet(const std::string &SetName)
ResultFlag
Flag returned by module methods to the RunController.
Definition: VModule.h:60
double PowerLaw(const double min, const double max, const double index) const
Vector object.
Definition: Vector.h:30
REGISTER_MODULE("RdREASSimPreparatorNG", RdREASSimPreparatorNG)
SimulationInput FillGenericRandomInput(SimulationInput &input)
void GenerateCoreForAERA(utl::Point &theCore, const double zenith, const double azimuth)
std::string AddZero(const int runID, const int numberofdigit)
fwk::VModule::ResultFlag Finish() override
Finish: invoked at end of the run (NOT end of the event)
char * filename
Definition: dump1090.h:266
utl::Point GetCore(const double zenith=std::nan("1"), const double azimuth=std::nan("1"))
fwk::VModule::ResultFlag Init() override
Initialize: invoked at beginning of run (NOT beginning of event)
constexpr double cm2
Definition: AugerUnits.h:118

, generated on Tue Sep 26 2023.