ROOT  6.06/09
Reference Guide
TGeoGlobalMagField.h
Go to the documentation of this file.
1 // @(#)root/geom:$Id$
2 
3 /*************************************************************************
4  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
5  * All rights reserved. *
6  * *
7  * For the licensing terms see $ROOTSYS/LICENSE. *
8  * For the list of contributors see $ROOTSYS/README/CREDITS. *
9  *************************************************************************/
10 
11 #ifndef ROOT_TGeoGlobalMagField
12 #define ROOT_TGeoGlobalMagField
13 
14 #ifndef ROOT_TObject
15 #include "TObject.h"
16 #endif
17 
18 #ifndef ROOT_TVirtualMagField
19 #include "TVirtualMagField.h"
20 #endif
21 
22 ////////////////////////////////////////////////////////////////////////////
23 // //
24 // TGeoGlobalMagField - Global magnetic field manager. A field derived //
25 // from TVirtualMagField becomes global if registered via SetField //
26 // method.
27 // //
28 ////////////////////////////////////////////////////////////////////////////
29 
31 {
32 private:
33  static TGeoGlobalMagField *fgInstance; // Static pointer to the field manager;
34  TVirtualMagField *fField; // Magnetic field
35  Bool_t fLock; // Lock flag for global field.
36 
37 protected:
40  void Unlock() {fLock = kFALSE;}
41 
42 public:
44  virtual ~TGeoGlobalMagField();
45 
46  // Using SetField() makes a given field global. The field manager owns it from now on.
47  TVirtualMagField *GetField() const {return fField;}
48  void SetField(TVirtualMagField *field);
49  Bool_t IsLocked() {return fLock;}
50  void Lock();
51 
52  // The field manager should be accessed via TGeoGlobalMagField::Instance()
53  static TGeoGlobalMagField *Instance();
55 
56  // Inline access to Field() method
57  void Field(const Double_t *x, Double_t *B) {if (fField) fField->Field(x,B);}
58 
59  ClassDef(TGeoGlobalMagField, 0) // Global field manager
60 };
61 
62 #endif
static double B[]
virtual void Field(const Double_t *x, Double_t *B)=0
static TGeoGlobalMagField * Instance()
Returns always a valid static pointer to the field manager.
bool Bool_t
Definition: RtypesCore.h:59
void Field(const Double_t *x, Double_t *B)
const Bool_t kFALSE
Definition: Rtypes.h:92
TVirtualMagField * GetField() const
Double_t x[n]
Definition: legend1.C:17
#define ClassDef(name, id)
Definition: Rtypes.h:254
virtual ~TGeoGlobalMagField()
Global field destructor.
static TGeoGlobalMagField * fgInstance
static TGeoGlobalMagField * GetInstance()
Static getter that does not create the object.
TGeoGlobalMagField & operator=(const TGeoGlobalMagField &)
double Double_t
Definition: RtypesCore.h:55
TVirtualMagField * fField
Mother of all ROOT objects.
Definition: TObject.h:58
void Lock()
Locks the global magnetic field if this is set. Cannot be unlocked.
void SetField(TVirtualMagField *field)
Field setter. Deletes previous field if any. Acts only if fLock=kFALSE.