]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliMagFC.cxx
protection against missing header
[u/mrichter/AliRoot.git] / STEER / AliMagFC.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
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  **************************************************************************/
15
16 /* $Id$ */
17
18 //-------------------------------------------------------------------------
19 //     Constant magnetic field class
20 //     Used by AliRun class
21 //     Author:
22 //-------------------------------------------------------------------------
23
24 #include <stdlib.h>
25
26 #include "AliMagFC.h"
27
28 ClassImp(AliMagFC)
29
30 //________________________________________
31 AliMagFC::AliMagFC(const char *name, const char *title, Int_t integ, 
32                    Float_t factor, Float_t fmax)
33   : AliMagF(name,title,integ,factor,fmax)
34 {
35   // 
36   // Standard constructor
37   //
38   fType = kConst;
39   fMap  = 1;
40 }
41
42 //________________________________________
43 void AliMagFC::Field(Float_t *x, Float_t *b) const
44 {
45   //
46   // Method to return the field in a point
47   //
48   b[0]=b[1]=b[2]=0;
49   if(fMap==1) {
50     if(TMath::Abs(x[2])<700 && x[0]*x[0]+(x[1]+30)*(x[1]+30) < 560*560) {
51       b[2]=2;
52     } else {
53       if ( -725 >= x[2] && x[2] >= -1225 ) {
54         Float_t dz = TMath::Abs(-975-x[2])*0.01;
55         b[0] = - (1-0.1*dz*dz)*7;
56       }
57       else {
58           ZDCField(x, b);
59       }
60     }
61     if(fFactor!=1) {
62         b[0]*=fFactor;
63         b[1]*=fFactor;
64         b[2]*=fFactor;
65     }
66   } else {
67       printf("Invalid field map for constant field %d\n",fMap);
68       exit(1);
69   }
70 }
71
72
73 void AliMagFC::ZDCField(Float_t *x, Float_t *b) const
74 {
75 //This is the ZDC part
76     Float_t rad2=x[0]*x[0]+x[1]*x[1];
77
78     if(x[2] < kCORBEG2 && x[2] > kCOREND2){
79         if(rad2<kCOR2RA2){
80             b[0] = - kFCORN2;
81         }
82     }
83     else if(x[2] < kZ1BEG && x[2] > kZ1END){  
84         if(rad2<kZ1RA2){
85             b[0] =  kG1*x[1];
86             b[1] = -kG1*x[0];
87         }
88     }
89     else if(x[2] < kZ2BEG && x[2] > kZ2END){  
90         if(rad2<kZ2RA2){
91             b[0] = -kG1*x[1];
92             b[1] =  kG1*x[0];
93         }
94     }
95     else if(x[2] < kZ3BEG && x[2] > kZ3END){  
96         if(rad2<kZ3RA2){
97             b[0] = -kG1*x[1];
98             b[1] =  kG1*x[0];
99         }
100     }
101     else if(x[2] < kZ4BEG && x[2] > kZ4END){  
102         if(rad2<kZ4RA2){
103             b[0] =  kG1*x[1];
104             b[1] = -kG1*x[0];
105         }
106     }
107     else if(x[2] < kD1BEG && x[2] > kD1END){ 
108         if(rad2<kD1RA2){
109             b[1] = -kFDIP;
110         }
111     }
112     else if(x[2] < kD2BEG && x[2] > kD2END){
113         if(((x[0]-kXCEN1D2)*(x[0]-kXCEN1D2)+(x[1]-kYCEN1D2)*(x[1]-kYCEN1D2))<kD2RA2
114            || ((x[0]-kXCEN2D2)*(x[0]-kXCEN2D2)+(x[1]-kYCEN2D2)*(x[1]-kYCEN2D2))<kD2RA2){
115             b[1] = kFDIP;
116         }
117     }
118     
119 }