ROOT
6.06/09
Reference Guide
ROOT Home Page
Main Page
Related Pages
User's Classes
Namespaces
All Classes
Files
Release Notes
File List
File Members
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Modules
Pages
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
//______________________________________________________________________________
15
// TVirtualMagField - ABC for magnetic field. Derived classes are encouraged to
16
// use the TVirtualMagField named constructor and must implement the method:
17
// Field(const Double_t *x, Double_t *B)
18
//
19
// A field object can be made global via:
20
// TGlobalMagField::Instance()->SetField(field) [1]
21
// A field which is made global is owned by the field manager. The used is not
22
// allowed to delete it directly anymore (otherwise a Fatal() is issued). Global
23
// field can be deleted by calling [1] with a different argument (which can be
24
// NULL). Otherwise the global field is deleted together with the field manager.
25
//
26
//______________________________________________________________________________
27
28
ClassImp
(
TVirtualMagField
)
29
30
////////////////////////////////////////////////////////////////////////////////
31
/// Destructor. Unregisters the field.
32
33
TVirtualMagField
::~
TVirtualMagField
()
34
{
35
if
(
TGeoGlobalMagField::GetInstance
()) {
36
TVirtualMagField *global_field =
TGeoGlobalMagField::GetInstance
()->
GetField
();
37
if
(global_field ==
this
)
38
Fatal
(
"~TVirtualMagField"
,
"Not allowed to delete a field once set global. \
39
\n To delete the field call: TGeoGlobalMagField::Instance()->SetField(NULL)"
);
40
}
41
}
42
43
//______________________________________________________________________________
44
// TGeoUniformMagField - Implementation for uniform magnetic field.
45
//______________________________________________________________________________
46
47
ClassImp
(
TGeoUniformMagField
)
48
49
////////////////////////////////////////////////////////////////////////////////
50
/// Default constructor;
51
52
TGeoUniformMagField
::
TGeoUniformMagField
()
53
:
TVirtualMagField
()
54
{
55
fB[0] = 0.;
56
fB[1] = 0.;
57
fB[2] = 0.;
58
}
59
60
////////////////////////////////////////////////////////////////////////////////
61
/// Default constructor;
62
63
TGeoUniformMagField::TGeoUniformMagField
(
Double_t
Bx,
Double_t
By,
Double_t
Bz)
64
:
TVirtualMagField
(
"Uniform magnetic field"
)
65
{
66
fB
[0] = Bx;
67
fB
[1] = By;
68
fB
[2] = Bz;
69
}
TVirtualMagField.h
Fatal
void Fatal(const char *location, const char *msgfmt,...)
TGeoGlobalMagField::GetField
TVirtualMagField * GetField() const
Definition:
TGeoGlobalMagField.h:47
ClassImp
ClassImp(TVirtualMagField) TVirtualMagField
Destructor. Unregisters the field.
Definition:
TVirtualMagField.cxx:28
TGeoUniformMagField::fB
Double_t fB[3]
Definition:
TVirtualMagField.h:47
TGeoGlobalMagField::GetInstance
static TGeoGlobalMagField * GetInstance()
Static getter that does not create the object.
Definition:
TGeoGlobalMagField.cxx:95
Double_t
double Double_t
Definition:
RtypesCore.h:55
TVirtualMagField
Definition:
TVirtualMagField.h:25
TGeoUniformMagField::TGeoUniformMagField
TGeoUniformMagField()
TGeoGlobalMagField.h
TGeoUniformMagField
Definition:
TVirtualMagField.h:44