]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/STEER/AliParamList.cxx
Fix for raw ctp decoding (Marek)
[u/mrichter/AliRoot.git] / STEER / STEER / AliParamList.cxx
1 #include "AliParamList.h"
2 #include <TString.h>
3 #include <AliLog.h>
4
5 ClassImp(AliParamList)
6
7 //_____________________________________________________________________
8 AliParamList::AliParamList(Int_t n, const Double_t *parVal)
9 : fID(0)
10   , fNPar(0)
11   , fNames(0)
12   , fParams(0)
13 {
14   // def. c-tor
15   //
16   if (n>0) {
17     SetNParams(n);
18     if (parVal) SetParameters(parVal);
19   }
20 }
21
22 //_____________________________________________________________________
23 AliParamList::AliParamList(const AliParamList& src)
24   : TNamed(src)
25   , fID(src.fID)
26   , fNPar(src.fNPar)
27   , fNames(0)
28   , fParams(0)
29 {
30   // copy c-tor
31   if (fNPar>0) {
32     fParams = new Double_t[fNPar];
33     for (int i=fNPar;i--;) {
34       fNames[i] = src.fNames[i];
35       fParams[i] = src.fParams[i];
36     }
37   }
38 }
39
40 //_____________________________________________________________________
41 AliParamList& 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 //_____________________________________________________________________
53 AliParamList::~AliParamList()
54 {
55   // d-tor
56   delete[] fNames;
57   delete[] fParams;
58 }
59
60 //_____________________________________________________________________
61 void 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;
66   fParams = new Double_t[fNPar];
67   fNames = new TString[fNPar];
68   for (int i=fNPar;i--;) fParams[i] = 0.;
69   //
70 }
71
72 //_____________________________________________________________________
73 void 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 //_____________________________________________________________________
81 void 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;
86   fNames[i] = nm;
87 }
88
89 //_____________________________________________________________________
90 void AliParamList::Print(Option_t *) const
91 {
92   // print itself
93   printf("ParamList#%d/%d %s %s\n",fID,GetUniqueID(),GetName(),GetTitle());
94   for (int i=0;i<fNPar;i++) printf("#%2d\t%20s\t%e\n",i,GetParName(i),GetParameter(i));
95 }
96
97 //_____________________________________________________________________
98 const Char_t* AliParamList::GetParName(Int_t i) const 
99 {
100   // get par name
101   return (fNames[i].IsNull()) ? Form("par%d",i) : fNames[i].Data();;
102 }