Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "GenfitField.h"
#include "GenfitMsg.h"
//External
#include "DD4hep/DD4hepUnits.h"
//genfit
#include "FieldManager.h"
#include "ConstField.h"
///-------------------------------------------------------------
/// GenfitField constructor
///-------------------------------------------------------------
GenfitField::GenfitField(dd4hep::OverlayedField dd4hepField)
:m_dd4hepField(dd4hepField)
{
genfit::FieldManager::getInstance()->init(this);
}
///-------------------------------------------------------------
/// GenfitField get field value by TVector3
///-------------------------------------------------------------
/// unit in genfit is cm and kGauss
TVector3 GenfitField::get(const TVector3& pos) const
{
double B[3]={1e9,1e9,1e9};
get(pos.X(),pos.Y(),pos.Z(),B[0],B[1],B[2]);
return TVector3(B[0],B[1],B[2]);
}
///-------------------------------------------------------------
/// GenfitField get field value by double
///-------------------------------------------------------------
/// unit in genfit for position is cm and Bxyz is kGauss
/// unit in DD4hepUnits kilogaus and cm? FIXME
void
GenfitField::get(const double& posX, const double& posY, const double& posZ,
double& Bx, double& By, double& Bz) const
{
/// get field from dd4hepField
const dd4hep::Direction& field=m_dd4hepField.magneticField(
dd4hep::Position(posX/dd4hep::cm,posY/dd4hep::cm,posZ/dd4hep::cm));
//m_dd4hepField.magneticField(pos,B);
Bx=field.X()/dd4hep::kilogauss;
By=field.Y()/dd4hep::kilogauss;
Bz=field.Z()/dd4hep::kilogauss;
// std::cout<<"GenfitField "
// <<Form("xyz(%f,%f,%f)cm B(%f,%f,%f)kilogauss",posX,posY,posZ,Bx,By,Bz)
// <<std::endl;
}
double GenfitField::getBz(const TVector3& pos) const
{
return get(pos).Z();
}