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