]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliMagFMaps.cxx
New version of the V0 finder (M.Ivanov)
[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 /* $Id$ */
17
18 //------------------------------------------------------------------------
19 // Magnetic field composed by 3 maps: the L3 magnet, extended region, and
20 // dipole magnet
21 // Used in the configuration macros (macros/Config.C, etc.)
22 // Author: Andreas Morsch <andreas.morsch@cern.ch>
23 //------------------------------------------------------------------------
24
25 #include <TFile.h>
26 #include <TSystem.h>
27
28 #include "AliLog.h"
29 #include "AliFieldMap.h"
30 #include "AliMagFMaps.h"
31
32 ClassImp(AliMagFMaps)
33     
34
35 //_______________________________________________________________________
36 AliMagFMaps::AliMagFMaps():
37   fSolenoid(0),
38   fSolenoidUser(0.),
39   fL3Option(0)
40 {
41   //
42   // Default constructor
43   //
44   //
45   // Don't replicate field information in gAlice
46   fFieldMap[0] = fFieldMap[1] = fFieldMap[2] = 0;
47 }
48
49 //_______________________________________________________________________
50 AliMagFMaps::AliMagFMaps(const char *name, const char *title, Int_t integ, 
51                          Float_t factor, Float_t fmax, Int_t map, 
52                          Int_t l3):
53   AliMagFC(name,title,integ,factor,fmax),
54   fSolenoid(0),
55   fSolenoidUser(0),
56   fL3Option(l3)
57 {
58   //
59   // Standard constructor
60   //
61   fType         = kConMesh;
62   fFieldMap[0]  = 0;
63   fMap          = map;
64   fL3Option     = l3;
65   ReadField();
66   //
67   // Don't replicate field information in gAlice
68   for (Int_t i = 0; i < 3; i++)  fFieldMap[i]->SetWriteEnable(0);
69   //
70 }
71
72 //_______________________________________________________________________
73 AliMagFMaps::AliMagFMaps(const AliMagFMaps &magf):
74   AliMagFC(magf),
75   fSolenoid(0),
76   fL3Option(0)
77 {
78   //
79   // Copy constructor
80   //
81   magf.Copy(*this);
82 }
83
84 //_______________________________________________________________________
85 AliMagFMaps::~AliMagFMaps()
86 {
87   //
88   //  Destructor
89   //
90   delete fFieldMap[0];
91   delete fFieldMap[1];
92   delete fFieldMap[2];    
93 }
94
95 //_______________________________________________________________________
96 void AliMagFMaps::ReadField()
97 {
98   //  Read Field Map from file
99   //
100   //  don't read twice
101   //
102     if (!fgReadField) return;
103     fgReadField = 0;
104   //    
105   char* fname;
106   TFile* file = 0;
107   if (fMap == k2kG) {
108       fSolenoid = 2.;
109       fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/L3B02.root");
110       file = new TFile(fname);
111       fFieldMap[0] = dynamic_cast<AliFieldMap*>(file->Get("L3B02"));
112       file->Close();
113       delete file;
114       fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/DipB02.root");
115       file = new TFile(fname);
116       fFieldMap[1] = dynamic_cast<AliFieldMap*>(file->Get("DipB02"));
117       file->Close();
118       delete file;;
119       
120       fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/ExtB02.root");
121       file = new TFile(fname);
122       fFieldMap[2] = dynamic_cast<AliFieldMap*>(file->Get("ExtB02"));
123       file->Close();
124       delete file;
125   } else if (fMap == k4kG) {
126       fSolenoid = 4.;
127       fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/L3B04.root");
128       file = new TFile(fname);
129       fFieldMap[0] = dynamic_cast<AliFieldMap*>(file->Get("L3B04"));
130       file->Close();
131       delete file;
132       fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/DipB04.root");
133       file = new TFile(fname);
134       fFieldMap[1] = dynamic_cast<AliFieldMap*>(file->Get("DipB04"));
135       file->Close();
136       delete file;
137       
138       fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/ExtB04.root");
139       file = new TFile(fname);
140       fFieldMap[2] = dynamic_cast<AliFieldMap*>(file->Get("ExtB04"));
141       file->Close();
142       delete file;
143   } else if (fMap == k5kG) {
144       fSolenoid = 5.;
145       fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/L3B05.root");
146       file = new TFile(fname);
147       fFieldMap[0] = dynamic_cast<AliFieldMap*>(file->Get("L3B05"));
148       file->Close();
149       delete file;
150       fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/DipB05.root");
151       file = new TFile(fname);
152       fFieldMap[1] = dynamic_cast<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] = dynamic_cast<AliFieldMap*>(file->Get("ExtB05"));
159       file->Close();
160       delete file;
161   }
162
163   if (!fL3Option) fSolenoidUser = fSolenoid;
164
165 }
166
167 //_______________________________________________________________________
168 Float_t AliMagFMaps::SolenoidField() const
169 {
170   //
171   // Returns max. L3 (solenoid) field strength 
172   // according to field map setting 
173   //
174   return fSolenoid;
175 }
176
177 //_______________________________________________________________________
178 void AliMagFMaps::Field(Float_t *x, Float_t *b) const
179 {
180   //
181   // Method to calculate the magnetic field
182   //
183   // --- find the position in the grid ---
184   
185
186     
187  //    if (!fFieldRead) ReadField();
188
189   //
190   // Field Maps have been calculated for the coordinate system in which 
191   // the Muon Spectrometer is placed at z > 0
192   // Transform coordinates corresponingly 
193   //
194   
195   b[0]=b[1]=b[2]=0;
196   Float_t xm[3];
197   xm[0] = - x[0];
198   xm[1] =   x[1];
199   xm[2] = - x[2];
200   
201   AliFieldMap* map = 0;
202   if (fFieldMap[0]->Inside(xm[0], xm[1], xm[2])) {
203       map = fFieldMap[0];
204       Float_t r = TMath::Sqrt(xm[0] * xm[0] + xm[1] * xm[1]);
205       
206       if (!fL3Option && TMath::Abs(xm[2]) < 370. && r < 550.) {
207       //
208       //     Constant L3 field , if this option was selected
209       //
210         b[2] = (- fSolenoid)*fFactor;
211           return;
212       } 
213   } else if (fFieldMap[1]->Inside(xm[0], xm[1], xm[2])) {
214     map = fFieldMap[1];
215   } else if (fFieldMap[2]->Inside(xm[0], xm[1], xm[2])) {
216     map = fFieldMap[2];
217   }
218   
219   if(map){
220     map->Field(xm,b);
221     b[0] = - b[0];
222     b[2] = - b[2];
223
224   } else {
225       //This is the ZDC part
226       ZDCField(x, b);
227   }
228
229   
230   if(fFactor!=1) {
231       b[0]*=fFactor;
232       b[1]*=fFactor;
233       b[2]*=fFactor;
234   }
235 }
236
237 //_______________________________________________________________________
238 void AliMagFMaps::Copy(TObject & /* magf */) const
239 {
240   //
241   // Copy *this onto magf -- Not implemented
242   //
243   AliFatal("Not implemented!");
244 }
245
246 //_______________________________________________________________________
247 void AliMagFMaps::Streamer(TBuffer &R__b)
248 {
249   // Stream an object of class AliMagFMaps.
250   if (R__b.IsReading()) {
251     AliMagFMaps::Class()->ReadBuffer(R__b, this);
252     ReadField();
253   } else {
254     AliMagFMaps::Class()->WriteBuffer(R__b, this);
255   }
256 }