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