]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliMagF.h
Fixing CONSTANT_EXPRESSION_RESULT Coverity defect
[u/mrichter/AliRoot.git] / STEER / AliMagF.h
index 9ec280dfbaa1190bb8ea45915742a122d3aa36b2..1f714a3b8a71956d0c3124f1a15b2a717a6ee059 100644 (file)
-#ifndef AliMagF_H
-#define AliMagF_H
+#ifndef ALIMAGF_H
+#define ALIMAGF_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
 
-#include "TNamed.h"
-#include "TVector.h"
+//
+// Interface between the TVirtualMagField and AliMagWrapCheb: wrapper to
+// the set of magnetic field data + Tosca parameterization by 
+// Chebyshev polynomials
+// 
+// Author: ruben.shahoyan@cern.ch
+//
 
-enum Field_t {Undef=1, Const=1, ConMesh=2};
+//#include <TGeoGlobalMagField.h>
+#include <TVirtualMagField.h>
+class AliMagWrapCheb;
 
-class AliMagF : public TNamed {
-
-protected:
-  Int_t     fMap;    // Field Map identifier
-  Int_t     fType;   // Mag Field type
-  Int_t     fInteg;  // Integration method as indicated in Geant
-  Float_t   fFactor; // Multiplicative factor
-  Float_t   fMax;    // Max Field as indicated in Geant
-
-public:
-  AliMagF(){}
-  AliMagF(const char *name, const char *title, const Int_t integ, const Int_t map, 
-         const Float_t factor, const Float_t fmax);
-  virtual ~AliMagF() {}
-  virtual void Field(Float_t *x, Float_t *b);
-  virtual Int_t Type() {return fType;}
-  virtual Float_t Max() const {return fMax;}
-  virtual Int_t Map() const {return fMap;}
-  virtual Int_t Integ() const {return fInteg;}
-  virtual Float_t Factor() const {return fFactor;}
-  virtual void ReadField() {}
-  
-  ClassDef(AliMagF,1)  //Base class for all Alice MagField
-};
-
-class AliMagFC  : public AliMagF
+class AliMagF : public TVirtualMagField
 {
-  //Alice Constant Magnetic Field
-private:
-
-public:
-  AliMagFC(){}
-  AliMagFC(const char *name, const char *title, const Int_t integ, const Int_t map, 
-          const Float_t factor, const Float_t fmax);
-  virtual ~AliMagFC() {}
-  virtual void Field(Float_t *x, Float_t *b);
-  virtual void ReadField() {}
-  
-  ClassDef(AliMagFC,1)  //Class for all Alice Constant MagField 
+ public:
+  enum BMap_t      {k2kG, k5kG, k5kGUniform};
+  enum BeamType_t  {kNoBeamField, kBeamTypepp, kBeamTypeAA};
+  enum PolarityConvention_t {kConvLHC,kConvDCS2008,kConvMap2005};
+  enum             {kOverrideGRP=BIT(14)}; // don't recreate from GRP if set
+  //
+  AliMagF();
+  AliMagF(const char *name, const char* title,Double_t factorSol=1., Double_t factorDip=1., 
+         BMap_t maptype = k5kG, BeamType_t btype=kBeamTypepp, Double_t benergy=-1,     
+         Int_t integ=2, Double_t fmax=15,const char* path="$(ALICE_ROOT)/data/maps/mfchebKGI_sym.root");
+  AliMagF(const AliMagF& src);             
+  AliMagF& operator=(const AliMagF& src);
+  virtual ~AliMagF();
+  //
+  virtual void Field(const Double_t *x, Double_t *b);
+  void       GetTPCInt(const Double_t *xyz, Double_t *b)         const;
+  void       GetTPCRatInt(const Double_t *xyz, Double_t *b)      const;
+  void       GetTPCIntCyl(const Double_t *rphiz, Double_t *b)    const;
+  void       GetTPCRatIntCyl(const Double_t *rphiz, Double_t *b) const;
+  Double_t   GetBz(const Double_t *xyz)                          const;
+  //
+  AliMagWrapCheb* GetMeasuredMap()                              const {return fMeasuredMap;}
+  //
+  // former AliMagF methods or their aliases
+  void         SetFactorSol(Float_t fc=1.);
+  void         SetFactorDip(Float_t fc=1.);
+  Double_t     GetFactorSol()                                   const;
+  Double_t     GetFactorDip()                                   const;
+  Double_t     Factor()                                         const {return GetFactorSol();}
+  Double_t     GetCurrentSol()                                  const {return GetFactorSol()*(fMapType==k2kG ? 12000:30000);}
+  Double_t     GetCurrentDip()                                  const {return GetFactorDip()*6000;}
+  Bool_t       IsUniform()                                      const {return fMapType == k5kGUniform;}
+  //
+  void         MachineField(const Double_t  *x, Double_t *b)    const;
+  BMap_t       GetMapType()                                     const {return fMapType;}
+  BeamType_t   GetBeamType()                                    const {return fBeamType;}
+  const char*  GetBeamTypeText()                                const;
+  Double_t     GetBeamEnergy()                                  const {return fBeamEnergy;}
+  Double_t     Max()                                            const {return fMax;}
+  Int_t        Integ()                                          const {return fInteg;}
+  Int_t        PrecInteg()                                      const {return fPrecInteg;}  
+  Double_t     SolenoidField()                                  const {return fFactorSol*fSolenoid;}
+  //
+  Char_t*      GetDataFileName()                                const {return (Char_t*)fParNames.GetName();}
+  Char_t*      GetParamName()                                   const {return (Char_t*)fParNames.GetTitle();}
+  void         SetDataFileName(const Char_t* nm)                      {fParNames.SetName(nm);}
+  void         SetParamName(const Char_t* nm)                         {fParNames.SetTitle(nm);}
+  virtual void Print(Option_t *opt)                             const;
+  //
+  Bool_t       LoadParameterization();
+  static Int_t GetPolarityConvention()                                {return Int_t(fgkPolarityConvention);}
+  static AliMagF* CreateFieldMap(Float_t l3Current=-30000., Float_t diCurrent=-6000., 
+                                Int_t convention=0, Bool_t uniform = kFALSE, 
+                                Float_t beamenergy=7000, const Char_t* btype="pp",
+                                const Char_t* path="$(ALICE_ROOT)/data/maps/mfchebKGI_sym.root");
+  //
+ protected:
+  // not supposed to be changed during the run, set only at the initialization via constructor
+  void         InitMachineField(BeamType_t btype, Double_t benergy);
+  void         SetBeamType(BeamType_t type)                           {fBeamType = type;}
+  void         SetBeamEnergy(Float_t energy)                          {fBeamEnergy = energy;}
+  //
+ protected:
+  AliMagWrapCheb*  fMeasuredMap;     //! Measured part of the field map
+  BMap_t           fMapType;         // field map type
+  Double_t         fSolenoid;        // Solenoid field setting
+  BeamType_t       fBeamType;        // Beam type: A-A (fBeamType=0) or p-p (fBeamType=1)
+  Double_t         fBeamEnergy;      // Beam energy in GeV
+  // 
+  Int_t            fInteg;           // Default integration method as indicated in Geant
+  Int_t            fPrecInteg;       // Alternative integration method, e.g. for higher precision
+  Double_t         fFactorSol;       // Multiplicative factor for solenoid
+  Double_t         fFactorDip;       // Multiplicative factor for dipole
+  Double_t         fMax;             // Max Field as indicated in Geant
+  Bool_t           fDipoleOFF;       // Dipole ON/OFF flag
+  //
+  Double_t         fQuadGradient;    // Gradient field for inner triplet quadrupoles
+  Double_t         fDipoleField;     // Field value for D1 and D2 dipoles
+  Double_t         fCCorrField;      // Side C 2nd compensator field
+  Double_t         fACorr1Field;     // Side A 1st compensator field 
+  Double_t         fACorr2Field;     // Side A 2nd compensator field
+  //
+  TNamed           fParNames;        // file and parameterization loadad
+  //
+  static const Double_t  fgkSol2DipZ;    // conventional Z of transition from L3 to Dipole field
+  static const UShort_t  fgkPolarityConvention; // convention for the mapping of the curr.sign on main component sign
+  //   
+  ClassDef(AliMagF, 2)           // Class for all Alice MagField wrapper for measured data + Tosca parameterization
 };
 
-class AliMagFCM : public AliMagF
-{
-  //Alice Magnetic Field with constan mesh
-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    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
-public:
-  AliMagFCM(){}
-  AliMagFCM(const char *name, const char *title, const Int_t integ, const Int_t map, 
-          const Float_t factor, const Float_t fmax);
-  virtual ~AliMagFCM() {delete fB;}
-  virtual void Field(Float_t *x, Float_t *b);
-  virtual void ReadField();
-
-  inline Float_t Bx(const Int_t ix, const Int_t iy, const Int_t iz) {
-    return (*fB)(3*(iz*(fXn*fYn)+iy*fXn+ix));
-  }
-  inline Float_t By(const Int_t ix, const Int_t iy, const Int_t iz) {
-    return (*fB)(3*(iz*(fXn*fYn)+iy*fXn+ix)+1);
-  }
-  inline Float_t Bz(const Int_t ix, const Int_t iy, const Int_t iz) {
-    return (*fB)(3*(iz*(fXn*fYn)+iy*fXn+ix)+2);
-  }
-  
-  ClassDef(AliMagFCM,1)  //Class for all Alice MagField with Constant Mesh
-};
 
 #endif