1 |
formato |
1.1 |
#ifndef PAMVMCFIELDMGR_H |
2 |
|
|
#define PAMVMCFIELDMGR_H |
3 |
|
|
#include <iostream> |
4 |
|
|
#include <RVersion.h> |
5 |
|
|
|
6 |
|
|
#include "TString.h" |
7 |
|
|
|
8 |
|
|
|
9 |
|
|
#define ZCAL 13.05 //cm |
10 |
|
|
#define CALS3 10.639 //cm |
11 |
|
|
#define ZSPEBP 2.97 //cm |
12 |
|
|
#define HORMG 22.57 //cm |
13 |
|
|
|
14 |
|
|
#define PAMFIELD 1 |
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 |
|
|
void Field(const Float_t* x, Float_t* b) { |
75 |
|
|
|
76 |
|
|
|
77 |
|
|
#ifdef PAMFIELD |
78 |
|
|
float xm[3]={x[0],x[1],x[2]-ZCAL-CALS3-ZSPEBP-HORMG}; |
79 |
|
|
|
80 |
|
|
b[0] = TrkParams::GetBX((float *)xm)*10; |
81 |
|
|
b[1] = TrkParams::GetBY((float *)xm)*10; |
82 |
|
|
b[2] = TrkParams::GetBZ((float *)xm)*10; |
83 |
|
|
|
84 |
|
|
#else |
85 |
|
|
if(x) { |
86 |
|
|
for (Int_t i=0; i<3; i++) b[i] = 0.0; |
87 |
|
|
} else { |
88 |
|
|
b[0]=b[1]=b[2]=0.0; |
89 |
|
|
} |
90 |
|
|
#endif |
91 |
|
|
|
92 |
|
|
} |
93 |
|
|
|
94 |
|
|
}; |
95 |
|
|
|
96 |
|
|
#endif |