]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliMagFMaps.cxx
Option for 0 solenoid field added.
[u/mrichter/AliRoot.git] / STEER / AliMagFMaps.cxx
CommitLineData
84737f5e 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
acd84897 16/* $Id$ */
84737f5e 17
5d8718b8 18//------------------------------------------------------------------------
19// Magnetic field composed by 3 maps: the L3 magnet, extended region, and
20// dipole magnet
21// Used in the configuration macros (macros/Config.C, etc.)
84737f5e 22// Author: Andreas Morsch <andreas.morsch@cern.ch>
5d8718b8 23//------------------------------------------------------------------------
84737f5e 24
25#include <TFile.h>
26#include <TSystem.h>
116cbefd 27#include <TVector.h>
e2afb3b6 28
84737f5e 29#include "AliFieldMap.h"
30#include "AliMagFMaps.h"
31
32
33ClassImp(AliMagFMaps)
34
e2afb3b6 35//_______________________________________________________________________
36AliMagFMaps::AliMagFMaps():
37 fSolenoid(0),
38 fL3Option(0),
39 fFieldRead(0)
40{
41 //
42 // Default constructor
43 //
44 fFieldMap[0] = fFieldMap[1] = fFieldMap[2] = 0;
45}
46
47//_______________________________________________________________________
84737f5e 48AliMagFMaps::AliMagFMaps(const char *name, const char *title, const Int_t integ,
e2afb3b6 49 const Float_t factor, const Float_t fmax, const Int_t map,
50 const Int_t l3):
51 AliMagF(name,title,integ,factor,fmax),
52 fSolenoid(0),
53 fL3Option(l3),
54 fFieldRead(0)
84737f5e 55{
56 //
57 // Standard constructor
58 //
59 fType = kConMesh;
60 fFieldMap[0] = 0;
c2b548d6 61 fMap = map;
62 fL3Option = l3;
63
64 ReadField();
65 fFieldRead = 1;
e2afb3b6 66 //
67 // Don't replicate field information in gAlice
7b6cddfa 68 for (Int_t i = 0; i < 3; i++) fFieldMap[i]->SetWriteEnable(0);
e2afb3b6 69 //
84737f5e 70}
71
e2afb3b6 72//_______________________________________________________________________
73AliMagFMaps::AliMagFMaps(const AliMagFMaps &magf):
74 AliMagF(magf),
75 fSolenoid(0),
76 fL3Option(0),
77 fFieldRead(0)
84737f5e 78{
79 //
80 // Copy constructor
81 //
82 magf.Copy(*this);
83}
84
e2afb3b6 85//_______________________________________________________________________
84737f5e 86AliMagFMaps::~AliMagFMaps()
87{
e2afb3b6 88 //
89 // Destructor
90 //
91 delete fFieldMap[0];
92 delete fFieldMap[1];
93 delete fFieldMap[2];
84737f5e 94}
95
e2afb3b6 96//_______________________________________________________________________
c2b548d6 97void AliMagFMaps::ReadField()
98{
e2afb3b6 99 // Read Field Map from file
100 //
101 // don't read twice
102 //
103 if (fFieldRead) return;
104 fFieldRead = 1;
105 //
106 char* fname;
107 TFile* file = 0;
108 if (fMap == k2kG) {
177a7fab 109 if (fL3Option) {
110 fSolenoid = 2.;
111 fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/L3B02.root");
112 file = new TFile(fname);
113 fFieldMap[0] = dynamic_cast<AliFieldMap*>(file->Get("L3B02"));
114 file->Close();
115 delete file;
116 }
117 fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/DipB02.root");
e2afb3b6 118 file = new TFile(fname);
177a7fab 119 fFieldMap[1] = dynamic_cast<AliFieldMap*>(file->Get("DipB02"));
120 file->Close();
121 delete file;;
122
123 fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/ExtB02.root");
124 file = new TFile(fname);
125 fFieldMap[2] = dynamic_cast<AliFieldMap*>(file->Get("ExtB02"));
e2afb3b6 126 file->Close();
127 delete file;
177a7fab 128
e2afb3b6 129 } else if (fMap == k4kG) {
177a7fab 130 if (fL3Option) {
131 fSolenoid = 4.;
132 fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/L3B04.root");
133 file = new TFile(fname);
134 fFieldMap[0] = dynamic_cast<AliFieldMap*>(file->Get("L3B04"));
135 file->Close();
136 delete file;
137 }
138
139 fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/DipB04.root");
e2afb3b6 140 file = new TFile(fname);
177a7fab 141 fFieldMap[1] = dynamic_cast<AliFieldMap*>(file->Get("DipB04"));
142 file->Close();
143 delete file;
144
145 fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/ExtB04.root");
146 file = new TFile(fname);
147 fFieldMap[2] = dynamic_cast<AliFieldMap*>(file->Get("ExtB04"));
e2afb3b6 148 file->Close();
149 delete file;
e2afb3b6 150 } else if (fMap == k5kG) {
177a7fab 151 if (fL3Option) {
152 fSolenoid = 5.;
153 fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/L3B05.root");
154 file = new TFile(fname);
155 fFieldMap[0] = dynamic_cast<AliFieldMap*>(file->Get("L3B05"));
156 file->Close();
157 delete file;
158 }
159
160 fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/DipB05.root");
e2afb3b6 161 file = new TFile(fname);
177a7fab 162 fFieldMap[1] = dynamic_cast<AliFieldMap*>(file->Get("DipB05"));
e2afb3b6 163 file->Close();
164 delete file;
177a7fab 165
166 fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/ExtB05.root");
167 file = new TFile(fname);
168 fFieldMap[2] = dynamic_cast<AliFieldMap*>(file->Get("ExtB05"));
169 file->Close();
170 delete file;
171
e2afb3b6 172 }
173
174 if (!fL3Option) {
177a7fab 175 //
176 // Dummy L3 map
177 fFieldMap[0] = new AliFieldMap();
178 fFieldMap[0] -> SetLimits(-800., 800., -800., 800., -700., 700.);
179 switch(fMap) {
180 case k2kG:
181 fSolenoid = 2.;
182 break;
183 case k4kG:
184 fSolenoid = 4.;
185 break;
186 case k5kG:
187 fSolenoid = 5.;
188 break;
189 case k0kG:
190 fSolenoid = 0.;
191 break;
192 }
e2afb3b6 193 }
c2b548d6 194}
195
e2afb3b6 196//_______________________________________________________________________
84737f5e 197Float_t AliMagFMaps::SolenoidField() const
198{
e2afb3b6 199 //
200 // Returns max. L3 (solenoid) field strength
201 // according to field map setting
202 //
203 return fSolenoid;
84737f5e 204}
205
e2afb3b6 206//_______________________________________________________________________
84737f5e 207void AliMagFMaps::Field(Float_t *x, Float_t *b)
208{
209 //
210 // Method to calculate the magnetic field
211 //
84737f5e 212 // --- find the position in the grid ---
213
ee4f31cd 214 if (!fFieldRead) ReadField();
e2afb3b6 215
84737f5e 216 b[0]=b[1]=b[2]=0;
217 AliFieldMap* map = 0;
84737f5e 218 if (fFieldMap[0]->Inside(x[0], x[1], x[2])) {
177a7fab 219 map = fFieldMap[0];
220 if (!fL3Option) {
e2afb3b6 221 //
222 // Constant L3 field, if this option was selected
223 //
84737f5e 224 b[2] = fSolenoid;
225 return;
e2afb3b6 226 }
84737f5e 227 } else if (fFieldMap[1]->Inside(x[0], x[1], x[2])) {
177a7fab 228 map = fFieldMap[1];
84737f5e 229 } else if (fFieldMap[2]->Inside(x[0], x[1], x[2])) {
177a7fab 230 map = fFieldMap[2];
84737f5e 231 }
232
233 if(map){
e2afb3b6 234 map->Field(x,b);
84737f5e 235 } else {
e2afb3b6 236 //This is the ZDC part
237 Float_t rad2=x[0]*x[0]+x[1]*x[1];
238 if(x[2]>kCORBEG2 && x[2]<kCOREND2){
177a7fab 239 if(rad2<kCOR2RA2){
240 b[0] = kFCORN2;
241 }
242 } else if(x[2]>kZ1BEG && x[2]<kZ1END){
243 if(rad2<kZ1RA2){
244 b[0] = -kG1*x[1];
245 b[1] = -kG1*x[0];
246 }
247 } else if(x[2]>kZ2BEG && x[2]<kZ2END){
248 if(rad2<kZ2RA2){
249 b[0] = kG1*x[1];
250 b[1] = kG1*x[0];
251 }
e2afb3b6 252 }
177a7fab 253 else if(x[2]>kZ3BEG && x[2]<kZ3END){
254 if(rad2<kZ3RA2){
255 b[0] = kG1*x[1];
256 b[1] = kG1*x[0];
257 }
e2afb3b6 258 }
177a7fab 259 else if(x[2]>kZ4BEG && x[2]<kZ4END){
260 if(rad2<kZ4RA2){
261 b[0] = -kG1*x[1];
262 b[1] = -kG1*x[0];
263 }
e2afb3b6 264 }
265 else if(x[2]>kD1BEG && x[2]<kD1END){
177a7fab 266 if(rad2<kD1RA2){
267 b[1] = -kFDIP;
268 }
e2afb3b6 269 }
270 else if(x[2]>kD2BEG && x[2]<kD2END){
177a7fab 271 if(((x[0]-kXCEN1D2)*(x[0]-kXCEN1D2)+(x[1]-kYCEN1D2)*(x[1]-kYCEN1D2))<kD2RA2
272 || ((x[0]-kXCEN2D2)*(x[0]-kXCEN2D2)+(x[1]-kYCEN2D2)*(x[1]-kYCEN2D2))<kD2RA2){
273 b[1] = kFDIP;
274 }
e2afb3b6 275 }
84737f5e 276 }
277 if(fFactor!=1) {
e2afb3b6 278 b[0]*=fFactor;
279 b[1]*=fFactor;
280 b[2]*=fFactor;
84737f5e 281 }
282}
283
e2afb3b6 284//_______________________________________________________________________
84737f5e 285void AliMagFMaps::Copy(AliMagFMaps & /* magf */) const
286{
287 //
288 // Copy *this onto magf -- Not implemented
289 //
290 Fatal("Copy","Not implemented!\n");
291}
292
e2afb3b6 293//_______________________________________________________________________
ee4f31cd 294void AliMagFMaps::Streamer(TBuffer &R__b)
295{
e2afb3b6 296 // Stream an object of class AliMagFMaps.
297 if (R__b.IsReading()) {
298 AliMagFMaps::Class()->ReadBuffer(R__b, this);
299 fFieldRead = 0;
300 } else {
301 AliMagFMaps::Class()->WriteBuffer(R__b, this);
302 }
ee4f31cd 303}