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