]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliMagFDM.cxx
Conding violations fixed. The code is now included in libSTEER (Mikolaj)
[u/mrichter/AliRoot.git] / STEER / AliMagFDM.cxx
index 50264c8fb865433534839bf68bf570e825f6ec5a..e4cccc9b18f07c41629898c9d57ffbb4a4177db5 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/*
-$Log$
-Revision 1.12  2001/05/28 14:10:35  morsch
-SetSolenoidField method to set the L3 field strength. 2 kG is default.
+/* $Id$ */
 
-Revision 1.11  2001/02/08 13:18:00  hristov
-Print removed (J.Gosset)
+//-------------------------------------------------------------------------
+//   Field with Magnetic Field map
+//   Used by AliRun class
+//   Author:
+//-------------------------------------------------------------------------
 
-Revision 1.10  2001/01/18 13:21:30  morsch
-Take pi from TMath.
-
-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)
-
-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.));
-
-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 <TMath.h>
+#include <TSystem.h>
 
+#include "AliLog.h"
 #include "AliMagFDM.h"
-    
 
 ClassImp(AliMagFDM)
 
@@ -105,9 +64,9 @@ AliMagFDM::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(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),
@@ -142,20 +101,20 @@ AliMagFDM::AliMagFDM(const char *name, const char *title, const Int_t integ,
   fMap  = 3;
   SetSolenoidField();
   
-  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());
+  AliDebug(1, Form(
+       "Field Map for Muon Arm from IP till muon filter %s created: map= %d, integ= %d, factor= %f, file=%s",
+       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
   //
   const Double_t keps=0.1E-06;
-  const Double_t PI2=2.*TMath::Pi();
+  const Double_t kPI2=2.*TMath::Pi();
   const Double_t kone=1;
   
   const    Int_t  kiip=33; 
@@ -180,11 +139,15 @@ void AliMagFDM::Field(Float_t *xfi, Float_t *b)
   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]);
@@ -241,17 +204,17 @@ if ((kfZbg/100<xL3[2] && xL3[2]<=zCmin && r0<=rPmax) || ((zCmin<xL3[2] && xL3[2]
        cphi=TMath::Abs(yyp/r0);
        Int_t kcphi=0;
        if (cphi > kone) {
-        printf("xL3[0] %e, xL3[1] %e, xL3[2] %e, yyp %e, r0 %e, cphi %e\n",xL3[0],xL3[1],xL3[2],yyp,r0,cphi);
+        AliDebug(2,Form("xL3[0] %e, xL3[1] %e, xL3[2] %e, yyp %e, r0 %e, cphi %e",xL3[0],xL3[1],xL3[2],yyp,r0,cphi));
         cphi =kone;
         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);
+        AliDebug(2,Form("xL3[0] %e, xL3[1] %e, xL3[2] %e, yyp %e, r0 %e, ph0 %e",xL3[0],xL3[1],xL3[2],yyp,r0,ph0));
        }  
        fip=ph0; 
        mp0=FZ(fip,fPhi,fPhid ,mpi,fPhin);
@@ -299,9 +262,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 
@@ -337,7 +300,7 @@ if ((kfZbg/100<xL3[2] && xL3[2]<=zCmin && r0<=rPmax) || ((zCmin<xL3[2] && xL3[2]
    if(xL3[0]<(xx1+m0*dx) || xL3[0] >(xx1+(m0+1)*dx)) 
     {
       m0=m0+1;   
-      printf(" m0 %d, m0+1 %d\n",m0,m0+1);  
+      AliDebug(2,Form(" m0 %d, m0+1 %d\n",m0,m0+1));  
     }
 
    x2=(xL3[0]-( xx1+m0*dx))/dx;
@@ -349,63 +312,21 @@ 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]; 
 
    } 
 
 
   } else {
-        printf("Unknown map of Dipole region %d\n",fMap);
+        AliError(Form("Unknown map of Dipole region %d",fMap));
  }
            
 } 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;
@@ -415,8 +336,8 @@ if ((kfZbg/100<xL3[2] && xL3[2]<=zCmin && r0<=rPmax) || ((zCmin<xL3[2] && xL3[2]
 }
 
 //_______________________________________________________________________
-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
@@ -449,15 +370,15 @@ Int_t AliMagFDM::FZ(Double_t temp, Float_t *Ar,
 //_______________________________________________________________________
 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)
+                       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:
@@ -485,8 +406,7 @@ Double_t AliMagFDM::Ba(Int_t kaai,Double_t zaa1, Double_t zaa2,
     fa23 = fBpz[kaa+1][0][maa+1]; 
     break;
   default:
-    Fatal("Ba","Invalid value of kaai %d\n",kaai);
-    exit(1);
+    AliFatal(Form("Invalid value of kaai %d",kaai));
   }                            
   faY1=alf1*fa11+alf2*fa12+alf3*fa13;
   faY2=alf1*fa21+alf2*fa22+alf3*fa23;
@@ -497,16 +417,16 @@ Double_t AliMagFDM::Ba(Int_t kaai,Double_t zaa1, Double_t zaa2,
   
 //_______________________________________________________________________
 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 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 ------------------*/
@@ -586,8 +506,7 @@ Double_t AliMagFDM::Bb(Double_t z1,Double_t z2, Double_t y1,Double_t y2,
     break;
 
   default:
-    Fatal("Bb","Invalid value of kv %d\n",kv);
-    exit(1);
+    AliFatal(Form("Invalid value of kv %d",kv));
   }  
   
   
@@ -620,12 +539,12 @@ void AliMagFDM::ReadField()
   Float_t zz, yy, bx,by,bz,bb;
 
   char *fname;
-  printf("Reading Magnetic Field %s from file %s\n",fName.Data(),fTitle.Data());
+  AliDebug(1,Form("Reading Magnetic Field %s from file %s",fName.Data(),fTitle.Data()));
   fname = gSystem->ExpandPathName(fTitle.Data());
   magfile=fopen(fname,"r");
   delete [] fname;
 
-  printf("Cartensian part\n");
+  AliDebug(2,"Cartensian part");
  
   if (magfile) {
   
@@ -633,7 +552,7 @@ void AliMagFDM::ReadField()
  
     fscanf(magfile,"%d %d %d ",&fYl, &fXl, &fZl); 
     
-    printf("fYl %d, fXl %d, fZl %d\n",fYl, fXl, fZl);     
+    AliDebug(3,Form("fYl %d, fXl %d, fZl %d",fYl, fXl, fZl));     
     
     for (ik=0; ik<fZl; ik++)
     { 
@@ -651,14 +570,14 @@ void AliMagFDM::ReadField()
     } 
     for (ik=0; ik<81; ik++)
     {    
-           printf("fZc %e,fY %e\n", fZc[ik],fY[ik]); 
+           AliDebug(4,Form("fZc %e,fY %e", fZc[ik],fY[ik])); 
     }   
              
     fscanf(magfile," %e %e %e %e %e %e %e %e %e %e %e ", &fYdel,&fXdel,&fZdel,&fZmax,&fZmin,&fYmax,&fYmin,&fAx1,&fCx1,&fAx2,&fCx2); 
 
-printf("fYdel %e, fXdel %e, fZdel %e\n",fYdel,fXdel,fZdel);
-printf("fZmax %e, fZmin %e, fYmax %e,fYmin %e\n",fZmax,fZmin,fYmax,fYmin);
-printf("fAx1 %e, fCx1 %e, fAx2 %e, fCx %e\n",fAx1,fCx1,fAx2,fCx2);
+AliDebug(3,Form("fYdel %e, fXdel %e, fZdel %e",fYdel,fXdel,fZdel));
+AliDebug(3,Form("fZmax %e, fZmin %e, fYmax %e,fYmin %e",fZmax,fZmin,fYmax,fYmin));
+AliDebug(3,Form("fAx1 %e, fCx1 %e, fAx2 %e, fCx %e",fAx1,fCx1,fAx2,fCx2));
 
     for (il=0; il<44; il++)  { 
      for (im=0; im<81; im++)  {      
@@ -691,40 +610,40 @@ printf("fAx1 %e, fCx1 %e, fAx2 %e, fCx %e\n",fAx1,fCx1,fAx2,fCx2);
     } 
 //----------------------   Polar part ---------------------------------
 
-    printf("Polar part\n");
+    AliDebug(2,"Polar part");
     fscanf(magfile,"%d %d %d ", &fZpl, &fRn, &fPhin); 
-    printf("fZpl %d, fRn %d, fPhin %d\n",fZpl,fRn,fPhin);   
+    AliDebug(3,Form("fZpl %d, fRn %d, fPhin %d",fZpl,fRn,fPhin));   
 
-    printf(" fZp array\n"); 
+    AliDebug(4," fZp array"); 
      
     for (ik=0; ik<51; ik++) 
     {    
      fscanf(magfile, " %e ", &zzp);
      fZp[ik]=zzp; 
-     printf(" %e\n",fZp[ik]);      
+     AliDebug(4,Form(" %e",fZp[ik]));      
     } 
   
-    printf(" fR array\n"); 
+    AliDebug(4," fR array"); 
          
     for (ik=0; ik<10; ik++) 
     {    
      fscanf(magfile, " %e ", &rr); 
      fR[ik]=rr;
-     printf(" %e\n",fR[ik]);
+     AliDebug(4,Form(" %e",fR[ik]));
     } 
     
-//    printf("fPhi array\n"); 
+//    AliDebug(4,"fPhi array"); 
      
      for (il=0; il<33; il++)  
      {
        fscanf(magfile, " %e ", &phii); 
        fPhi[il]=phii; 
-//        printf(" %e\n",fPhi[il]);          
+//        AliDebug(4,Form(" %e",fPhi[il]));          
      }
 
     fscanf(magfile," %e %e %e %e %e %e %e ",&fZpdl,&fPhid,&fRdel,&fZpmx,&fZpmn,&fRmax, &fRmin); 
 
-printf("fZpdl %e, fPhid %e, fRdel %e, fZpmx %e, fZpmn %e,fRmax %e,fRmin %e \n", fZpdl,fPhid, fRdel,fZpmx, fZpmn,fRmax, fRmin);
+AliDebug(3,Form("fZpdl %e, fPhid %e, fRdel %e, fZpmx %e, fZpmn %e,fRmax %e,fRmin %e", fZpdl,fPhid, fRdel,fZpmx, fZpmn,fRmax, fRmin));
 
                       
     for (il=0; il<33; il++)  { 
@@ -766,7 +685,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);
+    AliFatal(Form("File %s not found !",fTitle.Data()));
   }
 }