ATLAS Offline Software
Loading...
Searching...
No Matches
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
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
24using 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//=============================================================================
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//=============================================================================
48
49//=============================================================================
50// Initialize
51//=============================================================================
53 ATH_MSG_DEBUG("initializing...");
54 return StatusCode::SUCCESS;
55}
56
57//=============================================================================
58// GetPhysicsOption
59//=============================================================================
60auto ExtraParticlesPhysicsTool::GetPhysicsOption() -> UPPhysicsConstructor {
61 return std::make_unique<ExtraParticlesPhysicsTool::PhysicsConstructor>(
62 name(), this->msgLevel(), m_extraParticlesConfig);
63}
64
65//=============================================================================
66// ConstructParticle
67//=============================================================================
69 ATH_MSG_DEBUG("ExtraParticlesPhysicsTool::ConstructParticle - start");
71 "ExtraParticlesPhysicsTool::ConstructParticle - 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//=============================================================================
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}
#define ATH_MSG_DEBUG(x)
double charge(const T &p)
Definition AtlasPID.h:997
const double width
bool msgLvl(const MSG::Level lvl) const
Test the output level.
std::set< G4ParticleDefinition * > m_extraParticles
a set to hold the newly created extra particles
std::map< std::string, std::vector< double > > m_extraParticlesConfig
a set of parameters for extra particle building
ExtraParticlesPhysicsTool(const std::string &type, const std::string &name, const IInterface *parent)
Standard constructor.
virtual UPPhysicsConstructor GetPhysicsOption() override final
Implements.
virtual ~ExtraParticlesPhysicsTool()
Destructor.
std::map< std::string, std::vector< double > > m_extraParticlesConfig
a set of parameters for extra particle building
virtual StatusCode initialize() override final
Initialize method.