ATLAS Offline Software
LucidPhysicsTool.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 // local
6 #include "LucidPhysicsTool.h"
7 
8 #include "G4ProcessManager.hh"
9 #include "G4ParticleTable.hh"
10 #include "G4VProcess.hh"
11 #include "G4Version.hh"
12 
13 
14 #include "G4Cerenkov.hh"
15 #include "G4Scintillation.hh"
16 #include "G4OpAbsorption.hh"
17 #include "G4OpRayleigh.hh"
18 #include "G4OpBoundaryProcess.hh"
19 
20 #if G4VERSION_NUMBER > 1029
21 #define PARTICLEITERATOR (this->GetParticleIterator())
22 #elif G4VERSION_NUMBER > 1009
23 #define PARTICLEITERATOR aParticleIterator
24 #else
25 #define PARTICLEITERATOR theParticleIterator
26 #endif
27 
28 //-----------------------------------------------------------------------------
29 // Implementation file for class : LucidPhysicsTool
30 //
31 // 18-05-2015 : Edoardo Farina
32 //-----------------------------------------------------------------------------
33 
34 
35 
36 //=============================================================================
37 // Standard constructor, initializes variables
38 //=============================================================================
40  const std::string& nam,const IInterface* parent )
41  : G4VPhysicsConstructor(nam), AthAlgTool ( type, nam , parent )
42 {
44  ATH_MSG_INFO("LucidPhysicsTool "<<type<<" "<<nam);
45  declareInterface< IPhysicsOptionTool >( this ) ;
46 }
47 
48 //=============================================================================
49 // Destructor
50 //=============================================================================
51 
53 {
54 }
55 
56 //=============================================================================
57 // Initialize
58 //=============================================================================
60 {
61  ATH_MSG_INFO("LucidPhysicsTool initialize( )");
62  this->SetPhysicsName(name());
63  return StatusCode::SUCCESS;
64 }
65 
66 G4VPhysicsConstructor* LucidPhysicsTool::GetPhysicsOption()
67 {
68  return this;
69 }
70 
71 
73 {
74 
75 }
77 {
78  G4Cerenkov* theCerenkovProcess = new G4Cerenkov ("Cerenkov");
79  G4Scintillation* theScintillationProcess = new G4Scintillation ("Scintillation");
80  G4OpAbsorption* theOpAbsorptionProcess = new G4OpAbsorption ();
81  G4OpRayleigh* theOpRayleighProcess = new G4OpRayleigh ();
82  G4OpBoundaryProcess* theOpBoundaryProcess = new G4OpBoundaryProcess();
83 
84  theCerenkovProcess->SetVerboseLevel(0);
85  theScintillationProcess->SetVerboseLevel(0);
86  theOpAbsorptionProcess->SetVerboseLevel(0);
87  theOpRayleighProcess->SetVerboseLevel(0);
88  theOpBoundaryProcess->SetVerboseLevel(0);
89 
90  G4int MaxNumPhotons = 300;
91 
92  theCerenkovProcess->SetTrackSecondariesFirst(true);
93  theCerenkovProcess->SetMaxNumPhotonsPerStep(MaxNumPhotons);
94 
95  theScintillationProcess->SetTrackSecondariesFirst(true);
96 #if G4VERSION_NUMBER < 1100
97  // This should be defaulted to 1. in 11.0 and newer
98  theScintillationProcess->SetScintillationYieldFactor(1.);
99 #endif
100 
101  PARTICLEITERATOR->reset();
102 
103  while ((*PARTICLEITERATOR)())
104  {
105 
106  G4ParticleDefinition* particle = PARTICLEITERATOR->value();
107  G4ProcessManager* pmanager = particle->GetProcessManager();
108  G4String particleName = particle->GetParticleName();
109 
110  if (theCerenkovProcess->IsApplicable(*particle)) {
111  ATH_MSG_DEBUG( " Adding CerenkovProcess to: " << particleName );
112  pmanager->AddProcess (theCerenkovProcess);
113  pmanager->SetProcessOrdering(theCerenkovProcess, idxPostStep);
114  }
115 
116  if (theScintillationProcess->IsApplicable(*particle)) {
117  ATH_MSG_DEBUG( " Adding ScintillationProcess to: " << particleName );
118  pmanager->AddProcess (theScintillationProcess);
119  pmanager->SetProcessOrderingToLast(theScintillationProcess, idxAtRest);
120  pmanager->SetProcessOrderingToLast(theScintillationProcess, idxPostStep);
121  }
122 
123  if (particleName == "opticalphoton") {
124 
125  ATH_MSG_DEBUG(" Adding OpAbsorptionProcess, OpRayleighProcess and OpBoundaryProcess to opticalphoton " );
126  pmanager->AddDiscreteProcess(theOpAbsorptionProcess);
127  pmanager->AddDiscreteProcess(theOpRayleighProcess);
128  pmanager->AddDiscreteProcess(theOpBoundaryProcess);
129  }
130  }
131 
132 }
Trk::ParticleSwitcher::particle
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
Definition: ParticleHypothesis.h:76
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
PARTICLEITERATOR
#define PARTICLEITERATOR
Definition: LucidPhysicsTool.cxx:25
LucidPhysicsTool::LucidPhysicsTool
LucidPhysicsTool(const std::string &type, const std::string &name, const IInterface *parent)
Standard constructor.
Definition: LucidPhysicsTool.cxx:39
LucidPhysicsTool.h
LucidPhysicsTool::initialize
virtual StatusCode initialize() override final
Initialize method.
Definition: LucidPhysicsTool.cxx:59
G4StepHelper::particleName
std::string particleName(const G4Step *theStep)
TODO.
Definition: StepHelper.cxx:24
LucidPhysicsTool::ConstructProcess
virtual void ConstructProcess() override final
Definition: LucidPhysicsTool.cxx:76
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
LucidPhysicsTool::ConstructParticle
virtual void ConstructParticle() override final
Definition: LucidPhysicsTool.cxx:72
test_pyathena.parent
parent
Definition: test_pyathena.py:15
IPhysicsOptionTool::m_physicsOptionType
G4AtlasPhysicsOption::Type m_physicsOptionType
Definition: IPhysicsOptionTool.h:46
LucidPhysicsTool::GetPhysicsOption
virtual G4VPhysicsConstructor * GetPhysicsOption() override final
Implements.
Definition: LucidPhysicsTool.cxx:66
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
G4AtlasPhysicsOption::GlobalProcesses
@ GlobalProcesses
Definition: IPhysicsOptionTool.h:25
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
LucidPhysicsTool::~LucidPhysicsTool
virtual ~LucidPhysicsTool()
Destructor.
Definition: LucidPhysicsTool.cxx:52
AthAlgTool
Definition: AthAlgTool.h:26