]>
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 | ||
16 | /* | |
17 | $Log$ | |
7b6cddfa | 18 | Revision 1.3 2002/02/21 09:23:41 morsch |
19 | Create dummy field map for L3 in case no detailed map is needed. | |
20 | ||
7a1ab119 | 21 | Revision 1.2 2002/02/19 16:14:35 morsch |
22 | Reading of 0.2 T solenoid field map enabled. | |
23 | ||
bfd6c805 | 24 | Revision 1.1 2002/02/14 11:41:28 morsch |
25 | Magnetic field map for ALICE for L3+muon spectrometer stored in 3 seperate | |
26 | root files. | |
27 | ||
84737f5e | 28 | */ |
29 | ||
30 | // | |
31 | // Author: Andreas Morsch <andreas.morsch@cern.ch> | |
32 | // | |
33 | ||
34 | #include <TFile.h> | |
35 | #include <TSystem.h> | |
36 | #include "AliFieldMap.h" | |
37 | #include "AliMagFMaps.h" | |
38 | ||
39 | ||
40 | ClassImp(AliMagFMaps) | |
41 | ||
42 | //________________________________________ | |
43 | AliMagFMaps::AliMagFMaps(const char *name, const char *title, const Int_t integ, | |
44 | const Float_t factor, const Float_t fmax, const Int_t map) | |
45 | : AliMagF(name,title,integ,factor,fmax) | |
46 | { | |
47 | // | |
48 | // Standard constructor | |
49 | // | |
50 | fType = kConMesh; | |
51 | fFieldMap[0] = 0; | |
52 | char* fname; | |
53 | ||
54 | fMap = map; | |
55 | TFile* file = 0; | |
7a1ab119 | 56 | if (fMap == k2kG) { |
7b6cddfa | 57 | if (integ) { |
7a1ab119 | 58 | fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/L3B02.root"); |
59 | file = new TFile(fname); | |
60 | fFieldMap[0] = (AliFieldMap*) file->Get("L3B02"); | |
61 | file->Close(); | |
62 | delete file; | |
7b6cddfa | 63 | } |
64 | fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/DipB02.root"); | |
65 | file = new TFile(fname); | |
66 | fFieldMap[1] = (AliFieldMap*) file->Get("DipB02"); | |
67 | file->Close(); | |
68 | delete file;; | |
69 | ||
70 | fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/ExtB02.root"); | |
71 | file = new TFile(fname); | |
72 | fFieldMap[2] = (AliFieldMap*) file->Get("ExtB02"); | |
73 | file->Close(); | |
74 | delete file; | |
75 | fSolenoid = 2.; | |
76 | } else if (fMap == k4kG) { | |
77 | if (integ) { | |
78 | fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/L3B04.root"); | |
7a1ab119 | 79 | file = new TFile(fname); |
7b6cddfa | 80 | fFieldMap[0] = (AliFieldMap*) file->Get("L3B04"); |
7a1ab119 | 81 | file->Close(); |
7b6cddfa | 82 | delete file; |
83 | } | |
84 | ||
85 | fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/DipB04.root"); | |
86 | file = new TFile(fname); | |
87 | fFieldMap[1] = (AliFieldMap*) file->Get("DipB04"); | |
88 | file->Close(); | |
89 | delete file;; | |
90 | ||
91 | fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/ExtB04.root"); | |
92 | file = new TFile(fname); | |
93 | fFieldMap[2] = (AliFieldMap*) file->Get("ExtB04"); | |
94 | file->Close(); | |
95 | delete file; | |
96 | fSolenoid = 4.; | |
97 | } else if (fMap == k5kG) { | |
98 | if (integ) { | |
99 | fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/L3B05.root"); | |
7a1ab119 | 100 | file = new TFile(fname); |
7b6cddfa | 101 | fFieldMap[0] = (AliFieldMap*) file->Get("L3B05"); |
7a1ab119 | 102 | file->Close(); |
103 | delete file; | |
104 | } | |
7b6cddfa | 105 | |
106 | fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/DipB05.root"); | |
107 | file = new TFile(fname); | |
108 | fFieldMap[1] = (AliFieldMap*) file->Get("DipB05"); | |
109 | file->Close(); | |
110 | delete file;; | |
111 | ||
112 | fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/ExtB05.root"); | |
113 | file = new TFile(fname); | |
114 | fFieldMap[2] = (AliFieldMap*) file->Get("ExtB05"); | |
115 | file->Close(); | |
116 | delete file; | |
117 | ||
118 | fSolenoid = 5.; | |
119 | } | |
120 | ||
121 | if (!integ) { | |
122 | // | |
123 | // Dummy L3 map | |
124 | fFieldMap[0] = new AliFieldMap(); | |
125 | fFieldMap[0] -> SetLimits(-800., 800., -800., 800., -700., 700.); | |
126 | } | |
127 | ||
128 | // | |
129 | // Don't replicate field information in gAlice | |
130 | for (Int_t i = 0; i < 3; i++) fFieldMap[i]->SetWriteEnable(0); | |
131 | // | |
132 | SetL3ConstField(0); | |
84737f5e | 133 | } |
134 | ||
135 | //________________________________________ | |
136 | AliMagFMaps::AliMagFMaps(const AliMagFMaps &magf) | |
137 | { | |
138 | // | |
139 | // Copy constructor | |
140 | // | |
141 | magf.Copy(*this); | |
142 | } | |
143 | ||
144 | AliMagFMaps::~AliMagFMaps() | |
145 | { | |
146 | // | |
147 | // Destructor | |
148 | // | |
149 | delete fFieldMap[0]; | |
150 | delete fFieldMap[1]; | |
151 | delete fFieldMap[2]; | |
152 | } | |
153 | ||
154 | ||
155 | Float_t AliMagFMaps::SolenoidField() const | |
156 | { | |
157 | // | |
158 | // Returns max. L3 (solenoid) field strength | |
159 | // according to field map setting | |
160 | ||
161 | return fSolenoid; | |
162 | } | |
163 | ||
164 | ||
165 | ||
166 | //________________________________________ | |
167 | void AliMagFMaps::Field(Float_t *x, Float_t *b) | |
168 | { | |
169 | // | |
170 | // Method to calculate the magnetic field | |
171 | // | |
84737f5e | 172 | // --- find the position in the grid --- |
173 | ||
174 | b[0]=b[1]=b[2]=0; | |
175 | AliFieldMap* map = 0; | |
84737f5e | 176 | if (fFieldMap[0]->Inside(x[0], x[1], x[2])) { |
177 | map = fFieldMap[0]; | |
178 | if (fL3Option) { | |
179 | // | |
180 | // Constant L3 field, if this option was selected | |
181 | // | |
182 | b[2] = fSolenoid; | |
183 | return; | |
184 | } | |
185 | } else if (fFieldMap[1]->Inside(x[0], x[1], x[2])) { | |
186 | map = fFieldMap[1]; | |
187 | } else if (fFieldMap[2]->Inside(x[0], x[1], x[2])) { | |
188 | map = fFieldMap[2]; | |
189 | } | |
190 | ||
191 | if(map){ | |
192 | map->Field(x,b); | |
193 | } else { | |
194 | //This is the ZDC part | |
195 | Float_t rad2=x[0]*x[0]+x[1]*x[1]; | |
196 | if(x[2]>kCORBEG2 && x[2]<kCOREND2){ | |
197 | if(rad2<kCOR2RA2){ | |
198 | b[0] = kFCORN2; | |
199 | } | |
200 | } | |
201 | else if(x[2]>kZ1BEG && x[2]<kZ1END){ | |
202 | if(rad2<kZ1RA2){ | |
203 | b[0] = -kG1*x[1]; | |
204 | b[1] = -kG1*x[0]; | |
205 | } | |
206 | } | |
207 | else if(x[2]>kZ2BEG && x[2]<kZ2END){ | |
208 | if(rad2<kZ2RA2){ | |
209 | b[0] = kG1*x[1]; | |
210 | b[1] = kG1*x[0]; | |
211 | } | |
212 | } | |
213 | else if(x[2]>kZ3BEG && x[2]<kZ3END){ | |
214 | if(rad2<kZ3RA2){ | |
215 | b[0] = kG1*x[1]; | |
216 | b[1] = kG1*x[0]; | |
217 | } | |
218 | } | |
219 | else if(x[2]>kZ4BEG && x[2]<kZ4END){ | |
220 | if(rad2<kZ4RA2){ | |
221 | b[0] = -kG1*x[1]; | |
222 | b[1] = -kG1*x[0]; | |
223 | } | |
224 | } | |
225 | else if(x[2]>kD1BEG && x[2]<kD1END){ | |
226 | if(rad2<kD1RA2){ | |
227 | b[1] = -kFDIP; | |
228 | } | |
229 | } | |
230 | else if(x[2]>kD2BEG && x[2]<kD2END){ | |
231 | if(((x[0]-kXCEN1D2)*(x[0]-kXCEN1D2)+(x[1]-kYCEN1D2)*(x[1]-kYCEN1D2))<kD2RA2 | |
232 | || ((x[0]-kXCEN2D2)*(x[0]-kXCEN2D2)+(x[1]-kYCEN2D2)*(x[1]-kYCEN2D2))<kD2RA2){ | |
233 | b[1] = kFDIP; | |
234 | } | |
235 | } | |
236 | } | |
237 | if(fFactor!=1) { | |
238 | b[0]*=fFactor; | |
239 | b[1]*=fFactor; | |
240 | b[2]*=fFactor; | |
241 | } | |
242 | } | |
243 | ||
244 | //________________________________________ | |
245 | void AliMagFMaps::Copy(AliMagFMaps & /* magf */) const | |
246 | { | |
247 | // | |
248 | // Copy *this onto magf -- Not implemented | |
249 | // | |
250 | Fatal("Copy","Not implemented!\n"); | |
251 | } | |
252 | ||
253 | //________________________________________ | |
254 | AliMagFMaps & AliMagFMaps::operator =(const AliMagFMaps &magf) | |
255 | { | |
256 | magf.Copy(*this); | |
257 | return *this; | |
258 | } |