ArtificialShowerFileParticleIterator.cc
Go to the documentation of this file.
2 
3 #include <iostream>
4 #include <utl/PhysicalConstants.h>
5 #include <fwk/RandomEngineRegistry.h>
6 #include <utl/RandomEngine.h>
7 #include <CLHEP/Random/RandFlat.h>
8 #include <CLHEP/Random/RandPoisson.h>
9 #include <CLHEP/Random/RandGauss.h>
10 #include <fwk/CentralConfig.h>
11 #include <utl/Reader.h>
12 #include <utl/config.h>
13 
14 using namespace std;
15 using namespace utl;
16 using namespace io;
17 using CLHEP::RandFlat;
18 using CLHEP::RandPoisson;
19 using namespace fwk;
20 
21 
22 ArtificialShowerFileParticleIterator::ArtificialShowerFileParticleIterator() :
23  fCurrentParticle(utl::Particle::eUndefined,
24  utl::Particle::eShower,
25  Point(0,0,0, CoordinateSystem::GetRootCoordinateSystem()),
26  Vector(0,0,0, CoordinateSystem::GetRootCoordinateSystem()),
27  TimeInterval(0), 0),
28  fMaxRadius(4000.0*m),
29  fMuonEnergy(2.0*GeV),
30  fPhotonEnergy(80.0*MeV),
31  fElectronEnergy(80.0*MeV),
32  fMuonDensity(0.1/m/m),
33  fPhotonDensity(0.1/m/m),
34  fElectronDensity(0.1/m/m),
35  fParticleZenith(0.0*deg),
36  fParticleAzimuth(0.0*deg),
37  fParticleTime(2000.0*ns),
38  fParticleWeight(100.0),
39  fRandomAzimuth(false),
40  fGeneratedParticles(0)
41 {
43 
45 
46 }
47 
48 
50  double muonEnergy, double photonEnergy, double electronEnergy,
51  double muonDensity, double photonDensity, double electronDensity,
52  double particleZenith, double particleAzimuth, double particleTime,
53  double particleWeight, bool randomAzimuth) :
54  fCurrentParticle(utl::Particle::eUndefined,
55  utl::Particle::eShower,
56  Point(0,0,0, CoordinateSystem::GetRootCoordinateSystem()),
57  Vector(0,0,0, CoordinateSystem::GetRootCoordinateSystem()),
58  TimeInterval(0), 0),
59  fMaxRadius(maxRadius),
60  fMuonEnergy(muonEnergy),
61  fPhotonEnergy(photonEnergy),
62  fElectronEnergy(electronEnergy),
63  fMuonDensity(muonDensity),
64  fPhotonDensity(photonDensity),
65  fElectronDensity(electronDensity),
66  fParticleZenith(particleZenith),
67  fParticleAzimuth(particleAzimuth),
68  fParticleTime(particleTime),
69  fParticleWeight(particleWeight),
70  fRandomAzimuth(randomAzimuth),
71  fGeneratedParticles(0)
72 {
74 }
75 
76 
77 
79 {
80 }
81 
82 
84 {
85  fShowerZenith = showerZenith;
86 }
87 
88 
89 
91 {
92  fShowerAzimuth = showerAzimuth;
93 }
94 
95 
96 
97 
99 {
100  Branch topB = CentralConfig::GetInstance()->GetTopBranch("ArtificialShowerFile");
101  Branch maxRadiusB = topB.GetChild("ShowerRadius");
102  maxRadiusB.GetData(fMaxRadius);
103  Branch muonEnergyB = topB.GetChild("MuonEnergy");
104  muonEnergyB.GetData(fMuonEnergy);
105  Branch photonEnergyB = topB.GetChild("PhotonEnergy");
106  photonEnergyB.GetData(fPhotonEnergy);
107  Branch electronEnergyB = topB.GetChild("ElectronEnergy");
108  electronEnergyB.GetData(fElectronEnergy);
109  Branch muonDensityB = topB.GetChild("MuonDensity");
110  muonDensityB.GetData(fMuonDensity);
111  Branch photonDensityB = topB.GetChild("PhotonDensity");
112  photonDensityB.GetData(fPhotonDensity);
113  Branch electronDensityB = topB.GetChild("ElectronDensity");
114  electronDensityB.GetData(fElectronDensity);
115  Branch particleZenithB = topB.GetChild("ParticleZenith");
116  particleZenithB.GetData(fParticleZenith);
117  Branch particleAzimuthB = topB.GetChild("ParticleAzimuth");
118  particleAzimuthB.GetData(fParticleAzimuth);
119  Branch particleTimeB = topB.GetChild("ParticleTimeWindow");
120  particleTimeB.GetData(fParticleTime);
121  Branch particleWeightB = topB.GetChild("ParticleWeight");
122  particleWeightB.GetData(fParticleWeight);
123  Branch randomAzimuthB = topB.GetChild("RandomParticleAzimuth");
124  randomAzimuthB.GetData(fRandomAzimuth);
125 }
126 
127 
128 
130 {
131  fRandomEngine = &RandomEngineRegistry::GetInstance().Get(RandomEngineRegistry::eDetector).GetEngine();
132 
133 
134  const double particleType = RandFlat::shoot(fRandomEngine,0.0,1.0);
135  const double totalDensity = fMuonDensity + fPhotonDensity + fElectronDensity;
136  const double particleTime = RandFlat::shoot(fRandomEngine,0.0,1.0) * fParticleTime;
137  double particleX = RandFlat::shoot(fRandomEngine, -fMaxRadius, fMaxRadius);
138  double particleY = RandFlat::shoot(fRandomEngine, -fMaxRadius, fMaxRadius);
139 
140  while ( particleX*particleX + particleY*particleY > fMaxRadius * fMaxRadius )
141  {
142  particleX = RandFlat::shoot(fRandomEngine, -fMaxRadius, fMaxRadius);
143  particleY = RandFlat::shoot(fRandomEngine, -fMaxRadius, fMaxRadius);
144  }
145 
146  const double particleAz = fRandomAzimuth ? RandFlat::shoot(fRandomEngine, 0.0, 2.0*kPi) : fParticleAzimuth / rad;
147 
148  const double dirX = sin(fParticleZenith / rad) * cos(particleAz);
149  const double dirY = sin(fParticleZenith / rad) * sin(particleAz);
150  const double dirZ = cos(fParticleZenith / rad) * -1.0;
151 
152  double type;
153  double energy;
154 
155 
156  if (particleType < fMuonDensity / totalDensity)
157  {
159  energy=fMuonEnergy;
160  }
161  else if (particleType < (fPhotonDensity + fMuonDensity) / totalDensity)
162  {
164  energy=fPhotonEnergy;
165  }
166  else
167  {
169  energy=fElectronEnergy;
170  }
171 
173  Point( particleX, particleY, 0.0, groundCS ),
174  Vector( dirX, dirY, dirZ, groundCS ),
175  TimeInterval(particleTime),
177  energy);
178 }
179 
180 
181 Particle*
183 {
184 
186  return NULL;
187 
188 
189  GenerateParticle(groundCS);
190 
192 
193  return &fCurrentParticle;
194 }
195 
196 
197 void
199 {
201 }
202 
203 
204 /*
205 CoordinateSystemPtr
206 ArtificialShowerFileParticleIterator::ComputeExternalShowerCoordinateSystem(const utl::CoordinateSystemPtr& cs)
207 {
208  return CoordinateSystem::RotationY(fShowerZenith, CoordinateSystem::RotationZ(fShowerAzimuth, cs));
209 }
210 */
211 
Branch GetTopBranch() const
Definition: Branch.cc:63
Point object.
Definition: Point.h:32
Describes a particle for Simulation.
Definition: Particle.h:26
constexpr double rad
Definition: AugerUnits.h:137
virtual void Rewind()
Rewind the particle list in the shower file to the beginning.
Constructors for Transformer classes.
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
Definition: Branch.cc:211
constexpr double deg
Definition: AugerUnits.h:140
constexpr double MeV
Definition: AugerUnits.h:184
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
Class representing a document branch.
Definition: Branch.h:107
const double ns
virtual utl::Particle * GetOneParticle(const utl::CoordinateSystemPtr &groundCS)
Member function to fetch the next particle.
constexpr double kPi
Definition: MathConstants.h:24
void GetData(bool &b) const
Overloads of the GetData member template function.
Definition: Branch.cc:644
void GenerateParticle(const utl::CoordinateSystemPtr &groundCS)
A TimeInterval is used to represent time elapsed between two events.
Definition: TimeInterval.h:43
constexpr double GeV
Definition: AugerUnits.h:187
Vector object.
Definition: Vector.h:30
constexpr double m
Definition: AugerUnits.h:121

, generated on Tue Sep 26 2023.