| 1 |
#ifndef PAMVMCFIELDMGR_H |
| 2 |
#define PAMVMCFIELDMGR_H |
| 3 |
#include <iostream> |
| 4 |
#include <RVersion.h> |
| 5 |
|
| 6 |
#include "TString.h" |
| 7 |
|
| 8 |
#define PAMFIELD 1 |
| 9 |
|
| 10 |
|
| 11 |
#define ZCAL 13.05 //cm |
| 12 |
#define CALS3 10.639 //cm |
| 13 |
#define ZSPEBP 2.97 //cm |
| 14 |
#define HORMG 22.57 //cm |
| 15 |
|
| 16 |
#ifdef PAMFIELD |
| 17 |
#include "TrkParams.h" |
| 18 |
#endif |
| 19 |
|
| 20 |
|
| 21 |
#if ROOT_VERSION_CODE >= 333572 |
| 22 |
#include <TVirtualMagField.h> |
| 23 |
class PamVMCFieldMgr: public TVirtualMagField |
| 24 |
#else |
| 25 |
class PamVMCFieldMgr: public TObject |
| 26 |
#endif |
| 27 |
{ |
| 28 |
private: |
| 29 |
|
| 30 |
static PamVMCFieldMgr * fm; |
| 31 |
|
| 32 |
protected: |
| 33 |
PamVMCFieldMgr() {}; |
| 34 |
|
| 35 |
public: |
| 36 |
|
| 37 |
static PamVMCFieldMgr * Instance(); |
| 38 |
|
| 39 |
|
| 40 |
void LoadField(){ |
| 41 |
#ifdef PAMFIELD |
| 42 |
// Load the PAMELA magnetic field |
| 43 |
|
| 44 |
std::string pamcal=getenv("PAM_CALIB"); pamcal+="/trk-param/field_param-0/"; |
| 45 |
std::cout << "PAMELA env: " << pamcal << std::endl; |
| 46 |
TrkParams::SetTrackingMode(); |
| 47 |
TrkParams::SetPrecisionFactor(); |
| 48 |
TrkParams::SetStepMin(); |
| 49 |
TrkParams::Set(pamcal.c_str(),1); |
| 50 |
TrkParams::Load(1); |
| 51 |
#endif |
| 52 |
} |
| 53 |
|
| 54 |
|
| 55 |
void Field(const Double_t* x, Double_t* B) { |
| 56 |
|
| 57 |
#ifdef PAMFIELD |
| 58 |
float xm[3]={x[0],x[1],x[2]-ZCAL-CALS3-ZSPEBP-HORMG}; |
| 59 |
|
| 60 |
B[0] = TrkParams::GetBX((float *)xm)*10; |
| 61 |
B[1] = TrkParams::GetBY((float *)xm)*10; |
| 62 |
B[2] = TrkParams::GetBZ((float *)xm)*10; |
| 63 |
|
| 64 |
#else |
| 65 |
if(x) { |
| 66 |
for (Int_t i=0; i<3; i++) B[i] = 0.0; |
| 67 |
} else { |
| 68 |
B[0]=B[1]=B[2]=0.0; |
| 69 |
} |
| 70 |
#endif |
| 71 |
|
| 72 |
} |
| 73 |
|
| 74 |
|
| 75 |
void Field(const Float_t* x, Float_t* b) { |
| 76 |
|
| 77 |
|
| 78 |
#ifdef PAMFIELD |
| 79 |
float xm[3]={x[0],x[1],x[2]-ZCAL-CALS3-ZSPEBP-HORMG}; |
| 80 |
|
| 81 |
b[0] = TrkParams::GetBX((float *)xm)*10; |
| 82 |
b[1] = TrkParams::GetBY((float *)xm)*10; |
| 83 |
b[2] = TrkParams::GetBZ((float *)xm)*10; |
| 84 |
|
| 85 |
#else |
| 86 |
if(x) { |
| 87 |
for (Int_t i=0; i<3; i++) b[i] = 0.0; |
| 88 |
} else { |
| 89 |
b[0]=b[1]=b[2]=0.0; |
| 90 |
} |
| 91 |
#endif |
| 92 |
|
| 93 |
} |
| 94 |
|
| 95 |
}; |
| 96 |
|
| 97 |
#endif |