EIC Software
Reference for
EIC
simulation and reconstruction software on GitHub
Home page
Related Pages
Modules
Namespaces
Classes
Files
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
EicMagneticFieldGrad.cxx
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file EicMagneticFieldGrad.cxx
1
//
2
// RMP (rpetti@bnl.gov), 2016/03/02
3
//
4
// EIC magnetic field gradients;
5
//
6
7
#include <assert.h>
8
#include <stdlib.h>
9
#include <fcntl.h>
10
#include <sys/stat.h>
11
#include <sys/mman.h>
12
13
#include <
FairLogger.h
>
14
15
#include <
EicLibrary.h
>
16
#include <
EicMagneticFieldGrad.h
>
17
18
// =======================================================================================
19
20
// constructor
21
EicMagneticFieldGrad::EicMagneticFieldGrad
(
const
char
*fileName, TGeoMatrix *transformation,
22
TGeoShape *shape,
int
color
):
23
mTransformation(transformation), mColor(color), mInitialized(
false
)
24
{
25
if
(fileName) {
26
mFileName
= TString(fileName);
27
28
29
}
//if
30
else
{
31
FairLogger::GetLogger
()->
Fatal
(
MESSAGE_ORIGIN
,
"\033[5m\033[31m Failed to open '%s' field! \033[0m"
,
32
fileName);
33
}
34
35
// NB: here and in other similar places have to call Clone() method and cast
36
// TObject* to TGeoShape* dynamically because this way a default constructor
37
// is called and the TGeoShape* pointer is not bound to the current TGeoManager;
38
// any attempt to simplify things to 'mShape = new TGeoBBox(...)' cause segfault
39
// in the main simulation code because TGeoManager stuff gets ~reloaded and
40
// (as far as I understand) pointers get "orphan" (so that data members are
41
// available and one can use something like (new TGeoShape(mShape))->Contains()
42
// call, but not mShape->Contains() directly);
43
mShape
= shape ?
dynamic_cast<
TGeoShape*
>
(shape->Clone()) : 0;
44
}
// EicMagneticFieldGrad::EicMagneticFieldGrad()
45
46
// ---------------------------------------------------------------------------------------
47
48
int
EicMagneticFieldGrad::Initialize
()
49
{
50
51
mInitialized
=
true
;
52
53
return
0;
54
}
// EicMagneticFieldGrad::Initialize()
55
56
// ---------------------------------------------------------------------------------------
57
58
59
bool
EicMagneticFieldGrad::Contains
(
const
double
xx[])
const
60
{
61
// If the shape is not given, can not say anything -> return false; NB: it is
62
// assumed, that in a mixed environment (some maps have shapes, some not) voxel
63
// builder should make GetShape() call first (and if there is no shape returned,
64
// such a map is considered "global", ie will be queried basically for every xx[]);
65
if
(!
mShape
)
return
false
;
66
67
double
local[3];
68
69
// Move into the shape local coordinate system; if transformation is not given,
70
// assume map coordinate system matches the world one;
71
if
(
mTransformation
)
72
mTransformation
->MasterToLocal(xx, local);
73
else
74
memcpy(local, xx,
sizeof
(local));
75
76
// And then use ROOT library call for the bounding shape;
77
return
mShape
->Contains(local);
78
}
// EicMagneticFieldGrad::Contains()
EicRoot
blob
master
eic
field
EicMagneticFieldGrad.cxx
Built by
Jin Huang
. updated:
Mon Jan 22 2024 12:43:35
using
1.8.2 with
EIC GitHub integration