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
a17a6682
Commit
a17a6682
authored
10 months ago
by
Markus Frank
Committed by
MarkusFrankATcernch
10 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix to issue
https://github.com/AIDASoft/DD4hep/issues/1233
parent
58fa8c0b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
DDG4/src/Geant4InputHandling.cpp
+22
-5
22 additions, 5 deletions
DDG4/src/Geant4InputHandling.cpp
with
22 additions
and
5 deletions
DDG4/src/Geant4InputHandling.cpp
+
22
−
5
View file @
a17a6682
...
@@ -12,6 +12,7 @@
...
@@ -12,6 +12,7 @@
//==========================================================================
//==========================================================================
// Framework include files
// Framework include files
#include
<DD4hep/Printout.h>
#include
<DDG4/Geant4InputHandling.h>
#include
<DDG4/Geant4InputHandling.h>
#include
<DDG4/Geant4Primary.h>
#include
<DDG4/Geant4Primary.h>
#include
<DDG4/Geant4Context.h>
#include
<DDG4/Geant4Context.h>
...
@@ -22,12 +23,13 @@
...
@@ -22,12 +23,13 @@
// Geant4 include files
// Geant4 include files
#include
<G4Event.hh>
#include
<G4Event.hh>
#include
<G4ParticleDefinition.hh>
#include
<G4PrimaryParticle.hh>
#include
<G4PrimaryVertex.hh>
#include
<G4PrimaryVertex.hh>
#include
<G4PrimaryParticle.hh>
#include
<G4ParticleDefinition.hh>
// C/C++ include files
// C/C++ include files
#include
<stdexcept>
#include
<stdexcept>
#include
<limits>
#include
<cmath>
#include
<cmath>
using
namespace
dd4hep
::
sim
;
using
namespace
dd4hep
::
sim
;
...
@@ -345,14 +347,29 @@ int dd4hep::sim::smearInteraction(const Geant4Action* caller,
...
@@ -345,14 +347,29 @@ int dd4hep::sim::smearInteraction(const Geant4Action* caller,
static
G4PrimaryParticle
*
createG4Primary
(
const
Geant4ParticleHandle
p
)
{
static
G4PrimaryParticle
*
createG4Primary
(
const
Geant4ParticleHandle
p
)
{
G4PrimaryParticle
*
g4
=
0
;
G4PrimaryParticle
*
g4
=
0
;
const
G4ParticleDefinition
*
def
=
p
.
definition
();
/// First check against particle masses, which may be unequal to the generator particle mass.
double
energy
=
p
.
energy
();
double
mom2
=
(
p
->
psx
*
p
->
psx
)
+
(
p
->
psy
*
p
->
psy
)
+
(
p
->
psz
*
p
->
psz
);
double
mass2
=
energy
*
energy
-
mom2
;
if
(
mass2
<
0e0
)
{
if
(
def
)
{
mass2
=
def
->
GetPDGMass
()
*
def
->
GetPDGMass
();
}
energy
=
std
::
sqrt
(
mom2
+
mass2
);
if
(
std
::
fabs
(
p
.
energy
()
-
energy
)
>
0e0
/* 1e-10 */
)
{
dd4hep
::
printout
(
dd4hep
::
INFO
,
"createG4Primary"
,
"Change particle %s energy from %10.5f MeV by %g ppm to avoid negative Energy^2"
,
(
def
)
?
def
->
GetParticleName
().
c_str
()
:
"???"
,
p
.
energy
(),
std
::
fabs
(
p
.
energy
()
-
energy
)
*
1e6
);
}
}
if
(
0
!=
p
->
pdgID
)
{
if
(
0
!=
p
->
pdgID
)
{
// For ions we use the pdgID of the definition, in case we had to zero the excitation level, see Geant4Particle.cpp
// For ions we use the pdgID of the definition, in case we had to zero the excitation level, see Geant4Particle.cpp
const
int
pdgID
=
p
->
pdgID
<
1000000000
?
p
->
pdgID
:
p
.
definition
()
->
GetPDGEncoding
();
const
int
pdgID
=
p
->
pdgID
<
1000000000
?
p
->
pdgID
:
p
.
definition
()
->
GetPDGEncoding
();
g4
=
new
G4PrimaryParticle
(
pdgID
,
p
->
psx
,
p
->
psy
,
p
->
psz
,
p
.
energy
()
);
g4
=
new
G4PrimaryParticle
(
pdgID
,
p
->
psx
,
p
->
psy
,
p
->
psz
,
energy
);
}
}
else
{
else
{
const
G4ParticleDefinition
*
def
=
p
.
definition
();
g4
=
new
G4PrimaryParticle
(
def
,
p
->
psx
,
p
->
psy
,
p
->
psz
,
energy
);
g4
=
new
G4PrimaryParticle
(
def
,
p
->
psx
,
p
->
psy
,
p
->
psz
,
p
.
energy
());
g4
->
SetCharge
(
double
(
p
.
charge
())
/
3.0
);
g4
->
SetCharge
(
double
(
p
.
charge
())
/
3.0
);
}
}
// The particle is fully defined with the 4-vector set above, setting the mass isn't necessary, not
// The particle is fully defined with the 4-vector set above, setting the mass isn't necessary, not
...
...
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