ECCE @ EIC Software
Reference for
ECCE @ EIC
simulation and reconstruction software on GitHub
Home page
Related Pages
Modules
Namespaces
Classes
Files
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
G4MonopoleFieldSetup.cc
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file G4MonopoleFieldSetup.cc
1
//
2
// ********************************************************************
3
// * License and Disclaimer *
4
// * *
5
// * The Geant4 software is copyright of the Copyright Holders of *
6
// * the Geant4 Collaboration. It is provided under the terms and *
7
// * conditions of the Geant4 Software License, included in the file *
8
// * LICENSE and available at http://cern.ch/geant4/license . These *
9
// * include a list of copyright holders. *
10
// * *
11
// * Neither the authors of this software system, nor their employing *
12
// * institutes,nor the agencies providing financial support for this *
13
// * work make any representation or warranty, express or implied, *
14
// * regarding this software system or assume any liability for its *
15
// * use. Please see the license in the file LICENSE and URL above *
16
// * for the full disclaimer and the limitation of liability. *
17
// * *
18
// * This code implementation is the result of the scientific and *
19
// * technical work of the GEANT4 collaboration. *
20
// * By using, copying, modifying or distributing the software (or *
21
// * any work based on the software) you agree to acknowledge its *
22
// * use in resulting scientific publications, and indicate your *
23
// * acceptance of all terms of the Geant4 Software license. *
24
// ********************************************************************
25
//
28
//
29
//
30
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
31
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32
//
33
//
34
// G4MonopoleFieldSetup is responsible for setting up a magnetic field
35
// and the ability to use it with two different equation of motions,
36
// one for monopoles and another for the rest of the particles.
37
//
38
//
39
40
// =======================================================================
41
// Created: 13 May 2010, B. Bozsogi
42
// =======================================================================
43
44
#include "
G4MonopoleFieldSetup.hh
"
45
#include "
G4MonopoleFieldMessenger.hh
"
46
47
#include "
G4MagneticField.hh
"
48
#include "
G4UniformMagField.hh
"
49
#include "
G4FieldManager.hh
"
50
#include "
G4TransportationManager.hh
"
51
#include "
G4Mag_UsualEqRhs.hh
"
52
#include "
G4MonopoleEquation.hh
"
53
#include "
G4MagIntegratorStepper.hh
"
54
#include "
G4ChordFinder.hh
"
55
56
// #include "G4ExplicitEuler.hh"
57
// #include "G4ImplicitEuler.hh"
58
// #include "G4SimpleRunge.hh"
59
// #include "G4SimpleHeum.hh"
60
#include "
G4ClassicalRK4.hh
"
61
// #include "G4HelixExplicitEuler.hh"
62
// #include "G4HelixImplicitEuler.hh"
63
// #include "G4HelixSimpleRunge.hh"
64
// #include "G4CashKarpRKF45.hh"
65
// #include "G4RKG3_Stepper.hh"
66
67
#include "
G4SystemOfUnits.hh
"
68
69
//G4MonopoleFieldSetup* G4MonopoleFieldSetup::fMonopoleFieldSetup=0;
70
71
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
72
73
G4MonopoleFieldSetup::G4MonopoleFieldSetup
()
74
: fFieldManager(0),
75
fChordFinder(0),
76
fUsualChordFinder(0),
77
fMonopoleChordFinder(0),
78
fEquation(0),
79
fMonopoleEquation(0),
80
fMagneticField(0),
81
fStepper(0),
82
fMonopoleStepper(0),
83
fMinStep
(0.0),
84
fZmagFieldValue(0.2*
tesla
),
85
fMonopoleFieldMessenger(0)
86
{
87
88
fMonopoleFieldMessenger
=
new
G4MonopoleFieldMessenger
(
this
);
89
fFieldManager
=
GetGlobalFieldManager
();
90
}
91
92
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
93
94
// G4MonopoleFieldSetup* G4MonopoleFieldSetup::GetMonopoleFieldSetup()
95
// {
96
// if (0 == fMonopoleFieldSetup)
97
// {
98
// static G4ThreadLocal G4MonopoleFieldSetup theInstance;
99
// fMonopoleFieldSetup = &theInstance;
100
// }
101
102
// return fMonopoleFieldSetup;
103
// }
104
105
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
106
107
G4MonopoleFieldSetup::~G4MonopoleFieldSetup
()
108
{
109
delete
fMonopoleFieldMessenger
;
110
if
(
fMagneticField
)
delete
fMagneticField
;
111
// if(fChordFinder) delete fChordFinder;
112
if
(
fUsualChordFinder
)
delete
fUsualChordFinder
;
113
if
(
fMonopoleChordFinder
)
delete
fMonopoleChordFinder
;
114
if
(
fStepper
)
delete
fStepper
;
115
if
(
fMonopoleStepper
)
delete
fMonopoleStepper
;
116
}
117
118
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
119
120
void
G4MonopoleFieldSetup::SetZMagFieldValue
(
G4double
val)
121
{
122
//set new magnetic field value and rebuild the field
123
fZmagFieldValue
= val;
124
125
ConstructMagField
();
126
}
127
128
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
129
130
void
G4MonopoleFieldSetup::ConstructMagField
()
131
{
132
//apply a global uniform magnetic field along Z axis
133
if
(
fMagneticField
) {
delete
fMagneticField
; }
//delete the existing magn field
134
135
if
(
fZmagFieldValue
!= 0.)
// create a new one if non nul
136
{
137
// G4cout << "Go to create new field ..." << G4endl;
138
fMagneticField
=
new
G4UniformMagField
(
G4ThreeVector
(0., 0.,
139
fZmagFieldValue
));
140
InitialiseAll
();
141
}
142
else
143
{
144
// G4cout << "Set field = 0 ..." << G4endl;
145
fMagneticField
= 0;
146
}
147
148
fFieldManager
->
SetDetectorField
(
fMagneticField
);
149
150
}
151
152
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
153
154
void
G4MonopoleFieldSetup::InitialiseAll
()
155
{
156
fEquation
=
new
G4Mag_UsualEqRhs
(
fMagneticField
);
157
fMonopoleEquation
=
new
G4MonopoleEquation
(
fMagneticField
);
158
159
fMinStep
= 0.01*
mm
;
// minimal step of 1 mm is default
160
161
fMonopoleStepper
=
new
G4ClassicalRK4
(
fMonopoleEquation
, 8 );
162
fStepper
=
new
G4ClassicalRK4
(
fEquation
);
163
164
fUsualChordFinder
=
new
G4ChordFinder
(
fMagneticField
,
fMinStep
,
fStepper
);
165
fMonopoleChordFinder
=
new
G4ChordFinder
(
fMagneticField
,
fMinStep
,
166
fMonopoleStepper
);
167
168
SetStepperAndChordFinder
(0);
169
}
170
171
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
172
173
void
G4MonopoleFieldSetup::SetStepperAndChordFinder
(
G4int
val)
174
{
175
176
if
(
fMagneticField
)
177
{
178
fFieldManager
->
SetDetectorField
(
fMagneticField
);
179
// if(fChordFinder) delete fChordFinder;
180
181
switch
(val)
182
{
183
// case 0:
184
// fChordFinder = new G4ChordFinder( fMagneticField, fMinStep, fStepper);
185
// break;
186
// case 1:
187
// fChordFinder = new G4ChordFinder( fMagneticField, fMinStep,
188
// fMonopoleStepper);
189
// break;
190
case
0:
191
fChordFinder
=
fUsualChordFinder
;
192
break
;
193
case
1:
194
fChordFinder
=
fMonopoleChordFinder
;
195
break
;
196
}
197
198
fFieldManager
->
SetChordFinder
(
fChordFinder
);
199
}
200
201
}
202
203
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
204
205
G4FieldManager
*
G4MonopoleFieldSetup::GetGlobalFieldManager
()
206
{
207
return
G4TransportationManager::GetTransportationManager
()
208
->
GetFieldManager
();
209
}
210
211
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
geant4
tree
geant4-10.6-release
examples
extended
exoticphysics
monopole
src
G4MonopoleFieldSetup.cc
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:25:04
using
1.8.2 with
ECCE GitHub integration