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