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