KaliVeda
Toolkit for HIC analysis
KVDBParameterSet.cpp
1 /***************************************************************************
2 $Id: KVDBParameterSet.cpp,v 1.11 2007/04/18 14:30:20 ebonnet Exp $
3  KVDBParameterSet.cpp - description
4  -------------------
5  begin : jeu fév 13 2003
6  copyright : (C) 2003 by Alexis Mignon
7  email : mignon@ganil.fr
8  ***************************************************************************/
9 
10 /***************************************************************************
11  * *
12  * This program is free software; you can redistribute it and/or modify *
13  * it under the terms of the GNU General Public License as published by *
14  * the Free Software Foundation; either version 2 of the License, or *
15  * (at your option) any later version. *
16  * *
17  ***************************************************************************/
18 #include "KVDBParameterSet.h"
19 #include <cstdarg>
20 #include <iostream>
21 #include "TString.h"
22 #include "TBuffer.h"
23 using std::cout;
24 using std::endl;
25 
27 
28 //___________________________________________________________________________
29 
31 
33 {
34  fParamNumber = 0;
35 }
36 
37 
38 
44 
46  const Char_t* title,
47  UShort_t pnum): KVDBRecord(name, title)
48 {
49  //Initialise a KVDBRecord for a set of "pnum" parameters.
50  //The names of the parameters are "par_1", "par_2", etc.
51  //The KVDBKey "Runs" is initialised to cross-reference the runs for which
52  //this set of parameters is valid.
53  fParamNumber = pnum;
54  for (UInt_t i = 0; i < pnum; i++) {
55  fParameters.SetValue(Form("par_%u", i + 1), 0.0);
56  }
57  AddKey("Runs", "List of Runs");
58  //Unique not used because it makes the setting up of the list horribly slow
59  // if(key) key->SetUniqueStatus(kTRUE);
60 }
61 
62 
63 
65 
66 KVDBParameterSet::~KVDBParameterSet()
67 {
68 }
69 
70 
71 
76 
78 {
79  // Be cautious when using this method, if the number of arguments is lower than
80  // the expected number of parameters a segmantation fault will occur !!!!!
81  // exceeding argument won't be considered at all
82 
83  va_list ap;
84  va_start(ap, val);
85 
86  int arg_n = 0;
87  SetParameter(arg_n++, val);
88  while (arg_n < fParamNumber) {
89  SetParameter(arg_n, va_arg(ap, Double_t));
90  arg_n++;
91  }
92 
93  va_end(ap);
94 }
95 
96 
97 
99 
100 void KVDBParameterSet::SetParameters(const std::vector<Double_t>* const pars)
101 {
102  assert(pars->size() <= static_cast<UInt_t>(fParamNumber));
103 
104  UInt_t arg_n(0);
105  std::vector<Double_t>::const_iterator it;
106  for (it = pars->begin(); it != pars->end(); ++it) {
107  SetParameter(arg_n, *it);
108  ++arg_n;
109  }
110 }
111 
112 
113 
115 
117 {
119 }
120 
121 
122 
124 
126 {
128 }
129 
130 
131 
133 
135 {
137 }
138 
139 
140 
142 
144 {
145  fParameters.SetValue(name, val);
146 }
147 
148 
149 
151 
152 void KVDBParameterSet::SetParameter(const TString& name, const char* value)
153 {
155 }
156 
157 
158 
163 
165 {
166  // Be cautious when using this method, if the number of arguments is lower than
167  // the expected number of parameters a segmantation fault will occur !!!!!
168  // exceeding argument won't be considered at all
169 
170 #ifdef KV_DEBUG
171  Info("SetParamNames(const Char_t* name,...)", "Start");
172 #endif
173  va_list ap;
174  va_start(ap, name);
175 
176  int arg_n = 0;
177  SetParamName(arg_n, name);
178  while (arg_n < fParamNumber) {
179  SetParamName(arg_n, va_arg(ap, Char_t*));
180  arg_n++;
181  }
182 
183 #ifdef KV_DEBUG
184  Info("SetParamNames(const Char_t* name,...)", "OK");
185 #endif
186 }
187 
188 
189 
191 
193 {
195  cout << ">>>> KVParameterSet :" << endl
196  << GetName() << " " << GetTitle() << endl
197  << " Parameters :\t" << GetParamNumber() << endl;
198  fParameters.Print();
199  cout << endl << "<<<<<<<<<<" << endl;
200 }
201 
202 
unsigned int UInt_t
unsigned short UShort_t
char Char_t
double Double_t
const char Option_t
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
char name[80]
char * Form(const char *fmt,...)
To store calibration parameters in a database ,.
TString GetStringParameter(const TString &name) const
void SetParamName(UShort_t i, const Char_t *name)
Double_t GetParameter(UShort_t i=0) const
void Print(Option_t *option="") const
void SetParamNames(const Char_t *name,...)
void SetParameters(Double_t val,...)
KVNameValueList fParameters
parameters
Int_t fParamNumber
number of parameters
Int_t GetParamNumber() const
void SetParameter(UShort_t i, Double_t val)
Record folder for the database.
Definition: KVDBRecord.h:43
virtual void Print(Option_t *option="") const
Definition: KVDBRecord.cpp:222
virtual Bool_t AddKey(KVDBKey *key, Bool_t check=kTRUE)
Definition: KVDBRecord.cpp:65
virtual void Print(Option_t *opt="") const
KVNamedParameter * GetParameter(Int_t idx) const
return the parameter object with index idx
Double_t GetDoubleValue(const Char_t *name) const
void SetValue(const Char_t *name, value_type value)
TString GetTStringValue(const Char_t *name) const
const char * GetName() const override
const char * GetTitle() const override
virtual void SetName(const char *name)
virtual void Info(const char *method, const char *msgfmt,...) const
ClassImp(TPyArg)