Adding track references at decay points (M.Ivanov)
[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
84737f5e 32ClassImp(AliMagFMaps)
33
e2afb3b6 34//_______________________________________________________________________
35AliMagFMaps::AliMagFMaps():
36 fSolenoid(0),
02b50693 37 fSolenoidUser(0.),
e2afb3b6 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):
57754f18 51 AliMagFC(name,title,integ,factor,fmax),
e2afb3b6 52 fSolenoid(0),
02b50693 53 fSolenoidUser(0),
e2afb3b6 54 fL3Option(l3),
55 fFieldRead(0)
84737f5e 56{
57 //
58 // Standard constructor
59 //
60 fType = kConMesh;
61 fFieldMap[0] = 0;
c2b548d6 62 fMap = map;
63 fL3Option = l3;
c2b548d6 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):
57754f18 74 AliMagFC(magf),
e2afb3b6 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;
e2afb3b6 128 } else if (fMap == k4kG) {
177a7fab 129 if (fL3Option) {
130 fSolenoid = 4.;
131 fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/L3B04.root");
132 file = new TFile(fname);
133 fFieldMap[0] = dynamic_cast<AliFieldMap*>(file->Get("L3B04"));
134 file->Close();
135 delete file;
136 }
137
138 fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/DipB04.root");
e2afb3b6 139 file = new TFile(fname);
177a7fab 140 fFieldMap[1] = dynamic_cast<AliFieldMap*>(file->Get("DipB04"));
141 file->Close();
142 delete file;
143
144 fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/ExtB04.root");
145 file = new TFile(fname);
146 fFieldMap[2] = dynamic_cast<AliFieldMap*>(file->Get("ExtB04"));
e2afb3b6 147 file->Close();
148 delete file;
e2afb3b6 149 } else if (fMap == k5kG) {
177a7fab 150 if (fL3Option) {
151 fSolenoid = 5.;
152 fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/L3B05.root");
153 file = new TFile(fname);
154 fFieldMap[0] = dynamic_cast<AliFieldMap*>(file->Get("L3B05"));
155 file->Close();
156 delete file;
157 }
158
159 fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/DipB05.root");
e2afb3b6 160 file = new TFile(fname);
177a7fab 161 fFieldMap[1] = dynamic_cast<AliFieldMap*>(file->Get("DipB05"));
e2afb3b6 162 file->Close();
163 delete file;
177a7fab 164
165 fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/ExtB05.root");
166 file = new TFile(fname);
167 fFieldMap[2] = dynamic_cast<AliFieldMap*>(file->Get("ExtB05"));
168 file->Close();
169 delete file;
170
e2afb3b6 171 }
172
173 if (!fL3Option) {
177a7fab 174 //
175 // Dummy L3 map
176 fFieldMap[0] = new AliFieldMap();
177 fFieldMap[0] -> SetLimits(-800., 800., -800., 800., -700., 700.);
178 switch(fMap) {
179 case k2kG:
180 fSolenoid = 2.;
181 break;
182 case k4kG:
183 fSolenoid = 4.;
184 break;
185 case k5kG:
186 fSolenoid = 5.;
187 break;
177a7fab 188 }
02b50693 189 fSolenoidUser = fSolenoid;
e2afb3b6 190 }
c2b548d6 191}
192
e2afb3b6 193//_______________________________________________________________________
84737f5e 194Float_t AliMagFMaps::SolenoidField() const
195{
e2afb3b6 196 //
197 // Returns max. L3 (solenoid) field strength
198 // according to field map setting
199 //
200 return fSolenoid;
84737f5e 201}
202
e2afb3b6 203//_______________________________________________________________________
84737f5e 204void AliMagFMaps::Field(Float_t *x, Float_t *b)
205{
206 //
207 // Method to calculate the magnetic field
208 //
84737f5e 209 // --- find the position in the grid ---
210
57754f18 211
212
213 if (!fFieldRead) ReadField();
214
215 //
216 // Field Maps have been calculated for the coordinate system in which
217 // the Muon Spectrometer is placed at z > 0
218 // Transform coordinates corresponingly
219 //
e2afb3b6 220
84737f5e 221 b[0]=b[1]=b[2]=0;
57754f18 222 Float_t xm[3];
223 xm[0] = - x[0];
224 xm[1] = x[1];
225 xm[2] = - x[2];
226
84737f5e 227 AliFieldMap* map = 0;
57754f18 228 if (fFieldMap[0]->Inside(xm[0], xm[1], xm[2])) {
177a7fab 229 map = fFieldMap[0];
230 if (!fL3Option) {
e2afb3b6 231 //
232 // Constant L3 field, if this option was selected
233 //
02b50693 234 b[2] = fSolenoidUser;
84737f5e 235 return;
e2afb3b6 236 }
57754f18 237 } else if (fFieldMap[1]->Inside(xm[0], xm[1], xm[2])) {
88cb7938 238 map = fFieldMap[1];
57754f18 239 } else if (fFieldMap[2]->Inside(xm[0], xm[1], xm[2])) {
88cb7938 240 map = fFieldMap[2];
84737f5e 241 }
242
243 if(map){
57754f18 244 map->Field(xm,b);
245 b[0] = - b[0];
246 b[2] = - b[2];
247
84737f5e 248 } else {
57754f18 249 //This is the ZDC part
250 ZDCField(x, b);
84737f5e 251 }
57754f18 252
253
84737f5e 254 if(fFactor!=1) {
57754f18 255 b[0]*=fFactor;
256 b[1]*=fFactor;
257 b[2]*=fFactor;
84737f5e 258 }
259}
260
e2afb3b6 261//_______________________________________________________________________
84737f5e 262void AliMagFMaps::Copy(AliMagFMaps & /* magf */) const
263{
264 //
265 // Copy *this onto magf -- Not implemented
266 //
267 Fatal("Copy","Not implemented!\n");
268}
269
e2afb3b6 270//_______________________________________________________________________
ee4f31cd 271void AliMagFMaps::Streamer(TBuffer &R__b)
272{
e2afb3b6 273 // Stream an object of class AliMagFMaps.
274 if (R__b.IsReading()) {
275 AliMagFMaps::Class()->ReadBuffer(R__b, this);
276 fFieldRead = 0;
277 } else {
278 AliMagFMaps::Class()->WriteBuffer(R__b, this);
279 }
ee4f31cd 280}