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
36
37////////////////////////////////////////////////////////////////////////////////
38/// Destructor. Unregisters the field.
39
41{
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
53Implementation for uniform magnetic field.
54*/
55
56
57////////////////////////////////////////////////////////////////////////////////
58/// Default constructor;
59
61{
62 fB[0] = 0.;
63 fB[1] = 0.;
64 fB[2] = 0.;
65}
66
67////////////////////////////////////////////////////////////////////////////////
68/// Default constructor;
69
71 : TVirtualMagField("Uniform magnetic field")
72{
73 fB[0] = Bx;
74 fB[1] = By;
75 fB[2] = Bz;
76}
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
static TGeoGlobalMagField * GetInstance()
Static getter that does not create the object.
TGeoUniformMagField()
Default constructor;.
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
Definition TObject.cxx:1099
Abstract class for magnetic field.
~TVirtualMagField() override
Destructor. Unregisters the field.