ATLAS Offline Software
Loading...
Searching...
No Matches
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#include <memory>
17
18//-----------------------------------------------------------------------------
19// Implementation file for class : TRTPhysicsTool
20//
21// 18-05-2015 Edoardo Farina
22//-----------------------------------------------------------------------------
23
24#if G4VERSION_NUMBER > 1029
25#define PARTICLEITERATOR (this->GetParticleIterator())
26#elif G4VERSION_NUMBER > 1009
27#define PARTICLEITERATOR aParticleIterator
28#else
29#define PARTICLEITERATOR theParticleIterator
30#endif
31
32
33//=============================================================================
34// Standard constructor, initializes variables
35//=============================================================================
36TRTPhysicsTool::TRTPhysicsTool(const std::string& type, const std::string& name,
37 const IInterface* parent)
38 : base_class(type, name, parent) {
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 return StatusCode::SUCCESS;
51}
52
53//=============================================================================
54// Return the physics constructor
55//=============================================================================
56auto TRTPhysicsTool::GetPhysicsOption() -> UPPhysicsConstructor {
57 return std::make_unique<TRTPhysicsTool::PhysicsConstructor>(name(), this->msgLevel(), m_xmlFile);
58}
59
60//=============================================================================
61// Particle construction; not implemented
62//=============================================================================
64
65//=============================================================================
66// Physics process construction
67//=============================================================================
69 ATH_MSG_DEBUG("TRTPhysicsTool::ConstructProcess() - start");
70
71 // Use the Geant4 garbage collection mechanism to clean this up.
72 // It's just a convenient way to clean up in multi-threading.
73 auto trProc = new TRTTransitionRadiation("XTR", m_xmlFile) ;
74 G4AutoDelete::Register(trProc);
75
76 PARTICLEITERATOR->reset();
77 while( (*PARTICLEITERATOR)() ) {
78 G4ParticleDefinition* particle = PARTICLEITERATOR->value();
79 G4ProcessManager* pmanager = particle->GetProcessManager();
80 if ( particle->GetPDGCharge() != 0.0 && particle->GetPDGMass() != 0.0 ) {
81 trProc->SetVerboseLevel(1);
82 ATH_MSG_DEBUG("TRT Process Added to "<<particle->GetParticleName());
83 pmanager->AddDiscreteProcess(trProc);
84 }
85 }
86 ATH_MSG_DEBUG("TRTPhysicsTool::ConstructProcess() - end");
87}
#define ATH_MSG_DEBUG(x)
#define PARTICLEITERATOR
virtual void ConstructParticle() override
virtual void ConstructProcess() override
std::string m_xmlFile
virtual UPPhysicsConstructor GetPhysicsOption() override
IPhysicsOptionTool method; simply returns self.
TRTPhysicsTool(const std::string &type, const std::string &name, const IInterface *parent)
Standard constructor.
virtual StatusCode initialize() override
Destructor.