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
FieldMapReadBack.cc
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file FieldMapReadBack.cc
1
2
#include "
FieldMapReadBack.h
"
3
4
#include <phfield/PHField.h>
5
#include <phfield/PHField3DCartesian.h>
6
#include <phfield/PHFieldUtility.h>
7
8
#include <
fun4all/Fun4AllReturnCodes.h
>
9
10
#include <
phool/PHCompositeNode.h
>
11
12
#include <Geant4/G4SystemOfUnits.hh>
13
14
#include <iostream>
15
16
//____________________________________________________________________________..
17
int
FieldMapReadBack::InitRun
(
PHCompositeNode
*topNode)
18
{
19
fieldmap
=
PHFieldUtility::GetFieldMapNode
(
nullptr
, topNode);
20
if
(
fieldmap
)
21
{
22
std::cout <<
"Found or created fieldmap"
<< std::endl;
23
}
24
else
25
{
26
std::cout <<
"Fieldmap not found or created"
<< std::endl;
27
}
28
return
Fun4AllReturnCodes::EVENT_OK
;
29
}
30
31
//____________________________________________________________________________..
32
int
FieldMapReadBack::process_event
(
PHCompositeNode
*topNode)
33
{
34
double
bfield[3];
35
// the output needs to be converted into the unit you want - here it is tesla
36
fieldmap
->
GetFieldValue
(
Point
, bfield);
37
std::cout <<
"bx: "
<< bfield[0] / tesla
38
<<
" by: "
<< bfield[1] / tesla
39
<<
" bz: "
<< bfield[2] / tesla
40
<< std::endl;
41
return
Fun4AllReturnCodes::EVENT_OK
;
42
}
43
44
void
FieldMapReadBack::Load3dCartMap
(
const
std::string &fname,
const
float
magfield_rescale
)
45
{
46
fieldmap
=
new
PHField3DCartesian
(fname, magfield_rescale);
47
}
48
49
void
FieldMapReadBack::PrintField
(
const
double
x
,
const
double
y
,
const
double
z
,
const
double
t
)
50
{
51
SetFieldPoint
(x, y, z, t);
52
53
double
Bf[3];
54
fieldmap
->
GetFieldValue
(
Point
, Bf);
55
std::cout <<
"Point: "
<< x /
cm
<<
"/"
<< y /
cm
<<
"/"
<< z /
cm
<< std::endl;
56
std::cout <<
"BField: "
<< Bf[0] / tesla <<
"/"
<< Bf[1] / tesla <<
"/"
<< Bf[2] / tesla << std::endl;
57
return
;
58
}
59
60
void
FieldMapReadBack::SetFieldPoint
(
const
double
x
,
const
double
y
,
const
double
z
,
const
double
t
)
61
{
62
Point
[0] = x *
cm
;
63
Point
[1] = y *
cm
;
64
Point
[2] = z *
cm
;
65
Point
[3] = t *
s
;
66
}
67
68
void
FieldMapReadBack::Verbosity
(
const
int
i)
69
{
70
if
(
fieldmap
)
71
{
72
fieldmap
->
Verbosity
(i);
73
}
74
Fun4AllBase::Verbosity
(i);
75
return
;
76
}
fun4all_tutorials
blob
master
MagneticField
src
FieldMapReadBack.cc
Built by
Jin Huang
. updated:
Mon Jan 22 2024 12:43:54
using
1.8.2 with
EIC GitHub integration