]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliMagFMapsV1.cxx
Setter method added
[u/mrichter/AliRoot.git] / STEER / AliMagFMapsV1.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 4 maps: the L3 magnet (inside and outside measured region), 
20 // extended region, and dipole magnet.
21 // Used in the configuration macros (macros/Config.C, etc.)
22 // Author: Andreas Morsch <andreas.morsch@cern.ch>
23 //------------------------------------------------------------------------
24
25 #include <TClass.h>
26 #include <TFile.h>
27 #include <TMath.h>
28 #include <TSystem.h>
29
30 #include "AliLog.h"
31 #include "AliFieldMap.h"
32 #include "AliMagFMapsV1.h"
33
34 ClassImp(AliMagFMapsV1)
35     
36
37 //_______________________________________________________________________
38 AliMagFMapsV1::AliMagFMapsV1():
39   AliMagFMaps(),
40   fMeasuredMap(0) 
41 {
42   //
43   // Default constructor
44   //
45 }
46
47 //_______________________________________________________________________
48 AliMagFMapsV1::AliMagFMapsV1(const char *name, const char *title, Int_t integ, 
49                              Float_t factor, Float_t fmax, Int_t map, 
50                              Int_t l3):
51     AliMagFMaps(name, title, integ, factor, fmax, map, l3),
52     fMeasuredMap(0) 
53 {
54     //
55     // Constructor
56     //
57     char* fname;
58     fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/mfcheb.root");
59     TFile* file = new TFile(fname);
60     if (fMap == k2kG) {
61         fMeasuredMap = dynamic_cast<AliMagFCheb*>(file->Get("Sol12_Dip6_Hole"));
62         fSolenoid = 0.2; // T
63     } else if (fMap == k5kG) {
64         fMeasuredMap = dynamic_cast<AliMagFCheb*>(file->Get("Sol30_Dip6_Hole"));
65         fSolenoid = 0.5; // T
66     } else if (fMap == k4kG){
67         fMeasuredMap = 0;
68         fSolenoid = 0.4; // T
69     }
70     
71     
72     
73     file->Close();
74     delete file;
75 }
76
77
78 //_______________________________________________________________________
79 AliMagFMapsV1::AliMagFMapsV1(const AliMagFMapsV1 &magf):
80   AliMagFMaps(magf),
81   fMeasuredMap(0)
82 {
83   //
84   // Copy constructor
85   //
86   magf.Copy(*this);
87 }
88
89 //_______________________________________________________________________
90 AliMagFMapsV1::~AliMagFMapsV1()
91 {
92     // Destructor
93     delete fMeasuredMap;
94 }
95
96 //_______________________________________________________________________
97 void AliMagFMapsV1::Field(Float_t *x, Float_t *b) const
98 {
99   //
100   // Method to calculate the magnetic field at position x
101   //
102     const Float_t kRmax2 = 500. * 500.;
103     const Float_t kZmax  = 550.; 
104     const Float_t kTeslaTokG = 10.;
105     const Float_t kScale = 0.98838; // matching factor
106     
107     // Check if position inside measured map
108     Float_t r2 = x[0] * x[0] + x[1] * x[1];
109     if (fMeasuredMap              &&
110         r2 < kRmax2               && 
111         TMath::Abs(x[2]) < kZmax
112         ) 
113     {
114         fMeasuredMap->Field(x, b);
115         b[0] *= kTeslaTokG;
116         b[1] *= kTeslaTokG;
117         b[2] *= kTeslaTokG;
118     } else {
119         AliMagFMaps::Field(x, b);
120         // Match to measure map
121         b[0] = - b[0] * kScale;
122         b[2] = - b[2] * kScale;
123         b[1] = - b[1] * kScale;
124     }
125 }
126
127
128 Float_t AliMagFMapsV1::SolenoidField() const
129 {
130   //
131   // Returns max. L3 (solenoid) field strength 
132   // according to field map setting 
133   //
134         return fSolenoid;
135 }
136
137 void AliMagFMapsV1::Copy(TObject &fm) const
138 {
139   // dummy since the base class constructor is dummy
140   AliMagFMaps::Copy(fm);
141   AliMagFMapsV1* fmp = (AliMagFMapsV1*) &fm;
142   fmp->SetMeasuredMap(fMeasuredMap);
143 }