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
c2e8e984
Commit
c2e8e984
authored
8 months ago
by
Leonhard Reichenbach
Committed by
Andre Sailer
7 months ago
Browse files
Options
Downloads
Patches
Plain Diff
add Geant4TVUserParticleHandler
parent
27d79bab
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
DDG4/plugins/Geant4TVUserParticleHandler.cpp
+25
-32
25 additions, 32 deletions
DDG4/plugins/Geant4TVUserParticleHandler.cpp
DDG4/python/DDSim/Helper/ParticleHandler.py
+9
-1
9 additions, 1 deletion
DDG4/python/DDSim/Helper/ParticleHandler.py
with
34 additions
and
33 deletions
DDG4/plugins/Geant4TVUserParticleHandler.cpp
+
25
−
32
View file @
c2e8e984
...
@@ -14,18 +14,19 @@
...
@@ -14,18 +14,19 @@
/** \addtogroup Geant4Action
/** \addtogroup Geant4Action
*
*
@{
@{
\package Geant4T
C
UserParticleHandler
\package Geant4T
V
UserParticleHandler
* \brief Rejects to keep particles, which are created outside a tracking cylinder.
* \brief Rejects to keep particles, which are created outside a tracking cylinder.
*
*
*
*
@}
@}
*/
*/
#ifndef DD4HEP_DDG4_GEANT4T
C
USERPARTICLEHANDLER_H
#ifndef DD4HEP_DDG4_GEANT4T
V
USERPARTICLEHANDLER_H
#define DD4HEP_DDG4_GEANT4T
C
USERPARTICLEHANDLER_H
#define DD4HEP_DDG4_GEANT4T
V
USERPARTICLEHANDLER_H
// Framework include files
// Framework include files
#include
<DD4hep/Primitives.h>
#include
<DD4hep/Primitives.h>
#include
<DD4hep/Volumes.h>
#include
<DDG4/Geant4UserParticleHandler.h>
#include
<DDG4/Geant4UserParticleHandler.h>
/// Namespace for the AIDA detector description toolkit
/// Namespace for the AIDA detector description toolkit
...
@@ -34,22 +35,23 @@ namespace dd4hep {
...
@@ -34,22 +35,23 @@ namespace dd4hep {
/// Namespace for the Geant4 based simulation part of the AIDA detector description toolkit
/// Namespace for the Geant4 based simulation part of the AIDA detector description toolkit
namespace
sim
{
namespace
sim
{
/// Rejects to keep particles, which are created outside a tracking
cylinder
.
/// Rejects to keep particles, which are created outside a tracking
volume
.
/** Geant4T
C
UserParticleHandler
/** Geant4T
V
UserParticleHandler
*
*
* T
C
stands for Tracking
Cylinder
;-)
* T
V
stands for Tracking
Volume
;-)
*
*
* @author M.Frank
* @author M.Frank
* @version 1.0
* @version 1.0
*/
*/
class
Geant4TCUserParticleHandler
:
public
Geant4UserParticleHandler
{
class
Geant4TVUserParticleHandler
:
public
Geant4UserParticleHandler
{
double
m_zTrackerMin
,
m_zTrackerMax
,
m_rTracker
;
Volume
m_trackingVolume
;
public:
public:
/// Standard constructor
/// Standard constructor
Geant4T
C
UserParticleHandler
(
Geant4Context
*
context
,
const
std
::
string
&
nam
);
Geant4T
V
UserParticleHandler
(
Geant4Context
*
context
,
const
std
::
string
&
nam
);
/// Default destructor
/// Default destructor
virtual
~
Geant4T
C
UserParticleHandler
()
{}
virtual
~
Geant4T
V
UserParticleHandler
()
{}
/// Post-track action callback
/// Post-track action callback
/** Allow the user to force the particle handling in the post track action
/** Allow the user to force the particle handling in the post track action
...
@@ -69,7 +71,7 @@ namespace dd4hep {
...
@@ -69,7 +71,7 @@ namespace dd4hep {
}
// End namespace sim
}
// End namespace sim
}
// End namespace dd4hep
}
// End namespace dd4hep
#endif // DD4HEP_DDG4_GEANT4T
C
USERPARTICLEHANDLER_H
#endif // DD4HEP_DDG4_GEANT4T
V
USERPARTICLEHANDLER_H
//====================================================================
//====================================================================
// AIDA Detector description implementation
// AIDA Detector description implementation
...
@@ -79,32 +81,27 @@ namespace dd4hep {
...
@@ -79,32 +81,27 @@ namespace dd4hep {
//
//
//====================================================================
//====================================================================
// Framework include files
// Framework include files
//#include <DDG4/Geant4TCUserParticleHandler.h>
//#include <DDG4/Geant4TVUserParticleHandler.h>
#include
<DDG4/Geant4Particle.h>
#include
<DDG4/Factories.h>
#include
<DDG4/Factories.h>
#include
<DDG4/Geant4Particle.h>
#include
<DDG4/Geant4Kernel.h>
using
namespace
dd4hep
::
sim
;
using
namespace
dd4hep
::
sim
;
DECLARE_GEANT4ACTION
(
Geant4T
C
UserParticleHandler
)
DECLARE_GEANT4ACTION
(
Geant4T
V
UserParticleHandler
)
/// Standard constructor
/// Standard constructor
Geant4T
C
UserParticleHandler
::
Geant4T
C
UserParticleHandler
(
Geant4Context
*
ctxt
,
const
std
::
string
&
nam
)
Geant4T
V
UserParticleHandler
::
Geant4T
V
UserParticleHandler
(
Geant4Context
*
ctxt
,
const
std
::
string
&
nam
)
:
Geant4UserParticleHandler
(
ctxt
,
nam
)
:
Geant4UserParticleHandler
(
ctxt
,
nam
)
{
{
declareProperty
(
"TrackingVolume_Zmin"
,
m_zTrackerMin
=-
1e100
);
m_trackingVolume
=
ctxt
->
kernel
().
detectorDescription
().
trackingVolume
();
declareProperty
(
"TrackingVolume_Zmax"
,
m_zTrackerMax
=
1e100
);
declareProperty
(
"TrackingVolume_Rmax"
,
m_rTracker
=
1e100
);
}
}
/// Post-track action callback
/// Post-track action callback
void
Geant4T
C
UserParticleHandler
::
end
(
const
G4Track
*
/* track */
,
Particle
&
p
)
{
void
Geant4T
V
UserParticleHandler
::
end
(
const
G4Track
*
/* track */
,
Particle
&
p
)
{
double
r_prod
=
std
::
sqrt
(
p
.
vsx
*
p
.
vsx
+
p
.
vsy
*
p
.
vsy
);
std
::
array
<
double
,
3
>
start_point
=
{
p
.
vsx
,
p
.
vsy
,
p
.
vsz
};
double
z_prod
=
p
.
vsz
;
bool
starts_in_trk_vol
=
m_trackingVolume
.
ptr
()
->
Contains
(
start_point
.
data
());
bool
starts_in_trk_vol
=
(
r_prod
<=
m_rTracker
&&
z_prod
>=
(
m_zTrackerMin
==
-
1e100
?
-
m_zTrackerMax
:
m_zTrackerMin
)
&&
z_prod
<=
m_zTrackerMax
)
;
dd4hep
::
detail
::
ReferenceBitMask
<
int
>
reason
(
p
.
reason
);
dd4hep
::
detail
::
ReferenceBitMask
<
int
>
reason
(
p
.
reason
);
...
@@ -116,12 +113,8 @@ void Geant4TCUserParticleHandler::end(const G4Track* /* track */, Particle& p)
...
@@ -116,12 +113,8 @@ void Geant4TCUserParticleHandler::end(const G4Track* /* track */, Particle& p)
return
;
return
;
}
}
double
r_end
=
std
::
sqrt
(
p
.
vex
*
p
.
vex
+
p
.
vey
*
p
.
vey
);
std
::
array
<
double
,
3
>
end_point
=
{
p
.
vex
,
p
.
vey
,
p
.
vez
};
double
z_end
=
p
.
vez
;
bool
ends_in_trk_vol
=
m_trackingVolume
.
ptr
()
->
Contains
(
end_point
.
data
());
bool
ends_in_trk_vol
=
(
r_end
<=
m_rTracker
&&
z_end
>=
(
m_zTrackerMin
==
-
1e100
?
-
m_zTrackerMax
:
m_zTrackerMin
)
&&
z_end
<=
m_zTrackerMax
)
;
// created and ended in calo but not primary particle
// created and ended in calo but not primary particle
//
//
...
@@ -161,7 +154,7 @@ void Geant4TCUserParticleHandler::end(const G4Track* /* track */, Particle& p)
...
@@ -161,7 +154,7 @@ void Geant4TCUserParticleHandler::end(const G4Track* /* track */, Particle& p)
}
}
/// Post-event action callback
/// Post-event action callback
void
Geant4T
C
UserParticleHandler
::
end
(
const
G4Event
*
/* event */
)
{
void
Geant4T
V
UserParticleHandler
::
end
(
const
G4Event
*
/* event */
)
{
}
}
This diff is collapsed.
Click to expand it.
DDG4/python/DDSim/Helper/ParticleHandler.py
+
9
−
1
View file @
c2e8e984
...
@@ -122,7 +122,7 @@ class ParticleHandler(ConfigHelper):
...
@@ -122,7 +122,7 @@ class ParticleHandler(ConfigHelper):
if
not
self
.
userParticleHandler
:
if
not
self
.
userParticleHandler
:
return
return
if
self
.
userParticleHandler
not
in
[
"
Geant4TCUserParticleHandler
"
]:
if
self
.
userParticleHandler
not
in
[
"
Geant4TCUserParticleHandler
"
,
"
Geant4TVUserParticleHandler
"
]:
logger
.
error
(
"
unknown UserParticleHandler: %r
"
%
self
.
userParticleHandler
)
logger
.
error
(
"
unknown UserParticleHandler: %r
"
%
self
.
userParticleHandler
)
exit
(
1
)
exit
(
1
)
...
@@ -153,4 +153,12 @@ class ParticleHandler(ConfigHelper):
...
@@ -153,4 +153,12 @@ class ParticleHandler(ConfigHelper):
part
.
adopt
(
user
)
part
.
adopt
(
user
)
elif
self
.
userParticleHandler
==
"
Geant4TVUserParticleHandler
"
:
if
not
kernel
.
detectorDescription
().
trackingVolume
().
isValid
():
logger
.
error
(
"
Geant4TVUserParticleHandler requested but no tracking_volume defined in the XML
"
)
exit
(
1
)
user
=
DDG4
.
Action
(
kernel
,
"
%s/UserParticleHandler
"
%
self
.
userParticleHandler
)
part
.
adopt
(
user
)
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