]> git.uio.no Git - u/mrichter/AliRoot.git/blame - AliGeant4/AliMagneticField.cxx
corections in XML implementation described
[u/mrichter/AliRoot.git] / AliGeant4 / AliMagneticField.cxx
CommitLineData
676fb573 1// $Id$
2// Category: geometry
3//
4// According to:
5// Id: ExN02MagneticField.cc,v 1.1 1999/01/07 16:05:49 gunter Exp
6// GEANT4 tag Name: geant4-00-01
7
8#include "AliMagneticField.h"
9
10#include <G4FieldManager.hh>
11#include <G4TransportationManager.hh>
12
13// Constructors
14
15AliMagneticField::AliMagneticField()
16 : G4UniformMagField(G4ThreeVector())
17{
18//
6dd21a33 19 GetGlobalFieldManager()->SetDetectorField(this);
676fb573 20 GetGlobalFieldManager()->CreateChordFinder(this);
21}
22
23AliMagneticField::AliMagneticField(G4ThreeVector fieldVector)
24 : G4UniformMagField(fieldVector)
25{
26//
6dd21a33 27 GetGlobalFieldManager()->SetDetectorField(this);
676fb573 28 GetGlobalFieldManager()->CreateChordFinder(this);
29}
30
31AliMagneticField::AliMagneticField(const AliMagneticField& right)
32 : G4UniformMagField(right)
33{
34//
6dd21a33 35 GetGlobalFieldManager()->SetDetectorField(this);
676fb573 36 GetGlobalFieldManager()->CreateChordFinder(this);
37}
38
39AliMagneticField::~AliMagneticField() {
40//
41}
42
43// operators
44
45AliMagneticField&
46AliMagneticField::operator=(const AliMagneticField& right)
47{
48 // check assignement to self
49 if (this == &right) return *this;
50
51 // base class assignement
52 G4UniformMagField::operator=(right);
53
54 return *this;
55}
56
57// public methods
58
59void AliMagneticField::SetFieldValue(G4double fieldValue)
60{
61// Sets the value of the Global Field to fieldValue along Z.
62// ---
63
64 G4UniformMagField::SetFieldValue(G4ThreeVector(0,0,fieldValue));
65}
66
67void AliMagneticField::SetFieldValue(G4ThreeVector fieldVector)
68{
69// Sets the value of the Global Field.
70// ---
71
72 // Find the Field Manager for the global field
73 G4FieldManager* fieldMgr= GetGlobalFieldManager();
74
75 if(fieldVector!=G4ThreeVector(0.,0.,0.)) {
76 G4UniformMagField::SetFieldValue(fieldVector);
77 fieldMgr->SetDetectorField(this);
78 }
79 else {
80 // If the new field's value is Zero, then it is best to
81 // insure that it is not used for propagation.
6dd21a33 82 G4MagneticField* magField = 0;
676fb573 83 fieldMgr->SetDetectorField(magField);
84 }
85}
86
87G4FieldManager* AliMagneticField::GetGlobalFieldManager()
88{
89// Utility method/
90// ---
91
92 return G4TransportationManager::GetTransportationManager()
93 ->GetFieldManager();
94}
95