]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliMagFMaps.cxx
Minor corrections on the display (adc counts readable, ...).
[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
16/*
17$Log$
b9d0a01d 18Revision 1.5.6.2 2002/08/01 15:35:30 alibrary
19Updating VirtualMC
20
21Revision 1.7 2002/08/01 12:34:48 morsch
22Initialize maps in first call to Field() after streaming in.
23
ee4f31cd 24Revision 1.6 2002/04/11 11:17:48 morsch
25ReadField() used in Constructor.
26
c2b548d6 27Revision 1.5 2002/02/26 09:48:14 morsch
28Extra argument in constructor for l3 map choice.
29
356f9803 30Revision 1.4 2002/02/22 14:00:20 morsch
31Protection against replication of fieldmap data in gAlice.
32
7b6cddfa 33Revision 1.3 2002/02/21 09:23:41 morsch
34Create dummy field map for L3 in case no detailed map is needed.
35
7a1ab119 36Revision 1.2 2002/02/19 16:14:35 morsch
37Reading of 0.2 T solenoid field map enabled.
38
bfd6c805 39Revision 1.1 2002/02/14 11:41:28 morsch
40Magnetic field map for ALICE for L3+muon spectrometer stored in 3 seperate
41root files.
42
84737f5e 43*/
44
45//
46// Author: Andreas Morsch <andreas.morsch@cern.ch>
47//
48
49#include <TFile.h>
50#include <TSystem.h>
51#include "AliFieldMap.h"
52#include "AliMagFMaps.h"
53
54
55ClassImp(AliMagFMaps)
56
57//________________________________________
58AliMagFMaps::AliMagFMaps(const char *name, const char *title, const Int_t integ,
356f9803 59 const Float_t factor, const Float_t fmax, const Int_t map,
60 const Int_t l3)
84737f5e 61 : AliMagF(name,title,integ,factor,fmax)
62{
63 //
64 // Standard constructor
65 //
66 fType = kConMesh;
67 fFieldMap[0] = 0;
c2b548d6 68 fMap = map;
69 fL3Option = l3;
70
71 ReadField();
72 fFieldRead = 1;
7b6cddfa 73//
74// Don't replicate field information in gAlice
75 for (Int_t i = 0; i < 3; i++) fFieldMap[i]->SetWriteEnable(0);
76//
c2b548d6 77
84737f5e 78}
79
80//________________________________________
81AliMagFMaps::AliMagFMaps(const AliMagFMaps &magf)
82{
83 //
84 // Copy constructor
85 //
86 magf.Copy(*this);
87}
88
89AliMagFMaps::~AliMagFMaps()
90{
91//
92// Destructor
93//
94 delete fFieldMap[0];
95 delete fFieldMap[1];
96 delete fFieldMap[2];
97}
98
c2b548d6 99void AliMagFMaps::ReadField()
100{
101// Read Field Map from file
102//
103// don't read twice
104//
105 if (fFieldRead) return;
ee4f31cd 106 fFieldRead = 1;
c2b548d6 107//
108 char* fname;
109 TFile* file = 0;
110 if (fMap == k2kG) {
111 if (fL3Option) {
112 fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/L3B02.root");
113 file = new TFile(fname);
114 fFieldMap[0] = (AliFieldMap*) file->Get("L3B02");
115 file->Close();
116 delete file;
117 }
118 fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/DipB02.root");
119 file = new TFile(fname);
120 fFieldMap[1] = (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] = (AliFieldMap*) file->Get("ExtB02");
127 file->Close();
128 delete file;
129 fSolenoid = 2.;
130 } else if (fMap == k4kG) {
131 if (fL3Option) {
132 fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/L3B04.root");
133 file = new TFile(fname);
134 fFieldMap[0] = (AliFieldMap*) file->Get("L3B04");
135 file->Close();
136 delete file;
137 }
138
139 fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/DipB04.root");
140 file = new TFile(fname);
141 fFieldMap[1] = (AliFieldMap*) file->Get("DipB04");
142 file->Close();
143 delete file;;
144
145 fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/ExtB04.root");
146 file = new TFile(fname);
147 fFieldMap[2] = (AliFieldMap*) file->Get("ExtB04");
148 file->Close();
149 delete file;
150 fSolenoid = 4.;
151 } else if (fMap == k5kG) {
152 if (fL3Option) {
153 fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/L3B05.root");
154 file = new TFile(fname);
155 fFieldMap[0] = (AliFieldMap*) file->Get("L3B05");
156 file->Close();
157 delete file;
158 }
159
160 fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/DipB05.root");
161 file = new TFile(fname);
162 fFieldMap[1] = (AliFieldMap*) file->Get("DipB05");
163 file->Close();
164 delete file;;
165
166 fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/ExtB05.root");
167 file = new TFile(fname);
168 fFieldMap[2] = (AliFieldMap*) file->Get("ExtB05");
169 file->Close();
170 delete file;
171
172 fSolenoid = 5.;
173 }
174
175 if (!fL3Option) {
176//
177// Dummy L3 map
178 fFieldMap[0] = new AliFieldMap();
179 fFieldMap[0] -> SetLimits(-800., 800., -800., 800., -700., 700.);
180 }
181}
182
84737f5e 183
184Float_t AliMagFMaps::SolenoidField() const
185{
186//
187// Returns max. L3 (solenoid) field strength
188// according to field map setting
189
190 return fSolenoid;
191}
192
193
194
195//________________________________________
196void AliMagFMaps::Field(Float_t *x, Float_t *b)
197{
198 //
199 // Method to calculate the magnetic field
200 //
84737f5e 201 // --- find the position in the grid ---
202
ee4f31cd 203 if (!fFieldRead) ReadField();
204
84737f5e 205 b[0]=b[1]=b[2]=0;
206 AliFieldMap* map = 0;
84737f5e 207 if (fFieldMap[0]->Inside(x[0], x[1], x[2])) {
208 map = fFieldMap[0];
356f9803 209 if (!fL3Option) {
84737f5e 210//
211// Constant L3 field, if this option was selected
212//
213 b[2] = fSolenoid;
214 return;
215 }
216 } else if (fFieldMap[1]->Inside(x[0], x[1], x[2])) {
217 map = fFieldMap[1];
218 } else if (fFieldMap[2]->Inside(x[0], x[1], x[2])) {
219 map = fFieldMap[2];
220 }
221
222 if(map){
223 map->Field(x,b);
224 } else {
225//This is the ZDC part
226 Float_t rad2=x[0]*x[0]+x[1]*x[1];
227 if(x[2]>kCORBEG2 && x[2]<kCOREND2){
228 if(rad2<kCOR2RA2){
229 b[0] = kFCORN2;
230 }
231 }
232 else if(x[2]>kZ1BEG && x[2]<kZ1END){
233 if(rad2<kZ1RA2){
234 b[0] = -kG1*x[1];
235 b[1] = -kG1*x[0];
236 }
237 }
238 else if(x[2]>kZ2BEG && x[2]<kZ2END){
239 if(rad2<kZ2RA2){
240 b[0] = kG1*x[1];
241 b[1] = kG1*x[0];
242 }
243 }
244 else if(x[2]>kZ3BEG && x[2]<kZ3END){
245 if(rad2<kZ3RA2){
246 b[0] = kG1*x[1];
247 b[1] = kG1*x[0];
248 }
249 }
250 else if(x[2]>kZ4BEG && x[2]<kZ4END){
251 if(rad2<kZ4RA2){
252 b[0] = -kG1*x[1];
253 b[1] = -kG1*x[0];
254 }
255 }
256 else if(x[2]>kD1BEG && x[2]<kD1END){
257 if(rad2<kD1RA2){
258 b[1] = -kFDIP;
259 }
260 }
261 else if(x[2]>kD2BEG && x[2]<kD2END){
262 if(((x[0]-kXCEN1D2)*(x[0]-kXCEN1D2)+(x[1]-kYCEN1D2)*(x[1]-kYCEN1D2))<kD2RA2
263 || ((x[0]-kXCEN2D2)*(x[0]-kXCEN2D2)+(x[1]-kYCEN2D2)*(x[1]-kYCEN2D2))<kD2RA2){
264 b[1] = kFDIP;
265 }
266 }
267 }
268 if(fFactor!=1) {
269 b[0]*=fFactor;
270 b[1]*=fFactor;
271 b[2]*=fFactor;
272 }
273}
274
275//________________________________________
276void AliMagFMaps::Copy(AliMagFMaps & /* magf */) const
277{
278 //
279 // Copy *this onto magf -- Not implemented
280 //
281 Fatal("Copy","Not implemented!\n");
282}
283
284//________________________________________
285AliMagFMaps & AliMagFMaps::operator =(const AliMagFMaps &magf)
286{
287 magf.Copy(*this);
288 return *this;
289}
ee4f31cd 290
291void AliMagFMaps::Streamer(TBuffer &R__b)
292{
293 // Stream an object of class AliMagFMaps.
294 if (R__b.IsReading()) {
295 AliMagFMaps::Class()->ReadBuffer(R__b, this);
296 fFieldRead = 0;
297 } else {
298 AliMagFMaps::Class()->WriteBuffer(R__b, this);
299 }
300}