DD4hep
1.36.0
Detector Description Toolkit for High Energy Physics
DDG4
plugins
Geant4UserParticleHandlerHelper.cpp
Go to the documentation of this file.
1
2
//==========================================================================
3
// AIDA Detector description implementation
4
//--------------------------------------------------------------------------
5
// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
6
// All rights reserved.
7
//
8
// For the licensing terms see $DD4hepINSTALL/LICENSE.
9
// For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
10
//
11
// Author : M.Frank
12
//
13
//==========================================================================
14
15
#include "
Geant4UserParticleHandlerHelper.h
"
16
#include <
DDG4/Geant4Particle.h
>
17
#include <
DDG4/Geant4UserParticleHandler.h
>
18
19
// using namespace dd4hep::sim;
20
21
namespace
dd4hep::sim
{
22
23
void
setReason
(
Geant4Particle
& p,
bool
starts_in_trk_vol,
bool
ends_in_trk_vol) {
24
25
dd4hep::detail::ReferenceBitMask<int> reason(p.
reason
);
26
27
if
( reason.isSet(
G4PARTICLE_PRIMARY
) ) {
28
//do nothing
29
return
;
30
}
else
if
( starts_in_trk_vol && ! reason.isSet(
G4PARTICLE_ABOVE_ENERGY_THRESHOLD
) ) {
31
// created in tracking volume but below energy cut
32
p.
reason
= 0;
33
return
;
34
}
35
//keep particles that left tracker hits if they are above threshold.
36
if
(reason.isSet(
G4PARTICLE_CREATED_TRACKER_HIT
) && reason.isSet(
G4PARTICLE_ABOVE_ENERGY_THRESHOLD
)) {
37
return
;
38
}
39
40
// created and ended in calo but not primary particle
41
//
42
// we can have particles from the generator only in the calo, if we have a
43
// long particle with preassigned decay, we need to keep the reason or the
44
// MChistory will not be updated later on
45
if
( !starts_in_trk_vol ) {
46
if
( !ends_in_trk_vol ){
47
p.
reason
= 0;
48
}
49
//fg: dont keep backscatter that did not create a tracker hit
50
else
if
( ! reason.isSet(
G4PARTICLE_CREATED_TRACKER_HIT
) ) {
51
p.
reason
= 0;
52
}
53
}
54
}
55
56
void
setSimulatorStatus
(
Geant4Particle
& p,
bool
starts_in_trk_vol,
bool
ends_in_trk_vol) {
57
// Set the simulator status bits
58
dd4hep::detail::ReferenceBitMask<int> simStatus(p.
status
);
59
60
if
( ends_in_trk_vol ) {
61
simStatus.set(
G4PARTICLE_SIM_DECAY_TRACKER
);
62
}
63
64
// if the particle doesn't end in the tracker volume it must have ended in the calorimeter
65
if
( not ends_in_trk_vol && not simStatus.isSet(
G4PARTICLE_SIM_LEFT_DETECTOR
) ) {
66
simStatus.set(
G4PARTICLE_SIM_DECAY_CALO
);
67
}
68
69
if
( not starts_in_trk_vol && ends_in_trk_vol ) {
70
simStatus.set(
G4PARTICLE_SIM_BACKSCATTER
);
71
}
72
}
73
74
}
dd4hep::sim::G4PARTICLE_CREATED_TRACKER_HIT
@ G4PARTICLE_CREATED_TRACKER_HIT
Definition:
Geant4Particle.h:64
dd4hep::sim::G4PARTICLE_ABOVE_ENERGY_THRESHOLD
@ G4PARTICLE_ABOVE_ENERGY_THRESHOLD
Definition:
Geant4Particle.h:60
dd4hep::sim::Geant4Particle::reason
int reason
Definition:
Geant4Particle.h:112
Geant4UserParticleHandlerHelper.h
dd4hep::sim::setReason
void setReason(Geant4Particle &p, bool starts_in_trk_vol, bool ends_in_trk_vol)
determines if particle should be kept and sets p.reason = 0 otherwise
Definition:
Geant4UserParticleHandlerHelper.cpp:23
Geant4UserParticleHandler.h
dd4hep::sim::G4PARTICLE_SIM_BACKSCATTER
@ G4PARTICLE_SIM_BACKSCATTER
Definition:
Geant4Particle.h:87
dd4hep::sim::G4PARTICLE_SIM_DECAY_CALO
@ G4PARTICLE_SIM_DECAY_CALO
Definition:
Geant4Particle.h:88
dd4hep::sim::setSimulatorStatus
void setSimulatorStatus(Geant4Particle &p, bool starts_in_trk_vol, bool ends_in_trk_vol)
determines if particle has ended in the tracker, calorimeter or if it is backscatter and sets simulat...
Definition:
Geant4UserParticleHandlerHelper.cpp:56
dd4hep::sim::Geant4Particle::status
int status
Definition:
Geant4Particle.h:117
dd4hep::sim::G4PARTICLE_SIM_DECAY_TRACKER
@ G4PARTICLE_SIM_DECAY_TRACKER
Definition:
Geant4Particle.h:89
dd4hep::sim::G4PARTICLE_SIM_LEFT_DETECTOR
@ G4PARTICLE_SIM_LEFT_DETECTOR
Definition:
Geant4Particle.h:91
dd4hep::sim
Namespace for the Geant4 based simulation part of the AIDA detector description toolkit.
Definition:
EDM4hepFileReader.cpp:46
Geant4Particle.h
dd4hep::sim::G4PARTICLE_PRIMARY
@ G4PARTICLE_PRIMARY
Definition:
Geant4Particle.h:58
dd4hep::sim::Geant4Particle
Data structure to store the MC particle information.
Definition:
Geant4Particle.h:104
Generated on Mon Mar 23 2026 15:55:17 for DD4hep by
1.8.18