ATLAS Offline Software
Loading...
Searching...
No Matches
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
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//=============================================================================
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
53
54//=============================================================================
55// Initialize
56//=============================================================================
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
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
126auto AddPhysicsDecayTool::GetPhysicsOption() -> UPPhysicsConstructor {
127
128 return std::make_unique<AddPhysicsDecayTool::PhysicsConstructor>(
129 name(), this->msgLevel(), m_ParticleName.value(), m_BR.value(),
131}
132
134 //This should remain empty
135}
#define ATH_MSG_FATAL(x)
#define ATH_MSG_DEBUG(x)
static Double_t ss
#define PARTICLEITERATOR
Gaudi::Property< std::string > m_Daughters
virtual StatusCode initialize() override
Initialize method.
Gaudi::Property< std::string > m_ParticleName
virtual UPPhysicsConstructor GetPhysicsOption() override
virtual ~AddPhysicsDecayTool()
Destructor.
AddPhysicsDecayTool(const std::string &type, const std::string &name, const IInterface *parent)
Standard constructor.
std::vector< std::string > m_Daughters_vec
Gaudi::Property< double > m_BR