BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSPhysicsMuon.cc
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) Royal Holloway,
3University of London 2001 - 2024.
4
5This file is part of BDSIM.
6
7BDSIM is free software: you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published
9by the Free Software Foundation version 3 of the License.
10
11BDSIM is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with BDSIM. If not, see <http://www.gnu.org/licenses/>.
18*/
19#include "BDSDebug.hh"
20#include "BDSGlobalConstants.hh"
21#include "BDSPhysicsMuon.hh"
22
23#include "G4AutoDelete.hh"
24#include "G4AnnihiToMuPair.hh"
25#include "G4eeToHadrons.hh"
26#include "G4Gamma.hh"
27#include "G4GammaConversionToMuons.hh"
28#include "G4LeptonConstructor.hh"
29#include "G4MesonConstructor.hh"
30#include "G4MuBremsstrahlung.hh"
31#include "G4MuIonisation.hh"
32#include "G4MuMultipleScattering.hh"
33#include "G4MuPairProduction.hh"
34#include "G4OpticalPhoton.hh"
35#include "G4ParticleDefinition.hh"
36#include "G4PhysicsListHelper.hh"
37#include "G4Version.hh"
38
39
40BDSPhysicsMuon::BDSPhysicsMuon():
41 BDSPhysicsMuon(false)
42{;}
43
44BDSPhysicsMuon::BDSPhysicsMuon(G4bool emWillBeUsedIn):
45 G4VPhysicsConstructor("BDSPhysicsMuon"),
46 emWillBeUsed(emWillBeUsedIn)
47{;}
48
49BDSPhysicsMuon::~BDSPhysicsMuon()
50{;}
51
53{
54 // leptons
55 G4LeptonConstructor::ConstructParticle();
56
57 // mesons, inc. all pions
58 G4MesonConstructor::ConstructParticle();
59
60 // photons
61 G4Gamma::Gamma();
62 G4OpticalPhoton::OpticalPhoton();
63}
64
66{
67 if (Activated())
68 {return;}
69
70 // for gamma
71 G4GammaConversionToMuons* gammaToMuPair = new G4GammaConversionToMuons();
72 G4AutoDelete::Register(gammaToMuPair);
73
74 // for e+
75 G4AnnihiToMuPair* ePlusToMuPair = new G4AnnihiToMuPair();
76 G4AutoDelete::Register(ePlusToMuPair);
77 G4eeToHadrons* eeToHadrons = new G4eeToHadrons();
78 G4AutoDelete::Register(eeToHadrons);
79
80 // for muon +-
81 G4MuMultipleScattering* mumsc = nullptr;
82 G4MuIonisation* muion = nullptr;
83 G4MuBremsstrahlung* mubrm = nullptr;
84 if (!emWillBeUsed)
85 {// these are provided by em physics, so don't double register
86 mumsc = new G4MuMultipleScattering();
87 G4AutoDelete::Register(mumsc);
88 muion = new G4MuIonisation();
89 G4AutoDelete::Register(muion);
90 mubrm = new G4MuBremsstrahlung();
91 G4AutoDelete::Register(mubrm);
92 }
93 G4MuPairProduction* mupar = new G4MuPairProduction();
94 G4AutoDelete::Register(mupar);
95
96 G4PhysicsListHelper* ph = G4PhysicsListHelper::GetPhysicsListHelper();
97
98#if G4VERSION_NUMBER > 1029
99 auto aParticleIterator = GetParticleIterator();
100#endif
101 aParticleIterator->reset();
102
103 while( (*aParticleIterator)() )
104 {
105 G4ParticleDefinition* particle = aParticleIterator->value();
106 G4String particleName = particle->GetParticleName();
107
108 if(particleName == "gamma")
109 {
110 ph->RegisterProcess(gammaToMuPair, particle);
111 continue;
112 }
113 if(particleName == "e+")
114 {
115 ph->RegisterProcess(ePlusToMuPair, particle);
116 ph->RegisterProcess(eeToHadrons, particle);
117 continue;
118 }
119 if(particleName == "mu+" || particleName == "mu-")
120 {
121 if (!emWillBeUsed)
122 {// these are only instantiated if we're not using EM physics
123 ph->RegisterProcess(mumsc, particle);
124 ph->RegisterProcess(muion, particle);
125 ph->RegisterProcess(mubrm, particle);
126 ph->RegisterProcess(mupar, particle);
127 }
128 continue;
129 }
130 }
131
132 SetActivated();
133}
High energy muon processes.
virtual void ConstructProcess()
Construct and attach the processes to the relevant particles.
virtual void ConstructParticle()
Construct all leptons, photons (inc optical), and pion +- just in case.
G4bool Activated() const
Get whether this instance has been activated.
void SetActivated()
Flag this instance as activated for later querying.