1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 //-----------------------------------------------------------------------
19 // Class for Alice magnetic field with constant mesh
20 // Used in the configuration macros (macros/Config.C, etc.)
22 //-----------------------------------------------------------------------
27 #include "AliMagFCM.h"
31 //_______________________________________________________________________
32 AliMagFCM::AliMagFCM():
49 // Standard constructor
56 //_______________________________________________________________________
57 AliMagFCM::AliMagFCM(const char *name, const char *title, Int_t integ,
58 Float_t factor, Float_t fmax):
59 AliMagFC(name,title,integ,factor,fmax),
76 // Standard constructor
82 if(fDebug>-1) Info("ctor",
83 "%s: Constant Mesh Field %s created: map= %d, factor= %f, file= %s\n",
84 ClassName(),fName.Data(), fMap, factor,fTitle.Data());
87 //_______________________________________________________________________
88 AliMagFCM::AliMagFCM(const AliMagFCM &magf):
111 //_______________________________________________________________________
112 void AliMagFCM::Field(Float_t *x, Float_t *b)
115 // Method to calculate the magnetic field
117 Double_t ratx, raty, ratz, hix, hiy, hiz, ratx1, raty1, ratz1,
118 bhyhz, bhylz, blyhz, blylz, bhz, blz, xl[3];
119 const Double_t kone=1;
122 // --- find the position in the grid ---
127 if(-700 < -x[2] && -x[2] < fZbeg && x[0] * x[0] +(x[1]+30)*(x[1]+30) < 560*560) {
130 // The field map used here was calculated in a coordinate system where the muon arm is at z > 0
131 // Transfom x -> -x and z -> -z
136 Bool_t infield=(fZbeg <= zm && zm < fZbeg+fZdel*(fZn-1)
137 && ( fXbeg <= TMath::Abs(xm) && TMath::Abs(xm) < fXbeg+fXdel*(fXn-1) )
138 && ( fYbeg <= TMath::Abs(ym) && TMath::Abs(ym) < fYbeg+fYdel*(fYn-1) ));
140 xl[0]=TMath::Abs(xm)-fXbeg;
141 xl[1]=TMath::Abs(ym)-fYbeg;
159 // ... simple interpolation
163 bhyhz = Bx(ix ,iy+1,iz+1)*ratx1+Bx(ix+1,iy+1,iz+1)*ratx;
164 bhylz = Bx(ix ,iy+1,iz )*ratx1+Bx(ix+1,iy+1,iz )*ratx;
165 blyhz = Bx(ix ,iy ,iz+1)*ratx1+Bx(ix+1,iy ,iz+1)*ratx;
166 blylz = Bx(ix ,iy ,iz )*ratx1+Bx(ix+1,iy ,iz )*ratx;
167 bhz = blyhz *raty1+bhyhz *raty;
168 blz = blylz *raty1+bhylz *raty;
169 b[0] = blz *ratz1+bhz *ratz;
171 bhyhz = By(ix ,iy+1,iz+1)*ratx1+By(ix+1,iy+1,iz+1)*ratx;
172 bhylz = By(ix ,iy+1,iz )*ratx1+By(ix+1,iy+1,iz )*ratx;
173 blyhz = By(ix ,iy ,iz+1)*ratx1+By(ix+1,iy ,iz+1)*ratx;
174 blylz = By(ix ,iy ,iz )*ratx1+By(ix+1,iy ,iz )*ratx;
175 bhz = blyhz *raty1+bhyhz *raty;
176 blz = blylz *raty1+bhylz *raty;
177 b[1] = blz *ratz1+bhz *ratz;
179 bhyhz = Bz(ix ,iy+1,iz+1)*ratx1+Bz(ix+1,iy+1,iz+1)*ratx;
180 bhylz = Bz(ix ,iy+1,iz )*ratx1+Bz(ix+1,iy+1,iz )*ratx;
181 blyhz = Bz(ix ,iy ,iz+1)*ratx1+Bz(ix+1,iy ,iz+1)*ratx;
182 blylz = Bz(ix ,iy ,iz )*ratx1+Bz(ix+1,iy ,iz )*ratx;
183 bhz = blyhz *raty1+bhyhz *raty;
184 blz = blylz *raty1+bhylz *raty;
185 b[2] = blz *ratz1+bhz *ratz;
186 //printf("ratx,raty,ratz,b[0],b[1],b[2] %f %f %f %f %f %f\n",
187 //ratx,raty,ratz,b[0],b[1],b[2]);
189 // ... use the dipole symmetry
190 if (xm*ym < 0) b[1]=-b[1];
191 if (xm<0) b[2]=-b[2];
196 printf("Invalid field map for constant mesh %d\n",fMap);
199 //This is the ZDC part
211 //_______________________________________________________________________
212 void AliMagFCM::ReadField()
215 // Method to read the magnetic field map from file
218 Int_t ix, iy, iz, ipx, ipy, ipz;
221 if(fDebug) printf("%s: Reading Magnetic Field %s from file %s\n",ClassName(),fName.Data(),fTitle.Data());
222 fname = gSystem->ExpandPathName(fTitle.Data());
223 magfile=fopen(fname,"r");
226 fscanf(magfile,"%d %d %d %f %f %f %f %f %f",
227 &fXn, &fYn, &fZn, &fXdel, &fYdel, &fZdel, &fXbeg, &fYbeg, &fZbeg);
228 if(fDebug>1) printf("%s: fXn %d, fYn %d, fZn %d, fXdel %f, fYdel %f, fZdel %f, fXbeg %f, fYbeg %f, fZbeg %f\n",
229 ClassName(),fXn, fYn, fZn, fXdel, fYdel, fZdel, fXbeg, fYbeg, fZbeg);
233 fB = new TVector(3*fXn*fYn*fZn);
234 for (iz=0; iz<fZn; iz++) {
236 for (iy=0; iy<fYn; iy++) {
238 for (ix=0; ix<fXn; ix++) {
240 fscanf(magfile,"%f %f %f",&bz,&by,&bx);
248 printf("%s: File %s not found !\n",ClassName(),fTitle.Data());
253 //_______________________________________________________________________
254 void AliMagFCM::Copy(TObject & /* magf */) const
257 // Copy *this onto magf -- Not implemented
259 Fatal("Copy","Not implemented!\n");