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