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