ATLAS Offline Software
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 #include "CustomParticle.hh"
10 
11 // Geant4 headers
12 #include "G4MuIonisation.hh"
13 #include "G4ParticleTable.hh"
14 #include "G4ProcessManager.hh"
15 #include "G4Transportation.hh"
16 #include "G4Version.hh"
17 #include "G4hIonisation.hh"
18 #include "G4hMultipleScattering.hh"
19 
20 using namespace ExtraParticles;
21 
22 //-----------------------------------------------------------------------------
23 // Implementation file for class : ExtraParticlesPhysicsTool
24 //
25 // August-2019 : Miha Muskinja
26 //-----------------------------------------------------------------------------
27 
28 //=============================================================================
29 // Standard constructor, initializes variables
30 //=============================================================================
32  const std::string &name,
33  const IInterface *parent)
34  : base_class(type, name, parent) {
36 
37  declareProperty("ExtraParticlesConfig", m_extraParticlesConfig);
38 }
39 
40 //=============================================================================
41 // Destructor
42 //=============================================================================
44 
45 //=============================================================================
46 // Initialize
47 //=============================================================================
49  ATH_MSG_DEBUG("initializing...");
50  this->SetPhysicsName(this->name());
51  return StatusCode::SUCCESS;
52 }
53 
54 //=============================================================================
55 // GetPhysicsOption
56 //=============================================================================
58  return this;
59 }
60 
61 //=============================================================================
62 // ConstructParticle
63 //=============================================================================
65  ATH_MSG_DEBUG("ExtraParticlesPhysicsTool::ConstructParticle - start");
66  ATH_MSG_DEBUG("ExtraParticlesPhysicsTool::ConstructParticle - m_extraParticlesConfig = " << m_extraParticlesConfig);
67 
68  // the existing particle table
69  G4ParticleTable *theParticleTable = G4ParticleTable::GetParticleTable();
70 
71  for (const auto &particle : m_extraParticlesConfig) {
72 
73  G4String name = particle.first;
74  G4double mass = particle.second[0];
75  G4double width = particle.second[1];
76  G4int charge = particle.second[2];
77  G4int pdg = particle.second[3];
78  G4double lifetime = particle.second[4];
79  G4bool stable = false;
80 
81  // don't add if the particle already exists
82  if (theParticleTable->FindParticle(pdg)) {
83  ATH_MSG_DEBUG("Skipping " << theParticleTable->FindParticle(pdg)->GetParticleName() << " ("<<pdg<<") as it is already in the ParticleTable.");
84  continue;
85  }
86 
87  // printout
88  ATH_MSG_DEBUG("Adding: " << name << " " << pdg << " " << charge << " "
89  << mass << " " << width << " " << lifetime);
90 
91  // create the new particle
93  pdg, stable, lifetime));
94  }
95  ATH_MSG_DEBUG("ExtraParticlesPhysicsTool::ConstructParticle - end");
96 }
97 
98 //=============================================================================
99 // ConstructProcess
100 //=============================================================================
102  ATH_MSG_DEBUG("ExtraParticlesPhysicsTool::ConstructProcess - start");
103  if (msgLvl(MSG::DEBUG)) {
104  std::vector<std::string> extraParticleNames;
105  for ( G4ParticleDefinition* extraParticle : m_extraParticles) {
106  extraParticleNames.push_back(extraParticle->GetParticleName());
107  }
108  ATH_MSG_DEBUG("ExtraParticlesPhysicsTool::ConstructProcess - m_extraParticleNames = " << extraParticleNames);
109  }
110  for (auto *particle : m_extraParticles) {
111  if (particle->GetPDGCharge() != 0) {
112  ATH_MSG_DEBUG("Adding EM processes for "
113  << particle->GetParticleName());
114  G4ProcessManager *proc = particle->GetProcessManager();
115  proc->AddProcess(new G4hMultipleScattering, -1, 1, 1);
116  proc->AddProcess(new G4hIonisation, -1, 2, 2);
117  }
118  }
119  ATH_MSG_DEBUG("ExtraParticlesPhysicsTool::ConstructProcess - end");
120 }
Trk::ParticleSwitcher::particle
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
Definition: ParticleHypothesis.h:76
ExtraParticlesPhysicsTool
Definition: ExtraParticlesPhysicsTool.h:23
Base_Fragment.mass
mass
Definition: Sherpa_i/share/common/Base_Fragment.py:59
ExtraParticlesPhysicsTool.h
ExtraParticlesPhysicsTool::m_extraParticles
std::set< G4ParticleDefinition * > m_extraParticles
a set to hold the newly created extra particles
Definition: ExtraParticlesPhysicsTool.h:44
ExtraParticlesPhysicsTool::m_extraParticlesConfig
std::map< std::string, std::vector< double > > m_extraParticlesConfig
a set of parameters for extra particle building
Definition: ExtraParticlesPhysicsTool.h:41
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:48
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:31
ExtraParticlesPhysicsTool::ConstructProcess
virtual void ConstructProcess() override final
Definition: ExtraParticlesPhysicsTool.cxx:101
CustomParticle
Definition: CustomParticle.h:17
mc.proc
proc
Definition: mc.PhPy8EG_A14NNPDF23_gg4l_example.py:22
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
charge
double charge(const T &p)
Definition: AtlasPID.h:756
G4AtlasPhysicsOption::QS_ExtraParticles
@ QS_ExtraParticles
Definition: IPhysicsOptionTool.h:23
Base_Fragment.width
width
Definition: Sherpa_i/share/common/Base_Fragment.py:59
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
DEBUG
#define DEBUG
Definition: page_access.h:11
ExtraParticlesPhysicsTool::GetPhysicsOption
virtual ExtraParticlesPhysicsTool * GetPhysicsOption() override final
Implements.
Definition: ExtraParticlesPhysicsTool.cxx:57
ExtraParticlesPhysicsTool::ConstructParticle
virtual void ConstructParticle() override final
Definition: ExtraParticlesPhysicsTool.cxx:64
ExtraParticlesPhysicsTool::~ExtraParticlesPhysicsTool
virtual ~ExtraParticlesPhysicsTool()
Destructor.
Definition: ExtraParticlesPhysicsTool.cxx:43