ROOT
6.07/09
Reference Guide
ROOT Home Page
Main Page
Tutorials
User's Classes
Namespaces
All Classes
Files
Release Notes
File List
File Members
geom
geom
src
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
35
ClassImp
(
TVirtualMagField
)
36
37
////////////////////////////////////////////////////////////////////////////////
38
/// Destructor. Unregisters the field.
39
40
TVirtualMagField
::~
TVirtualMagField
()
41
{
42
if
(
TGeoGlobalMagField::GetInstance
()) {
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
56
ClassImp
(
TGeoUniformMagField
)
57
58
////////////////////////////////////////////////////////////////////////////////
59
/// Default constructor;
60
61
TGeoUniformMagField
::
TGeoUniformMagField
()
62
:
TVirtualMagField
()
63
{
64
fB[0] = 0.;
65
fB[1] = 0.;
66
fB[2] = 0.;
67
}
68
69
////////////////////////////////////////////////////////////////////////////////
70
/// Default constructor;
71
72
TGeoUniformMagField::TGeoUniformMagField
(
Double_t
Bx,
Double_t
By,
Double_t
Bz)
73
:
TVirtualMagField
(
"Uniform magnetic field"
)
74
{
75
fB
[0] = Bx;
76
fB
[1] = By;
77
fB
[2] = Bz;
78
}
TVirtualMagField.h
Fatal
void Fatal(const char *location, const char *msgfmt,...)
TGeoGlobalMagField::GetField
TVirtualMagField * GetField() const
Definition:
TGeoGlobalMagField.h:39
TGeoUniformMagField::fB
Double_t fB[3]
Definition:
TVirtualMagField.h:40
TGeoGlobalMagField::GetInstance
static TGeoGlobalMagField * GetInstance()
Static getter that does not create the object.
Definition:
TGeoGlobalMagField.cxx:106
ClassImp
#define ClassImp(name)
Definition:
Rtypes.h:279
Double_t
double Double_t
Definition:
RtypesCore.h:55
TVirtualMagField
Abstract class for magnetic field.
Definition:
TVirtualMagField.h:18
TGeoUniformMagField::TGeoUniformMagField
TGeoUniformMagField()
Default constructor;.
Definition:
TVirtualMagField.cxx:61
TGeoGlobalMagField.h
TGeoUniformMagField
Implementation for uniform magnetic field.
Definition:
TVirtualMagField.h:37