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 //-----------------------------------------------------------------------
26 #include "AliMagFCM.h"
30 //_______________________________________________________________________
31 AliMagFCM::AliMagFCM():
48 // Standard constructor
55 //_______________________________________________________________________
56 AliMagFCM::AliMagFCM(const char *name, const char *title, const Int_t integ,
57 const Float_t factor, const Float_t fmax):
58 AliMagF(name,title,integ,factor,fmax),
75 // Standard constructor
81 if(fDebug>-1) Info("ctor",
82 "%s: Constant Mesh Field %s created: map= %d, factor= %f, file= %s\n",
83 ClassName(),fName.Data(), fMap, factor,fTitle.Data());
86 //_______________________________________________________________________
87 AliMagFCM::AliMagFCM(const AliMagFCM &magf):
110 //_______________________________________________________________________
111 void AliMagFCM::Field(Float_t *x, Float_t *b)
114 // Method to calculate the magnetic field
116 Double_t ratx, raty, ratz, hix, hiy, hiz, ratx1, raty1, ratz1,
117 bhyhz, bhylz, blyhz, blylz, bhz, blz, xl[3];
118 const Double_t kone=1;
121 // --- find the position in the grid ---
124 if(-700<x[2] && x[2]<fZbeg && x[0]*x[0]+(x[1]+30)*(x[1]+30) < 560*560) {
127 Bool_t infield=(fZbeg<=x[2] && x[2]<fZbeg+fZdel*(fZn-1)
128 && ( fXbeg <= TMath::Abs(x[0]) && TMath::Abs(x[0]) < fXbeg+fXdel*(fXn-1) )
129 && ( fYbeg <= TMath::Abs(x[1]) && TMath::Abs(x[1]) < fYbeg+fYdel*(fYn-1) ));
131 xl[0]=TMath::Abs(x[0])-fXbeg;
132 xl[1]=TMath::Abs(x[1])-fYbeg;
150 // ... simple interpolation
154 bhyhz = Bx(ix ,iy+1,iz+1)*ratx1+Bx(ix+1,iy+1,iz+1)*ratx;
155 bhylz = Bx(ix ,iy+1,iz )*ratx1+Bx(ix+1,iy+1,iz )*ratx;
156 blyhz = Bx(ix ,iy ,iz+1)*ratx1+Bx(ix+1,iy ,iz+1)*ratx;
157 blylz = Bx(ix ,iy ,iz )*ratx1+Bx(ix+1,iy ,iz )*ratx;
158 bhz = blyhz *raty1+bhyhz *raty;
159 blz = blylz *raty1+bhylz *raty;
160 b[0] = blz *ratz1+bhz *ratz;
162 bhyhz = By(ix ,iy+1,iz+1)*ratx1+By(ix+1,iy+1,iz+1)*ratx;
163 bhylz = By(ix ,iy+1,iz )*ratx1+By(ix+1,iy+1,iz )*ratx;
164 blyhz = By(ix ,iy ,iz+1)*ratx1+By(ix+1,iy ,iz+1)*ratx;
165 blylz = By(ix ,iy ,iz )*ratx1+By(ix+1,iy ,iz )*ratx;
166 bhz = blyhz *raty1+bhyhz *raty;
167 blz = blylz *raty1+bhylz *raty;
168 b[1] = blz *ratz1+bhz *ratz;
170 bhyhz = Bz(ix ,iy+1,iz+1)*ratx1+Bz(ix+1,iy+1,iz+1)*ratx;
171 bhylz = Bz(ix ,iy+1,iz )*ratx1+Bz(ix+1,iy+1,iz )*ratx;
172 blyhz = Bz(ix ,iy ,iz+1)*ratx1+Bz(ix+1,iy ,iz+1)*ratx;
173 blylz = Bz(ix ,iy ,iz )*ratx1+Bz(ix+1,iy ,iz )*ratx;
174 bhz = blyhz *raty1+bhyhz *raty;
175 blz = blylz *raty1+bhylz *raty;
176 b[2] = blz *ratz1+bhz *ratz;
177 //printf("ratx,raty,ratz,b[0],b[1],b[2] %f %f %f %f %f %f\n",
178 //ratx,raty,ratz,b[0],b[1],b[2]);
180 // ... use the dipole symmetry
181 if (x[0]*x[1] < 0) b[1]=-b[1];
182 if (x[0]<0) b[2]=-b[2];
184 printf("Invalid field map for constant mesh %d\n",fMap);
187 //This is the ZDC part
188 Float_t rad2=x[0]*x[0]+x[1]*x[1];
189 if(x[2]>kCORBEG2 && x[2]<kCOREND2){
194 else if(x[2]>kZ1BEG && x[2]<kZ1END){
200 else if(x[2]>kZ2BEG && x[2]<kZ2END){
206 else if(x[2]>kZ3BEG && x[2]<kZ3END){
212 else if(x[2]>kZ4BEG && x[2]<kZ4END){
218 else if(x[2]>kD1BEG && x[2]<kD1END){
223 else if(x[2]>kD2BEG && x[2]<kD2END){
224 if(((x[0]-kXCEN1D2)*(x[0]-kXCEN1D2)+(x[1]-kYCEN1D2)*(x[1]-kYCEN1D2))<kD2RA2
225 || ((x[0]-kXCEN2D2)*(x[0]-kXCEN2D2)+(x[1]-kYCEN2D2)*(x[1]-kYCEN2D2))<kD2RA2){
239 //_______________________________________________________________________
240 void AliMagFCM::ReadField()
243 // Method to read the magnetic field map from file
246 Int_t ix, iy, iz, ipx, ipy, ipz;
249 if(fDebug) printf("%s: Reading Magnetic Field %s from file %s\n",ClassName(),fName.Data(),fTitle.Data());
250 fname = gSystem->ExpandPathName(fTitle.Data());
251 magfile=fopen(fname,"r");
254 fscanf(magfile,"%d %d %d %f %f %f %f %f %f",
255 &fXn, &fYn, &fZn, &fXdel, &fYdel, &fZdel, &fXbeg, &fYbeg, &fZbeg);
256 if(fDebug>1) printf("%s: fXn %d, fYn %d, fZn %d, fXdel %f, fYdel %f, fZdel %f, fXbeg %f, fYbeg %f, fZbeg %f\n",
257 ClassName(),fXn, fYn, fZn, fXdel, fYdel, fZdel, fXbeg, fYbeg, fZbeg);
261 fB = new TVector(3*fXn*fYn*fZn);
262 for (iz=0; iz<fZn; iz++) {
264 for (iy=0; iy<fYn; iy++) {
266 for (ix=0; ix<fXn; ix++) {
268 fscanf(magfile,"%f %f %f",&bz,&by,&bx);
276 printf("%s: File %s not found !\n",ClassName(),fTitle.Data());
281 //_______________________________________________________________________
282 void AliMagFCM::Copy(AliMagFCM & /* magf */) const
285 // Copy *this onto magf -- Not implemented
287 Fatal("Copy","Not implemented!\n");