Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
17Abstract class for magnetic field. Derived classes are encouraged to
18use the TVirtualMagField named constructor and must implement the method:
19
20~~~ {.cpp}
21 Field(const Double_t *x, Double_t *B)
22~~~
23
24A field object can be made global via:
25
26~~~ {.cpp}
27 TGlobalMagField::Instance()->SetField(field) [1]
28~~~
29
30A field which is made global is owned by the field manager. The used is not
31allowed to delete it directly anymore (otherwise a Fatal() is issued). Global
32field can be deleted by calling [1] with a different argument (which can be
33NULL). 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
54Implementation 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}
double Double_t
Definition RtypesCore.h:59
#define ClassImp(name)
Definition Rtypes.h:364
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:991
Abstract class for magnetic field.
virtual ~TVirtualMagField()
Destructor. Unregisters the field.