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