]>
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> | |
116cbefd | 27 | #include <TVector.h> |
e2afb3b6 | 28 | |
84737f5e | 29 | #include "AliFieldMap.h" |
30 | #include "AliMagFMaps.h" | |
31 | ||
32 | ||
33 | ClassImp(AliMagFMaps) | |
34 | ||
e2afb3b6 | 35 | //_______________________________________________________________________ |
36 | AliMagFMaps::AliMagFMaps(): | |
37 | fSolenoid(0), | |
38 | fL3Option(0), | |
39 | fFieldRead(0) | |
40 | { | |
41 | // | |
42 | // Default constructor | |
43 | // | |
44 | fFieldMap[0] = fFieldMap[1] = fFieldMap[2] = 0; | |
45 | } | |
46 | ||
47 | //_______________________________________________________________________ | |
84737f5e | 48 | AliMagFMaps::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): | |
51 | AliMagF(name,title,integ,factor,fmax), | |
52 | fSolenoid(0), | |
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; | |
63 | ||
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 | //_______________________________________________________________________ |
73 | AliMagFMaps::AliMagFMaps(const AliMagFMaps &magf): | |
74 | AliMagF(magf), | |
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 | 86 | AliMagFMaps::~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 | 97 | void 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) { | |
c2b548d6 | 109 | if (fL3Option) { |
e2afb3b6 | 110 | fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/L3B02.root"); |
111 | file = new TFile(fname); | |
112 | fFieldMap[0] = dynamic_cast<AliFieldMap*>(file->Get("L3B02")); | |
113 | file->Close(); | |
114 | delete file; | |
c2b548d6 | 115 | } |
116 | fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/DipB02.root"); | |
117 | file = new TFile(fname); | |
e2afb3b6 | 118 | fFieldMap[1] = dynamic_cast<AliFieldMap*>(file->Get("DipB02")); |
c2b548d6 | 119 | file->Close(); |
120 | delete file;; | |
121 | ||
122 | fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/ExtB02.root"); | |
123 | file = new TFile(fname); | |
e2afb3b6 | 124 | fFieldMap[2] = dynamic_cast<AliFieldMap*>(file->Get("ExtB02")); |
c2b548d6 | 125 | file->Close(); |
126 | delete file; | |
127 | fSolenoid = 2.; | |
e2afb3b6 | 128 | } else if (fMap == k4kG) { |
c2b548d6 | 129 | if (fL3Option) { |
e2afb3b6 | 130 | fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/L3B04.root"); |
131 | file = new TFile(fname); | |
132 | fFieldMap[0] = dynamic_cast<AliFieldMap*>(file->Get("L3B04")); | |
133 | file->Close(); | |
134 | delete file; | |
c2b548d6 | 135 | } |
136 | ||
137 | fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/DipB04.root"); | |
138 | file = new TFile(fname); | |
e2afb3b6 | 139 | fFieldMap[1] = dynamic_cast<AliFieldMap*>(file->Get("DipB04")); |
c2b548d6 | 140 | file->Close(); |
e2afb3b6 | 141 | delete file; |
c2b548d6 | 142 | |
143 | fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/ExtB04.root"); | |
144 | file = new TFile(fname); | |
e2afb3b6 | 145 | fFieldMap[2] = dynamic_cast<AliFieldMap*>(file->Get("ExtB04")); |
c2b548d6 | 146 | file->Close(); |
147 | delete file; | |
148 | fSolenoid = 4.; | |
e2afb3b6 | 149 | } else if (fMap == k5kG) { |
c2b548d6 | 150 | if (fL3Option) { |
e2afb3b6 | 151 | fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/L3B05.root"); |
152 | file = new TFile(fname); | |
153 | fFieldMap[0] = dynamic_cast<AliFieldMap*>(file->Get("L3B05")); | |
154 | file->Close(); | |
155 | delete file; | |
c2b548d6 | 156 | } |
157 | ||
158 | fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/DipB05.root"); | |
159 | file = new TFile(fname); | |
e2afb3b6 | 160 | fFieldMap[1] = dynamic_cast<AliFieldMap*>(file->Get("DipB05")); |
c2b548d6 | 161 | file->Close(); |
e2afb3b6 | 162 | delete file; |
c2b548d6 | 163 | |
164 | fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/ExtB05.root"); | |
165 | file = new TFile(fname); | |
e2afb3b6 | 166 | fFieldMap[2] = dynamic_cast<AliFieldMap*>(file->Get("ExtB05")); |
c2b548d6 | 167 | file->Close(); |
168 | delete file; | |
169 | ||
170 | fSolenoid = 5.; | |
e2afb3b6 | 171 | } |
172 | ||
173 | if (!fL3Option) { | |
174 | // | |
175 | // Dummy L3 map | |
c2b548d6 | 176 | fFieldMap[0] = new AliFieldMap(); |
177 | fFieldMap[0] -> SetLimits(-800., 800., -800., 800., -700., 700.); | |
e2afb3b6 | 178 | } |
c2b548d6 | 179 | } |
180 | ||
e2afb3b6 | 181 | //_______________________________________________________________________ |
84737f5e | 182 | Float_t AliMagFMaps::SolenoidField() const |
183 | { | |
e2afb3b6 | 184 | // |
185 | // Returns max. L3 (solenoid) field strength | |
186 | // according to field map setting | |
187 | // | |
188 | return fSolenoid; | |
84737f5e | 189 | } |
190 | ||
e2afb3b6 | 191 | //_______________________________________________________________________ |
84737f5e | 192 | void AliMagFMaps::Field(Float_t *x, Float_t *b) |
193 | { | |
194 | // | |
195 | // Method to calculate the magnetic field | |
196 | // | |
84737f5e | 197 | // --- find the position in the grid --- |
198 | ||
ee4f31cd | 199 | if (!fFieldRead) ReadField(); |
e2afb3b6 | 200 | |
84737f5e | 201 | b[0]=b[1]=b[2]=0; |
202 | AliFieldMap* map = 0; | |
84737f5e | 203 | if (fFieldMap[0]->Inside(x[0], x[1], x[2])) { |
e2afb3b6 | 204 | map = fFieldMap[0]; |
205 | if (!fL3Option) { | |
206 | // | |
207 | // Constant L3 field, if this option was selected | |
208 | // | |
84737f5e | 209 | b[2] = fSolenoid; |
210 | return; | |
e2afb3b6 | 211 | } |
84737f5e | 212 | } else if (fFieldMap[1]->Inside(x[0], x[1], x[2])) { |
e2afb3b6 | 213 | map = fFieldMap[1]; |
84737f5e | 214 | } else if (fFieldMap[2]->Inside(x[0], x[1], x[2])) { |
e2afb3b6 | 215 | map = fFieldMap[2]; |
84737f5e | 216 | } |
217 | ||
218 | if(map){ | |
e2afb3b6 | 219 | map->Field(x,b); |
84737f5e | 220 | } else { |
e2afb3b6 | 221 | //This is the ZDC part |
222 | Float_t rad2=x[0]*x[0]+x[1]*x[1]; | |
223 | if(x[2]>kCORBEG2 && x[2]<kCOREND2){ | |
84737f5e | 224 | if(rad2<kCOR2RA2){ |
e2afb3b6 | 225 | b[0] = kFCORN2; |
84737f5e | 226 | } |
e2afb3b6 | 227 | } |
228 | else if(x[2]>kZ1BEG && x[2]<kZ1END){ | |
84737f5e | 229 | if(rad2<kZ1RA2){ |
e2afb3b6 | 230 | b[0] = -kG1*x[1]; |
231 | b[1] = -kG1*x[0]; | |
84737f5e | 232 | } |
e2afb3b6 | 233 | } |
234 | else if(x[2]>kZ2BEG && x[2]<kZ2END){ | |
84737f5e | 235 | if(rad2<kZ2RA2){ |
e2afb3b6 | 236 | b[0] = kG1*x[1]; |
237 | b[1] = kG1*x[0]; | |
84737f5e | 238 | } |
e2afb3b6 | 239 | } |
240 | else if(x[2]>kZ3BEG && x[2]<kZ3END){ | |
84737f5e | 241 | if(rad2<kZ3RA2){ |
e2afb3b6 | 242 | b[0] = kG1*x[1]; |
243 | b[1] = kG1*x[0]; | |
84737f5e | 244 | } |
e2afb3b6 | 245 | } |
246 | else if(x[2]>kZ4BEG && x[2]<kZ4END){ | |
84737f5e | 247 | if(rad2<kZ4RA2){ |
e2afb3b6 | 248 | b[0] = -kG1*x[1]; |
249 | b[1] = -kG1*x[0]; | |
84737f5e | 250 | } |
e2afb3b6 | 251 | } |
252 | else if(x[2]>kD1BEG && x[2]<kD1END){ | |
84737f5e | 253 | if(rad2<kD1RA2){ |
e2afb3b6 | 254 | b[1] = -kFDIP; |
84737f5e | 255 | } |
e2afb3b6 | 256 | } |
257 | else if(x[2]>kD2BEG && x[2]<kD2END){ | |
84737f5e | 258 | if(((x[0]-kXCEN1D2)*(x[0]-kXCEN1D2)+(x[1]-kYCEN1D2)*(x[1]-kYCEN1D2))<kD2RA2 |
259 | || ((x[0]-kXCEN2D2)*(x[0]-kXCEN2D2)+(x[1]-kYCEN2D2)*(x[1]-kYCEN2D2))<kD2RA2){ | |
e2afb3b6 | 260 | b[1] = kFDIP; |
84737f5e | 261 | } |
e2afb3b6 | 262 | } |
84737f5e | 263 | } |
264 | if(fFactor!=1) { | |
e2afb3b6 | 265 | b[0]*=fFactor; |
266 | b[1]*=fFactor; | |
267 | b[2]*=fFactor; | |
84737f5e | 268 | } |
269 | } | |
270 | ||
e2afb3b6 | 271 | //_______________________________________________________________________ |
84737f5e | 272 | void AliMagFMaps::Copy(AliMagFMaps & /* magf */) const |
273 | { | |
274 | // | |
275 | // Copy *this onto magf -- Not implemented | |
276 | // | |
277 | Fatal("Copy","Not implemented!\n"); | |
278 | } | |
279 | ||
e2afb3b6 | 280 | //_______________________________________________________________________ |
ee4f31cd | 281 | void AliMagFMaps::Streamer(TBuffer &R__b) |
282 | { | |
e2afb3b6 | 283 | // Stream an object of class AliMagFMaps. |
284 | if (R__b.IsReading()) { | |
285 | AliMagFMaps::Class()->ReadBuffer(R__b, this); | |
286 | fFieldRead = 0; | |
287 | } else { | |
288 | AliMagFMaps::Class()->WriteBuffer(R__b, this); | |
289 | } | |
ee4f31cd | 290 | } |