FairShip
Loading...
Searching...
No Matches
FairShipFields.cxx
Go to the documentation of this file.
1
// SPDX-License-Identifier: LGPL-3.0-or-later
2
// SPDX-FileCopyrightText: Copyright CERN for the benefit of the SHiP
3
// Collaboration
4
5
/*
6
generic interface to B fields of FairShip
7
assumes that magnetic fields for tracking are global fields, not matched to a
8
volume.
9
*/
10
#include "
FairShipFields.h
"
11
12
#include <iostream>
13
14
#include "TVirtualMC.h"
15
using
std::cout;
16
using
std::endl;
17
18
namespace
genfit
{
19
20
FairShipFields::FairShipFields
() : AbsBField() { ; }
21
22
TVector3
FairShipFields::get
(
const
TVector3& pos)
const
{
23
Double_t bx, by, bz;
24
get
(pos.X(), pos.Y(), pos.Z(), bx, by, bz);
25
TVector3 field_(bx, by, bz);
26
return
field_;
27
}
28
29
void
FairShipFields::get
(
const
double
& x,
const
double
& y,
const
double
& z,
30
double
& Bx,
double
& By,
double
& Bz)
const
{
31
Double_t X[3] = {x, y, z};
32
Double_t B[3] = {0., 0., 0.};
33
Bx = 0.;
34
By = 0.;
35
Bz = 0.;
36
if
(!gMC && !
gField_
) {
37
cout <<
"no Field Manager instantiated"
<< endl;
38
return
;
39
}
40
if
(gMC) {
41
TVirtualMagField* magField = gMC->GetMagField();
42
if
(!magField) {
43
cout <<
"no magnetic field set in the Virtual MC"
<< endl;
44
return
;
45
}
46
magField->Field(X, B);
47
}
else
{
48
gField_
->Field(X, B);
49
}
50
Bx = B[0];
51
By = B[1];
52
Bz = B[2];
53
}
54
55
}
/* End of namespace genfit */
FairShipFields.h
genfit::FairShipFields::FairShipFields
FairShipFields()
Definition
FairShipFields.cxx:20
genfit::FairShipFields::gField_
ShipCompField * gField_
Definition
FairShipFields.h:35
genfit::FairShipFields::get
TVector3 get(const TVector3 &pos) const override
return value at position
Definition
FairShipFields.cxx:22
genfit
Definition
FairShipFields.cxx:18
field
FairShipFields.cxx
Generated by
Doxygen
1.15.0