24 #ifndef genfit_FieldManager_h
25 #define genfit_FieldManager_h
27 #include "AbsBField.h"
42 double posX;
double posY;
double posZ;
43 double Bx;
double By;
double Bz;
65 return field_->
get(position);
69 void getFieldVal(
const double& posX,
const double& posY,
const double& posZ,
double& Bx,
double& By,
double& Bz);
71 inline void getFieldVal(
const double& posX,
const double& posY,
const double& posZ,
double& Bx,
double& By,
double& Bz) {
73 return field_->
get(posX, posY, posZ, Bx, By, Bz);
83 if (instance_ !=
nullptr) {
89 bool isInitialized() {
return field_ !=
nullptr; }
91 void checkInitialized() {
92 if(! isInitialized()){
93 errorOut <<
"FieldManager hasn't been initialized with a correct AbsBField pointer!" << std::endl;
94 std::string msg(
"FieldManager hasn't been initialized with a correct AbsBField pointer!");
95 std::runtime_error err(msg);
100 static void checkInstanciated() {
101 if(instance_==
nullptr){
102 errorOut <<
"FieldManager hasn't been instantiated yet, call getInstance() and init() before getFieldVal()!" << std::endl;
103 std::string msg(
"FieldManager hasn't been instantiated yet, call getInstance() and init() before getFieldVal()!");
104 std::runtime_error err(msg);
111 void useCache(
bool opt =
true,
unsigned int nBuckets = 8);
113 void useCache(
bool opt =
true,
unsigned int nBuckets = 8) {
114 std::cerr <<
"genfit::FieldManager::useCache() - FieldManager is compiled w/o CACHE, no caching will be done!" << std::endl;
120 if(instance_ ==
nullptr) {
131 ~FieldManager() {
delete cache_; }
135 static FieldManager* instance_;
136 static AbsBField* field_;
139 static bool useCache_;
140 static unsigned int n_buckets_;
141 static fieldCache* cache_;
Abstract Interface to magnetic fields in GENFIT.
virtual TVector3 get(const TVector3 &position) const =0
Get the magneticField [kGauss] at position.
Singleton which provides access to magnetic field maps.
void useCache(bool opt=true, unsigned int nBuckets=8)
Cache last lookup positions, and use stored field values if a lookup at (almost) the same position is...
TVector3 getFieldVal(const TVector3 &position)
This does NOT use the cache!
static FieldManager * getInstance()
Get singleton instance.
void init(AbsBField *b)
set the magnetic field here. Magnetic field classes must be derived from AbsBField.
Defines for I/O streams used for error and debug printing.
std::ostream errorOut
Default stream for error output.
Cache B field at a position.