Event server (Mihai)
[u/mrichter/AliRoot.git] / STEER / STEER / AliParamList.cxx
CommitLineData
18327966 1#include "AliParamList.h"
2#include <TString.h>
3#include <AliLog.h>
4
5ClassImp(AliParamList)
6
7//_____________________________________________________________________
8AliParamList::AliParamList(Int_t n, const Double_t *parVal)
d0a8f0b5 9: fID(0)
10 , fNPar(0)
11 , fNames(0)
12 , fParams(0)
18327966 13{
14 // def. c-tor
15 //
16 if (n>0) {
17 SetNParams(n);
18 if (parVal) SetParameters(parVal);
19 }
20}
21
22//_____________________________________________________________________
23AliParamList::AliParamList(const AliParamList& src)
24 : TNamed(src)
d0a8f0b5 25 , fID(src.fID)
18327966 26 , fNPar(src.fNPar)
27 , fNames(0)
28 , fParams(0)
29{
30 // copy c-tor
31 if (fNPar>0) {
18327966 32 fParams = new Double_t[fNPar];
33 for (int i=fNPar;i--;) {
b42c78d3 34 fNames[i] = src.fNames[i];
18327966 35 fParams[i] = src.fParams[i];
36 }
37 }
38}
39
40//_____________________________________________________________________
41AliParamList& AliParamList::operator=(const AliParamList& src)
42{
43 // copy op.
44 if (this != &src) {
45 this->~AliParamList();
46 new(this) AliParamList(src);
47 }
48 return *this;
49 //
50}
51
52//_____________________________________________________________________
53AliParamList::~AliParamList()
54{
55 // d-tor
56 delete[] fNames;
57 delete[] fParams;
58}
59
60//_____________________________________________________________________
61void AliParamList::SetNParams(Int_t n)
62{
63 // init params structure
64 if (fNPar) AliFatal(Form("N params was already set to %d",fNPar));
65 fNPar = n;
18327966 66 fParams = new Double_t[fNPar];
b42c78d3 67 fNames = new TString[fNPar];
d0a8f0b5 68 for (int i=fNPar;i--;) fParams[i] = 0.;
69 //
18327966 70}
71
72//_____________________________________________________________________
73void AliParamList::SetParName(Int_t i,const char* nm)
74{
75 // assign param name
76 if (i<0||i>=fNPar) AliFatal(Form("Param %d accessed while the range is %d : %d",i,0,fNPar));
77 fNames[i] = nm;
78}
79
80//_____________________________________________________________________
81void AliParamList::SetParameter(Int_t i, Double_t v, const char* nm)
82{
83 // assign param value and optionally name
84 if (i<0||i>=fNPar) AliFatal(Form("Param %d accessed while the range is %d : %d",i,0,fNPar));
85 fParams[i] = v;
b42c78d3 86 fNames[i] = nm;
18327966 87}
88
89//_____________________________________________________________________
90void AliParamList::Print(Option_t *) const
91{
92 // print itself
d0a8f0b5 93 printf("ParamList#%d/%d %s %s\n",fID,GetUniqueID(),GetName(),GetTitle());
b42c78d3 94 for (int i=0;i<fNPar;i++) printf("#%2d\t%20s\t%e\n",i,GetParName(i),GetParameter(i));
18327966 95}
d0a8f0b5 96
97//_____________________________________________________________________
98const Char_t* AliParamList::GetParName(Int_t i) const
99{
100 // get par name
b42c78d3 101 return (fNames[i].IsNull()) ? Form("par%d",i) : fNames[i].Data();;
d0a8f0b5 102}