]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliFieldMap.h
Stricter check of map boundary. Caused index out of range before.
[u/mrichter/AliRoot.git] / STEER / AliFieldMap.h
index 757c6ac7d3e0cfef3daf88c1aef0555f7fd4eec2..ee3e6fea02057f62569f0fc752224de6cf81e872 100644 (file)
@@ -6,8 +6,11 @@
 /* $Id$ */
 
 //
+// Class to handle the field map of ALICE
+// I/O and interpolation
 // Author: Andreas Morsch <andreas.morsch@cern.ch>
 //
+
 #include <TNamed.h>
 #include <TVector.h>
 
@@ -20,67 +23,70 @@ public:
     AliFieldMap(const char *name, const char *title);
     AliFieldMap(const AliFieldMap &mag);
     virtual ~AliFieldMap();
-    void Copy(AliFieldMap &map) const;
+    void Copy(TObject &map) const;
     virtual AliFieldMap & operator=(const AliFieldMap &map);
 
-    virtual void Field(Float_t *x, Float_t *b);
-    Float_t Bx(const Int_t ix, const Int_t iy, const Int_t iz) {
-       return (*fB)(3*(ix*(fZn*fYn)+iy*fZn+iz));
+    virtual void Field(Float_t *x, Float_t *b) const;
+    Float_t Bx(Int_t ix, Int_t iy, Int_t iz) const{
+       return (*fB)(3*((ix*fYn+iy)*fZn+iz));
     }
-    Float_t By(const Int_t ix, const Int_t iy, const Int_t iz) {
-       return (*fB)(3*(ix*(fZn*fYn)+iy*fZn+iz)+1);
+    Float_t By(Int_t ix, Int_t iy, Int_t iz) const{
+       return (*fB)(3*((ix*fYn+iy)*fZn+iz)+1);
     }
-    Float_t Bz(const Int_t ix, const Int_t iy, const Int_t iz) {
-       return (*fB)(3*(ix*(fZn*fYn)+iy*fZn+iz)+2);
+    Float_t Bz(Int_t ix, Int_t iy, Int_t iz) const{
+       return (*fB)(3*((ix*fYn+iy)*fZn+iz)+2);
     }
 
-    Bool_t Inside(Float_t x, Float_t y, Float_t z) 
-       { return (x > fXbeg && x <= fXend &&
-                 y > fYbeg && y <= fYend &&
-                 z > fZbeg && z <= fZend);
+    Bool_t Inside(Float_t x, Float_t y, Float_t z) const
+       { return (x > fXbeg && x < fXend &&
+                 y > fYbeg && y < fYend &&
+                 z > fZbeg && z < fZend);
        }
-    Float_t Xmin()  {return fXbeg;}
-    Float_t Xmax()  {return fXend;}
-    Float_t DelX()  {return fXdel;}
-    Float_t DeliX() {return fXdeli;}
+    Float_t Xmin()  const {return fXbeg;}
+    Float_t Xmax()  const {return fXend;}
+    Float_t DelX()  const {return fXdel;}
+    Float_t DeliX() const {return fXdeli;}
     
-    Float_t Ymin()  {return fYbeg;}
-    Float_t Ymax()  {return fYend;}
-    Float_t DelY()  {return fYdel;}
-    Float_t DeliY() {return fYdeli;}
+    Float_t Ymin()  const {return fYbeg;}
+    Float_t Ymax()  const {return fYend;}
+    Float_t DelY()  const {return fYdel;}
+    Float_t DeliY() const {return fYdeli;}
     
-    Float_t Zmin()  {return fZbeg;}
-    Float_t Zmax()  {return fZend;}
-    Float_t DelZ()  {return fZdel;}
-    Float_t DeliZ() {return fZdeli;}
+    Float_t Zmin()  const {return fZbeg;}
+    Float_t Zmax()  const {return fZend;}
+    Float_t DelZ()  const {return fZdel;}
+    Float_t DeliZ() const {return fZdeli;}
     void    SetLimits(Float_t xmin, Float_t xmax, Float_t ymin, Float_t ymax,
                      Float_t zmin, Float_t zmax)
        {
            fXbeg = xmin; fXend = xmax; fYbeg = ymin; fYend = ymax;
            fZbeg = zmin; fZend = zmax;
        }
+    void SetWriteEnable(Int_t flag = 1) {fWriteEnable = flag;}
+ protected:
+    
+    Float_t    fXbeg;         // Start of mesh in x
+    Float_t    fYbeg;         // Start of mesh in y
+    Float_t    fZbeg;         // Start of mesh in z
+    Float_t    fXend;         // End of mesh in x
+    Float_t    fYend;         // End of mesh in y
+    Float_t    fZend;         // End of mesh in z
+    Float_t    fXdel;         // Mesh step in x
+    Float_t    fYdel;         // Mesh step in y
+    Float_t    fZdel;         // Mesh step in z
+    Double_t   fXdeli;        // Inverse of Mesh step in x
+    Double_t   fYdeli;        // Inverse of Mesh step in y
+    Double_t   fZdeli;        // Inverse of Mesh step in z
+    Int_t      fXn;           // Number of mesh points in x
+    Int_t      fYn;           // Number of mesh points in y
+    Int_t      fZn;           // Number of mesh points in z
+    Int_t      fWriteEnable;  // Enable flag for writing of field data.
+    TVector*   fB;            // Field map
+    
  private:
     void    ReadField();
- protected:
 
-    Float_t    fXbeg;     // Start of mesh in x
-    Float_t    fYbeg;     // Start of mesh in y
-    Float_t    fZbeg;     // Start of mesh in z
-    Float_t    fXend;     // End of mesh in x
-    Float_t    fYend;     // End of mesh in y
-    Float_t    fZend;     // End of mesh in z
-    Float_t    fXdel;     // Mesh step in x
-    Float_t    fYdel;     // Mesh step in y
-    Float_t    fZdel;     // Mesh step in z
-    Double_t   fXdeli;    // Inverse of Mesh step in x
-    Double_t   fYdeli;    // Inverse of Mesh step in y
-    Double_t   fZdeli;    // Inverse of Mesh step in z
-    Int_t      fXn;       // Number of mesh points in x
-    Int_t      fYn;       // Number of mesh points in y
-    Int_t      fZn;       // Number of mesh points in z
-    TVector*   fB;        //!Field map
-    
-    ClassDef(AliFieldMap,2)  //Class for Field Map
+    ClassDef(AliFieldMap,3)  //Class for Field Map
 };
 
 #endif