Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
19private:
20 static TGeoGlobalMagField *fgInstance; // Static pointer to the field manager;
21 TVirtualMagField *fField{nullptr}; // Magnetic field
22 Bool_t fLock{kFALSE}; // Lock flag for global field.
23
24protected:
27 void Unlock() { fLock = kFALSE; }
28
29public:
31 ~TGeoGlobalMagField() override;
32
33 // Using SetField() makes a given field global. The field manager owns it from now on.
34 TVirtualMagField *GetField() const { return fField; }
35 void SetField(TVirtualMagField *field);
36 Bool_t IsLocked() { return fLock; }
37 void Lock();
38
39 // The field manager should be accessed via TGeoGlobalMagField::Instance()
42
43 // Inline access to Field() method
44 void Field(const Double_t *x, Double_t *B)
45 {
46 if (fField)
47 fField->Field(x, B);
48 }
49
50 ClassDefOverride(TGeoGlobalMagField, 0) // Global field manager
51};
52
53#endif
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
Global magnetic field manager.
TGeoGlobalMagField(const TGeoGlobalMagField &)=delete
TVirtualMagField * fField
void SetField(TVirtualMagField *field)
Field setter. Deletes previous field if any. Acts only if fLock=kFALSE.
void Field(const Double_t *x, Double_t *B)
TGeoGlobalMagField & operator=(const TGeoGlobalMagField &)=delete
TVirtualMagField * GetField() const
TGeoGlobalMagField()
Global field default constructor.
void Lock()
Locks the global magnetic field if this is set. Cannot be unlocked.
~TGeoGlobalMagField() override
Global field destructor.
static TGeoGlobalMagField * fgInstance
static TGeoGlobalMagField * Instance()
Returns always a valid static pointer to the field manager.
static TGeoGlobalMagField * GetInstance()
Static getter that does not create the object.
Mother of all ROOT objects.
Definition TObject.h:41
Abstract class for magnetic field.
virtual void Field(const Double_t *x, Double_t *B)=0
Double_t x[n]
Definition legend1.C:17