Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
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 #include "TObject.h"
15 
16 #include "TVirtualMagField.h"
17 
18 class TGeoGlobalMagField : public TObject
19 {
20 private:
21  static TGeoGlobalMagField *fgInstance; // Static pointer to the field manager;
22  TVirtualMagField *fField; // Magnetic field
23  Bool_t fLock; // Lock flag for global field.
24 
25 protected:
26  TGeoGlobalMagField(const TGeoGlobalMagField&);
27  TGeoGlobalMagField& operator=(const TGeoGlobalMagField&);
28  void Unlock() {fLock = kFALSE;}
29 
30 public:
31  TGeoGlobalMagField();
32  virtual ~TGeoGlobalMagField();
33 
34  // Using SetField() makes a given field global. The field manager owns it from now on.
35  TVirtualMagField *GetField() const {return fField;}
36  void SetField(TVirtualMagField *field);
37  Bool_t IsLocked() {return fLock;}
38  void Lock();
39 
40  // The field manager should be accessed via TGeoGlobalMagField::Instance()
41  static TGeoGlobalMagField *Instance();
42  static TGeoGlobalMagField *GetInstance();
43 
44  // Inline access to Field() method
45  void Field(const Double_t *x, Double_t *B) {if (fField) fField->Field(x,B);}
46 
47  ClassDef(TGeoGlobalMagField, 0) // Global field manager
48 };
49 
50 #endif