ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Simulation
G4Extensions
ExtraParticles
src
ExtraParticlesPhysicsTool.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
// Include files
6
7
// local
8
#include "
ExtraParticlesPhysicsTool.h
"
9
10
#include <G4VPhysicsConstructor.hh>
11
#include <memory>
12
13
#include "CustomParticle.hh"
14
15
// Geant4 headers
16
#include "G4MuIonisation.hh"
17
#include "G4ParticleTable.hh"
18
#include "G4ProcessManager.hh"
19
#include "G4Transportation.hh"
20
#include "G4Version.hh"
21
#include "G4hIonisation.hh"
22
#include "G4hMultipleScattering.hh"
23
24
using namespace
ExtraParticles;
25
26
//-----------------------------------------------------------------------------
27
// Implementation file for class : ExtraParticlesPhysicsTool
28
//
29
// August-2019 : Miha Muskinja
30
//-----------------------------------------------------------------------------
31
32
//=============================================================================
33
// Standard constructor, initializes variables
34
//=============================================================================
35
ExtraParticlesPhysicsTool::ExtraParticlesPhysicsTool
(
const
std::string &
type
,
36
const
std::string &name,
37
const
IInterface *parent)
38
: base_class(
type
, name, parent) {
39
m_physicsOptionType = G4AtlasPhysicsOption::Type::QS_ExtraParticles;
40
41
declareProperty(
"ExtraParticlesConfig"
,
m_extraParticlesConfig
);
42
}
43
44
//=============================================================================
45
// Destructor
46
//=============================================================================
47
ExtraParticlesPhysicsTool::~ExtraParticlesPhysicsTool
() {}
48
49
//=============================================================================
50
// Initialize
51
//=============================================================================
52
StatusCode
ExtraParticlesPhysicsTool::initialize
() {
53
ATH_MSG_DEBUG
(
"initializing..."
);
54
return
StatusCode::SUCCESS;
55
}
56
57
//=============================================================================
58
// GetPhysicsOption
59
//=============================================================================
60
auto
ExtraParticlesPhysicsTool::GetPhysicsOption
() -> UPPhysicsConstructor {
61
return
std::make_unique<ExtraParticlesPhysicsTool::PhysicsConstructor>(
62
name(), this->msgLevel(),
m_extraParticlesConfig
);
63
}
64
65
//=============================================================================
66
// ConstructParticle
67
//=============================================================================
68
void
ExtraParticlesPhysicsTool::PhysicsConstructor::ConstructParticle
() {
69
ATH_MSG_DEBUG
(
"ExtraParticlesPhysicsTool::ConstructParticle - start"
);
70
ATH_MSG_DEBUG
(
71
"ExtraParticlesPhysicsTool::ConstructParticle - m_extraParticlesConfig = "
72
<<
m_extraParticlesConfig
);
73
74
// the existing particle table
75
G4ParticleTable *theParticleTable = G4ParticleTable::GetParticleTable();
76
77
for
(
const
auto
&particle :
m_extraParticlesConfig
) {
78
79
G4String name = particle.first;
80
G4double mass = particle.second[0];
81
G4double
width
= particle.second[1];
82
G4int
charge
= particle.second[2];
83
G4int pdg = particle.second[3];
84
G4double lifetime = particle.second[4];
85
G4bool stable =
false
;
86
87
// don't add if the particle already exists
88
if
(theParticleTable->FindParticle(pdg)) {
89
ATH_MSG_DEBUG
(
"Skipping "
90
<< theParticleTable->FindParticle(pdg)->GetParticleName()
91
<<
" ("
<< pdg
92
<<
") as it is already in the ParticleTable."
);
93
continue
;
94
}
95
96
// printout
97
ATH_MSG_DEBUG
(
"Adding: "
<< name <<
" "
<< pdg <<
" "
<<
charge
<<
" "
98
<< mass <<
" "
<<
width
<<
" "
<< lifetime);
99
100
// create the new particle
101
m_extraParticles
.insert(
102
new
CustomParticle
(name, mass,
width
,
charge
, pdg, stable, lifetime));
103
}
104
ATH_MSG_DEBUG
(
"ExtraParticlesPhysicsTool::ConstructParticle - end"
);
105
}
106
107
//=============================================================================
108
// ConstructProcess
109
//=============================================================================
110
void
ExtraParticlesPhysicsTool::PhysicsConstructor::ConstructProcess
() {
111
ATH_MSG_DEBUG
(
"ExtraParticlesPhysicsTool::ConstructProcess - start"
);
112
if
(
msgLvl
(MSG::DEBUG)) {
113
std::vector<std::string> extraParticleNames;
114
for
( G4ParticleDefinition* extraParticle :
m_extraParticles
) {
115
extraParticleNames.push_back(extraParticle->GetParticleName());
116
}
117
ATH_MSG_DEBUG
(
"ExtraParticlesPhysicsTool::ConstructProcess - m_extraParticleNames = "
<< extraParticleNames);
118
}
119
for
(
auto
*particle :
m_extraParticles
) {
120
if
(particle->GetPDGCharge() != 0) {
121
ATH_MSG_DEBUG
(
"Adding EM processes for "
122
<< particle->GetParticleName());
123
G4ProcessManager *proc = particle->GetProcessManager();
124
proc->AddProcess(
new
G4hMultipleScattering, -1, 1, 1);
125
proc->AddProcess(
new
G4hIonisation, -1, 2, 2);
126
}
127
}
128
ATH_MSG_DEBUG
(
"ExtraParticlesPhysicsTool::ConstructProcess - end"
);
129
}
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
charge
double charge(const T &p)
Definition
AtlasPID.h:1003
ExtraParticlesPhysicsTool.h
width
const double width
Definition
TTileTripReader.cxx:24
AthMessaging::msgLvl
bool msgLvl(const MSG::Level lvl) const
Test the output level.
Definition
AthMessaging.h:151
CustomParticle
Definition
CustomParticle.h:18
ExtraParticlesPhysicsTool::PhysicsConstructor::m_extraParticles
std::set< G4ParticleDefinition * > m_extraParticles
a set to hold the newly created extra particles
Definition
ExtraParticlesPhysicsTool.h:52
ExtraParticlesPhysicsTool::PhysicsConstructor::ConstructParticle
virtual void ConstructParticle() override
Definition
ExtraParticlesPhysicsTool.cxx:68
ExtraParticlesPhysicsTool::PhysicsConstructor::ConstructProcess
virtual void ConstructProcess() override
Definition
ExtraParticlesPhysicsTool.cxx:110
ExtraParticlesPhysicsTool::PhysicsConstructor::m_extraParticlesConfig
std::map< std::string, std::vector< double > > m_extraParticlesConfig
a set of parameters for extra particle building
Definition
ExtraParticlesPhysicsTool.h:49
ExtraParticlesPhysicsTool::ExtraParticlesPhysicsTool
ExtraParticlesPhysicsTool(const std::string &type, const std::string &name, const IInterface *parent)
Standard constructor.
Definition
ExtraParticlesPhysicsTool.cxx:35
ExtraParticlesPhysicsTool::GetPhysicsOption
virtual UPPhysicsConstructor GetPhysicsOption() override final
Implements.
Definition
ExtraParticlesPhysicsTool.cxx:60
ExtraParticlesPhysicsTool::~ExtraParticlesPhysicsTool
virtual ~ExtraParticlesPhysicsTool()
Destructor.
Definition
ExtraParticlesPhysicsTool.cxx:47
ExtraParticlesPhysicsTool::m_extraParticlesConfig
std::map< std::string, std::vector< double > > m_extraParticlesConfig
a set of parameters for extra particle building
Definition
ExtraParticlesPhysicsTool.h:57
ExtraParticlesPhysicsTool::initialize
virtual StatusCode initialize() override final
Initialize method.
Definition
ExtraParticlesPhysicsTool.cxx:52
type
Generated on
for ATLAS Offline Software by
1.17.0