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