KaliVeda
Toolkit for HIC analysis
KVDBRun.h
1 /***************************************************************************
2  * *
3  * This program is free software; you can redistribute it and/or modify *
4  * it under the terms of the GNU General Public License as published by *
5  * the Free Software Foundation; either version 2 of the License, or *
6  * (at your option) any later version. *
7  * *
8  ***************************************************************************/
9 #ifndef KV_DB_RUN_H
10 #define KV_DB_RUN_H
11 
12 #include "KVDBRecord.h"
13 #include "KVDBSystem.h"
14 #include "KVTarget.h"
15 #include "KVString.h"
16 #include "TDatime.h"
17 #include "KVNameValueList.h"
18 #include <RQ_OBJECT.h>
19 
20 #define KV__GET_INT(__param) return (fParameters.HasIntParameter(__param) ? fParameters.GetIntValue(__param) : 0);
21 #define KV__GET_ULONG(__param) return (fParameters.HasValue64bit(__param) ? fParameters.GetValue64bit(__param) : 0);
22 #define KV__GET_DBL(__param) return (fParameters.HasDoubleParameter(__param) ? fParameters.GetDoubleValue(__param) : 0.);
23 #define KV__GET_STR(__param) return (fParameters.HasStringParameter(__param) ? fParameters.GetStringValue(__param) : "");
24 #define KV__SET_INT(__param,__val) fParameters.SetValue(__param,__val);
25 #define KV__SET_ULONG(__param,__val) fParameters.SetValue64bit(__param,__val);
26 #define KV__SET_DBL(__param,__val) fParameters.SetValue(__param,__val);
27 #define KV__SET_STR(__param,__val) fParameters.SetValue(__param,__val);
28 
36 class KVDBRun: public KVDBRecord {
37 
38  RQ_OBJECT("KVDBRun")
40 
41 protected:
42 
47 
48 public:
49 
50  void SetKVVersion(const Char_t* V)
51  {
52  fKVVersion = V;
53  };
54  const Char_t* GetKVVersion() const
55  {
56  return fKVVersion.Data();
57  };
58  void SetUserName(const Char_t* U)
59  {
60  fUserName = U;
61  };
62  const Char_t* GetUserName() const
63  {
64  return fUserName.Data();
65  };
66 
67  void Modified() // *SIGNAL*
68  {
70  if (!fBlockSignals) Emit("Modified()");
71  };
72  void BlockSignals(Bool_t yes = kTRUE)
73  {
76  fBlockSignals = yes;
77  };
78 
81  Bool_t Has(const Char_t* param, Bool_t check_whitespace = kTRUE) const
82  {
83  if (check_whitespace && fParameters.HasStringParameter(param)) {
84  return !(fParameters.GetTStringValue(param).IsWhitespace());
85  }
87  };
88 
89  KVDBRun();
90  KVDBRun(Int_t number, const Char_t* title);
91  virtual ~ KVDBRun();
92 
93  void SetNumber(Int_t n)
94  {
96  Modified();
97  }
98 
99  void SetTrigger(Int_t trig)
100  {
101  SetScaler("Trigger multiplicity", trig);
102  };
103 
105  {
106  return GetScaler("Trigger multiplicity");
107  };
108  const Char_t* GetTriggerString() const
109  {
110  if (GetTrigger() > 0) return Form("M>=%d", GetTrigger());
111  else return Form("xxx");
112  };
113 
114  const TDatime& GetDatime() const
115  {
116  return fDatime;
117  };
119  {
120  return fDatime.AsString();
121  };
122  void SetDatime(TDatime& dat)
123  {
124  dat.Copy(fDatime);
125  Modified();
126  };
127 
128  KVDBSystem* GetSystem() const;
129  const Char_t* GetSystemName() const
130  {
131  return (GetSystem() ? GetSystem()->GetName() : "");
132  };
133 
135  {
136  return GetScaler64("Events");
137  };
139  {
140  return Get("Length (min.)");
141  };
143  {
144  return Get("Size (MB)");
145  };
146 
147  const Char_t* GetComments() const
148  {
149  return GetString("Comments");
150  };
151  const Char_t* GetStartDate() const
152  {
153  return GetString("Start Date");
154  };
155  const Char_t* GetDate() const
156  {
157  return GetStartDate();
158  };
159  const Char_t* GetEndDate() const
160  {
161  return GetString("End Date");
162  };
163 
166  {
167  return (GetSystem() ? GetSystem()->GetTarget() : 0);
168  };
169 
170  void SetEvents(ULong64_t evt_number)
171  {
172  SetScaler64("Events", evt_number);
173  };
174  void SetTime(Double_t time)
175  {
176  Set("Length (min.)", time);
177  };
179  {
180  Set("Size (MB)", s);
181  };
182  void SetComments(const KVString& comments)
183  {
184  Set("Comments", comments);
185  };
186  void SetStartDate(const KVString& date)
187  {
188  Set("Start Date", date);
189  };
190  void SetDate(const KVString& d)
191  {
192  SetStartDate(d);
193  };
194  void SetEndDate(const KVString& d)
195  {
196  Set("End Date", d);
197  };
198 
199  virtual void SetSystem(KVDBSystem* system);
200  virtual void UnsetSystem();
201 
202  virtual void Print(Option_t* option = "") const;
203 
204  virtual void WriteRunListLine(std::ostream&, Char_t delim = '|') const;
205  virtual void ReadRunListLine(const KVString&);
206  virtual void WriteRunListHeader(std::ostream&, Char_t delim = '|') const;
207 
209  virtual void SetScaler(const Char_t* name, Int_t val)
210  {
211  KV__SET_INT(name, val)
212  Modified();
213  };
215  virtual Int_t GetScaler(const Char_t* name) const
216  {
217  KV__GET_INT(name)
218  };
220  virtual void SetScaler64(const Char_t* name, ULong64_t val)
221  {
222  KV__SET_ULONG(name, val)
223  Modified();
224  };
226  virtual ULong64_t GetScaler64(const Char_t* name) const
227  {
228  KV__GET_ULONG(name)
229  };
231  void Set(const Char_t* param, Double_t val)
232  {
233  KV__SET_DBL(param, val)
234  Modified();
235  };
237  Double_t Get(const Char_t* param) const
238  {
239  KV__GET_DBL(param)
240  };
242  void Set(const Char_t* param, const KVString& val)
243  {
244  KV__SET_STR(param, val)
245  Modified();
246  };
248  const Char_t* GetString(const Char_t* param) const
249  {
250  KV__GET_STR(param)
251  };
252 
253  ClassDef(KVDBRun, 10) //Base class for an experiment run
254 };
255 #endif
int Int_t
#define RQ_OBJECT(sender_class)
#define d(i)
bool Bool_t
char Char_t
double Double_t
const char Option_t
#define ClassDef(name, id)
char name[80]
char * Form(const char *fmt,...)
Record folder for the database.
Definition: KVDBRecord.h:43
virtual void SetNumber(Int_t n)
Definition: KVDBRecord.h:77
Description of an experimental run in database ,,.
Definition: KVDBRun.h:36
void SetEvents(ULong64_t evt_number)
Definition: KVDBRun.h:170
virtual void SetSystem(KVDBSystem *system)
Set system for run. Any previous system is unassociated (run will be removed from system's list)
Definition: KVDBRun.cpp:256
TDatime fDatime
set dynamically with date&time of ROOT file corresponding to run
Definition: KVDBRun.h:44
void SetDatime(TDatime &dat)
Definition: KVDBRun.h:122
virtual void SetScaler64(const Char_t *name, ULong64_t val)
Set value for 64-bit scaler with the given name for this run.
Definition: KVDBRun.h:220
void SetTime(Double_t time)
Definition: KVDBRun.h:174
KVNameValueList fParameters
list of named parameters for run
Definition: KVDBRun.h:43
ULong64_t GetEvents() const
Definition: KVDBRun.h:134
void SetUserName(const Char_t *U)
Definition: KVDBRun.h:58
TString fKVVersion
set dynamically with KaliVeda version used to generate ROOT file corresponding to run
Definition: KVDBRun.h:45
void SetSize(Double_t s)
Definition: KVDBRun.h:178
virtual ULong64_t GetScaler64(const Char_t *name) const
Get value of 64-bit scaler with the given name for this run.
Definition: KVDBRun.h:226
void SetKVVersion(const Char_t *V)
Definition: KVDBRun.h:50
const Char_t * GetSystemName() const
Definition: KVDBRun.h:129
KVTarget * GetTarget() const
Return target used for this run (actually target of KVDBSystem associated to run)
Definition: KVDBRun.h:165
void SetComments(const KVString &comments)
Definition: KVDBRun.h:182
KVDBSystem * GetSystem() const
Definition: KVDBRun.cpp:242
virtual void WriteRunListLine(std::ostream &, Char_t delim='|') const
Definition: KVDBRun.cpp:96
const Char_t * GetEndDate() const
Definition: KVDBRun.h:159
const TDatime & GetDatime() const
Definition: KVDBRun.h:114
Bool_t Has(const Char_t *param, Bool_t check_whitespace=kTRUE) const
Definition: KVDBRun.h:81
void SetStartDate(const KVString &date)
Definition: KVDBRun.h:186
Bool_t fBlockSignals
Definition: KVDBRun.h:39
const Char_t * GetKVVersion() const
Definition: KVDBRun.h:54
void Set(const Char_t *param, Double_t val)
Set numerical (non-scaler) characteristic of run.
Definition: KVDBRun.h:231
virtual void Print(Option_t *option="") const
Definition: KVDBRun.cpp:69
void SetEndDate(const KVString &d)
Definition: KVDBRun.h:194
TString fUserName
set dynamically with name of user who generated ROOT file corresponding to run
Definition: KVDBRun.h:46
Double_t Get(const Char_t *param) const
Get numerical (non-scaler) characteristic of run.
Definition: KVDBRun.h:237
const Char_t * GetTriggerString() const
Definition: KVDBRun.h:108
Int_t GetTrigger() const
Definition: KVDBRun.h:104
Double_t GetSize() const
Definition: KVDBRun.h:142
void BlockSignals(Bool_t yes=kTRUE)
Definition: KVDBRun.h:72
const Char_t * GetStartDate() const
Definition: KVDBRun.h:151
void SetTrigger(Int_t trig)
Definition: KVDBRun.h:99
void SetDate(const KVString &d)
Definition: KVDBRun.h:190
virtual void ReadRunListLine(const KVString &)
Definition: KVDBRun.cpp:143
void Modified()
Definition: KVDBRun.h:67
void Set(const Char_t *param, const KVString &val)
Set characteristic of run.
Definition: KVDBRun.h:242
virtual void UnsetSystem()
Definition: KVDBRun.cpp:225
virtual Int_t GetScaler(const Char_t *name) const
Get value of scaler with the given name for this run.
Definition: KVDBRun.h:215
virtual ~ KVDBRun()
const Char_t * GetDate() const
Definition: KVDBRun.h:155
const Char_t * GetString(const Char_t *param) const
Get characteristic of run.
Definition: KVDBRun.h:248
KVDBRun()
default ctor
Definition: KVDBRun.cpp:33
const Char_t * GetComments() const
Definition: KVDBRun.h:147
const Char_t * GetDatimeString()
Definition: KVDBRun.h:118
Double_t GetTime() const
Definition: KVDBRun.h:138
virtual void SetScaler(const Char_t *name, Int_t val)
Set value for the scaler with the given name for this run.
Definition: KVDBRun.h:209
void SetNumber(Int_t n)
Definition: KVDBRun.h:93
virtual void WriteRunListHeader(std::ostream &, Char_t delim='|') const
Write the version flag.
Definition: KVDBRun.cpp:211
const Char_t * GetUserName() const
Definition: KVDBRun.h:62
Database class used to store information on different colliding systems studied during an experiment....
Definition: KVDBSystem.h:52
Handles lists of named parameters with different types, a list of KVNamedParameter objects.
Bool_t HasStringParameter(const Char_t *name) const
Bool_t HasIntParameter(const Char_t *name) const
Bool_t HasDoubleParameter(const Char_t *name) const
TString GetTStringValue(const Char_t *name) const
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
Definition: KVString.h:73
Calculation/correction of energy losses of particles through an experimental target.
Definition: KVTarget.h:127
void Copy(TDatime &datime) const
const char * AsString() const
const char * GetName() const override
const char * Data() const
Bool_t IsWhitespace() const
unsigned long long ULong64_t
const Int_t n