]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliMagFDM.cxx
syntax correction for Mylar
[u/mrichter/AliRoot.git] / STEER / AliMagFDM.cxx
index f2b80903753e9231191efb77df1b12707d94d7a3..269ce397f3d8db5bdb59658ce099dfe4bff04494 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/*
-$Log$
-Revision 1.9  2001/01/17 20:02:20  morsch
-In the AliMagFDM tree  call-by-reference functions were changed to
-call-by-value, what is more adequate for our task. There were added
-a few comments and put protection to values of cos > 1.000 in
-AliMagFDM.cxx. (Galina Chabratova)
+/* $Id$ */
 
-Revision 1.8  2000/12/18 10:44:01  morsch
-Possibility to set field map by passing pointer to objet of type AliMagF via
-SetField().
-Example:
-gAlice->SetField(new AliMagFCM("Map2", "$(ALICE_ROOT)/data/field01.dat",2,1.,10.));
+//-------------------------------------------------------------------------
+//   Field with Magnetic Field map
+//   Used by AliRun class
+//   Author:
+//-------------------------------------------------------------------------
 
-Revision 1.7  2000/12/01 11:20:27  alibrary
-Corrector dipole removed from ZDC
-
-Revision 1.6  2000/11/10 18:09:55  fca
-New field map for the ZDC
-
-Revision 1.5  2000/10/27 14:17:04  morsch
-- Bug causing segmentation violation during muon reconstruction corrected
-- Coding rule violations corrected.
-(Galina Chabratova)
-
-Revision 1.4  2000/10/02 21:28:14  fca
-Removal of useless dependecies via forward declarations
-
-Revision 1.3  2000/07/13 16:19:09  fca
-Mainly coding conventions + some small bug fixes
-
-Revision 1.2  2000/07/12 08:56:25  fca
-Coding convention correction and warning removal
-
-Revision 1.1  2000/07/11 18:24:59  fca
-Coding convention corrections + few minor bug fixes
-
-*/
-
-#include <stdlib.h>
+#include "TSystem.h"
 
 #include "AliMagFDM.h"
-#include "TSystem.h"
-    
 
 ClassImp(AliMagFDM)
 
-//________________________________________
-AliMagFDM::AliMagFDM(const char *name, const char *title, const Int_t integ,
-          const Float_t factor, const Float_t fmax)
-  : AliMagF(name,title,integ,factor,fmax)
+//_______________________________________________________________________
+AliMagFDM::AliMagFDM():
+  fSolenoid(0),
+  fInd(0),
+  fZmin(0),
+  fZmax(0),
+  fYmax(0),
+  fYmin(0),
+  fZpmx(0),
+  fZpmn(0),
+  fRmax(0),
+  fRmin(0),
+  fXdel(0),
+  fYdel(0),
+  fZdel(0),
+  fRdel(0),
+  fPhid(0),
+  fZpdl(0),
+  fCx1(0),
+  fCx2(0),
+  fAx1(0),
+  fAx2(0),
+  fXl(0),
+  fYl(0),
+  fZl(0),    
+  fRn(0),
+  fPhin(0),
+  fZpl(0)  
+{
+  //
+  // Default constructor for the Dipole field
+  //
+}
+
+//_______________________________________________________________________
+AliMagFDM::AliMagFDM(const char *name, const char *title, Int_t integ,
+                     Float_t factor, Float_t fmax):
+  AliMagFC(name,title,integ,factor,fmax),
+  fSolenoid(0),
+  fInd(0),
+  fZmin(0),
+  fZmax(0),
+  fYmax(0),
+  fYmin(0),
+  fZpmx(0),
+  fZpmn(0),
+  fRmax(0),
+  fRmin(0),
+  fXdel(0),
+  fYdel(0),
+  fZdel(0),
+  fRdel(0),
+  fPhid(0),
+  fZpdl(0),
+  fCx1(0),
+  fCx2(0),
+  fAx1(0),
+  fAx2(0),
+  fXl(0),
+  fYl(0),
+  fZl(0),    
+  fRn(0),
+  fPhin(0),
+  fZpl(0)  
 {
   //
   // Standard constructor for the Dipole field
   //
   fType = kDipoMap;
   fMap  = 3;
+  SetSolenoidField();
   
- printf("Field Map for Muon Arm from IP till muon filter %s created: map= %d, integ= %d, factor= %f, file=%s\n",fName.Data(), fMap ,integ,factor,fTitle.Data());
+  Info("ctor",
+       "Field Map for Muon Arm from IP till muon filter %s created: map= %d, integ= %d, factor= %f, file=%s\n",
+       fName.Data(), fMap ,integ,factor,fTitle.Data());
  
 }
 
-//________________________________________
-
-void AliMagFDM::Field(Float_t *xfi, Float_t *b)
+//_______________________________________________________________________
+void AliMagFDM::Field(Float_t *xfi, Float_t *b) const
 {
   //
   // Main routine to compute the field in a point
   //
-  static  const Double_t keps=0.1E-06;
-  static  const Double_t PI2=2.*TMath::Pi();
-  static  const Double_t kone=1;
-
-  static  const    Int_t  kiip=33; 
-  static  const    Int_t  kmiip=0;    
-  static  const    Int_t  kliip=0;
-
-  static  const    Int_t  kiic=0;
-  static  const    Int_t  kmiic=0;    
-  static  const    Int_t  kliic=0;       
-
-  static  const Double_t    kfZbg=502.92;  // Start of Map using in z
-  static  const Double_t    kfZL3=600;  // Beginning of L3 door in z
+  const Double_t keps=0.1E-06;
+  const Double_t kPI2=2.*TMath::Pi();
+  const Double_t kone=1;
+  
+  const    Int_t  kiip=33; 
+  const    Int_t  kmiip=0;    
+  const    Int_t  kliip=0;
+  
+  const    Int_t  kiic=0;
+  const    Int_t  kmiic=0;    
+  const    Int_t  kliic=0;       
+  
+  const Double_t    kfZbg=502.92;  // Start of Map using in z
+  const Double_t    kfZL3=600;  // Beginning of L3 door in z
 
   Double_t   x[3];   
   Double_t   xL3[3]; 
   Double_t   bint[3]; 
   
   Double_t r0;
-    Int_t iKvar,jb;
+  Int_t iKvar,jb;
 
   Double_t zp1, zp2,xp1,xp2,yp1,yp2; 
   Double_t zz1, zz2,yy1,yy2,x2,x1; 
      
 // --- start the map fiel from z = 502.92 cm ---
+//
+// This map has been calculated in a coordinate system in which the muon spectrometer sits at z > 0
+// Transfor correspondingly.
 
-  x[0] = xfi[0];
-  x[1] = xfi[1];
-  x[2] = xfi[2];
+  x[0] = xfi[0];
+  x[1] =   xfi[1];
+  x[2] = xfi[2];
   b[0]=b[1]=b[2]=0;
+//
   //       printf("x[0]  %f,x[1] %f,x[2]  %f\n",x[0],x[1],x[2]); 
 
   Double_t rr=TMath::Sqrt(x[0]*x[0]+x[1]*x[1]);
@@ -124,7 +157,7 @@ void AliMagFDM::Field(Float_t *xfi, Float_t *b)
        || (kfZbg<x[2] && x[2]<=kfZL3 && (rr>rPmax*100 && rr< 560)) )
        {
         b[0]=b[1]=0;
-        b[2]=2;
+        b[2]=fSolenoid;
        }
 
   xL3[0]=x[0]/100;
@@ -174,10 +207,10 @@ if ((kfZbg/100<xL3[2] && xL3[2]<=zCmin && r0<=rPmax) || ((zCmin<xL3[2] && xL3[2]
         kcphi=777;
        } 
        ph0=TMath::ACos(cphi);
-       if (xL3[0] < 0 && yyp > 0 ) {ph0=PI2/2 - ph0;}  
-       if (xL3[0] < 0 && yyp < 0 ) {ph0=PI2/2 + ph0;} 
-       if (xL3[0] > 0 && yyp < 0 ) {ph0=PI2 - ph0;}  
-       if (ph0 > PI2) {       ph0=ph0 - PI2;}
+       if (xL3[0] < 0 && yyp > 0 ) {ph0=kPI2/2 - ph0;}  
+       if (xL3[0] < 0 && yyp < 0 ) {ph0=kPI2/2 + ph0;} 
+       if (xL3[0] > 0 && yyp < 0 ) {ph0=kPI2 - ph0;}  
+       if (ph0 > kPI2) {       ph0=ph0 - kPI2;}
        if (kcphi==777) {
         printf("xL3[0] %e, xL3[1] %e, xL3[2] %e, yyp %e, r0 %e, ph0 %e\n",xL3[0],xL3[1],xL3[2],yyp,r0,ph0);
        }  
@@ -227,9 +260,9 @@ if ((kfZbg/100<xL3[2] && xL3[2]<=zCmin && r0<=rPmax) || ((zCmin<xL3[2] && xL3[2]
         }
        }
 
-       b[0]=bint[0];
+       b[0]=-bint[0];
        b[1]=bint[1];
-       b[2]=bint[2];
+       b[2]=-bint[2];
 
    }  
    else 
@@ -277,12 +310,11 @@ if ((kfZbg/100<xL3[2] && xL3[2]<=zCmin && r0<=rPmax) || ((zCmin<xL3[2] && xL3[2]
        bint[jb-3] = Bb(zz1,zz2,yy1,yy2,x1,x2,iKvar,k0, l0, m0)*10 ; 
      }    
  
-   b[0]=bint[0];
+   b[0]=-bint[0];
    b[1]=bint[1];
-   b[2]=bint[2]; 
+   b[2]=-bint[2]; 
 
    } 
- printf("x %f, y %f, z %f:: bx %f, by %f, bz %f\n",xfi[0],xfi[1],xfi[2],b[0],b[1],b[2]); 
 
 
   } else {
@@ -290,51 +322,9 @@ if ((kfZbg/100<xL3[2] && xL3[2]<=zCmin && r0<=rPmax) || ((zCmin<xL3[2] && xL3[2]
  }
            
 } else {
+    ZDCField(xfi,b);
 
-//This is the ZDC part
-    Float_t rad2=x[0]*x[0]+x[1]*x[1];
-    if(x[2]>kCORBEG2 && x[2]<kCOREND2){
-      if(rad2<kCOR2RA2){
-        b[0] = kFCORN2;
-      }
-    }
-    else if(x[2]>kZ1BEG && x[2]<kZ1END){  
-      if(rad2<kZ1RA2){
-        b[0] = -kG1*x[1];
-        b[1] = -kG1*x[0];
-      }
     }
-    else if(x[2]>kZ2BEG && x[2]<kZ2END){  
-      if(rad2<kZ2RA2){
-        b[0] = kG1*x[1];
-        b[1] = kG1*x[0];
-      }
-    }
-    else if(x[2]>kZ3BEG && x[2]<kZ3END){  
-      if(rad2<kZ3RA2){
-        b[0] = kG1*x[1];
-        b[1] = kG1*x[0];
-      }
-    }
-    else if(x[2]>kZ4BEG && x[2]<kZ4END){  
-      if(rad2<kZ4RA2){
-        b[0] = -kG1*x[1];
-        b[1] = -kG1*x[0];
-      }
-    }
-    else if(x[2]>kD1BEG && x[2]<kD1END){ 
-      if(rad2<kD1RA2){
-        b[1] = -kFDIP;
-      }
-    }
-    else if(x[2]>kD2BEG && x[2]<kD2END){
-      if(((x[0]-kXCEN1D2)*(x[0]-kXCEN1D2)+(x[1]-kYCEN1D2)*(x[1]-kYCEN1D2))<kD2RA2
-        || ((x[0]-kXCEN2D2)*(x[0]-kXCEN2D2)+(x[1]-kYCEN2D2)*(x[1]-kYCEN2D2))<kD2RA2){
-       b[1] = kFDIP;
-      }
-    }
-      }
-    
 
   if(fFactor!=1) {
     b[0]*=fFactor;
@@ -343,9 +333,9 @@ if ((kfZbg/100<xL3[2] && xL3[2]<=zCmin && r0<=rPmax) || ((zCmin<xL3[2] && xL3[2]
   }
 }
 
-//_____________________  FZ ____________________
-
-Int_t AliMagFDM::FZ(Double_t temp, Float_t  *Ar, Float_t delu,Int_t ik,Int_t nk)
+//_______________________________________________________________________
+Int_t AliMagFDM::FZ(Double_t temp, const Float_t *Ar, 
+                    Float_t delu, Int_t ik, Int_t nk) const
 {
   //
   // Quest of a point position at x,y,z (Cartensian) and R,Phi,z (Polar) axises
@@ -375,17 +365,18 @@ Int_t AliMagFDM::FZ(Double_t temp, Float_t  *Ar, Float_t delu,Int_t ik,Int_t nk)
     return kf;
   }
 
-/*---------------------Ba------------------*/
-
-Double_t AliMagFDM::Ba(Int_t kaai,Double_t zaa1, Double_t zaa2, Double_t alf1, Double_t alf2, Double_t alf3, Int_t kaa, Int_t maa)
+//_______________________________________________________________________
+Double_t AliMagFDM::Ba(Int_t kaai,Double_t zaa1, Double_t zaa2, 
+                       Double_t alf1, Double_t alf2, Double_t alf3, 
+                       Int_t kaa, Int_t maa) const
 {
   //
   // Calculation of field componet for case (keps <r0<= fRdel) at a given axis
   //
-  Double_t fa11,fa12,fa13;
-  Double_t fa21,fa22,fa23;
-  Double_t faY1,faY2;
-  Double_t bba;
+  Double_t fa11=0,fa12=0,fa13=0;
+  Double_t fa21=0,fa22=0,fa23=0;
+  Double_t faY1=0,faY2=0;
+  Double_t bba=0;
 
   switch (kaai) {
   case 0:
@@ -414,7 +405,6 @@ Double_t AliMagFDM::Ba(Int_t kaai,Double_t zaa1, Double_t zaa2, Double_t alf1, D
     break;
   default:
     Fatal("Ba","Invalid value of kaai %d\n",kaai);
-    exit(1);
   }                            
   faY1=alf1*fa11+alf2*fa12+alf3*fa13;
   faY2=alf1*fa21+alf2*fa22+alf3*fa23;
@@ -423,18 +413,18 @@ Double_t AliMagFDM::Ba(Int_t kaai,Double_t zaa1, Double_t zaa2, Double_t alf1, D
 }
 
   
-/*------------------------Bb--------------------------*/
-
-Double_t AliMagFDM::Bb(Double_t z1,Double_t z2, Double_t y1,Double_t y2, Double_t x1,Double_t x2, Int_t kv, Int_t k, Int_t l, Int_t m)
+//_______________________________________________________________________
+Double_t AliMagFDM::Bb(Double_t z1,Double_t z2, Double_t y1,Double_t y2, 
+                       Double_t x1,Double_t x2, Int_t kv, Int_t k, Int_t l, Int_t m) const
 {  
   //
   // Calculation of field componet at a given axis (general case)
   //
-  Double_t fy1, fy2, ffy;
-  Double_t gy1,gy2,ggy;
-  Double_t bbi;
-  Double_t bf11,bf12,bf21,bf22;
-  Double_t bg11,bg12,bg21,bg22;
+  Double_t fy1=0,fy2=0,ffy=0;
+  Double_t gy1=0,gy2=0,ggy=0;
+  Double_t bbi=0;
+  Double_t bf11=0,bf12=0,bf21=0,bf22=0;
+  Double_t bg11=0,bg12=0,bg21=0,bg22=0;
 
   
   /*-----------------Polar part ------------------*/
@@ -515,7 +505,6 @@ Double_t AliMagFDM::Bb(Double_t z1,Double_t z2, Double_t y1,Double_t y2, Double_
 
   default:
     Fatal("Bb","Invalid value of kv %d\n",kv);
-    exit(1);
   }  
   
   
@@ -534,8 +523,8 @@ Double_t AliMagFDM::Bb(Double_t z1,Double_t z2, Double_t y1,Double_t y2, Double_
   return bbi;
   
 }     
-//____________________________________________
 
+//_______________________________________________________________________
 void AliMagFDM::ReadField()
 {
   //
@@ -694,8 +683,6 @@ printf("fZpdl %e, fPhid %e, fRdel %e, fZpmx %e, fZpmn %e,fRmax %e,fRmin %e \n",
     }
 //
   } else { 
-    printf("File %s not found !\n",fTitle.Data());
-    exit(1);
+    Fatal("ReadField","File %s not found !\n",fTitle.Data());
   }
 }
-//________________________________