]>
Commit | Line | Data |
---|---|---|
8fd1d27e | 1 | #include "TVirtualMCApplication.h" |
4ba5ffc7 | 2 | #include "Fdblprc.h" //(DBLPRC) fluka common |
3 | // | |
4 | // #include "TCallf77.h" | |
5 | ||
6 | #ifndef WIN32 | |
7 | #define magfld magfld_ | |
8 | #define type_of_call | |
9 | #else | |
10 | #define magfld MAGFLD | |
11 | #define type_of_call _stdcall | |
12 | #endif | |
13 | ||
14 | extern "C" void type_of_call magfld(double& x, double& y, double& z, | |
15 | double& btx, double& bty, double& btz, double& b, | |
a7bb59a2 | 16 | int& /*nreg*/,int& idisc) |
4ba5ffc7 | 17 | { |
18 | ||
19 | /* | |
20 | *----------------------------------------------------------------------* | |
21 | * * | |
22 | * * | |
23 | * Input variables: * | |
24 | * x,y,z = current position * | |
25 | * nreg = current region * | |
26 | * Output variables: * | |
27 | * btx,bty,btz = cosines of the magn. field vector * | |
28 | * B = magnetic field intensity (Tesla) * | |
29 | * idisc = set to 1 if the particle has to be discarded * | |
30 | * * | |
31 | *----------------------------------------------------------------------* | |
32 | */ | |
4ba5ffc7 | 33 | |
34 | idisc = 0; | |
35 | ||
8fd1d27e | 36 | Double_t bc[3]; |
37 | Double_t xc[3]; | |
4ba5ffc7 | 38 | |
b36901ee | 39 | xc[0] = x; |
40 | xc[1] = y; | |
4ba5ffc7 | 41 | xc[2] = z; |
42 | ||
43 | ||
44 | ||
8fd1d27e | 45 | (TVirtualMCApplication::Instance())->Field(xc, bc); |
4ba5ffc7 | 46 | |
47 | b = sqrt(bc[0] * bc[0] + bc[1] * bc[1] + bc[2] * bc[2]); | |
48 | if (b) { | |
a8e80ce5 | 49 | btx = bc[0]/b; |
50 | bty = bc[1]/b; | |
4ba5ffc7 | 51 | Double_t btt = btx * btx + bty * bty; |
52 | if (btt >= (Double_t) 1.) { | |
53 | btx /= TMath::Sqrt(btt); | |
54 | bty /= TMath::Sqrt(btt); | |
55 | b /= TMath::Sqrt(btt); | |
56 | btz = (Double_t) 0.; | |
57 | } else { | |
a8e80ce5 | 58 | btz = TMath::Sign(TMath::Sqrt((Double_t) 1. - btt), bc[2]); |
4ba5ffc7 | 59 | } |
60 | } else { | |
61 | btx = 0.; | |
62 | bty = 0.; | |
63 | btz = 1.; | |
64 | } | |
65 | ||
66 | // from kG to T | |
67 | b /= (Double_t) 10.; | |
4ba5ffc7 | 68 | } |