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 2000/07/13 16:19:09 fca
19 Mainly coding conventions + some small bug fixes
21 Revision 1.2 2000/07/12 08:56:25 fca
22 Coding convention correction and warning removal
24 Revision 1.1 2000/07/11 18:24:59 fca
25 Coding convention corrections + few minor bug fixes
31 #include "AliMagFDM.h"
37 //________________________________________
38 AliMagFDM::AliMagFDM(const char *name, const char *title, const Int_t integ,
39 const Int_t map, const Float_t factor, const Float_t fmax)
40 : AliMagF(name,title,integ,map,factor,fmax)
44 // Standard constructor for the Dipole field
48 printf("Field Map for Muon Arm from IP till muon filter %s created: map= %d, factor= %f, file=%s\n",fName.Data(),map,factor,fTitle.Data());
52 //________________________________________
54 void AliMagFDM::Field(Float_t *xfi, Float_t *b)
57 // Main routine to compute the field in a point
59 static const Double_t keps=0.1E-06;
60 static const Double_t kpi2=.6283185E+01;
61 static const Double_t kone=1;
63 static const Int_t kiip=33;
64 static const Int_t kmiip=0;
65 static const Int_t kliip=0;
67 static const Int_t kiic=0;
68 static const Int_t kmiic=0;
69 static const Int_t kliic=0;
71 static const Double_t kfdZbg=502.92; // Start of Map using in z
72 static const Double_t kfdZL3=600; // Beginning of L3 door in z
83 Double_t zp1, zp2,xp1,xp2,yp1,yp2;
84 Double_t zz1, zz2,yy1,yy2,x2,x1;
86 // --- start the map fiel from z = 502.92 cm ---
92 // printf("x[0] %f,x[1] %f,x[2] %f\n",x[0],x[1],x[2]);
94 Double_t rr=TMath::Sqrt(x[0]*x[0]+x[1]*x[1]);
98 if ( (-700<x[2] && x[2]<=kfdZbg &&
99 (x[0]*x[0]+(x[1]+30)*(x[1]+30))< 560*560)
100 || (kfdZbg<x[2] && x[2]<=kfdZL3 && rr>=rPmax*100) )
106 xL3[1]=(x[1]+30)/100;
109 Double_t xminn=xL3[2]*fdAx1+fdCx1;
110 Double_t xmaxx=xL3[2]*fdAx2+fdCx2;
111 Double_t zCmin,zCmax,yCmin,yCmax;
118 if ((kfdZbg/100<xL3[2] && xL3[2]<zCmin && r0<rPmax) || ((zCmin<=xL3[2] && xL3[2] <= zCmax ) && (yCmin<=xL3[1] && xL3[1]<= yCmax) && (xminn <= xL3[0] && xL3[0] <= xmaxx)))
122 if (xL3[2]<zCmin && r0<rPmax)
124 //--------------------- Polar part ----------------------
129 Double_t alp1,alp2,alp3;
130 Double_t zpz,rp,fip,cphi;
138 FZ(&zpz, fdZp ,&fdZpdl,&kpi,&kp0,&zp1 ,&zp2,&fdZpl) ;
142 ph0=TMath::ACos(cphi);
143 if (xL3[0]< 0) {ph0=kpi2 - ph0;}
146 FZ(&fip,fdPhi,&fdPhid ,&mpi,&mp0, &xp1,&xp2,&fdPhin);
157 bint[0]=(zp1*fdBpx[kp0][0][0] + zp2*fdBpx[kp0+1][0][0])*10;
158 bint[1]=(zp1*fdBpy[kp0][0][0] + zp2*fdBpy[kp0+1][0][0])*10;
159 bint[2]=(zp1*fdBpz[kp0][0][0] + zp2*fdBpz[kp0+1][0][0])*10;
163 alp2= fdB[0][0][mp0]*yyp + fdB[0][1][mp0]*xL3[0];
164 alp3= fdB[1][0][mp0]*yyp + fdB[1][1][mp0]*xL3[0];
165 alp1= kone - alp2 - alp3;
167 for (jb=0; jb<3 ; jb++)
170 FRfuncBi(&iKvar,&zp1,&zp2,&alp1,&alp2,&alp3, &kp0,&mp0, &bbj);
178 FZ(&rp,fdR ,&fdRdel,&lpi,&lp0,&yp1,&yp2,&fdRn);
180 for (jb=0; jb<3 ; jb++)
183 FGfuncBi(&zp1,&zp2,&yp1,&yp2,&xp1,&xp2,&iKvar,&kp0,&lp0,&mp0,&bbj);
193 // fprintf(fitest,"------------- Freg2 run -------------\n");
198 //-------------- Cartensian part ------------------
202 Double_t xx1, xx2,dx, xxx ,xXl;
209 xx1 = fdAx1*xL3[2] + fdCx1;
210 xx2 = fdAx2*xL3[2] + fdCx2;
213 FZ(&zzc, fdZc ,&fdZdel, &kci,&k0, &zz1, &zz2, &fdZl);
216 FZ(&yyc, fdY , &fdYdel,&lci, &l0, &yy1, &yy2,&fdYl);
224 if(xL3[0]<(xx1+m0*dx) || xL3[0] >(xx1+(m0+1)*dx))
227 printf(" m0 %d, m0+1 %d\n",m0,m0+1);
230 x2=(xL3[0]-( xx1+m0*dx))/dx;
233 for (jb=3; jb<6; jb++)
236 FGfuncBi(&zz1,&zz2,&yy1,&yy2,&x1,&x2,&iKvar,&k0, &l0, &m0, &bbj);
237 bint[jb-3] = bbj*10 ;
244 // fprintf(fitest,"------------ Freg1 run -----------------\n");
248 printf("Unknown map of Dipole region %d\n",fMap);
253 //This is the ZDC part
254 Float_t rad2=x[0]*x[0]+x[1]*x[1];
258 // Separator Dipole D2
259 if(x[2]<kD2END) b[1]=kFDIP;
260 } else if(x[2]>kD1BEG) {
262 // Separator Dipole D1
263 if(x[2]<kD1END) b[1]=-kFDIP;
267 // First quadrupole of inner triplet de-focussing in x-direction
276 } else if(x[2]>kZ3BEG) {
283 } else if(x[2]>kZ2BEG) {
290 } else if(x[2]>kZ1BEG) {
297 } else if(x[2]>kCORBEG) {
299 // Corrector dipole (because of dimuon arm)
315 //_________________________________________
317 void AliMagFDM::FZ(Double_t *u, Float_t *Ar, Float_t *du,Int_t *ki,Int_t *kf,Double_t *a1,Double_t *a2 ,Int_t *nu)
320 // Z component of the field
322 static const Double_t kone=1;
325 Double_t ddu,delu,ar;
340 for(l=ikj; l<nk; l++)
346 *a2=(temp-Ar[l])/(Ar[l+1]-Ar[l]);
353 /*-------------FRfuncBi----------------*/
355 void AliMagFDM::FRfuncBi(Int_t *kai,Double_t *za1, Double_t *za2, Double_t *al1, Double_t *al2, Double_t *al3, Int_t *ka, Int_t *ma, Double_t *ba)
358 // This method needs to be commented
360 Double_t fa11,fa12,fa13;
361 Double_t fa21,fa22,fa23;
365 Double_t zaa1,zaa2,alf1,alf2,alf3;
378 fa11 = fdBpx[kaa][0][0];
379 fa12 = fdBpx[kaa][0][maa];
380 fa13 = fdBpx[kaa][0][maa+1];
381 fa21 = fdBpx[kaa+1][0][0];
382 fa22 = fdBpx[kaa+1][0][maa];
383 fa23 = fdBpx[kaa+1][0][maa+1];
386 fa11 = fdBpy[kaa][0][0];
387 fa12 = fdBpy[kaa][0][maa];
388 fa13 = fdBpy[kaa][0][maa+1];
389 fa21 = fdBpy[kaa+1][0][0];
390 fa22 = fdBpy[kaa+1][0][maa];
391 fa23 = fdBpy[kaa+1][0][maa+1];
394 fa11 = fdBpz[kaa][0][0];
395 fa12 = fdBpz[kaa][0][maa];
396 fa13 = fdBpz[kaa][0][maa+1];
397 fa21 = fdBpz[kaa+1][0][0];
398 fa22 = fdBpz[kaa+1][0][maa];
399 fa23 = fdBpz[kaa+1][0][maa+1];
402 Fatal("FRfuncBi","Invalid value of kaai %d\n",kaai);
405 faY1=alf1*fa11+alf2*fa12+alf3*fa13;
406 faY2=alf1*fa21+alf2*fa22+alf3*fa23;
407 bba = zaa1*faY1+zaa2*faY2;
413 /*----------- FGfuncBi------------*/
415 void AliMagFDM::FGfuncBi(Double_t *zz1,Double_t *zz2, Double_t *yy1,Double_t *yy2, Double_t *xx1,Double_t *xx2, Int_t *kvr, Int_t *kk, Int_t *ll, Int_t *mm, Double_t *bb)
418 // This method needs to be commented
420 Double_t fy1, fy2, ffy;
421 Double_t gy1,gy2,ggy;
422 Double_t z1,z2,y1,y2,x1,x2;
427 Double_t bf11,bf12,bf21,bf22;
428 Double_t bg11,bg12,bg21,bg22;
442 /*-----------------Polar part ------------------*/
447 bf12=fdBpx[k+1][l][m];
448 bf21=fdBpx[k+1][l+1][m];
449 bf22=fdBpx[k][l+1][m];
451 bg11=fdBpx[k][l][m+1];
452 bg12=fdBpx[k+1][l][m+1];
453 bg21=fdBpx[k+1][l+1][m+1];
454 bg22=fdBpx[k][l+1][m+1];
459 bf12=fdBpy[k+1][l][m];
460 bf21=fdBpy[k+1][l+1][m];
461 bf22=fdBpy[k][l+1][m];
463 bg11=fdBpy[k][l][m+1];
464 bg12=fdBpy[k+1][l][m+1];
465 bg21=fdBpy[k+1][l+1][m+1];
466 bg22=fdBpy[k][l+1][m+1];
471 bf12=fdBpz[k+1][l][m];
472 bf21=fdBpz[k+1][l+1][m];
473 bf22=fdBpz[k][l+1][m];
475 bg11=fdBpz[k][l][m+1];
476 bg12=fdBpz[k+1][l][m+1];
477 bg21=fdBpz[k+1][l+1][m+1];
478 bg22=fdBpz[k][l+1][m+1];
480 /*-----------------Cartensian part ---------------*/
484 bf12=fdBcx[k+1][l][m];
485 bf21=fdBcx[k+1][l+1][m];
486 bf22=fdBcx[k][l+1][m];
488 bg11=fdBcx[k][l][m+1];
489 bg12=fdBcx[k+1][l][m+1];
490 bg21=fdBcx[k+1][l+1][m+1];
491 bg22=fdBcx[k][l+1][m+1];
496 bf12=fdBcy[k+1][l][m];
497 bf21=fdBcy[k+1][l+1][m];
498 bf22=fdBcy[k][l+1][m];
500 bg11=fdBcy[k][l][m+1];
501 bg12=fdBcy[k+1][l][m+1];
502 bg21=fdBcy[k+1][l+1][m+1];
503 bg22=fdBcy[k][l+1][m+1];
508 bf12=fdBcz[k+1][l][m];
509 bf21=fdBcz[k+1][l+1][m];
510 bf22=fdBcz[k][l+1][m];
512 bg11=fdBcz[k][l][m+1];
513 bg12=fdBcz[k+1][l][m+1];
514 bg21=fdBcz[k+1][l+1][m+1];
515 bg22=fdBcz[k][l+1][m+1];
519 Fatal("FGfuncBi","Invalid value of kv %d\n",kv);
526 fy2=z2*bf21+z1* bf22;
530 gy1 = z1*bg11+z2*bg12;
531 gy2 = z2*bg21+z1*bg22;
532 ggy= y1*gy1 + y2*gy2;
539 //____________________________________________
541 void AliMagFDM::ReadField()
544 // Method to read the magnetic field from file
549 Float_t zzp, rr,phii;
550 Float_t zz, yy, bx,by,bz,bb;
553 printf("Reading Magnetic Field %s from file %s\n",fName.Data(),fTitle.Data());
554 fname = gSystem->ExpandPathName(fTitle.Data());
555 magfile=fopen(fname,"r");
558 printf("Cartensian part\n");
564 fscanf(magfile,"%d %d %d ",&fdYl, &fdXl, &fdZl);
566 printf("fdYl %d, fdXl %d, fdZl %d\n",fdYl, fdXl, fdZl);
568 for (ik=0; ik<fdZl; ik++)
571 fscanf(magfile, " %e ", &zz);
576 for (ik=0; ik<fdYl; ik++)
578 fscanf(magfile, " %e ", &yy);
582 for (ik=0; ik<81; ik++)
584 printf("fdZc %e,fdY %e\n", fdZc[ik],fdY[ik]);
587 fscanf(magfile," %e %e %e %e %e %e %e %e %e %e %e ", &fdYdel,&fdXdel,&fdZdel,&fdZmax,&fdZmin,&fdYmax,&fdYmin,&fdAx1,&fdCx1,&fdAx2,&fdCx2);
589 printf("fdYdel %e, fdXdel %e, fdZdel %e\n",fdYdel,fdXdel,fdZdel);
590 printf("fdZmax %e, fdZmin %e, fdYmax %e,fdYmin %e\n",fdZmax,fdZmin,fdYmax,fdYmin);
591 printf("fdAx1 %e, fdCx1 %e, fdAx2 %e, fdCx %e\n",fdAx1,fdCx1,fdAx2,fdCx2);
593 for (il=0; il<44; il++) {
594 for (im=0; im<81; im++) {
595 for (ik=0; ik<81; ik++) {
597 fscanf(magfile, " %e ", &by);
598 fdBcy[ik][im][il]=by;
603 for (il=0; il<44; il++) {
604 for (im=0; im<81; im++) {
605 for (ik=0; ik<81; ik++) {
607 fscanf(magfile, " %e ", &bx);
608 fdBcx[ik][im][il]=bx;
613 for (il=0; il<44; il++) {
614 for (im=0; im<81; im++) {
615 for (ik=0; ik<81; ik++) {
617 fscanf(magfile, " %e ", &bz);
618 fdBcz[ik][im][il]=bz;
622 //---------------------- Polar part ---------------------------------
624 printf("Polar part\n");
625 fscanf(magfile,"%d %d %d ", &fdZpl, &fdRn, &fdPhin);
626 printf("fdZpl %d, fdRn %d, fdPhin %d\n",fdZpl,fdRn,fdPhin);
628 printf(" fdZp array\n");
630 for (ik=0; ik<51; ik++)
632 fscanf(magfile, " %e ", &zzp);
634 printf(" %e\n",fdZp[ik]);
637 printf(" fdR array\n");
639 for (ik=0; ik<10; ik++)
641 fscanf(magfile, " %e ", &rr);
643 printf(" %e\n",fdR[ik]);
646 // printf("fdPhi array\n");
648 for (il=0; il<33; il++)
650 fscanf(magfile, " %e ", &phii);
652 // printf(" %e\n",fdPhi[il]);
655 fscanf(magfile," %e %e %e %e %e %e %e ",&fdZpdl,&fdPhid,&fdRdel,&fdZpmx,&fdZpmn,&fdRmax, &fdRmin);
657 printf("fdZpdl %e, fdPhid %e, fdRdel %e, fdZpmx %e, fdZpmn %e,fdRmax %e,fdRmin %e \n", fdZpdl,fdPhid, fdRdel,fdZpmx, fdZpmn,fdRmax, fdRmin);
660 for (il=0; il<33; il++) {
661 for (im=0; im<10; im++) {
662 for (ik=0; ik<51; ik++) {
663 fscanf(magfile, " %e ", &by);
664 fdBpy[ik][im][il]=by;
669 for (il=0; il<33; il++) {
670 for (im=0; im<10; im++) {
671 for (ik=0; ik<51; ik++) {
672 fscanf(magfile, " %e ", &bx);
673 fdBpx[ik][im][il]=bx;
679 for (il=0; il<33; il++) {
680 for (im=0; im<10; im++) {
681 for (ik=0; ik<51; ik++) {
682 fscanf(magfile, " %e ", &bz);
683 fdBpz[ik][im][il]=bz;
689 for (il=0; il<32; il++) {
690 for (im=0; im<2; im++) {
691 for (ik=0; ik<2; ik++) {
692 fscanf(magfile, " %e ", &bb);
699 printf("File %s not found !\n",fTitle.Data());
703 //________________________________