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 //-----------------------------------------------------------------------
29 #include "AliMagFCM.h"
33 //_______________________________________________________________________
34 AliMagFCM::AliMagFCM():
51 // Standard constructor
58 //_______________________________________________________________________
59 AliMagFCM::AliMagFCM(const char *name, const char *title, Int_t integ,
60 Float_t factor, Float_t fmax):
61 AliMagFC(name,title,integ,factor,fmax),
78 // Standard constructor
85 "Constant Mesh Field %s created: map= %d, factor= %f, file= %s",
86 fName.Data(), fMap, factor,fTitle.Data()));
89 //_______________________________________________________________________
90 AliMagFCM::AliMagFCM(const AliMagFCM &magf):
113 //_______________________________________________________________________
114 void AliMagFCM::Field(Float_t *x, Float_t *b) const
117 // Method to calculate the magnetic field
119 Double_t ratx, raty, ratz, hix, hiy, hiz, ratx1, raty1, ratz1,
120 bhyhz, bhylz, blyhz, blylz, bhz, blz, xl[3];
121 const Double_t kone=1;
124 // --- find the position in the grid ---
129 if(-700 < -x[2] && -x[2] < fZbeg && x[0] * x[0] +(x[1]+30)*(x[1]+30) < 560*560) {
132 // The field map used here was calculated in a coordinate system where the muon arm is at z > 0
133 // Transfom x -> -x and z -> -z
138 Bool_t infield=(fZbeg <= zm && zm < fZbeg+fZdel*(fZn-1)
139 && ( fXbeg <= TMath::Abs(xm) && TMath::Abs(xm) < fXbeg+fXdel*(fXn-1) )
140 && ( fYbeg <= TMath::Abs(ym) && TMath::Abs(ym) < fYbeg+fYdel*(fYn-1) ));
142 xl[0]=TMath::Abs(xm)-fXbeg;
143 xl[1]=TMath::Abs(ym)-fYbeg;
161 // ... simple interpolation
165 bhyhz = Bx(ix ,iy+1,iz+1)*ratx1+Bx(ix+1,iy+1,iz+1)*ratx;
166 bhylz = Bx(ix ,iy+1,iz )*ratx1+Bx(ix+1,iy+1,iz )*ratx;
167 blyhz = Bx(ix ,iy ,iz+1)*ratx1+Bx(ix+1,iy ,iz+1)*ratx;
168 blylz = Bx(ix ,iy ,iz )*ratx1+Bx(ix+1,iy ,iz )*ratx;
169 bhz = blyhz *raty1+bhyhz *raty;
170 blz = blylz *raty1+bhylz *raty;
171 b[0] = blz *ratz1+bhz *ratz;
173 bhyhz = By(ix ,iy+1,iz+1)*ratx1+By(ix+1,iy+1,iz+1)*ratx;
174 bhylz = By(ix ,iy+1,iz )*ratx1+By(ix+1,iy+1,iz )*ratx;
175 blyhz = By(ix ,iy ,iz+1)*ratx1+By(ix+1,iy ,iz+1)*ratx;
176 blylz = By(ix ,iy ,iz )*ratx1+By(ix+1,iy ,iz )*ratx;
177 bhz = blyhz *raty1+bhyhz *raty;
178 blz = blylz *raty1+bhylz *raty;
179 b[1] = blz *ratz1+bhz *ratz;
181 bhyhz = Bz(ix ,iy+1,iz+1)*ratx1+Bz(ix+1,iy+1,iz+1)*ratx;
182 bhylz = Bz(ix ,iy+1,iz )*ratx1+Bz(ix+1,iy+1,iz )*ratx;
183 blyhz = Bz(ix ,iy ,iz+1)*ratx1+Bz(ix+1,iy ,iz+1)*ratx;
184 blylz = Bz(ix ,iy ,iz )*ratx1+Bz(ix+1,iy ,iz )*ratx;
185 bhz = blyhz *raty1+bhyhz *raty;
186 blz = blylz *raty1+bhylz *raty;
187 b[2] = blz *ratz1+bhz *ratz;
188 //printf("ratx,raty,ratz,b[0],b[1],b[2] %f %f %f %f %f %f\n",
189 //ratx,raty,ratz,b[0],b[1],b[2]);
191 // ... use the dipole symmetry
192 if (xm*ym < 0) b[1]=-b[1];
193 if (xm<0) b[2]=-b[2];
198 AliError(Form("Invalid field map for constant mesh %d",fMap));
201 //This is the ZDC part
213 //_______________________________________________________________________
214 void AliMagFCM::ReadField()
217 // Method to read the magnetic field map from file
220 Int_t ix, iy, iz, ipx, ipy, ipz;
223 AliDebug(1,Form("Reading Magnetic Field %s from file %s",fName.Data(),fTitle.Data()));
224 fname = gSystem->ExpandPathName(fTitle.Data());
225 magfile=fopen(fname,"r");
228 fscanf(magfile,"%d %d %d %f %f %f %f %f %f",
229 &fXn, &fYn, &fZn, &fXdel, &fYdel, &fZdel, &fXbeg, &fYbeg, &fZbeg);
230 AliDebug(2,Form("fXn %d, fYn %d, fZn %d, fXdel %f, fYdel %f, fZdel %f, fXbeg %f, fYbeg %f, fZbeg %f",
231 fXn, fYn, fZn, fXdel, fYdel, fZdel, fXbeg, fYbeg, fZbeg));
235 fB = new TVector(3*fXn*fYn*fZn);
236 for (iz=0; iz<fZn; iz++) {
238 for (iy=0; iy<fYn; iy++) {
240 for (ix=0; ix<fXn; ix++) {
242 fscanf(magfile,"%f %f %f",&bz,&by,&bx);
250 AliFatal(Form("File %s not found !",fTitle.Data()));
254 //_______________________________________________________________________
255 void AliMagFCM::Copy(TObject & /* magf */) const
258 // Copy *this onto magf -- Not implemented
260 AliFatal("Not implemented!");