ROOT
git-r3/HEAD
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
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
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
57
////////////////////////////////////////////////////////////////////////////////
58
/// Default constructor;
59
60
TGeoUniformMagField::TGeoUniformMagField
() :
TVirtualMagField
()
61
{
62
fB
[0] = 0.;
63
fB
[1] = 0.;
64
fB
[2] = 0.;
65
}
66
67
////////////////////////////////////////////////////////////////////////////////
68
/// Default constructor;
69
70
TGeoUniformMagField::TGeoUniformMagField
(
Double_t
Bx,
Double_t
By,
Double_t
Bz)
71
:
TVirtualMagField
(
"Uniform magnetic field"
)
72
{
73
fB
[0] = Bx;
74
fB
[1] = By;
75
fB
[2] = Bz;
76
}
Double_t
double Double_t
Double 8 bytes.
Definition
RtypesCore.h:73
TGeoGlobalMagField.h
TVirtualMagField.h
TGeoGlobalMagField::GetField
TVirtualMagField * GetField() const
Definition
TGeoGlobalMagField.h:34
TGeoGlobalMagField::GetInstance
static TGeoGlobalMagField * GetInstance()
Static getter that does not create the object.
Definition
TGeoGlobalMagField.cxx:109
TGeoUniformMagField::TGeoUniformMagField
TGeoUniformMagField()
Default constructor;.
Definition
TVirtualMagField.cxx:60
TGeoUniformMagField::fB
Double_t fB[3]
Definition
TVirtualMagField.h:35
TObject::Fatal
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
Definition
TObject.cxx:1126
TVirtualMagField::TVirtualMagField
TVirtualMagField()
Definition
TVirtualMagField.h:18
TVirtualMagField::~TVirtualMagField
~TVirtualMagField() override
Destructor. Unregisters the field.
Definition
TVirtualMagField.cxx:40
geom
geom
src
TVirtualMagField.cxx
ROOTgit-r3/HEAD - Reference Guide Generated on
(GVA Time) using Doxygen 1.16.1