ROOT logo
// @(#)root/geom:$Id: TGeoGlobalMagField.h 27191 2009-01-20 08:09:20Z brun $

/*************************************************************************
 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT_TGeoGlobalMagField
#define ROOT_TGeoGlobalMagField

#ifndef ROOT_TObject
#include "TObject.h"
#endif

#ifndef ROOT_TVirtualMagField
#include "TVirtualMagField.h"
#endif

////////////////////////////////////////////////////////////////////////////
//                                                                        //
// TGeoGlobalMagField - Global magnetic field manager. A field derived    //
//   from TVirtualMagField becomes global if registered via SetField      //
//   method.
//                                                                        //
////////////////////////////////////////////////////////////////////////////

class TGeoGlobalMagField : public TObject
{
private:
   static TGeoGlobalMagField *fgInstance;     // Static pointer to the field manager;
   TVirtualMagField       *fField;            // Magnetic field
   Bool_t                  fLock;             // Lock flag for global field.

protected:
   TGeoGlobalMagField(const TGeoGlobalMagField&);
   TGeoGlobalMagField& operator=(const TGeoGlobalMagField&);
   void                    Unlock() {fLock = kFALSE;}
   
public:
   TGeoGlobalMagField();
   virtual ~TGeoGlobalMagField();
   
   // Using SetField() makes a given field global. The field manager owns it from now on.
   TVirtualMagField       *GetField() const {return fField;}
   void                    SetField(TVirtualMagField *field);
   Bool_t                  IsLocked() {return fLock;}
   void                    Lock();
   
   // The field manager should be accessed via TGeoGlobalMagField::Instance()
   static TGeoGlobalMagField *Instance();

   // Inline access to Field() method
   void                    Field(const Double_t *x, Double_t *B) {if (fField) fField->Field(x,B);}
   
   ClassDef(TGeoGlobalMagField, 0)              // Global field manager
};

#endif
 TGeoGlobalMagField.h:1
 TGeoGlobalMagField.h:2
 TGeoGlobalMagField.h:3
 TGeoGlobalMagField.h:4
 TGeoGlobalMagField.h:5
 TGeoGlobalMagField.h:6
 TGeoGlobalMagField.h:7
 TGeoGlobalMagField.h:8
 TGeoGlobalMagField.h:9
 TGeoGlobalMagField.h:10
 TGeoGlobalMagField.h:11
 TGeoGlobalMagField.h:12
 TGeoGlobalMagField.h:13
 TGeoGlobalMagField.h:14
 TGeoGlobalMagField.h:15
 TGeoGlobalMagField.h:16
 TGeoGlobalMagField.h:17
 TGeoGlobalMagField.h:18
 TGeoGlobalMagField.h:19
 TGeoGlobalMagField.h:20
 TGeoGlobalMagField.h:21
 TGeoGlobalMagField.h:22
 TGeoGlobalMagField.h:23
 TGeoGlobalMagField.h:24
 TGeoGlobalMagField.h:25
 TGeoGlobalMagField.h:26
 TGeoGlobalMagField.h:27
 TGeoGlobalMagField.h:28
 TGeoGlobalMagField.h:29
 TGeoGlobalMagField.h:30
 TGeoGlobalMagField.h:31
 TGeoGlobalMagField.h:32
 TGeoGlobalMagField.h:33
 TGeoGlobalMagField.h:34
 TGeoGlobalMagField.h:35
 TGeoGlobalMagField.h:36
 TGeoGlobalMagField.h:37
 TGeoGlobalMagField.h:38
 TGeoGlobalMagField.h:39
 TGeoGlobalMagField.h:40
 TGeoGlobalMagField.h:41
 TGeoGlobalMagField.h:42
 TGeoGlobalMagField.h:43
 TGeoGlobalMagField.h:44
 TGeoGlobalMagField.h:45
 TGeoGlobalMagField.h:46
 TGeoGlobalMagField.h:47
 TGeoGlobalMagField.h:48
 TGeoGlobalMagField.h:49
 TGeoGlobalMagField.h:50
 TGeoGlobalMagField.h:51
 TGeoGlobalMagField.h:52
 TGeoGlobalMagField.h:53
 TGeoGlobalMagField.h:54
 TGeoGlobalMagField.h:55
 TGeoGlobalMagField.h:56
 TGeoGlobalMagField.h:57
 TGeoGlobalMagField.h:58
 TGeoGlobalMagField.h:59
 TGeoGlobalMagField.h:60
 TGeoGlobalMagField.h:61