Geant4 VMC Version 6.6
Loading...
Searching...
No Matches
G4MonopoleFieldSetup.cxx
Go to the documentation of this file.
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// $Id: G4MonopoleFieldSetup.cc 104872 2017-06-23 14:19:16Z gcosmo $
30//
31//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33//
34//
35// G4MonopoleFieldSetup is responsible for setting up a magnetic field
36// and the ability to use it with two different equation of motions,
37// one for monopoles and another for the rest of the particles.
38//
39//
40
41// =======================================================================
42// Created: 13 May 2010, B. Bozsogi
43// =======================================================================
44
45// Modified for use in Geant4 VMC
46// I. Hrivnacova, IPN Orsay; 12/09/2018
47
49// #include "G4MonopoleFieldMessenger.hh"
50
51#include "G4ChordFinder.hh"
52#include "G4FieldManager.hh"
53#include "G4MagIntegratorStepper.hh"
54#include "G4Mag_UsualEqRhs.hh"
55#include "G4MagneticField.hh"
56#include "G4MonopoleEquation.hh"
57#include "G4TransportationManager.hh"
58#include "G4UniformMagField.hh"
59
60// #include "G4ExplicitEuler.hh"
61// #include "G4ImplicitEuler.hh"
62// #include "G4SimpleRunge.hh"
63// #include "G4SimpleHeum.hh"
64#include "G4ClassicalRK4.hh"
65// #include "G4HelixExplicitEuler.hh"
66// #include "G4HelixImplicitEuler.hh"
67// #include "G4HelixSimpleRunge.hh"
68// #include "G4CashKarpRKF45.hh"
69// #include "G4RKG3_Stepper.hh"
70
71#include "G4SystemOfUnits.hh"
72
74
75//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
76
78 : fFieldManager(0),
79 fMagneticField(0),
80 fChordFinder(0),
81 fUsualChordFinder(0),
82 fDefaultEquation(0),
83 fDefaultStepper(0),
84 fMonopoleChordFinder(0),
85 fMonopoleEquation(0),
86 fMonopoleStepper(0),
87 fMinStep(0.0),
88 fZmagFieldValue(0.2 * tesla) //,
89 // fMonopoleFieldMessenger(0)
90{
91
92 // fMonopoleFieldMessenger = new G4MonopoleFieldMessenger(this);
93 // fFieldManager = GetGlobalFieldManager();
94}
95
96//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
97
99{
100 if (!fgInstance) {
101 // static G4ThreadLocal G4MonopoleFieldSetup theInstance;
103 }
104
105 return fgInstance;
106}
107
108//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
109
111{
112 // delete fMonopoleFieldMessenger;
113 if (fMagneticField) delete fMagneticField;
114 // if(fChordFinder) delete fChordFinder;
119
120 fgInstance = 0;
121}
122
123//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
124
125// void G4MonopoleFieldSetup::SetMagField(G4double fieldValue,
126// bool checkIfAlreadyDefined)
127// {
128// if(checkIfAlreadyDefined&&fMagneticField){
129// // G4double fieldSet[4], fValue;
130// // fMagneticField->GetFieldValue(fieldSet, &fValue);
131// G4cout << "Do nothing, already defined ..." << G4endl;
132// return;
133// }
134
135// fZmagFieldValue = fieldValue;
136
137// //apply a global uniform magnetic field along Z axis
138// if (fMagneticField) { delete fMagneticField; } //delete the existing magn
139// field
140
141// if (fZmagFieldValue != 0.) // create a new one if non nul
142// {
143// G4cout << "Go to create new field ..." << G4endl;
144// fMagneticField = new G4UniformMagField(G4ThreeVector(0., 0.,
145// fZmagFieldValue));
146// InitialiseAll();
147// }
148// else
149// {
150// G4cout << "Set field = 0 ..." << G4endl;
151// fMagneticField = 0;
152// }
153
154// fFieldManager->SetDetectorField(fMagneticField);
155
156// }
157
158//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
159
161{
162 if (fMagneticField) delete fMagneticField;
163
164 fMagneticField = magneticField;
165}
166
167//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
168
170{
172 G4TransportationManager::GetTransportationManager()->GetFieldManager();
173
174 fDefaultEquation = new G4Mag_UsualEqRhs(fMagneticField);
176
177 fMinStep = 0.01 * mm; // minimal step of 1 mm is default
178
179 fMonopoleStepper = new G4ClassicalRK4(fMonopoleEquation, 8);
180 fDefaultStepper = new G4ClassicalRK4(fDefaultEquation);
181
183 new G4ChordFinder(fMagneticField, fMinStep, fDefaultStepper);
185 new G4ChordFinder(fMagneticField, fMinStep, fMonopoleStepper);
186
188}
189
190//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
191
193{
194
195 if (fMagneticField) {
196 fFieldManager->SetDetectorField(fMagneticField);
197
198 switch (val) {
199 case 0:
201 break;
202 case 1:
204 break;
205 }
206
207 fFieldManager->SetChordFinder(fChordFinder);
208 }
209}
210
211//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Definition of the G4MonopoleEquation class.
Definition of the G4MonopoleFieldSetup class.
G4ChordFinder * fMonopoleChordFinder
G4MagIntegratorStepper * fDefaultStepper
void SetStepperAndChordFinder(G4int val)
G4EquationOfMotion * fDefaultEquation
G4MonopoleEquation * fMonopoleEquation
static G4ThreadLocal G4MonopoleFieldSetup * fgInstance
thread local instance
G4ChordFinder * fUsualChordFinder
static G4MonopoleFieldSetup * GetMonopoleFieldSetup()
void SetMagneticField(G4MagneticField *magneticField)
G4MagIntegratorStepper * fMonopoleStepper
G4MagneticField * fMagneticField
G4FieldManager * fFieldManager