Logo ROOT   6.08/07
Reference Guide
TVirtualMagField.cxx
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 #include "TGeoGlobalMagField.h"
12 #include "TVirtualMagField.h"
13 
14 /** \class TVirtualMagField
15 \ingroup Geometry_classes
16 Abstract class for magnetic field. Derived classes are encouraged to
17 use the TVirtualMagField named constructor and must implement the method:
18 
19 ~~~ {.cpp}
20  Field(const Double_t *x, Double_t *B)
21 ~~~
22 
23 A field object can be made global via:
24 
25 ~~~ {.cpp}
26  TGlobalMagField::Instance()->SetField(field) [1]
27 ~~~
28 
29 A field which is made global is owned by the field manager. The used is not
30 allowed to delete it directly anymore (otherwise a Fatal() is issued). Global
31 field can be deleted by calling [1] with a different argument (which can be
32 NULL). Otherwise the global field is deleted together with the field manager.
33 */
34 
36 
37 ////////////////////////////////////////////////////////////////////////////////
38 /// Destructor. Unregisters the field.
39 
41 {
43  TVirtualMagField *global_field = TGeoGlobalMagField::GetInstance()->GetField();
44  if (global_field == this)
45  Fatal("~TVirtualMagField", "Not allowed to delete a field once set global. \
46  \n To delete the field call: TGeoGlobalMagField::Instance()->SetField(NULL)");
47  }
48 }
49 
50 /** \class TGeoUniformMagField
51 \ingroup Geometry_classes
52 
53 Implementation for uniform magnetic field.
54 */
55 
57 
58 ////////////////////////////////////////////////////////////////////////////////
59 /// Default constructor;
60 
63 {
64  fB[0] = 0.;
65  fB[1] = 0.;
66  fB[2] = 0.;
67 }
68 
69 ////////////////////////////////////////////////////////////////////////////////
70 /// Default constructor;
71 
73  :TVirtualMagField("Uniform magnetic field")
74 {
75  fB[0] = Bx;
76  fB[1] = By;
77  fB[2] = Bz;
78 }
void Fatal(const char *location, const char *msgfmt,...)
TVirtualMagField * GetField() const
static TGeoGlobalMagField * GetInstance()
Static getter that does not create the object.
#define ClassImp(name)
Definition: Rtypes.h:279
double Double_t
Definition: RtypesCore.h:55
Abstract class for magnetic field.
TGeoUniformMagField()
Default constructor;.
Implementation for uniform magnetic field.