]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliFieldMap.cxx
Conding violations fixed. The code is now included in libSTEER (Mikolaj)
[u/mrichter/AliRoot.git] / STEER / AliFieldMap.cxx
index 58a3ad6945cd48a45faffa320757d741a392f4c8..97a37b6eb954b23e273a35f3d28cc5c496faf2ee 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/*
-$Log$
-Revision 1.5  2002/10/14 14:57:32  hristov
-Merging the VirtualMC branch to the main development branch (HEAD)
-
-Revision 1.3.6.1  2002/07/24 10:08:13  alibrary
-Updating VirtualMC
-
-Revision 1.4  2002/07/10 15:06:22  morsch
-Initialize TVector* save.
-
-Revision 1.3  2002/02/26 16:13:07  morsch
-Correction in streamer.
-
-Revision 1.2  2002/02/22 14:00:20  morsch
-Protection against replication of fieldmap data in gAlice.
-
-Revision 1.1  2002/02/14 11:41:28  morsch
-Magnetic field map for ALICE for L3+muon spectrometer stored in 3 seperate
-root files.
-
-*/
+/* $Id$ */
 
+//-----------------------------------------------------------------------
 //
+// Class to handle the field
+// I/O and interpolation
+// of the field map to return the value
+// of the magnetic field in an arbitrary position
 // Author: Andreas Morsch <andreas.morsch@cern.ch>
 //
+//-----------------------------------------------------------------------
 
-#include <TVector.h>
+#include <cstdlib>
+#include <TClass.h>
+#include <TSystem.h>
+
+#include "AliLog.h"
 #include "AliFieldMap.h"
-#include "TSystem.h"
 
 ClassImp(AliFieldMap)
 
@@ -149,8 +137,8 @@ void AliFieldMap::ReadField()
   Int_t   ix, iy, iz, ipx, ipy, ipz;
   Float_t bx, by, bz;
   char *fname = 0;
-  printf("%s: Reading Magnetic Field Map %s from file %s\n",
-        ClassName(),fName.Data(),fTitle.Data());
+  AliInfo(Form("Reading Magnetic Field Map %s from file %s",
+              fName.Data(),fTitle.Data()));
 
   fname   = gSystem->ExpandPathName(fTitle.Data());
   magfile = fopen(fname,"r");
@@ -223,7 +211,7 @@ void AliFieldMap::ReadField()
 }
 
 //_______________________________________________________________________
-void AliFieldMap::Field(Float_t *x, Float_t *b)
+void AliFieldMap::Field(Float_t *x, Float_t *b) const
 {
   //
   // Use simple interpolation to obtain field at point x
@@ -235,19 +223,19 @@ void AliFieldMap::Field(Float_t *x, Float_t *b)
     b[0]=b[1]=b[2]=0;
     //
     
-    xl[0]=TMath::Abs(x[0])-fXbeg;
-    xl[1]=TMath::Abs(x[1])-fYbeg;
-    xl[2]=x[2]-fZbeg;
+    xl[0] = x[0] - fXbeg;
+    xl[1] = x[1] - fYbeg;
+    xl[2] = x[2] - fZbeg;
     
-    hix=xl[0]*fXdeli;
+    hix=TMath::Max(0.,TMath::Min(xl[0]*fXdeli,fXn-1.0001));
     ratx=hix-int(hix);
     ix=int(hix);
     
-    hiy=xl[1]*fYdeli;
+    hiy=TMath::Max(0.,TMath::Min(xl[1]*fYdeli,fYn-1.0001));
     raty=hiy-int(hiy);
     iy=int(hiy);
     
-    hiz=xl[2]*fZdeli;
+    hiz=TMath::Max(0.,TMath::Min(xl[2]*fZdeli,fZn-1.0001));
     ratz=hiz-int(hiz);
     iz=int(hiz);
 
@@ -255,6 +243,8 @@ void AliFieldMap::Field(Float_t *x, Float_t *b)
     raty1=kone-raty;
     ratz1=kone-ratz;
 
+    if (!fB) return;
+
     bhyhz = Bx(ix  ,iy+1,iz+1)*ratx1+Bx(ix+1,iy+1,iz+1)*ratx;
     bhylz = Bx(ix  ,iy+1,iz  )*ratx1+Bx(ix+1,iy+1,iz  )*ratx;
     blyhz = Bx(ix  ,iy  ,iz+1)*ratx1+Bx(ix+1,iy  ,iz+1)*ratx;
@@ -281,12 +271,12 @@ void AliFieldMap::Field(Float_t *x, Float_t *b)
 }
 
 //_______________________________________________________________________
-void AliFieldMap::Copy(AliFieldMap & /* magf */) const
+void AliFieldMap::Copy(TObject & /* magf */) const
 {
   //
   // Copy *this onto magf -- Not implemented
   //
-  Fatal("Copy","Not implemented!\n");
+  AliFatal("Not implemented!");
 }
 
 //_______________________________________________________________________