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