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 - 2023.
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 leptons;
56 leptons.ConstructParticle();
57
58 // mesons, inc. all pions
59 G4MesonConstructor mConstructor;
60 mConstructor.ConstructParticle();
61
62 // photons
63 G4Gamma::Gamma();
64 G4OpticalPhoton::OpticalPhoton();
65}
66
68{
69 if (Activated())
70 {return;}
71
72 // for gamma
73 G4GammaConversionToMuons* gammaToMuPair = new G4GammaConversionToMuons();
74 G4AutoDelete::Register(gammaToMuPair);
75
76 // for e+
77 G4AnnihiToMuPair* ePlusToMuPair = new G4AnnihiToMuPair();
78 G4AutoDelete::Register(ePlusToMuPair);
79 G4eeToHadrons* eeToHadrons = new G4eeToHadrons();
80 G4AutoDelete::Register(eeToHadrons);
81
82 // for muon +-
83 G4MuMultipleScattering* mumsc = nullptr;
84 G4MuIonisation* muion = nullptr;
85 G4MuBremsstrahlung* mubrm = nullptr;
86 if (!emWillBeUsed)
87 {// these are provided by em physics, so don't double register
88 mumsc = new G4MuMultipleScattering();
89 G4AutoDelete::Register(mumsc);
90 muion = new G4MuIonisation();
91 G4AutoDelete::Register(muion);
92 mubrm = new G4MuBremsstrahlung();
93 G4AutoDelete::Register(mubrm);
94 }
95 G4MuPairProduction* mupar = new G4MuPairProduction();
96 G4AutoDelete::Register(mupar);
97
98 G4PhysicsListHelper* ph = G4PhysicsListHelper::GetPhysicsListHelper();
99
100#if G4VERSION_NUMBER > 1029
101 auto aParticleIterator = GetParticleIterator();
102#endif
103 aParticleIterator->reset();
104
105 while( (*aParticleIterator)() )
106 {
107 G4ParticleDefinition* particle = aParticleIterator->value();
108 G4String particleName = particle->GetParticleName();
109
110 if(particleName == "gamma")
111 {
112 ph->RegisterProcess(gammaToMuPair, particle);
113 continue;
114 }
115 if(particleName == "e+")
116 {
117 ph->RegisterProcess(ePlusToMuPair, particle);
118 ph->RegisterProcess(eeToHadrons, particle);
119 continue;
120 }
121 if(particleName == "mu+" || particleName == "mu-")
122 {
123 if (!emWillBeUsed)
124 {// these are only instantiated if we're not using EM physics
125 ph->RegisterProcess(mumsc, particle);
126 ph->RegisterProcess(muion, particle);
127 ph->RegisterProcess(mubrm, particle);
128 ph->RegisterProcess(mupar, particle);
129 }
130 continue;
131 }
132 }
133
134 SetActivated();
135}
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.
Definition: BDSSingleUse.hh:37
void SetActivated()
Flag this instance as activated for later querying.
Definition: BDSSingleUse.hh:40