]> git.uio.no Git - u/mrichter/AliRoot.git/blob - AliGeant4/AliMagneticField.cxx
This commit was generated by cvs2svn to compensate for changes in r1459,
[u/mrichter/AliRoot.git] / AliGeant4 / AliMagneticField.cxx
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
15 AliMagneticField::AliMagneticField()
16   : G4UniformMagField(G4ThreeVector()) 
17 {
18 //
19   GetGlobalFieldManager()->CreateChordFinder(this);
20 }
21
22 AliMagneticField::AliMagneticField(G4ThreeVector fieldVector)
23   : G4UniformMagField(fieldVector)
24 {    
25 //
26   GetGlobalFieldManager()->CreateChordFinder(this);
27 }
28
29 AliMagneticField::AliMagneticField(const AliMagneticField& right)
30   : G4UniformMagField(right)
31 {
32 //  
33   GetGlobalFieldManager()->CreateChordFinder(this);
34 }
35
36 AliMagneticField::~AliMagneticField() {
37 //
38 }
39
40 // operators
41
42 AliMagneticField& 
43 AliMagneticField::operator=(const AliMagneticField& right)
44 {                                 
45   // check assignement to self
46   if (this == &right) return *this;
47
48   // base class assignement
49   G4UniformMagField::operator=(right);
50   
51   return *this;
52 }  
53
54 // public methods
55
56 void AliMagneticField::SetFieldValue(G4double fieldValue)
57 {
58 // Sets the value of the Global Field to fieldValue along Z.
59 // ---
60
61   G4UniformMagField::SetFieldValue(G4ThreeVector(0,0,fieldValue));
62 }
63
64 void AliMagneticField::SetFieldValue(G4ThreeVector fieldVector)
65 {
66 // Sets the value of the Global Field.
67 // ---
68
69   // Find the Field Manager for the global field
70   G4FieldManager* fieldMgr= GetGlobalFieldManager();
71     
72   if(fieldVector!=G4ThreeVector(0.,0.,0.)) { 
73     G4UniformMagField::SetFieldValue(fieldVector); 
74     fieldMgr->SetDetectorField(this);
75   } 
76   else {
77     // If the new field's value is Zero, then it is best to
78     //  insure that it is not used for propagation.
79     G4MagneticField* magField = NULL;
80     fieldMgr->SetDetectorField(magField);
81   }
82 }
83
84 G4FieldManager*  AliMagneticField::GetGlobalFieldManager()
85 {
86 // Utility method/
87 // ---
88
89   return G4TransportationManager::GetTransportationManager()
90            ->GetFieldManager();
91 }
92