Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 
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 //=============================================================================
36  const std::string &name,
37  const IInterface *parent)
38  : base_class(type, name, parent) {
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 //=============================================================================
60 auto 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 }
Trk::ParticleSwitcher::particle
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
Definition: ParticleHypothesis.h:76
Base_Fragment.mass
mass
Definition: Sherpa_i/share/common/Base_Fragment.py:59
ExtraParticlesPhysicsTool.h
ExtraParticlesPhysicsTool::PhysicsConstructor::ConstructProcess
virtual void ConstructProcess() override
Definition: ExtraParticlesPhysicsTool.cxx:110
ExtraParticlesPhysicsTool::GetPhysicsOption
virtual UPPhysicsConstructor GetPhysicsOption() override final
Implements.
Definition: ExtraParticlesPhysicsTool.cxx:60
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
ExtraParticlesPhysicsTool::m_extraParticlesConfig
std::map< std::string, std::vector< double > > m_extraParticlesConfig
a set of parameters for extra particle building
Definition: ExtraParticlesPhysicsTool.h:57
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
ExtraParticlesPhysicsTool::initialize
virtual StatusCode initialize() override final
Initialize method.
Definition: ExtraParticlesPhysicsTool.cxx:52
test_pyathena.parent
parent
Definition: test_pyathena.py:15
MCTruthPartClassifier::stable
@ stable
Definition: TruthClassifiers.h:148
ExtraParticlesPhysicsTool::ExtraParticlesPhysicsTool
ExtraParticlesPhysicsTool(const std::string &type, const std::string &name, const IInterface *parent)
Standard constructor.
Definition: ExtraParticlesPhysicsTool.cxx:35
ExtraParticlesPhysicsTool::PhysicsConstructor::ConstructParticle
virtual void ConstructParticle() override
Definition: ExtraParticlesPhysicsTool.cxx:68
CustomParticle
Definition: CustomParticle.h:18
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
mc.proc
proc
Definition: mc.PhPy8EG_A14NNPDF23_gg4l_example.py:22
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
charge
double charge(const T &p)
Definition: AtlasPID.h:931
G4AtlasPhysicsOption::QS_ExtraParticles
@ QS_ExtraParticles
Definition: IPhysicsOptionTool.h:24
Base_Fragment.width
width
Definition: Sherpa_i/share/common/Base_Fragment.py:59
DEBUG
#define DEBUG
Definition: page_access.h:11
ExtraParticlesPhysicsTool::~ExtraParticlesPhysicsTool
virtual ~ExtraParticlesPhysicsTool()
Destructor.
Definition: ExtraParticlesPhysicsTool.cxx:47
ExtraParticlesPhysicsTool::PhysicsConstructor::m_extraParticles
std::set< G4ParticleDefinition * > m_extraParticles
a set to hold the newly created extra particles
Definition: ExtraParticlesPhysicsTool.h:52