]>
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 | |
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 | 34 | ClassImp(AliMagFMaps) |
a0201063 | 35 | |
84737f5e | 36 | |
e2afb3b6 | 37 | //_______________________________________________________________________ |
38 | AliMagFMaps::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 | 52 | AliMagFMaps::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 | //_______________________________________________________________________ |
75 | AliMagFMaps::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 | 88 | AliMagFMaps::~AliMagFMaps() |
89 | { | |
e2afb3b6 | 90 | // |
91 | // Destructor | |
92 | // | |
93 | delete fFieldMap[0]; | |
94 | delete fFieldMap[1]; | |
95 | delete fFieldMap[2]; | |
84737f5e | 96 | } |
97 | ||
e2afb3b6 | 98 | //_______________________________________________________________________ |
c2b548d6 | 99 | void AliMagFMaps::ReadField() |
100 | { | |
e2afb3b6 | 101 | // Read Field Map from file |
102 | // | |
103 | // don't read twice | |
104 | // | |
972ca52f | 105 | if (!fReadField) return; |
106 | fReadField = kFALSE; | |
e2afb3b6 | 107 | // |
5ce1fbec | 108 | |
109 | ||
316c6cd9 | 110 | char* fname = 0; |
e2afb3b6 | 111 | TFile* file = 0; |
112 | if (fMap == k2kG) { | |
b6ee07d3 | 113 | fSolenoid = 2.; |
114 | fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/L3B02.root"); | |
115 | file = new TFile(fname); | |
116 | fFieldMap[0] = dynamic_cast<AliFieldMap*>(file->Get("L3B02")); | |
117 | file->Close(); | |
118 | delete file; | |
8a8d346e | 119 | delete [] fname; // see documentation to expand filenam |
177a7fab | 120 | fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/DipB02.root"); |
e2afb3b6 | 121 | file = new TFile(fname); |
177a7fab | 122 | fFieldMap[1] = dynamic_cast<AliFieldMap*>(file->Get("DipB02")); |
123 | file->Close(); | |
124 | delete file;; | |
8a8d346e | 125 | delete [] fname; |
177a7fab | 126 | fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/ExtB02.root"); |
127 | file = new TFile(fname); | |
128 | fFieldMap[2] = dynamic_cast<AliFieldMap*>(file->Get("ExtB02")); | |
e2afb3b6 | 129 | file->Close(); |
130 | delete file; | |
8a8d346e | 131 | delete [] fname; |
e2afb3b6 | 132 | } else if (fMap == k4kG) { |
b6ee07d3 | 133 | fSolenoid = 4.; |
134 | fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/L3B04.root"); | |
135 | file = new TFile(fname); | |
136 | fFieldMap[0] = dynamic_cast<AliFieldMap*>(file->Get("L3B04")); | |
137 | file->Close(); | |
138 | delete file; | |
8a8d346e | 139 | delete [] fname; |
177a7fab | 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(); | |
8a8d346e | 144 | delete [] fname; |
177a7fab | 145 | delete file; |
146 | ||
147 | fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/ExtB04.root"); | |
148 | file = new TFile(fname); | |
149 | fFieldMap[2] = dynamic_cast<AliFieldMap*>(file->Get("ExtB04")); | |
e2afb3b6 | 150 | file->Close(); |
8a8d346e | 151 | delete [] fname; |
e2afb3b6 | 152 | delete file; |
e2afb3b6 | 153 | } else if (fMap == k5kG) { |
b6ee07d3 | 154 | fSolenoid = 5.; |
155 | fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/L3B05.root"); | |
156 | file = new TFile(fname); | |
157 | fFieldMap[0] = dynamic_cast<AliFieldMap*>(file->Get("L3B05")); | |
158 | file->Close(); | |
316c6cd9 | 159 | delete file; |
8a8d346e | 160 | delete [] fname; |
177a7fab | 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; | |
8a8d346e | 166 | delete [] fname; |
177a7fab | 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; | |
8a8d346e | 172 | delete [] fname; |
e2afb3b6 | 173 | } |
b6ee07d3 | 174 | |
175 | if (!fL3Option) fSolenoidUser = fSolenoid; | |
176 | ||
c2b548d6 | 177 | } |
178 | ||
e2afb3b6 | 179 | //_______________________________________________________________________ |
84737f5e | 180 | Float_t AliMagFMaps::SolenoidField() const |
181 | { | |
e2afb3b6 | 182 | // |
183 | // Returns max. L3 (solenoid) field strength | |
184 | // according to field map setting | |
185 | // | |
7ebb06c3 | 186 | return -Factor()*fSolenoid; |
84737f5e | 187 | } |
188 | ||
e2afb3b6 | 189 | //_______________________________________________________________________ |
6f3038e9 | 190 | void AliMagFMaps::Field(Float_t *x, Float_t *b) const |
84737f5e | 191 | { |
192 | // | |
193 | // Method to calculate the magnetic field | |
194 | // | |
84737f5e | 195 | // --- find the position in the grid --- |
196 | ||
57754f18 | 197 | |
198 | ||
6f3038e9 | 199 | // if (!fFieldRead) ReadField(); |
57754f18 | 200 | |
201 | // | |
202 | // Field Maps have been calculated for the coordinate system in which | |
203 | // the Muon Spectrometer is placed at z > 0 | |
204 | // Transform coordinates corresponingly | |
205 | // | |
e2afb3b6 | 206 | |
84737f5e | 207 | b[0]=b[1]=b[2]=0; |
57754f18 | 208 | Float_t xm[3]; |
209 | xm[0] = - x[0]; | |
210 | xm[1] = x[1]; | |
211 | xm[2] = - x[2]; | |
212 | ||
84737f5e | 213 | AliFieldMap* map = 0; |
57754f18 | 214 | if (fFieldMap[0]->Inside(xm[0], xm[1], xm[2])) { |
177a7fab | 215 | map = fFieldMap[0]; |
0ae44e30 | 216 | Float_t r = TMath::Sqrt(xm[0] * xm[0] + xm[1] * xm[1]); |
217 | ||
218 | if (!fL3Option && TMath::Abs(xm[2]) < 370. && r < 550.) { | |
e2afb3b6 | 219 | // |
b6ee07d3 | 220 | // Constant L3 field , if this option was selected |
e2afb3b6 | 221 | // |
81e97e0d | 222 | b[2] = (- fSolenoid)*fFactor; |
84737f5e | 223 | return; |
b6ee07d3 | 224 | } |
57754f18 | 225 | } else if (fFieldMap[1]->Inside(xm[0], xm[1], xm[2])) { |
88cb7938 | 226 | map = fFieldMap[1]; |
57754f18 | 227 | } else if (fFieldMap[2]->Inside(xm[0], xm[1], xm[2])) { |
88cb7938 | 228 | map = fFieldMap[2]; |
84737f5e | 229 | } |
230 | ||
231 | if(map){ | |
57754f18 | 232 | map->Field(xm,b); |
233 | b[0] = - b[0]; | |
234 | b[2] = - b[2]; | |
235 | ||
84737f5e | 236 | } else { |
57754f18 | 237 | //This is the ZDC part |
238 | ZDCField(x, b); | |
84737f5e | 239 | } |
57754f18 | 240 | |
241 | ||
84737f5e | 242 | if(fFactor!=1) { |
57754f18 | 243 | b[0]*=fFactor; |
244 | b[1]*=fFactor; | |
245 | b[2]*=fFactor; | |
84737f5e | 246 | } |
247 | } | |
248 | ||
e2afb3b6 | 249 | //_______________________________________________________________________ |
6c4904c2 | 250 | void AliMagFMaps::Copy(TObject & /* magf */) const |
84737f5e | 251 | { |
252 | // | |
253 | // Copy *this onto magf -- Not implemented | |
254 | // | |
594d8990 | 255 | AliFatal("Not implemented!"); |
84737f5e | 256 | } |
257 | ||
e2afb3b6 | 258 | //_______________________________________________________________________ |
ee4f31cd | 259 | void AliMagFMaps::Streamer(TBuffer &R__b) |
260 | { | |
e2afb3b6 | 261 | // Stream an object of class AliMagFMaps. |
262 | if (R__b.IsReading()) { | |
972ca52f | 263 | R__b.ReadClassBuffer(AliMagFMaps::Class(), this); |
5ce1fbec | 264 | // |
265 | fReadField = kTRUE; | |
266 | ReadField(); | |
e2afb3b6 | 267 | } else { |
972ca52f | 268 | R__b.WriteClassBuffer(AliMagFMaps::Class(), this); |
e2afb3b6 | 269 | } |
ee4f31cd | 270 | } |