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 Revision 1.3 1999/09/29 09:24:29 fca
19 Introduction of the Copyright and cvs Log
29 //ZDC part -------------------------------------------------------------------
31 static const Float_t G1=20.03;
32 static const Float_t FDIP=-37.34;
33 static const Float_t FDIMU=6.;
34 static const Float_t FCORN=11.72;
36 // ZBEG Beginning of the inner triplet
37 // D1BEG Beginning of separator dipole 1
38 // D2BEG Beginning of separator dipole 2
39 // CORBEG Corrector dipole beginning (because of dimuon arm)
41 static const Float_t CORBEG=1920,COREND=CORBEG+190, CORRA2=4.5*4.5;
43 static const Float_t ZBEG=2300;
44 static const Float_t Z1BEG=ZBEG+ 0,Z1END=Z1BEG+630,Z1RA2=3.5*3.5;
45 static const Float_t Z2BEG=ZBEG+ 880,Z2END=Z2BEG+550,Z2RA2=3.5*3.5;
46 static const Float_t Z3BEG=ZBEG+1530,Z3END=Z3BEG+550,Z3RA2=3.5*3.5;
47 static const Float_t Z4BEG=ZBEG+2430,Z4END=Z4BEG+630,Z4RA2=3.5*3.5;
48 static const Float_t D1BEG=5843.5 ,D1END=D1BEG+945,D1RA2=4.5*4.5;
49 static const Float_t D2BEG=12113.2 ,D2END=D2BEG+945,D2RA2=4.5*.5;
51 //ZDC part -------------------------------------------------------------------
55 //________________________________________
56 AliMagF::AliMagF(const char *name, const char *title, const Int_t integ, const Int_t map,
57 const Float_t factor, const Float_t fmax)
67 //________________________________________
68 void AliMagF::Field(Float_t*, Float_t *b)
70 printf("Undefined MagF Field called, returning 0\n");
76 //________________________________________
77 AliMagFC::AliMagFC(const char *name, const char *title, const Int_t integ, const Int_t map,
78 const Float_t factor, const Float_t fmax)
79 : AliMagF(name,title,integ,map,factor,fmax)
81 printf("Constant Field %s created: map= %d, factor= %f\n",fName.Data(),map,factor);
85 //________________________________________
86 void AliMagFC::Field(Float_t *x, Float_t *b)
90 if(TMath::Abs(x[2])<700 && x[0]*x[0]+(x[1]+30)*(x[1]+30) < 560*560) {
93 if ( 725 <= x[2] && x[2] <= 1225 ) {
94 Float_t dz = TMath::Abs(975-x[2])*0.01;
98 //This is the ZDC part
99 Float_t rad2=x[0]*x[0]+x[1]*x[1];
103 // Separator Dipole D2
104 if(x[2]<D2END) b[1]=FDIP;
105 } else if(x[2]>D1BEG) {
107 // Separator Dipole D1
108 if(x[2]<D1END) b[1]=-FDIP;
112 // First quadrupole of inner triplet de-focussing in x-direction
121 } else if(x[2]>Z3BEG) {
128 } else if(x[2]>Z2BEG) {
135 } else if(x[2]>Z1BEG) {
142 } else if(x[2]>CORBEG) {
144 // Corrector dipole (because of dimuon arm)
158 printf("Invalid field map for constant field %d\n",fMap);
165 //________________________________________
166 AliMagFCM::AliMagFCM(const char *name, const char *title, const Int_t integ, const Int_t map,
167 const Float_t factor, const Float_t fmax)
168 : AliMagF(name,title,integ,map,factor,fmax)
171 printf("Constant Mesh Field %s created: map= %d, factor= %f, file= %s\n",fName.Data(),map,factor,fTitle.Data());
174 //________________________________________
175 void AliMagFCM::Field(Float_t *x, Float_t *b)
177 Double_t ratx, raty, ratz, hix, hiy, hiz, ratx1, raty1, ratz1,
178 bhyhz, bhylz, blyhz, blylz, bhz, blz, xl[3];
179 const Double_t one=1;
182 // --- find the position in the grid ---
185 if(-700<x[2] && x[2]<fZbeg && x[0]*x[0]+(x[1]+30)*(x[1]+30) < 560*560) {
188 Bool_t infield=(fZbeg<=x[2] && x[2]<fZbeg+fZdel*(fZn-1)
189 && ( fXbeg <= TMath::Abs(x[0]) && TMath::Abs(x[0]) < fXbeg+fXdel*(fXn-1) )
190 && ( fYbeg <= TMath::Abs(x[1]) && TMath::Abs(x[1]) < fYbeg+fYdel*(fYn-1) ));
192 xl[0]=TMath::Abs(x[0])-fXbeg;
193 xl[1]=TMath::Abs(x[1])-fYbeg;
211 // ... simple interpolation
215 bhyhz = Bx(ix ,iy+1,iz+1)*ratx1+Bx(ix+1,iy+1,iz+1)*ratx;
216 bhylz = Bx(ix ,iy+1,iz )*ratx1+Bx(ix+1,iy+1,iz )*ratx;
217 blyhz = Bx(ix ,iy ,iz+1)*ratx1+Bx(ix+1,iy ,iz+1)*ratx;
218 blylz = Bx(ix ,iy ,iz )*ratx1+Bx(ix+1,iy ,iz )*ratx;
219 bhz = blyhz *raty1+bhyhz *raty;
220 blz = blylz *raty1+bhylz *raty;
221 b[0] = blz *ratz1+bhz *ratz;
223 bhyhz = By(ix ,iy+1,iz+1)*ratx1+By(ix+1,iy+1,iz+1)*ratx;
224 bhylz = By(ix ,iy+1,iz )*ratx1+By(ix+1,iy+1,iz )*ratx;
225 blyhz = By(ix ,iy ,iz+1)*ratx1+By(ix+1,iy ,iz+1)*ratx;
226 blylz = By(ix ,iy ,iz )*ratx1+By(ix+1,iy ,iz )*ratx;
227 bhz = blyhz *raty1+bhyhz *raty;
228 blz = blylz *raty1+bhylz *raty;
229 b[1] = blz *ratz1+bhz *ratz;
231 bhyhz = Bz(ix ,iy+1,iz+1)*ratx1+Bz(ix+1,iy+1,iz+1)*ratx;
232 bhylz = Bz(ix ,iy+1,iz )*ratx1+Bz(ix+1,iy+1,iz )*ratx;
233 blyhz = Bz(ix ,iy ,iz+1)*ratx1+Bz(ix+1,iy ,iz+1)*ratx;
234 blylz = Bz(ix ,iy ,iz )*ratx1+Bz(ix+1,iy ,iz )*ratx;
235 bhz = blyhz *raty1+bhyhz *raty;
236 blz = blylz *raty1+bhylz *raty;
237 b[2] = blz *ratz1+bhz *ratz;
238 //printf("ratx,raty,ratz,b[0],b[1],b[2] %f %f %f %f %f %f\n",
239 //ratx,raty,ratz,b[0],b[1],b[2]);
241 // ... use the dipole symmetry
242 if (x[0]*x[1] < 0) b[1]=-b[1];
243 if (x[0]<0) b[2]=-b[2];
245 printf("Invalid field map for constant mesh %d\n",fMap);
248 //This is the ZDC part
249 Float_t rad2=x[0]*x[0]+x[1]*x[1];
253 // Separator Dipole D2
254 if(x[2]<D2END) b[1]=FDIP;
255 } else if(x[2]>D1BEG) {
257 // Separator Dipole D1
258 if(x[2]<D1END) b[1]=-FDIP;
262 // First quadrupole of inner triplet de-focussing in x-direction
271 } else if(x[2]>Z3BEG) {
278 } else if(x[2]>Z2BEG) {
285 } else if(x[2]>Z1BEG) {
292 } else if(x[2]>CORBEG) {
294 // Corrector dipole (because of dimuon arm)
309 //________________________________________
310 void AliMagFCM::ReadField()
313 Int_t ix, iy, iz, ipx, ipy, ipz;
316 printf("Reading Magnetic Field %s from file %s\n",fName.Data(),fTitle.Data());
317 fname = gSystem->ExpandPathName(fTitle.Data());
318 magfile=fopen(fname,"r");
321 fscanf(magfile,"%d %d %d %f %f %f %f %f %f",
322 &fXn, &fYn, &fZn, &fXdel, &fYdel, &fZdel, &fXbeg, &fYbeg, &fZbeg);
323 printf("fXn %d, fYn %d, fZn %d, fXdel %f, fYdel %f, fZdel %f, fXbeg %f, fYbeg %f, fZbeg %f\n",
324 fXn, fYn, fZn, fXdel, fYdel, fZdel, fXbeg, fYbeg, fZbeg);
328 fB = new TVector(3*fXn*fYn*fZn);
329 for (iz=0; iz<fZn; iz++) {
331 for (iy=0; iy<fYn; iy++) {
333 for (ix=0; ix<fXn; ix++) {
335 fscanf(magfile,"%f %f %f",&bz,&by,&bx);
343 printf("File %s not found !\n",fTitle.Data());