ATLAS Offline Software
TRTPhysicsTool.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 "TRTPhysicsTool.h"
7 
8 #include "G4ProcessManager.hh"
9 #include "G4ParticleTable.hh"
10 #include "G4VProcess.hh"
11 #include "G4Version.hh"
12 #include "G4AutoDelete.hh"
13 
14 #include "globals.hh"
15 #include <iostream>
16 
17 //-----------------------------------------------------------------------------
18 // Implementation file for class : TRTPhysicsTool
19 //
20 // 18-05-2015 Edoardo Farina
21 //-----------------------------------------------------------------------------
22 
23 #if G4VERSION_NUMBER > 1029
24 #define PARTICLEITERATOR (this->GetParticleIterator())
25 #elif G4VERSION_NUMBER > 1009
26 #define PARTICLEITERATOR aParticleIterator
27 #else
28 #define PARTICLEITERATOR theParticleIterator
29 #endif
30 
31 
32 //=============================================================================
33 // Standard constructor, initializes variables
34 //=============================================================================
36  const std::string& nam,const IInterface* parent )
37  : G4VPhysicsConstructor(nam), base_class ( type, nam , parent )
38 {
39  m_physicsOptionType = G4AtlasPhysicsOption::Type::GlobalProcesses;
40 
41  declareProperty("XMLFile", m_xmlFile="TRgeomodelgeometry.xml");
42 }
43 
44 //=============================================================================
45 // Initialize
46 //=============================================================================
48 {
49  ATH_MSG_DEBUG("TRTPhysicsTool initialize()");
50  this->SetPhysicsName(name());
51  return StatusCode::SUCCESS;
52 }
53 
54 //=============================================================================
55 // Return the physics constructor
56 //=============================================================================
57 G4VPhysicsConstructor* TRTPhysicsTool::GetPhysicsOption()
58 {
59  // I am the physics constructor, so return self.
60  return this;
61 }
62 
63 //=============================================================================
64 // Particle construction; not implemented
65 //=============================================================================
67 {
68 }
69 
70 //=============================================================================
71 // Physics process construction
72 //=============================================================================
74 {
75  ATH_MSG_DEBUG("TRTPhysicsTool::ConstructProcess() - start");
76 
77  // Use the Geant4 garbage collection mechanism to clean this up.
78  // It's just a convenient way to clean up in multi-threading.
79  auto trProc = new TRTTransitionRadiation("XTR", m_xmlFile) ;
80  G4AutoDelete::Register(trProc);
81 
82  PARTICLEITERATOR->reset();
83  while( (*PARTICLEITERATOR)() ) {
84  G4ParticleDefinition* particle = PARTICLEITERATOR->value();
85  G4ProcessManager* pmanager = particle->GetProcessManager();
86  if ( particle->GetPDGCharge() != 0.0 && particle->GetPDGMass() != 0.0 ) {
87  trProc->SetVerboseLevel(1);
88  ATH_MSG_DEBUG("TRT Process Added to "<<particle->GetParticleName());
89  pmanager->AddDiscreteProcess(trProc);
90  }
91  }
92  ATH_MSG_DEBUG("TRTPhysicsTool::ConstructProcess() - end");
93 }
Trk::ParticleSwitcher::particle
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
Definition: ParticleHypothesis.h:76
TRTTransitionRadiation
Definition: TRTTransitionRadiation.h:24
TRTPhysicsTool::TRTPhysicsTool
TRTPhysicsTool(const std::string &type, const std::string &name, const IInterface *parent)
Standard constructor.
Definition: TRTPhysicsTool.cxx:35
TRTPhysicsTool::m_xmlFile
std::string m_xmlFile
Definition: TRTPhysicsTool.h:45
TRTPhysicsTool.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
TRTPhysicsTool::initialize
virtual StatusCode initialize() override
Destructor.
Definition: TRTPhysicsTool.cxx:47
TRTPhysicsTool::ConstructProcess
virtual void ConstructProcess() override
Definition: TRTPhysicsTool.cxx:73
test_pyathena.parent
parent
Definition: test_pyathena.py:15
TRTPhysicsTool::GetPhysicsOption
virtual G4VPhysicsConstructor * GetPhysicsOption() override
IPhysicsOptionTool method; simply returns self.
Definition: TRTPhysicsTool.cxx:57
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
TRTTransitionRadiation.h
G4AtlasPhysicsOption::GlobalProcesses
@ GlobalProcesses
Definition: IPhysicsOptionTool.h:25
TRTPhysicsTool::ConstructParticle
virtual void ConstructParticle() override
Definition: TRTPhysicsTool.cxx:66
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
PARTICLEITERATOR
#define PARTICLEITERATOR
Definition: TRTPhysicsTool.cxx:28