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