Logo ROOT   6.08/07
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 
23 {
24 private:
25  static TGeoGlobalMagField *fgInstance; // Static pointer to the field manager;
26  TVirtualMagField *fField; // Magnetic field
27  Bool_t fLock; // Lock flag for global field.
28 
29 protected:
32  void Unlock() {fLock = kFALSE;}
33 
34 public:
36  virtual ~TGeoGlobalMagField();
37 
38  // Using SetField() makes a given field global. The field manager owns it from now on.
39  TVirtualMagField *GetField() const {return fField;}
40  void SetField(TVirtualMagField *field);
41  Bool_t IsLocked() {return fLock;}
42  void Lock();
43 
44  // The field manager should be accessed via TGeoGlobalMagField::Instance()
45  static TGeoGlobalMagField *Instance();
47 
48  // Inline access to Field() method
49  void Field(const Double_t *x, Double_t *B) {if (fField) fField->Field(x,B);}
50 
51  ClassDef(TGeoGlobalMagField, 0) // Global field manager
52 };
53 
54 #endif
static double B[]
virtual void Field(const Double_t *x, Double_t *B)=0
TVirtualMagField * GetField() const
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
TGeoGlobalMagField()
Global field default constructor.
Double_t x[n]
Definition: legend1.C:17
#define ClassDef(name, id)
Definition: Rtypes.h:254
virtual ~TGeoGlobalMagField()
Global field destructor.
Global magnetic field manager.
static TGeoGlobalMagField * GetInstance()
Static getter that does not create the object.
static TGeoGlobalMagField * fgInstance
TGeoGlobalMagField & operator=(const TGeoGlobalMagField &)
double Double_t
Definition: RtypesCore.h:55
Abstract class for magnetic field.
TVirtualMagField * fField
Mother of all ROOT objects.
Definition: TObject.h:37
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.