4 #include <conexHEModels.h>
6 #include <io/CONEXStructures.h>
8 #include <atm/Atmosphere.h>
9 #include <atm/InclinedAtmosphericProfile.h>
10 #include <atm/ProfileResult.h>
12 #include <det/Detector.h>
14 #include <tls/Atmosphere.h>
16 #include <utl/AugerException.h>
17 #include <utl/ErrorLogger.h>
18 #include <utl/Particle.h>
19 #include <utl/RandomEngine.h>
20 #include <utl/Reader.h>
21 #include <utl/NucleusProperties.h>
22 #include <utl/ReferenceEllipsoid.h>
23 #include <fwk/RandomEngineRegistry.h>
24 #include <fwk/CentralConfig.h>
26 #include <evt/ShowerSimData.h>
27 #include <evt/Event.h>
33 #include <CLHEP/Random/RandFlat.h>
35 using CLHEP::RandFlat;
36 using namespace ConexShowerGeneratorKG;
48 if (NucleusProperties::IsNucleus(type))
56 errMsg <<
" can not convert particle type " << type <<
" to CONEX ID";
69 const string parameterPathName =
70 topB.
GetChild(
"parameterDirectoryPath") ?
71 topB.
GetChild(
"parameterDirectoryPath").
Get<
string>() :
string(_CONEX_PREFIX) +
"/cfg";
73 const string interactionModelName = topB.
GetChild(
"interactionModel").
Get<
string>();
75 EHEModel interactionModel;
76 if (interactionModelName ==
"QGSJet01")
77 interactionModel = eQGSJet01;
78 else if (interactionModelName ==
"EPOS")
79 #if _CONEX2R_VERSION >= 436
80 interactionModel = eEposLHC;
82 interactionModel = eEpos199;
84 else if (interactionModelName ==
"Sibyll")
85 #if _CONEX2R_VERSION >= 530
86 interactionModel = eSibyll23;
88 interactionModel = eSibyll21;
90 else if (interactionModelName ==
"QGSJetII")
91 interactionModel = eQGSJetII;
94 errMsg <<
" unknown interaction model " << interactionModelName;
104 if (fMinXmax < 0 || fMaxXmax < fMinXmax) {
105 ostringstream errMsg;
106 errMsg <<
" inconsistent xMax range: minXmax = "
107 << fMinXmax /
g *
cm2 <<
", maxXmax = "
108 << fMaxXmax /
g *
cm2 ;
115 if (randomDistanceB) {
116 fRandomDistance =
true;
118 if (fMaxHeight < 0) {
119 ostringstream errMsg;
120 errMsg <<
" maximum height must be positve: maxHeight= "
131 fPropagateAltitude =
false;
132 if (topB.
GetChild(
"propagateAltitude"))
137 if (fStoredGenerations < 0)
138 fStoredGenerations = 0;
139 if (fStoredGenerations > 100)
140 fStoredGenerations = 100;
145 if (fStoredParticles < 0)
146 fStoredParticles = 0;
150 RandomEngineRegistry::GetInstance().Get(RandomEngineRegistry::ePhysics);
151 const long physicsSeed = randomEngine.
GetEngine().getSeed();
155 info <<
" Version: " << GetVersionInfo(VModule::eRevisionNumber) <<
"\n"
157 info <<
" he-model: " << interactionModelName <<
"\n"
158 " he-model-code: " << interactionModel <<
"\n"
159 " conex-config-path: " << parameterPathName <<
"\n"
160 " stored generations: " << fStoredGenerations <<
"\n"
161 " seed: " << physicsSeed <<
"\n";
165 new ConexInterface(interactionModel, parameterPathName, fStoredGenerations, physicsSeed);
175 INFO(
"event without sim shower --> skip ");
190 if (fPropagateAltitude) {
196 info <<
"simulating shower, lg(E/eV)=" << log10(energyInGeV)+9 <<
", "
197 "zenith =" << zenith <<
" "
198 "azimuth=" << azimuth <<
" "
199 "altitude=" << altitude <<
" "
201 "CONEX pid=" << particleType;
208 if (!(fShowerCounter % fRecycle))
209 fConexInterface->SimulateShower(particleType, energyInGeV, zenith, azimuth, altitude, fStoredParticles);
213 const std::vector<io::CONEXLeadingParticles>& fLeadingParticles = fConexInterface->GetLPvector();
219 RandomEngineRegistry::GetInstance().Get(RandomEngineRegistry::ePhysics);
220 const double xMax = RandFlat::shoot(&randEngine.
GetEngine(), fMinXmax, fMaxXmax);
221 xShift = xMax - conexShower.
fXmax *
g/
cm2;
224 if (fRandomDistance) {
226 ERROR(
"RandomDistance only for up-going showers. Skipping shower.");
227 return eContinueLoop;
230 const double maxDistance = -fMaxHeight / cos(zenith *
deg);
232 RandomEngineRegistry::GetInstance().Get(RandomEngineRegistry::ePhysics);
233 const double distanceShift = RandFlat::shoot(&randEngine.
GetEngine(), maxDistance);
235 info <<
"Moving the point of first interaction along the axis to "
236 << distanceShift/
meter <<
" meters from the shower core.";
239 const double depthStepSize = 5 *
g/
cm2;
240 const Atmosphere& atmo = det::Detector::GetInstance().GetAtmosphere();
243 xShift = slantDepthProfile.
Y(distanceShift);
251 stringstream runIdentifier;
252 runIdentifier <<
"cx_" << conexHeader.
fVersion
254 <<
'_' << conexHeader.
fSeed;
264 "\t ----------- CONEX -------------\n";
266 info <<
"\t xmax/g*cm2: "
269 info <<
" [random Xmax] ";
271 info <<
" [random Distance] ";
274 info <<
"\t no GH paramaters!! ";
277 "\t energy/eV: " << simEvent.
GetEnergy()/
eV <<
"\n"
278 "\t zenith/deg: " << zenith <<
"\n"
279 "\t ----------- CONEX ------------- ";
286 ERROR(
"Skipping shower.");
287 return eContinueLoop;
297 delete fConexInterface;
298 fConexInterface =
nullptr;
306 delete fConexInterface;
utl::CoordinateSystemPtr GetLocalCoordinateSystem() const
Get the Auger coordinate system associated to the shower core position.
int GetPrimaryParticle() const
Get the type of the shower primary particle.
unsigned int GetNPoints() const
Top of the interface to Atmosphere information.
virtual double GetAtomicNumber() const
Get atomic mass number A of particle.
Wrapper for CONEX header shower profile data.
void InitSlantProfileModel(const utl::Point &core, const utl::Vector &dir, const double deltaX) const
RandomEngineType & GetEngine()
const evt::VGaisserHillasParameter & GetGHParameters() const
Get the Gaisser-Hillas parameters of the shower.
bool HasSimShower() const
fwk::VModule::ResultFlag Run(evt::Event &event)
Run: invoked once per event.
Class to hold properties of nuclei.
#define INFO(message)
Macro for logging informational messages.
Base class for exceptions trying to access non-existing components.
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
int ConexParticleNumber(const int type)
double Y(const double x) const
Get the Y value (coordinate) for given X (ordinate)
Interface class to access Shower Simulated parameters.
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
Class representing a document branch.
Reference ellipsoids for UTM transformations.
const utl::Vector & GetDirection() const
Get the direction of the shower axis. This is the true direction of shower movement.
virtual ~ConexShowerGenerator()
Wraps the random number engine used to generate distributions.
Class describing the Atmospheric profile.
const utl::Point & GetPosition() const
Get the position of the shower core.
Triple PointToLatitudeLongitudeHeight(const Point &thePoint) const
Convert Point to Lat/Long/Height.
double GetEnergy() const
Get the energy of the shower primary particle.
void GetData(bool &b) const
Overloads of the GetData member template function.
fwk::VModule::ResultFlag Finish()
Finish: invoked at end of the run (NOT end of the event)
ResultFlag
Flag returned by module methods to the RunController.
void SetShowerNumber(const int sid)
bool HasGHParameters() const
Check initialization of the Gaisser-Hillas parameters.
void FillShowerProfileDataFromConex(const CONEXHeader &conexHeader, const CONEXShower &conexShower, const std::vector< io::CONEXLeadingParticles > conexLPvector, const float conexFileVersion, evt::ShowerSimData &, const double xShift=0)
Main configuration utility.
fwk::VModule::ResultFlag Init()
Initialize: invoked at beginning of run (NOT beginning of event)
void SetShowerRunId(const std::string srid)
const atm::ProfileResult & EvaluateSlantDepthVsDistance() const
#define ERROR(message)
Macro for logging error messages.
bool HasLongitudinalProfile(const ProfileType type=eCharged) const
Check initialization of the longitudinal profile.
utl::Branch GetTopBranch(const std::string &id)
Get top branch for moduleConfigLink with given id (XML files)
const utl::TabulatedFunction & GetLongitudinalProfile(const ProfileType type=eCharged) const
Get the longitudinal charge profile of the shower.