]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliMagFMaps.cxx
Using AliMpDDLStore::GetBusPatchId instead of static arrays (Christian)
[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
a1e17193 25#include <TClass.h>
84737f5e 26#include <TFile.h>
3010c308 27#include <TMath.h>
84737f5e 28#include <TSystem.h>
e2afb3b6 29
594d8990 30#include "AliLog.h"
84737f5e 31#include "AliFieldMap.h"
32#include "AliMagFMaps.h"
33
84737f5e 34ClassImp(AliMagFMaps)
a0201063 35
84737f5e 36
e2afb3b6 37//_______________________________________________________________________
38AliMagFMaps::AliMagFMaps():
39 fSolenoid(0),
02b50693 40 fSolenoidUser(0.),
a0201063 41 fL3Option(0)
e2afb3b6 42{
43 //
44 // Default constructor
45 //
10eca208 46 //
47 // Don't replicate field information in gAlice
e2afb3b6 48 fFieldMap[0] = fFieldMap[1] = fFieldMap[2] = 0;
49}
50
51//_______________________________________________________________________
d0f1ee3b 52AliMagFMaps::AliMagFMaps(const char *name, const char *title, Int_t integ,
53 Float_t factor, Float_t fmax, Int_t map,
54 Int_t l3):
57754f18 55 AliMagFC(name,title,integ,factor,fmax),
e2afb3b6 56 fSolenoid(0),
02b50693 57 fSolenoidUser(0),
a0201063 58 fL3Option(l3)
84737f5e 59{
60 //
61 // Standard constructor
62 //
63 fType = kConMesh;
64 fFieldMap[0] = 0;
c2b548d6 65 fMap = map;
66 fL3Option = l3;
c2b548d6 67 ReadField();
e2afb3b6 68 //
69 // Don't replicate field information in gAlice
7b6cddfa 70 for (Int_t i = 0; i < 3; i++) fFieldMap[i]->SetWriteEnable(0);
e2afb3b6 71 //
84737f5e 72}
73
e2afb3b6 74//_______________________________________________________________________
75AliMagFMaps::AliMagFMaps(const AliMagFMaps &magf):
57754f18 76 AliMagFC(magf),
e2afb3b6 77 fSolenoid(0),
fe12e09c 78 fSolenoidUser(0),
a0201063 79 fL3Option(0)
84737f5e 80{
81 //
82 // Copy constructor
83 //
84 magf.Copy(*this);
85}
86
e2afb3b6 87//_______________________________________________________________________
84737f5e 88AliMagFMaps::~AliMagFMaps()
89{
e2afb3b6 90 //
91 // Destructor
92 //
93 delete fFieldMap[0];
94 delete fFieldMap[1];
95 delete fFieldMap[2];
3ce3918c 96 fgReadField = kTRUE;
84737f5e 97}
98
e2afb3b6 99//_______________________________________________________________________
c2b548d6 100void AliMagFMaps::ReadField()
101{
e2afb3b6 102 // Read Field Map from file
103 //
104 // don't read twice
105 //
a0201063 106 if (!fgReadField) return;
107 fgReadField = 0;
e2afb3b6 108 //
109 char* fname;
110 TFile* file = 0;
111 if (fMap == k2kG) {
b6ee07d3 112 fSolenoid = 2.;
113 fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/L3B02.root");
114 file = new TFile(fname);
115 fFieldMap[0] = dynamic_cast<AliFieldMap*>(file->Get("L3B02"));
116 file->Close();
117 delete file;
177a7fab 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;
e2afb3b6 129 } else if (fMap == k4kG) {
b6ee07d3 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;
177a7fab 136 fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/DipB04.root");
e2afb3b6 137 file = new TFile(fname);
177a7fab 138 fFieldMap[1] = dynamic_cast<AliFieldMap*>(file->Get("DipB04"));
139 file->Close();
140 delete file;
141
142 fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/ExtB04.root");
143 file = new TFile(fname);
144 fFieldMap[2] = dynamic_cast<AliFieldMap*>(file->Get("ExtB04"));
e2afb3b6 145 file->Close();
146 delete file;
e2afb3b6 147 } else if (fMap == k5kG) {
b6ee07d3 148 fSolenoid = 5.;
149 fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/L3B05.root");
150 file = new TFile(fname);
151 fFieldMap[0] = dynamic_cast<AliFieldMap*>(file->Get("L3B05"));
152 file->Close();
153 delete file;
177a7fab 154 fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/DipB05.root");
e2afb3b6 155 file = new TFile(fname);
177a7fab 156 fFieldMap[1] = dynamic_cast<AliFieldMap*>(file->Get("DipB05"));
e2afb3b6 157 file->Close();
158 delete file;
177a7fab 159
160 fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/ExtB05.root");
161 file = new TFile(fname);
162 fFieldMap[2] = dynamic_cast<AliFieldMap*>(file->Get("ExtB05"));
163 file->Close();
164 delete file;
e2afb3b6 165 }
b6ee07d3 166
167 if (!fL3Option) fSolenoidUser = fSolenoid;
168
c2b548d6 169}
170
e2afb3b6 171//_______________________________________________________________________
84737f5e 172Float_t AliMagFMaps::SolenoidField() const
173{
e2afb3b6 174 //
175 // Returns max. L3 (solenoid) field strength
176 // according to field map setting
177 //
7ebb06c3 178 return -Factor()*fSolenoid;
84737f5e 179}
180
e2afb3b6 181//_______________________________________________________________________
6f3038e9 182void AliMagFMaps::Field(Float_t *x, Float_t *b) const
84737f5e 183{
184 //
185 // Method to calculate the magnetic field
186 //
84737f5e 187 // --- find the position in the grid ---
188
57754f18 189
190
6f3038e9 191 // if (!fFieldRead) ReadField();
57754f18 192
193 //
194 // Field Maps have been calculated for the coordinate system in which
195 // the Muon Spectrometer is placed at z > 0
196 // Transform coordinates corresponingly
197 //
e2afb3b6 198
84737f5e 199 b[0]=b[1]=b[2]=0;
57754f18 200 Float_t xm[3];
201 xm[0] = - x[0];
202 xm[1] = x[1];
203 xm[2] = - x[2];
204
84737f5e 205 AliFieldMap* map = 0;
57754f18 206 if (fFieldMap[0]->Inside(xm[0], xm[1], xm[2])) {
177a7fab 207 map = fFieldMap[0];
0ae44e30 208 Float_t r = TMath::Sqrt(xm[0] * xm[0] + xm[1] * xm[1]);
209
210 if (!fL3Option && TMath::Abs(xm[2]) < 370. && r < 550.) {
e2afb3b6 211 //
b6ee07d3 212 // Constant L3 field , if this option was selected
e2afb3b6 213 //
81e97e0d 214 b[2] = (- fSolenoid)*fFactor;
84737f5e 215 return;
b6ee07d3 216 }
57754f18 217 } else if (fFieldMap[1]->Inside(xm[0], xm[1], xm[2])) {
88cb7938 218 map = fFieldMap[1];
57754f18 219 } else if (fFieldMap[2]->Inside(xm[0], xm[1], xm[2])) {
88cb7938 220 map = fFieldMap[2];
84737f5e 221 }
222
223 if(map){
57754f18 224 map->Field(xm,b);
225 b[0] = - b[0];
226 b[2] = - b[2];
227
84737f5e 228 } else {
57754f18 229 //This is the ZDC part
230 ZDCField(x, b);
84737f5e 231 }
57754f18 232
233
84737f5e 234 if(fFactor!=1) {
57754f18 235 b[0]*=fFactor;
236 b[1]*=fFactor;
237 b[2]*=fFactor;
84737f5e 238 }
239}
240
e2afb3b6 241//_______________________________________________________________________
6c4904c2 242void AliMagFMaps::Copy(TObject & /* magf */) const
84737f5e 243{
244 //
245 // Copy *this onto magf -- Not implemented
246 //
594d8990 247 AliFatal("Not implemented!");
84737f5e 248}
249
e2afb3b6 250//_______________________________________________________________________
ee4f31cd 251void AliMagFMaps::Streamer(TBuffer &R__b)
252{
e2afb3b6 253 // Stream an object of class AliMagFMaps.
254 if (R__b.IsReading()) {
255 AliMagFMaps::Class()->ReadBuffer(R__b, this);
10eca208 256 ReadField();
e2afb3b6 257 } else {
258 AliMagFMaps::Class()->WriteBuffer(R__b, this);
259 }
ee4f31cd 260}