00001 // @(#)root/geom:$Id: TGeoGlobalMagField.h 27191 2009-01-20 08:09:20Z brun $ 00002 00003 /************************************************************************* 00004 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. * 00005 * All rights reserved. * 00006 * * 00007 * For the licensing terms see $ROOTSYS/LICENSE. * 00008 * For the list of contributors see $ROOTSYS/README/CREDITS. * 00009 *************************************************************************/ 00010 00011 #ifndef ROOT_TGeoGlobalMagField 00012 #define ROOT_TGeoGlobalMagField 00013 00014 #ifndef ROOT_TObject 00015 #include "TObject.h" 00016 #endif 00017 00018 #ifndef ROOT_TVirtualMagField 00019 #include "TVirtualMagField.h" 00020 #endif 00021 00022 //////////////////////////////////////////////////////////////////////////// 00023 // // 00024 // TGeoGlobalMagField - Global magnetic field manager. A field derived // 00025 // from TVirtualMagField becomes global if registered via SetField // 00026 // method. 00027 // // 00028 //////////////////////////////////////////////////////////////////////////// 00029 00030 class TGeoGlobalMagField : public TObject 00031 { 00032 private: 00033 static TGeoGlobalMagField *fgInstance; // Static pointer to the field manager; 00034 TVirtualMagField *fField; // Magnetic field 00035 Bool_t fLock; // Lock flag for global field. 00036 00037 protected: 00038 TGeoGlobalMagField(const TGeoGlobalMagField&); 00039 TGeoGlobalMagField& operator=(const TGeoGlobalMagField&); 00040 void Unlock() {fLock = kFALSE;} 00041 00042 public: 00043 TGeoGlobalMagField(); 00044 virtual ~TGeoGlobalMagField(); 00045 00046 // Using SetField() makes a given field global. The field manager owns it from now on. 00047 TVirtualMagField *GetField() const {return fField;} 00048 void SetField(TVirtualMagField *field); 00049 Bool_t IsLocked() {return fLock;} 00050 void Lock(); 00051 00052 // The field manager should be accessed via TGeoGlobalMagField::Instance() 00053 static TGeoGlobalMagField *Instance(); 00054 00055 // Inline access to Field() method 00056 void Field(const Double_t *x, Double_t *B) {if (fField) fField->Field(x,B);} 00057 00058 ClassDef(TGeoGlobalMagField, 0) // Global field manager 00059 }; 00060 00061 #endif