Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DD4hep
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cepc
externals
mirroring
DD4hep
Commits
535efcab
Commit
535efcab
authored
3 years ago
by
Wouter Deconinck
Committed by
MarkusFrankATcernch
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Geant4IsotropeGenerator::getParticleMomentumUniform(double& momentum)
parent
e6291aaa
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
DDG4/include/DDG4/Geant4IsotropeGenerator.h
+6
-0
6 additions, 0 deletions
DDG4/include/DDG4/Geant4IsotropeGenerator.h
DDG4/src/Geant4IsotropeGenerator.cpp
+25
-3
25 additions, 3 deletions
DDG4/src/Geant4IsotropeGenerator.cpp
with
31 additions
and
3 deletions
DDG4/include/DDG4/Geant4IsotropeGenerator.h
+
6
−
0
View file @
535efcab
...
@@ -40,6 +40,10 @@ namespace dd4hep {
...
@@ -40,6 +40,10 @@ namespace dd4hep {
double
m_thetaMin
;
double
m_thetaMin
;
/// Property: Maximal theta angular value
/// Property: Maximal theta angular value
double
m_thetaMax
;
double
m_thetaMax
;
/// Property: Minimal momentum value
double
m_momentumMin
;
/// Property: Maximal momentum value
double
m_momentumMax
;
/// Particle modification. Caller presets defaults to: ( direction = m_direction, momentum = m_energy)
/// Particle modification. Caller presets defaults to: ( direction = m_direction, momentum = m_energy)
/** Use this function to implement isotrop guns, multiple guns etc.
/** Use this function to implement isotrop guns, multiple guns etc.
...
@@ -54,6 +58,8 @@ namespace dd4hep {
...
@@ -54,6 +58,8 @@ namespace dd4hep {
void
getParticleDirectionCosTheta
(
int
num
,
ROOT
::
Math
::
XYZVector
&
direction
,
double
&
momentum
)
const
;
void
getParticleDirectionCosTheta
(
int
num
,
ROOT
::
Math
::
XYZVector
&
direction
,
double
&
momentum
)
const
;
/// Uniform particle distribution
/// Uniform particle distribution
void
getParticleDirectionUniform
(
int
num
,
ROOT
::
Math
::
XYZVector
&
direction
,
double
&
momentum
)
const
;
void
getParticleDirectionUniform
(
int
num
,
ROOT
::
Math
::
XYZVector
&
direction
,
double
&
momentum
)
const
;
/// Uniform particle momentum
void
getParticleMomentumUniform
(
double
&
momentum
)
const
;
public:
public:
/// Inhibit default constructor
/// Inhibit default constructor
...
...
This diff is collapsed.
Click to expand it.
DDG4/src/Geant4IsotropeGenerator.cpp
+
25
−
3
View file @
535efcab
...
@@ -29,6 +29,8 @@ Geant4IsotropeGenerator::Geant4IsotropeGenerator(Geant4Context* ctxt, const stri
...
@@ -29,6 +29,8 @@ Geant4IsotropeGenerator::Geant4IsotropeGenerator(Geant4Context* ctxt, const stri
declareProperty
(
"PhiMax"
,
m_phiMax
=
2.0
*
M_PI
);
declareProperty
(
"PhiMax"
,
m_phiMax
=
2.0
*
M_PI
);
declareProperty
(
"ThetaMin"
,
m_thetaMin
=
0.0
);
declareProperty
(
"ThetaMin"
,
m_thetaMin
=
0.0
);
declareProperty
(
"ThetaMax"
,
m_thetaMax
=
M_PI
);
declareProperty
(
"ThetaMax"
,
m_thetaMax
=
M_PI
);
declareProperty
(
"MomentumMin"
,
m_momentumMin
=
0.0
);
declareProperty
(
"MomentumMax"
,
m_momentumMax
=
-
1.0
);
declareProperty
(
"Distribution"
,
m_distribution
=
"uniform"
);
declareProperty
(
"Distribution"
,
m_distribution
=
"uniform"
);
}
}
...
@@ -37,6 +39,16 @@ Geant4IsotropeGenerator::~Geant4IsotropeGenerator() {
...
@@ -37,6 +39,16 @@ Geant4IsotropeGenerator::~Geant4IsotropeGenerator() {
InstanceCount
::
decrement
(
this
);
InstanceCount
::
decrement
(
this
);
}
}
/// Uniform momentum distribution
void
Geant4IsotropeGenerator
::
getParticleMomentumUniform
(
double
&
momentum
)
const
{
Geant4Event
&
evt
=
context
()
->
event
();
Geant4Random
&
rnd
=
evt
.
random
();
if
(
m_momentumMax
<
m_momentumMin
)
momentum
=
m_momentumMin
+
(
momentum
-
m_momentumMin
)
*
rnd
.
rndm
();
else
momentum
=
m_momentumMin
+
(
m_momentumMax
-
m_momentumMin
)
*
rnd
.
rndm
();
}
/// Uniform particle distribution
/// Uniform particle distribution
void
Geant4IsotropeGenerator
::
getParticleDirectionUniform
(
int
,
ROOT
::
Math
::
XYZVector
&
direction
,
double
&
momentum
)
const
{
void
Geant4IsotropeGenerator
::
getParticleDirectionUniform
(
int
,
ROOT
::
Math
::
XYZVector
&
direction
,
double
&
momentum
)
const
{
Geant4Event
&
evt
=
context
()
->
event
();
Geant4Event
&
evt
=
context
()
->
event
();
...
@@ -48,7 +60,7 @@ void Geant4IsotropeGenerator::getParticleDirectionUniform(int, ROOT::Math::XYZVe
...
@@ -48,7 +60,7 @@ void Geant4IsotropeGenerator::getParticleDirectionUniform(int, ROOT::Math::XYZVe
double
x3
=
std
::
cos
(
theta
);
double
x3
=
std
::
cos
(
theta
);
direction
.
SetXYZ
(
x1
,
x2
,
x3
);
direction
.
SetXYZ
(
x1
,
x2
,
x3
);
momentum
=
rnd
.
rndm
()
*
momentum
;
getParticleMomentumUniform
(
momentum
)
;
}
}
/// Particle distribution ~ cos(theta)
/// Particle distribution ~ cos(theta)
...
@@ -63,7 +75,10 @@ void Geant4IsotropeGenerator::getParticleDirectionCosTheta(int, ROOT::Math::XYZV
...
@@ -63,7 +75,10 @@ void Geant4IsotropeGenerator::getParticleDirectionCosTheta(int, ROOT::Math::XYZV
double
x3
=
cos_theta
;
double
x3
=
cos_theta
;
direction
.
SetXYZ
(
x1
,
x2
,
x3
);
direction
.
SetXYZ
(
x1
,
x2
,
x3
);
momentum
=
rnd
.
rndm
()
*
momentum
;
if
(
m_momentumMax
<
m_momentumMin
)
momentum
=
m_momentumMin
+
(
momentum
-
m_momentumMin
)
*
rnd
.
rndm
();
else
momentum
=
m_momentumMin
+
(
m_momentumMax
-
m_momentumMin
)
*
rnd
.
rndm
();
}
}
/// Particle distribution flat in eta (pseudo rapidity)
/// Particle distribution flat in eta (pseudo rapidity)
...
@@ -84,7 +99,10 @@ void Geant4IsotropeGenerator::getParticleDirectionEta(int, ROOT::Math::XYZVector
...
@@ -84,7 +99,10 @@ void Geant4IsotropeGenerator::getParticleDirectionEta(int, ROOT::Math::XYZVector
double
x3
=
std
::
sinh
(
eta
);
double
x3
=
std
::
sinh
(
eta
);
double
r
=
std
::
sqrt
(
1.0
+
x3
*
x3
);
double
r
=
std
::
sqrt
(
1.0
+
x3
*
x3
);
direction
.
SetXYZ
(
x1
/
r
,
x2
/
r
,
x3
/
r
);
direction
.
SetXYZ
(
x1
/
r
,
x2
/
r
,
x3
/
r
);
momentum
=
rnd
.
rndm
()
*
momentum
;
if
(
m_momentumMax
<
m_momentumMin
)
momentum
=
m_momentumMin
+
(
momentum
-
m_momentumMin
)
*
rnd
.
rndm
();
else
momentum
=
m_momentumMin
+
(
m_momentumMax
-
m_momentumMin
)
*
rnd
.
rndm
();
}
}
/// e+e- --> ffbar particle distribution ~ 1 + cos^2(theta)
/// e+e- --> ffbar particle distribution ~ 1 + cos^2(theta)
...
@@ -110,6 +128,10 @@ void Geant4IsotropeGenerator::getParticleDirectionFFbar(int, ROOT::Math::XYZVect
...
@@ -110,6 +128,10 @@ void Geant4IsotropeGenerator::getParticleDirectionFFbar(int, ROOT::Math::XYZVect
double
x2
=
std
::
sin
(
theta
)
*
std
::
sin
(
phi
);
double
x2
=
std
::
sin
(
theta
)
*
std
::
sin
(
phi
);
double
x3
=
std
::
cos
(
theta
);
double
x3
=
std
::
cos
(
theta
);
direction
.
SetXYZ
(
x1
,
x2
,
x3
);
direction
.
SetXYZ
(
x1
,
x2
,
x3
);
if
(
m_momentumMax
<
m_momentumMin
)
momentum
=
m_momentumMin
+
(
momentum
-
m_momentumMin
)
*
rnd
.
rndm
();
else
momentum
=
m_momentumMin
+
(
m_momentumMax
-
m_momentumMin
)
*
rnd
.
rndm
();
momentum
=
rnd
.
rndm
()
*
momentum
;
momentum
=
rnd
.
rndm
()
*
momentum
;
return
;
return
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment