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