]> git.uio.no Git - u/mrichter/AliRoot.git/blob - Flugg/WrapMag.cxx
Implementation of ITS tracking for HLT. The tracking is based on the off-line AliITSt...
[u/mrichter/AliRoot.git] / Flugg / WrapMag.cxx
1
2 // Flugg tag 
3
4 ///////////////////////////////////////////////////////////////////
5 //
6 // WrapMag.hh - Sara Vanini
7 //
8 // Wrapper for geometry tracking in magnetic field: returns magnetic 
9 // field values in a given position.
10 //
11 // modified 26/X/1998
12 // modified 18/XI/1999
13 // modified 24.10.01: by I. Hrivnacova
14 //   functions declarations separated from implementation
15 //   (moved to Wrappers.hh);
16 //
17 /////////////////////////////////////////////////////////////////
18
19
20 #include "Wrappers.hh"
21 #include "FGeometryInit.hh"
22 #include "globals.hh"
23
24 void magfld(const G4double& pX, const G4double& pY, const G4double& pZ,
25             G4double& cosBx, G4double& cosBy, G4double& cosBz, 
26             G4double& Bmag, G4int& reg, G4int& idiscflag)
27
28 {
29   //flag
30 #ifdef G4GEOMETRY_DEBUG
31   G4cout<<"================== MAGFLD ================="<<G4endl;
32 #endif 
33   
34   //Geoinit Pointer
35   FGeometryInit * ptrGeoInit=FGeometryInit::GetInstance();
36   
37   //get FieldManager, Field pointers for magnetic field handling
38   G4FieldManager * pFieldMgr = ptrGeoInit->getFieldManager();
39   const G4Field * ptrField = pFieldMgr->GetDetectorField();
40   
41   //compute field
42   G4double point[3];
43   point[0] = pX*10.;
44   point[1] = pY*10.;
45   point[2] = pZ*10.;
46   G4double B[3];
47   ptrField->GetFieldValue(point,B);
48   G4double Bnor = sqrt(sqr(B[0])+sqr(B[1])+sqr(B[2]));
49   if(Bnor) {
50     cosBx = B[0]/Bnor;
51     cosBy = B[1]/Bnor;
52     cosBz = B[2]/Bnor;
53   }
54   else {
55     cosBx = 0;
56     cosBy = 0;
57     cosBz = 1;
58   }
59   
60   Bmag = Bnor/tesla;
61   idiscflag = 0;
62 }
63
64
65
66