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