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