]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliMagFC.cxx
Updates (R. Shahoyan)
[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 "AliLog.h"
27 #include "AliMagFC.h"
28
29 ClassImp(AliMagFC)
30
31 //________________________________________
32 AliMagFC::AliMagFC()
33     :AliMagF(),
34     fCompensator(kFALSE),
35     fBeamType(kBeamTypepp),
36     fBeamEnergy(0),
37     fQuadGradient(0),
38     fDipoleField(0),
39     fCCorrField(0), 
40     fACorr1Field(0),
41     fACorr2Field(0)
42 {
43   // 
44   // Default constructor
45   //
46 }
47
48 //________________________________________
49 AliMagFC::AliMagFC(const char *name, const char *title, Int_t integ, 
50                    Float_t factor, Float_t fmax)
51     : AliMagF(name,title,integ,factor,fmax),
52     fCompensator(kFALSE),
53     fBeamType(kBeamTypepp), 
54     fBeamEnergy(7000.),
55     fQuadGradient(0),
56     fDipoleField(0),
57     fCCorrField(0), 
58     fACorr1Field(0),
59     fACorr2Field(0)
60
61 {
62   // 
63   // Standard constructor
64   //
65   fType = kConst;
66   fMap  = 1;
67   
68   //////////////////////////////////////////////////////////////////////
69   // ---- Magnetic field values (according to beam type and energy) ----
70   // p-p @ 5+5 TeV
71   if(fBeamType==kBeamTypepp && fBeamEnergy==5000.){
72     fQuadGradient = 15.7145;
73     fDipoleField  = 27.0558;
74     // SIDE C
75     fCCorrField   = 9.7017; 
76     // SIDE A
77     fACorr1Field  = -13.2143; 
78     fACorr2Field  = -11.9909; 
79   }
80   // Pb-Pb @ 2.7+2.7 TeV or p-p @ 7+7 TeV
81   else{
82     fQuadGradient = 22.0002;
83     fDipoleField  = 37.8781;
84     // SIDE C
85     fCCorrField   = 9.6908; 
86     // SIDE A
87     fACorr1Field  = -13.2014; 
88     fACorr2Field  = -9.6908; 
89   }
90 }
91
92 //________________________________________
93 void AliMagFC::Field(Float_t *x, Float_t *b) const
94 {
95   //
96   // Method to return the field in a point
97   //
98   b[0]=b[1]=b[2]=0;
99   if(fMap==1) {
100     if(TMath::Abs(x[2])<700 && x[0]*x[0]+(x[1]+30)*(x[1]+30) < 560*560) {
101       b[2]=2;
102     } 
103     else {
104       if(-725 >= x[2] && x[2] >= -1225 ){
105         Float_t dz = TMath::Abs(-975-x[2])*0.01;
106         b[0] = - (1-0.1*dz*dz)*7;
107       }
108       else {
109           ZDCField(x, b);
110       }
111     }
112     if(fFactor!=1) {
113         b[0]*=fFactor;
114         b[1]*=fFactor;
115         b[2]*=fFactor;
116     }
117   } 
118   else {
119       AliFatal(Form("Invalid field map for constant field %d",fMap));
120   }
121 }
122
123 //___________________________________________________
124 void AliMagFC::ZDCField(Float_t *x, Float_t *b) const
125 {
126   // ---- This is the ZDC part
127   
128   Float_t rad2 = x[0] * x[0] + x[1] * x[1];
129   
130   // SIDE C **************************************************
131   if(x[2]<0.){  
132     if(x[2] < kCCorrBegin && x[2] > kCCorrEnd && rad2 < kCCorrSqRadius){
133         b[0] = fCCorrField;
134         b[1] = 0.;
135         b[2] = 0.;
136     }
137     else if(x[2] < kCQ1Begin && x[2] > kCQ1End && rad2 < kCQ1SqRadius){
138         b[0] = fQuadGradient*x[1];
139         b[1] = fQuadGradient*x[0];
140         b[2] = 0.;
141     }
142     else if(x[2] < kCQ2Begin && x[2] > kCQ2End && rad2 < kCQ2SqRadius){
143         b[0] = -fQuadGradient*x[1];
144         b[1] = -fQuadGradient*x[0];
145         b[2] = 0.;
146     }
147     else if(x[2] < kCQ3Begin && x[2] > kCQ3End && rad2 < kCQ3SqRadius){
148         b[0] = -fQuadGradient*x[1];
149         b[1] = -fQuadGradient*x[0];
150         b[2] = 0.;
151     }
152     else if(x[2] < kCQ4Begin && x[2] > kCQ4End && rad2 < kCQ4SqRadius){
153         b[0] = fQuadGradient*x[1];
154         b[1] = fQuadGradient*x[0];
155         b[2] = 0.;
156     }
157     else if(x[2] < kCD1Begin && x[2] > kCD1End && rad2 < kCD1SqRadius){
158         b[1] = fDipoleField;
159         b[2] = 0.;
160         b[2] = 0.;
161     }
162     else if(x[2] < kCD2Begin && x[2] > kCD2End){
163         if(((x[0]-kCD2XCentre1)*(x[0]-kCD2XCentre1)+(x[1]*x[1]))<kCD2SqRadius
164            || ((x[0]-kCD2XCentre2)*(x[0]-kCD2XCentre2)+(x[1]*x[1]))<kCD2SqRadius){
165           b[1] = -fDipoleField;
166           b[2] = 0.;
167           b[2] = 0.;
168         }
169     }
170   }
171   
172   // SIDE A **************************************************
173   else{        
174     if(fCompensator && (x[2] > kACorr1Begin && x[2] < kACorr1End) && rad2 < kCCorr1SqRadius) {
175       // Compensator magnet at z = 1075 m 
176         b[0] = fACorr1Field;
177         b[1] = 0.;
178         b[2] = 0.;
179         return;
180     }
181     
182     if(x[2] > kACorr2Begin && x[2] < kACorr2End && rad2 < kCCorr2SqRadius){
183         b[0] = fACorr2Field;
184         b[1] = 0.;
185         b[2] = 0.;
186     }          
187     else if(x[2] > kAQ1Begin && x[2] < kAQ1End && rad2 < kAQ1SqRadius){
188         // First quadrupole of inner triplet de-focussing in x-direction
189         b[0] = -fQuadGradient*x[1];
190         b[1] = -fQuadGradient*x[0];
191         b[2] = 0.;
192     }
193     else if(x[2] > kAQ2Begin && x[2] < kAQ2End && rad2 < kAQ2SqRadius){
194         b[0] = fQuadGradient*x[1];
195         b[1] = fQuadGradient*x[0];
196         b[2] = 0.;
197     }
198     else if(x[2] > kAQ3Begin && x[2] < kAQ3End && rad2 < kAQ3SqRadius){
199         b[0] = fQuadGradient*x[1];
200         b[1] = fQuadGradient*x[0];
201         b[2] = 0.;
202     }
203     else if(x[2] > kAQ4Begin && x[2] < kAQ4End && rad2 < kAQ4SqRadius){
204         b[0] = -fQuadGradient*x[1];
205         b[1] = -fQuadGradient*x[0];
206         b[2] = 0.;
207     }
208     else if(x[2] > kAD1Begin && x[2] < kAD1End && rad2 < kAD1SqRadius){
209         b[0] = 0.;
210         b[1] = -fDipoleField;
211         b[2] = 0.;
212     }
213     else if(x[2] > kAD2Begin && x[2] < kAD2End){
214         if(((x[0]-kAD2XCentre1)*(x[0]-kAD2XCentre1)+(x[1]*x[1])) < kAD2SqRadius
215            || ((x[0]-kAD2XCentre2)*(x[0]-kAD2XCentre2)+(x[1]*x[1])) < kAD2SqRadius){
216             b[1] = fDipoleField;
217         }
218     }
219   }
220     
221 }
222