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