]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliMagWrapCheb.cxx
Initialization of the field outside of the measured map
[u/mrichter/AliRoot.git] / STEER / AliMagWrapCheb.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 #include <TClass.h>
18 #include <TFile.h>
19 #include <TSystem.h>
20
21 #include "AliMagWrapCheb.h"
22 #include "AliLog.h"
23
24 ClassImp(AliMagWrapCheb)
25     
26
27 //_______________________________________________________________________
28 AliMagWrapCheb::AliMagWrapCheb():
29   AliMagFC(),
30   fMeasuredMap(0),
31   fSolenoid(5.)
32 {
33   // Default constructor
34   //
35 }
36
37 //_______________________________________________________________________
38 AliMagWrapCheb::AliMagWrapCheb(const char *name, const char *title, Int_t integ, 
39                                Float_t factor, Float_t fmax, Int_t map, 
40                                Bool_t dipoleON,const char* path):
41   AliMagFC(name, title, integ, factor, fmax),
42   fMeasuredMap(0),
43   fSolenoid(5.)
44 {
45   //
46   fMap = map;
47   char* fname = gSystem->ExpandPathName(path);
48   TFile* file = TFile::Open(fname);
49   if (!file) {
50     AliError(Form("Failed to open magnetic field data file %s\n",fname)); 
51     return;
52   }
53   const char* parname = 0;
54   if        (fMap == k2kG) {
55     fSolenoid = 2.;
56     parname = dipoleON ? "Sol12_Dip6_Hole":"Sol12_Dip0_Hole";
57   } else if (fMap == k5kG) {
58     fSolenoid = 5.;
59     parname = dipoleON ? "Sol30_Dip6_Hole":"Sol30_Dip0_Hole";
60   } else {
61     AliError(Form("Unknown field identifier %d is requested\n",fMap)); 
62     return;
63   }
64   //
65   fMeasuredMap = dynamic_cast<AliMagFCheb*>(file->Get(parname));
66   if (!fMeasuredMap) {
67     AliError(Form("Did not find field %s in %s\n",parname,fname)); 
68     return;
69   }
70   file->Close();
71   delete file;
72 }
73
74
75 //_______________________________________________________________________
76 AliMagWrapCheb::AliMagWrapCheb(const AliMagWrapCheb &src):
77   AliMagFC(src),
78   fMeasuredMap(0),
79   fSolenoid(src.fSolenoid)
80 {
81   if (src.fMeasuredMap) fMeasuredMap = new AliMagFCheb(*src.fMeasuredMap);
82 }
83
84 //_______________________________________________________________________
85 AliMagWrapCheb::~AliMagWrapCheb()
86 {
87   delete fMeasuredMap;
88 }
89
90 //_______________________________________________________________________
91 void AliMagWrapCheb::GetTPCInt(Float_t *xyz, Float_t *b) const
92 {
93   // Method to calculate the integral of magnetic integral from xyz to nearest cathode plane
94   //
95   b[0]=b[1]=b[2]=0.0;
96   if (fMeasuredMap) fMeasuredMap->GetTPCInt(xyz,b);
97   for (int i=3;i--;) b[i] *= fFactor;
98 }
99
100 //_______________________________________________________________________
101 void AliMagWrapCheb::GetTPCIntCyl(Float_t *rphiz, Float_t *b) const
102 {
103   // Method to calculate the integral of magnetic integral from point to nearest cathode plane
104   // in cylindrical coordiates ( -pi<phi<pi convention )
105   b[0]=b[1]=b[2]=0.0;
106   if (fMeasuredMap) fMeasuredMap->GetTPCIntCyl(rphiz,b);
107   for (int i=3;i--;) b[i] *= fFactor;
108 }
109
110 //_______________________________________________________________________
111 void AliMagWrapCheb::Field(Float_t *xyz, Float_t *b) const
112 {
113   // Method to calculate the field at point  xyz
114   //
115   b[0]=b[1]=b[2]=0.0;
116     if (xyz[2] > 919. || xyz[2] < -1972.) {
117         ZDCField(xyz, b);
118     } else {
119         if (fMeasuredMap) fMeasuredMap->Field(xyz,b);
120     }
121     
122   for (int i=3;i--;) b[i] *= fFactor;
123 }
124
125 //_______________________________________________________________________
126 AliMagWrapCheb& AliMagWrapCheb::operator=(const AliMagWrapCheb& maps)
127 {
128   fSolenoid=maps.fSolenoid;
129   if (this != &maps && maps.fMeasuredMap) { 
130     if (fMeasuredMap) delete fMeasuredMap;
131     fMeasuredMap = new AliMagFCheb(*maps.fMeasuredMap);
132   }
133   return *this;
134 }