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