SND@LHC Software
Loading...
Searching...
No Matches
FairShipFields.cc
Go to the documentation of this file.
1/*
2generic interface to B fields of FairShip
3assumes that magnetic fields for tracking are global fields, not matched to a volume.
4*/
5#include "FairShipFields.h"
6#include "TVirtualMC.h"
7#include <iostream>
8using std::cout;
9using std::endl;
10
11namespace genfit {
12
16
17
18TVector3 FairShipFields::get(const TVector3& pos) const {
19 Double_t bx,by,bz;
20 get(pos.X(),pos.Y(),pos.Z(),bx,by,bz);
21 TVector3 field_(bx,by,bz);
22 return field_;
23}
24
25void FairShipFields::get(const double& x, const double& y, const double& z, double& Bx, double& By, double& Bz) const {
26 Double_t X[3] = {x,y,z};
27 Double_t B[3] = {Bx,By,Bz};
28 if (!gMC && !gField_){
29 cout<<"no Field Manager instantiated"<<endl;
30 return;
31 }
32 if (gMC){
33 gMC->GetMagField()->Field(X,B);
34 } else {
35 gField_->Field(X,B);
36 }
37 Bx = B[0];
38 By = B[1];
39 Bz = B[2];
40}
41
42} /* End of namespace genfit */
virtual void Field(const Double_t *position, Double_t *B)
The total magnetic field from all of the composite sources (linear superposition)
Abstract Interface to magnetic fields in GENFIT.
Definition AbsBField.h:36
TVector3 get(const TVector3 &pos) const
return value at position
ShipCompField * gField_
Matrix inversion tools.
Definition AbsBField.h:29