ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Simulation
G4Utilities
TrackWriteFastSim
src
NeutronFastSim.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
TrackWriteFastSim/NeutronFastSim.h
"
6
#include "
MCTruth/TrackHelper.h
"
7
#include "
AtlasHepMC/GenParticle.h
"
8
9
#include "G4Neutron.hh"
10
#include "G4SDManager.hh"
11
#include "G4VSensitiveDetector.hh"
12
#include "
TrackWriteFastSim/TrackFastSimSD.h
"
13
14
#include "
TruthUtils/MagicNumbers.h
"
15
16
NeutronFastSim::NeutronFastSim
(
const
std::string& name, G4Region* region,
const
std::string& fsSDname,
const
double
etaCut,
const
double
timeCut)
17
: G4VFastSimulationModel(name, region)
18
,
m_Energy
(5)
19
,
m_fsSD
(0)
20
,
m_init
(false)
21
,
m_fsSDname
(fsSDname)
22
,
m_etaCut
(etaCut)
23
,
m_timeCut
(timeCut)
24
{
25
}
26
27
G4bool
NeutronFastSim::IsApplicable
(
const
G4ParticleDefinition&)
28
{
29
if
(!
m_init
){
30
m_init
=
true
;
31
32
G4SDManager *sdm = G4SDManager::GetSDMpointer();
33
G4VSensitiveDetector * vsd = sdm->FindSensitiveDetector(
m_fsSDname
);
34
if
(!vsd) {
35
G4cout <<
"NeutronFastSim::IsApplicable WARNING Could not get TrackFastSimSD sensitive detector. If you are not writing track records this is expected."
<< G4endl;
36
}
else
{
37
m_fsSD
=
dynamic_cast<
TrackFastSimSD
*
>
(vsd);
38
if
(!
m_fsSD
) {
39
G4cout <<
"NeutronFastSim::IsApplicable WARNING Could not cast the SD. If you are not writing track records this is expected."
<< G4endl;
40
}
41
}
// found the SD
42
}
// End of lazy init
43
return
true
;
44
}
45
46
G4bool
NeutronFastSim::ModelTrigger
(
const
G4FastTrack& fastTrack)
47
{
48
// Trigger if the neutron energy is below our threshold or if the time is over 150 ns
49
if
(fastTrack.GetPrimaryTrack()->GetDefinition() == G4Neutron::NeutronDefinition() ){
50
return
(
m_Energy
<0?
true
:fastTrack.GetPrimaryTrack()->GetKineticEnergy()<
m_Energy
) || fastTrack.GetPrimaryTrack()->GetGlobalTime()>
m_timeCut
;
51
}
52
53
// Not a neutron... Pick it up if the primary had eta>6.0
54
TrackHelper
trackHelper(fastTrack.GetPrimaryTrack());
55
HepMC::ConstGenParticlePtr
primaryGenParticle = trackHelper.
GetPrimaryGenParticle
();
56
if
(!primaryGenParticle) {
57
return
false
;
58
}
59
if
(std::abs(primaryGenParticle->momentum().eta())>
m_etaCut
&& !
HepMC::is_simulation_particle
(primaryGenParticle)){
60
return
true
;
61
}
else
{
62
return
false
;
63
}
64
}
65
66
void
NeutronFastSim::DoIt
(
const
G4FastTrack& fastTrack, G4FastStep& fastStep)
67
{
68
if
(
m_fsSD
)
m_fsSD
->WriteTrack( fastTrack.GetPrimaryTrack() ,
false
,
false
);
69
fastStep.KillPrimaryTrack();
70
}
GenParticle.h
MagicNumbers.h
NeutronFastSim.h
TrackFastSimSD.h
TrackHelper.h
NeutronFastSim::ModelTrigger
virtual G4bool ModelTrigger(const G4FastTrack &) override final
Definition
NeutronFastSim.cxx:46
NeutronFastSim::m_fsSDname
std::string m_fsSDname
Definition
NeutronFastSim.h:34
NeutronFastSim::m_etaCut
double m_etaCut
Definition
NeutronFastSim.h:35
NeutronFastSim::DoIt
void DoIt(const G4FastTrack &, G4FastStep &) override final
Definition
NeutronFastSim.cxx:66
NeutronFastSim::m_fsSD
TrackFastSimSD * m_fsSD
Definition
NeutronFastSim.h:32
NeutronFastSim::m_init
bool m_init
Definition
NeutronFastSim.h:33
NeutronFastSim::m_timeCut
double m_timeCut
Definition
NeutronFastSim.h:36
NeutronFastSim::m_Energy
G4double m_Energy
Definition
NeutronFastSim.h:31
NeutronFastSim::IsApplicable
G4bool IsApplicable(const G4ParticleDefinition &) override final
Definition
NeutronFastSim.cxx:27
NeutronFastSim::NeutronFastSim
NeutronFastSim(const std::string &name, G4Region *region, const std::string &fsSDname, const double etaCut, const double timeCut)
Definition
NeutronFastSim.cxx:16
TrackFastSimSD
Definition
TrackFastSimSD.h:24
TrackHelper
Definition
TrackHelper.h:20
TrackHelper::GetPrimaryGenParticle
HepMC::GenParticlePtr GetPrimaryGenParticle()
Return the primary truth particle associated with this track.
Definition
TrackHelper.cxx:84
HepMC::ConstGenParticlePtr
HepMC3::ConstGenParticlePtr ConstGenParticlePtr
Definition
GenParticle.h:20
HepMC::is_simulation_particle
bool is_simulation_particle(const T &p)
Method to establish if a particle (or barcode) was created during the simulation (TODO update to be s...
Definition
MagicNumbers.h:322
Generated on
for ATLAS Offline Software by
1.17.0