3 #include <fwk/CentralConfig.h>
4 #include <fwk/RandomEngineRegistry.h>
6 #include <det/Detector.h>
9 #include <evt/ShowerSimData.h>
10 #include <evt/DefaultShowerGeometryProducer.h>
12 #include <utl/AugerUnits.h>
13 #include <utl/ErrorLogger.h>
14 #include <utl/Reader.h>
15 #include <utl/PhysicalConstants.h>
16 #include <utl/RandomEngine.h>
17 #include <utl/Particle.h>
18 #include <utl/NucleusProperties.h>
19 #include <utl/RandomSamplerFromPDF.h>
21 #include <CLHEP/Random/RandFlat.h>
28 using CLHEP::RandFlat;
31 PrimaryGenerator::~PrimaryGenerator()
51 if (fMaxLogE < fMinLogE || fMinLogE <= 0 || fMaxLogE <= 0) {
53 msg <<
"Wrong energy assignement: " << fMaxLogE <<
" < " << fMinLogE;
60 vector<double> primaryFractions;
61 vector<double> indices;
62 unsigned int index = 0;
63 double totFraction = 0;
65 if (ptypeB.GetName() == string(
"primary")) {
66 fPrimZ.
push_back(ptypeB.GetChild(
"Z").Get<
double>());
67 fPrimA.push_back(ptypeB.GetChild(
"A").Get<
double>());
68 primaryFractions.push_back(ptypeB.GetChild(
"fraction").Get<
double>());
69 indices.push_back(index);
70 totFraction += primaryFractions.back();
75 if (primaryFractions.size() < 1) {
76 ERROR(
"Particle type(s) not specified");
80 if (fabs(totFraction - 1) > 1e-6) {
82 msg <<
"Wrong particle fractions, totFraction = " << totFraction
83 <<
" ... please check!";
89 &RandomEngineRegistry::GetInstance().Get(RandomEngineRegistry::ePhysics);
95 info <<
" Version: " << GetVersionInfo(VModule::eRevisionNumber) <<
"\n"
97 " lg(Emin): " << fMinLogE <<
"\n"
98 " lg(Emax): " << fMaxLogE <<
"\n"
99 " index: " << fIndex <<
"\n"
100 " sampling from: dN/dE = E^index\n";
101 for (
unsigned int i = 0; i < fPrimA.size(); ++i)
102 info <<
" primary " << setw(2) << i <<
":"
103 " A=" << setw(2) << fPrimA[i]
104 <<
" Z=" << setw(2) << fPrimZ[i]
105 <<
" fraction=" << setw(4) << primaryFractions[i] <<
'\n';
116 ERROR(
"Event not cleared - has SimShower. Cannot produce primary.");
126 info <<
"Shower energy log(E/eV)=" << log10(theShower.
GetEnergy());
128 const int prim = fRandomPDF->shoot(fRandomEngine->GetEngine());
130 if (fPrimZ[prim] == 0 && fPrimA[prim] == 0)
132 else if (fPrimZ[prim] == 1 && fPrimA[prim] == 1)
139 if (fVerbosity >= 1) {
148 PrimaryGenerator::Finish()
151 fRandomPDF =
nullptr;
157 PrimaryGenerator::DiceEnergy()
159 if (fMinLogE == fMaxLogE)
160 return pow(10, fMinLogE) *
eV;
162 const double minE =
pow(10, fMinLogE);
163 const double maxE =
pow(10, fMaxLogE);
165 const double randNo = RandFlat::shoot(&fRandomEngine->GetEngine(), 0, 1);
168 return pow(10, fMinLogE + randNo * (fMaxLogE - fMinLogE)) *
eV;
170 return pow(
pow(minE, fIndex + 1) + randNo * (
pow(maxE, fIndex + 1) -
171 pow(minE, fIndex + 1)), 1/(fIndex + 1)) *
eV;
int GetPrimaryParticle() const
Get the type of the shower primary particle.
bool HasSimShower() const
#define INFO(message)
Macro for logging informational messages.
void Init()
Initialise the registry.
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
double pow(const double x, const unsigned int i)
Interface class to access Shower Simulated parameters.
Branch GetNextSibling() const
Get next sibling of this branch.
Class representing a document branch.
ShowerSimData & GetSimShower()
void SetEnergy(const double theEnergy)
Set the energy of the shower primary particle.
double GetEnergy() const
Get the energy of the shower primary particle.
void GetData(bool &b) const
Overloads of the GetData member template function.
void SetPrimaryParticle(const int type)
Set the type of the shower primary particle.
ResultFlag
Flag returned by module methods to the RunController.
void MakeSimShower(const evt::VShowerGeometryProducer &p)
Simple event generator to be used in conjunction with ConexShowerGeneratorKG or ProfileSimulatorOG.
Main configuration utility.
Branch GetFirstChild() const
Get first child of this Branch.
#define ERROR(message)
Macro for logging error messages.
utl::Branch GetTopBranch(const std::string &id)
Get top branch for moduleConfigLink with given id (XML files)