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