DD4hep
1.30.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
}
else
if
( starts_in_trk_vol && ! reason.isSet(
G4PARTICLE_ABOVE_ENERGY_THRESHOLD
) ) {
30
// created in tracking volume but below energy cut
31
p.
reason
= 0;
32
return
;
33
}
34
35
// created and ended in calo but not primary particle
36
//
37
// we can have particles from the generator only in the calo, if we have a
38
// long particle with preassigned decay, we need to keep the reason or the
39
// MChistory will not be updated later on
40
if
( not reason.isSet(
G4PARTICLE_PRIMARY
) ) {
41
if
( !starts_in_trk_vol ) {
42
if
( !ends_in_trk_vol ){
43
p.
reason
= 0;
44
}
45
//fg: dont keep backscatter that did not create a tracker hit
46
else
if
( ! reason.isSet(
G4PARTICLE_CREATED_TRACKER_HIT
) ) {
47
p.
reason
= 0;
48
}
49
}
50
}
51
}
52
53
void
setSimulatorStatus
(
Geant4Particle
& p,
bool
starts_in_trk_vol,
bool
ends_in_trk_vol) {
54
// Set the simulator status bits
55
dd4hep::detail::ReferenceBitMask<int> simStatus(p.
status
);
56
57
if
( ends_in_trk_vol ) {
58
simStatus.set(
G4PARTICLE_SIM_DECAY_TRACKER
);
59
}
60
61
// if the particle doesn't end in the tracker volume it must have ended in the calorimeter
62
if
( not ends_in_trk_vol && not simStatus.isSet(
G4PARTICLE_SIM_LEFT_DETECTOR
) ) {
63
simStatus.set(
G4PARTICLE_SIM_DECAY_CALO
);
64
}
65
66
if
( not starts_in_trk_vol && ends_in_trk_vol ) {
67
simStatus.set(
G4PARTICLE_SIM_BACKSCATTER
);
68
}
69
}
70
71
}
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:111
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:86
dd4hep::sim::G4PARTICLE_SIM_DECAY_CALO
@ G4PARTICLE_SIM_DECAY_CALO
Definition:
Geant4Particle.h:87
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:53
dd4hep::sim::Geant4Particle::status
int status
Definition:
Geant4Particle.h:116
dd4hep::sim::G4PARTICLE_SIM_DECAY_TRACKER
@ G4PARTICLE_SIM_DECAY_TRACKER
Definition:
Geant4Particle.h:88
dd4hep::sim::G4PARTICLE_SIM_LEFT_DETECTOR
@ G4PARTICLE_SIM_LEFT_DETECTOR
Definition:
Geant4Particle.h:90
dd4hep::sim
Namespace for the Geant4 based simulation part of the AIDA detector description toolkit.
Definition:
Geant4Output2EDM4hep.cpp:49
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:103
Generated on Tue Dec 10 2024 18:30:09 for DD4hep by
1.8.18