ATLAS Offline Software
Simulation
G4Atlas
G4AtlasTools
src
AddPhysicsDecayTool.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
// Include files
6
7
// local
8
#include "
G4AtlasTools/AddPhysicsDecayTool.h
"
9
10
#include <G4VPhysicsConstructor.hh>
11
#include <memory>
12
#include <sstream>
13
14
// Geant4 physics lists
15
16
17
#include "G4ProcessManager.hh"
18
#include "G4ParticleTable.hh"
19
#include "G4DecayTable.hh"
20
#include "G4VDecayChannel.hh"
21
#include "G4PhaseSpaceDecayChannel.hh"
22
//-----------------------------------------------------------------------------
23
// Implementation file for class : AddPhysicsDecayTool
24
//
25
// 15-05-2015 : Edoardo Farina
26
//-----------------------------------------------------------------------------
27
#include "G4Version.hh"
28
#if G4VERSION_NUMBER > 1029
29
#define PARTICLEITERATOR (this->GetParticleIterator())
30
#elif G4VERSION_NUMBER > 1009
31
#define PARTICLEITERATOR aParticleIterator
32
#else
33
#define PARTICLEITERATOR theParticleIterator
34
#endif
35
36
//=============================================================================
37
// Standard constructor, initializes variables
38
//=============================================================================
39
AddPhysicsDecayTool::AddPhysicsDecayTool
(
const
std::string&
type
,
40
const
std::string& nam,
const
IInterface*
parent
)
41
: base_class (
type
, nam ,
parent
)
42
{
43
m_physicsOptionType =
G4AtlasPhysicsOption::Type::GlobalProcesses
;
44
}
45
46
//=============================================================================
47
// Destructor
48
//=============================================================================
49
50
AddPhysicsDecayTool::~AddPhysicsDecayTool
()
51
{
52
}
53
54
//=============================================================================
55
// Initialize
56
//=============================================================================
57
StatusCode
AddPhysicsDecayTool::initialize
( )
58
{
59
ATH_MSG_DEBUG
(
"AddPhysicsDecayTool initialize( )"
);
60
ATH_MSG_DEBUG
(
"Add Decay to the particle: "
<<
m_ParticleName
);
61
62
std::istringstream
ss
(
m_Daughters
);
63
std::string token;
64
65
while
(std::getline(
ss
, token,
','
))
66
{
67
m_Daughters_vec
.push_back(token);
68
}
69
70
return
StatusCode::SUCCESS;
71
}
72
73
void
AddPhysicsDecayTool::PhysicsConstructor::ConstructProcess
() {
74
PARTICLEITERATOR
->reset();
75
while
( (*
PARTICLEITERATOR
)() )
76
{
77
G4ParticleDefinition *
particle
=
PARTICLEITERATOR
->value();
78
if
(
m_ParticleName
==
static_cast<
const
std::string&
>
(
particle
->GetParticleName()))
79
{
80
81
G4DecayTable *
table
=
particle
->GetDecayTable();
82
if
(!
table
)
83
{
84
table
=
new
G4DecayTable();
85
}
86
87
G4VDecayChannel *mode_vec(
nullptr
);
88
89
if
(
m_Daughters_vec
.size()==2)
90
{
91
mode_vec =
new
G4PhaseSpaceDecayChannel(
m_ParticleName
,
m_BR
,2,
m_Daughters_vec
[0],
m_Daughters_vec
[1]);
92
}
93
else
if
(
m_Daughters_vec
.size()==3)
94
{
95
mode_vec =
new
G4PhaseSpaceDecayChannel(
m_ParticleName
,
m_BR
,3,
m_Daughters_vec
[0],
m_Daughters_vec
[1],
m_Daughters_vec
[2]);
96
}
97
else
if
(
m_Daughters_vec
.size()==4)
98
{
99
mode_vec =
new
G4PhaseSpaceDecayChannel(
m_ParticleName
,
m_BR
,4,
m_Daughters_vec
[0],
m_Daughters_vec
[1],
m_Daughters_vec
[2],
m_Daughters_vec
[3]);
100
}
101
else
102
{
103
//This could be checked during initialize also
104
ATH_MSG_FATAL
(
"No decay in more than 4 particles allowed"
);
105
throw
"Decay with more than four particles"
;
106
}
107
/*
108
for (int i=0; i<table->entries(); i++)
109
{
110
if(*(table->GetDecayChannel(i))==*mode_vec)
111
{
112
ATH_MSG_FATAL("Trying to Add a decay already present" );
113
throw "FailedAddDecay";
114
}
115
}
116
*/
117
118
table
->Insert(mode_vec);
119
120
ATH_MSG_DEBUG
(
"Adding decay to "
<<
m_ParticleName
);
121
particle
->SetDecayTable(
table
);
122
}
123
}
124
}
125
126
auto
AddPhysicsDecayTool::GetPhysicsOption
() -> UPPhysicsConstructor {
127
128
return
std::make_unique<AddPhysicsDecayTool::PhysicsConstructor>(
129
name
(), this->msgLevel(),
m_ParticleName
.value(),
m_BR
.value(),
130
m_Daughters_vec
);
131
}
132
133
void
AddPhysicsDecayTool::PhysicsConstructor::ConstructParticle
() {
134
//This should remain empty
135
}
AddPhysicsDecayTool::m_ParticleName
Gaudi::Property< std::string > m_ParticleName
Definition:
AddPhysicsDecayTool.h:56
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition:
AthMsgStreamMacros.h:34
Trk::ParticleSwitcher::particle
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
Definition:
ParticleHypothesis.h:79
PowhegControl_ttHplus_NLO.ss
ss
Definition:
PowhegControl_ttHplus_NLO.py:83
AddPhysicsDecayTool::GetPhysicsOption
virtual UPPhysicsConstructor GetPhysicsOption() override
Definition:
AddPhysicsDecayTool.cxx:126
AddPhysicsDecayTool::PhysicsConstructor::ConstructParticle
virtual void ConstructParticle() override
Definition:
AddPhysicsDecayTool.cxx:133
AddPhysicsDecayTool::PhysicsConstructor::m_BR
double m_BR
Definition:
AddPhysicsDecayTool.h:51
AddPhysicsDecayTool::PhysicsConstructor::m_Daughters_vec
std::vector< std::string > m_Daughters_vec
Definition:
AddPhysicsDecayTool.h:52
AddPhysicsDecayTool::PhysicsConstructor::m_ParticleName
std::string m_ParticleName
Definition:
AddPhysicsDecayTool.h:50
PARTICLEITERATOR
#define PARTICLEITERATOR
Definition:
AddPhysicsDecayTool.cxx:33
AddPhysicsDecayTool::initialize
virtual StatusCode initialize() override
Initialize method.
Definition:
AddPhysicsDecayTool.cxx:57
python.CaloAddPedShiftConfig.type
type
Definition:
CaloAddPedShiftConfig.py:42
AddPhysicsDecayTool::m_Daughters_vec
std::vector< std::string > m_Daughters_vec
Definition:
AddPhysicsDecayTool.h:59
AddPhysicsDecayTool.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition:
PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition:
AthMsgStreamMacros.h:29
test_pyathena.parent
parent
Definition:
test_pyathena.py:15
name
std::string name
Definition:
Control/AthContainers/Root/debug.cxx:240
python.ext.table_printer.table
list table
Definition:
table_printer.py:78
G4AtlasPhysicsOption::GlobalProcesses
@ GlobalProcesses
Definition:
IPhysicsOptionTool.h:26
AddPhysicsDecayTool::~AddPhysicsDecayTool
virtual ~AddPhysicsDecayTool()
Destructor.
Definition:
AddPhysicsDecayTool.cxx:50
AddPhysicsDecayTool::PhysicsConstructor::ConstructProcess
virtual void ConstructProcess() override
Definition:
AddPhysicsDecayTool.cxx:73
AddPhysicsDecayTool::AddPhysicsDecayTool
AddPhysicsDecayTool(const std::string &type, const std::string &name, const IInterface *parent)
Standard constructor.
Definition:
AddPhysicsDecayTool.cxx:39
AddPhysicsDecayTool::m_Daughters
Gaudi::Property< std::string > m_Daughters
Definition:
AddPhysicsDecayTool.h:58
AddPhysicsDecayTool::m_BR
Gaudi::Property< double > m_BR
Definition:
AddPhysicsDecayTool.h:57
Generated on Wed Sep 3 2025 21:06:10 for ATLAS Offline Software by
1.8.18