-
Notifications
You must be signed in to change notification settings - Fork 494
Expand file tree
/
Copy pathMagFieldParam.cxx
More file actions
107 lines (99 loc) · 3.26 KB
/
MagFieldParam.cxx
File metadata and controls
107 lines (99 loc) · 3.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// Copyright CERN and copyright holders of ALICE O2. This software is
// distributed under the terms of the GNU General Public License v3 (GPL
// Version 3), copied verbatim in the file "COPYING".
//
// See http://alice-o2.web.cern.ch/license for full licensing information.
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
/// \file MagFieldParam.cxx
/// \brief Implementation of the MagFieldParam class
/// \author [email protected]
#include "Field/MagFieldParam.h"
#include "Field/MagneticField.h"
#include "FairParamList.h"
#include "FairRun.h"
#include "FairRuntimeDb.h"
using namespace o2::field;
//========================================
ClassImp(MagFieldParam);
MagFieldParam::MagFieldParam(const char* name, const char* title, const char* context)
: FairParGenericSet(name, title, context), mMapType(k5kG), mBeamType(kNoBeamField), mDefaultIntegration(0), mFactorSol(0.), mFactorDip(0.), mBeamEnergy(0.), mMaxField(0.), mMapPath()
{
/// create param for alice mag. field
}
void MagFieldParam::SetParam(const MagneticField* field)
{
/// fill parameters from the initialized field
// SetName(field->GetName()); ? is this needed
// SetTitle(field->GetTitle());
mMapType = field->getMapType();
mBeamType = field->getBeamType();
mDefaultIntegration = field->Integral();
mFactorSol = field->getFactorSolenoid();
mFactorDip = field->getFactorDipole();
mBeamEnergy = field->getBeamEnergy();
mMaxField = field->Max();
mMapPath = field->getDataFileName();
//
}
void MagFieldParam::putParams(FairParamList* list)
{
/// store parameters in the list
if (!list) {
return;
}
list->add("Map Type ID", int(mMapType));
list->add("Beam Type ID", int(mBeamType));
list->add("Integral Type", mDefaultIntegration);
list->add("Fact.Solenoid", mFactorSol);
list->add("Fact.Dipole ", mFactorDip);
list->add("Beam Energy ", mBeamEnergy);
list->add("Max. Field ", mMaxField);
list->add("Path to map ", mMapPath.Data());
//
}
Bool_t MagFieldParam::getParams(FairParamList* list)
{
/// retried parameters
int int2enum = 0;
if (!list->fill("Map Type ID", &int2enum)) {
return kFALSE;
}
mMapType = static_cast<BMap_t>(int2enum);
if (!list->fill("Beam Type ID", &int2enum)) {
return kFALSE;
}
mBeamType = static_cast<BeamType_t>(int2enum);
//
if (!list->fill("Integral Type", &mDefaultIntegration)) {
return kFALSE;
}
if (!list->fill("Fact.Solenoid", &mFactorSol)) {
return kFALSE;
}
if (!list->fill("Fact.Dipole ", &mFactorDip)) {
return kFALSE;
}
if (!list->fill("Beam Energy ", &mBeamEnergy)) {
return kFALSE;
}
if (!list->fill("Max. Field ", &mMaxField)) {
return kFALSE;
}
FairParamObj* parpath = list->find("Path to map ");
if (!parpath) {
return kFALSE;
}
int lgt = parpath->getLength();
// RS: is there a bug in FairParamList::fill(const Text_t* name,Text_t* value,const Int_t length)?
// I think the "if (l<length-1)" should be "if (l<length)"
char cbuff[lgt + 2];
memset(cbuff, 0, sizeof(char) * (lgt + 2));
if (!list->fill("Path to map ", cbuff, lgt + 2)) {
return kFALSE;
}
mMapPath = cbuff;
return kTRUE;
}