KaliVeda
Toolkit for HIC analysis
KVDBRunFile.h
1 #pragma once
2 
3 #include "KVBase.h"
4 #include "KVNameValueList.h"
5 #include "KVDatime.h"
6 #include "KVString.h"
7 #include "run_index.h"
8 
9 #include <TROOT.h>
10 
11 #define KV__GET_INT(__param) return (fParameters.HasIntParameter(__param) ? fParameters.GetIntValue(__param) : 0);
12 #define KV__GET_ULONG(__param) return (fParameters.HasValue64bit(__param) ? fParameters.GetValue64bit(__param) : 0);
13 #define KV__GET_DBL(__param) return (fParameters.HasDoubleParameter(__param) ? fParameters.GetDoubleValue(__param) : 0.);
14 #define KV__GET_STR(__param) return (fParameters.HasStringParameter(__param) ? fParameters.GetStringValue(__param) : "");
15 #define KV__SET_INT(__param,__val) fParameters.SetValue(__param,__val);
16 #define KV__SET_ULONG(__param,__val) fParameters.SetValue64bit(__param,__val);
17 #define KV__SET_DBL(__param,__val) fParameters.SetValue(__param,__val);
18 #define KV__SET_STR(__param,__val) fParameters.SetValue(__param,__val);
19 
38 class KVDBRunFile : public KVBase
39 {
40  KVNameValueList fParameters;//list of named parameters for run
45  Int_t fIndex = -1;
46  bool fBadFile = false;
48 
49  friend class KVExpSetUpDB;
50 
52  {
54  }
55 
56 public:
57  KVDBRunFile() = default;
58  KVDBRunFile(const KVString& filename, const run_index_t& run_index)
59  : KVBase(Form("run_%s", run_index.as_string().Data()), filename),
60  fRun(run_index.run()), fIndex(run_index.index())
61  {}
62 
63  Int_t GetRun() const
64  {
66  return fRun;
67  }
68  Int_t GetIndex() const
69  {
71  return fIndex;
72  }
74  {
76  return {fRun, fIndex};
77  }
80  Bool_t Has(const Char_t* param, Bool_t check_whitespace = kTRUE) const
81  {
82  if (check_whitespace && fParameters.HasStringParameter(param)) {
83  return !(fParameters.GetTStringValue(param).IsWhitespace());
84  }
86  }
87 
89  void SetScaler(const Char_t* name, Int_t val)
90  {
91  KV__SET_INT(name, val)
92  }
94  Int_t GetScaler(const Char_t* name) const
95  {
96  KV__GET_INT(name)
97  }
99  void SetScaler64(const Char_t* name, ULong64_t val)
100  {
101  KV__SET_ULONG(name, val)
102 
103  }
105  ULong64_t GetScaler64(const Char_t* name) const
106  {
107  KV__GET_ULONG(name)
108  }
110  void Set(const Char_t* param, Double_t val)
111  {
112  KV__SET_DBL(param, val)
113  }
115  Double_t Get(const Char_t* param) const
116  {
117  KV__GET_DBL(param)
118  }
120  void Set(const Char_t* param, const KVString& val)
121  {
122  KV__SET_STR(param, val)
123  }
125  const Char_t* GetString(const Char_t* param) const
126  {
127  KV__GET_STR(param)
128  }
129  void SetKVVersion(const Char_t* V)
130  {
131  fKVVersion = V;
132  }
133  const Char_t* GetKVVersion() const
134  {
135  return fKVVersion.Data();
136  }
137  void SetUserName(const Char_t* U)
138  {
139  fUserName = U;
140  }
141  const Char_t* GetUserName() const
142  {
143  return fUserName.Data();
144  }
145  const TDatime& GetDatime() const
146  {
147  return fDatime;
148  }
149  const Char_t* GetDatimeString() const
150  {
151  return fDatime.AsString();
152  }
153  void SetDatime(const TDatime& dat)
154  {
155  dat.Copy(fDatime);
156  }
158  {
159  return GetScaler64("Events");
160  }
162  {
163  return Get("Length (min.)");
164  }
166  {
167  return Get("Size (MB)");
168  }
169 
170  const Char_t* GetStartDate() const
171  {
172  return GetString("Start Date");
173  }
174  const Char_t* GetDate() const
175  {
176  return GetStartDate();
177  }
178  const Char_t* GetEndDate() const
179  {
180  return GetString("End Date");
181  }
182 
183  void SetEvents(ULong64_t evt_number)
184  {
185  SetScaler64("Events", evt_number);
186  }
187  void SetTime(Double_t time)
188  {
189  Set("Length (min.)", time);
190  }
192  {
193  Set("Size (MB)", s);
194  }
195 
196  void SetStartDate(const KVString& date)
197  {
198  Set("Start Date", date);
199  }
200  void SetDate(const KVString& d)
201  {
202  SetStartDate(d);
203  }
204  void SetEndDate(const KVString& d)
205  {
206  Set("End Date", d);
207  }
208 
210  {
211  return GetTitle();
212  }
213 
214  void ls(Option_t* = "") const override
215  {
217  std::cout << "runfile=" << run_index_t{fRun, fIndex}.as_string() << "\tevents=" << GetEvents()
218  << " start=" << GetStartDate();
219  if (IsBad()) std::cout << " (bad)";
220  std::cout << std::endl;
223  std::cout << fParameters.List("64bit|Events") << std::endl;
225  }
226  void Print(Option_t* = "") const override
227  {
228  ls();
229  }
230  void SetBad(Bool_t is_bad = kTRUE)
231  {
233  fBadFile = is_bad;
234  }
235  Bool_t IsBad() const
236  {
238  return fBadFile;
239  }
241  {
243  return fParameters;
244  }
246  {
252  return fGlobalRunFileNumber;
253  }
254 
256 };
257 
int Int_t
ROOT::R::TRInterface & r
#define d(i)
bool Bool_t
char Char_t
double Double_t
const char Option_t
#define ClassDefOverride(name, id)
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
char name[80]
char * Form(const char *fmt,...)
Base class for KaliVeda framework.
Definition: KVBase.h:139
A single raw data file associated with an experimental run ,,.
Definition: KVDBRunFile.h:39
Double_t GetSize() const
Definition: KVDBRunFile.h:165
const Char_t * GetKVVersion() const
Definition: KVDBRunFile.h:133
void ls(Option_t *="") const override
Definition: KVDBRunFile.h:214
Int_t GetScaler(const Char_t *name) const
Get value of scaler with the given name for this run.
Definition: KVDBRunFile.h:94
void SetScaler64(const Char_t *name, ULong64_t val)
Set value for 64-bit scaler with the given name for this run.
Definition: KVDBRunFile.h:99
void SetEndDate(const KVString &d)
Definition: KVDBRunFile.h:204
const Char_t * GetDatimeString() const
Definition: KVDBRunFile.h:149
const Char_t * GetDate() const
Definition: KVDBRunFile.h:174
void SetDate(const KVString &d)
Definition: KVDBRunFile.h:200
void SetSize(Double_t s)
Definition: KVDBRunFile.h:191
void Print(Option_t *="") const override
Definition: KVDBRunFile.h:226
void Set(const Char_t *param, Double_t val)
Set numerical (non-scaler) characteristic of run.
Definition: KVDBRunFile.h:110
const Char_t * GetStartDate() const
Definition: KVDBRunFile.h:170
void SetGlobalRunFileNumber(Int_t r)
Definition: KVDBRunFile.h:51
ULong64_t GetEvents() const
Definition: KVDBRunFile.h:157
Int_t GetRun() const
Definition: KVDBRunFile.h:63
TDatime fDatime
Definition: KVDBRunFile.h:41
const Char_t * GetUserName() const
Definition: KVDBRunFile.h:141
run_index_t GetRunIndex() const
Definition: KVDBRunFile.h:73
void SetBad(Bool_t is_bad=kTRUE)
Definition: KVDBRunFile.h:230
void SetStartDate(const KVString &date)
Definition: KVDBRunFile.h:196
void SetKVVersion(const Char_t *V)
Definition: KVDBRunFile.h:129
const KVNameValueList & GetParameters() const
Definition: KVDBRunFile.h:240
Double_t GetTime() const
Definition: KVDBRunFile.h:161
Int_t GetGlobalRunFileNumber() const
Definition: KVDBRunFile.h:245
const Char_t * GetEndDate() const
Definition: KVDBRunFile.h:178
Int_t GetIndex() const
Definition: KVDBRunFile.h:68
void SetEvents(ULong64_t evt_number)
Definition: KVDBRunFile.h:183
TString fUserName
set dynamically with KaliVeda version used to generate ROOT file corresponding to run
Definition: KVDBRunFile.h:43
KVString GetFileName() const
Definition: KVDBRunFile.h:209
Int_t fGlobalRunFileNumber
Definition: KVDBRunFile.h:47
Int_t fIndex
Definition: KVDBRunFile.h:45
ULong64_t GetScaler64(const Char_t *name) const
Get value of 64-bit scaler with the given name for this run.
Definition: KVDBRunFile.h:105
const TDatime & GetDatime() const
Definition: KVDBRunFile.h:145
Bool_t Has(const Char_t *param, Bool_t check_whitespace=kTRUE) const
Definition: KVDBRunFile.h:80
KVDBRunFile()=default
void SetDatime(const TDatime &dat)
Definition: KVDBRunFile.h:153
Double_t Get(const Char_t *param) const
Get numerical (non-scaler) characteristic of run.
Definition: KVDBRunFile.h:115
KVNameValueList fParameters
Definition: KVDBRunFile.h:40
KVDBRunFile(const KVString &filename, const run_index_t &run_index)
Definition: KVDBRunFile.h:58
void Set(const Char_t *param, const KVString &val)
Set characteristic of run.
Definition: KVDBRunFile.h:120
Bool_t IsBad() const
Definition: KVDBRunFile.h:235
Int_t fRun
set dynamically with name of user who generated ROOT file corresponding to run
Definition: KVDBRunFile.h:44
bool fBadFile
Definition: KVDBRunFile.h:46
TString fKVVersion
set dynamically with date&time of ROOT file corresponding to run
Definition: KVDBRunFile.h:42
void SetScaler(const Char_t *name, Int_t val)
Set value for the scaler with the given name for this run.
Definition: KVDBRunFile.h:89
void SetUserName(const Char_t *U)
Definition: KVDBRunFile.h:137
const Char_t * GetString(const Char_t *param) const
Get characteristic of run.
Definition: KVDBRunFile.h:125
void SetTime(Double_t time)
Definition: KVDBRunFile.h:187
Calibration database for experiments using coupled detector arrays.
Definition: KVExpSetUpDB.h:17
Handles lists of named parameters with different types, a list of KVNamedParameter objects.
Bool_t HasStringParameter(const Char_t *name) const
TString List(Option_t *opt="") 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
void Copy(TDatime &datime) const
const char * AsString() const
const char * GetTitle() const override
static Int_t IncreaseDirLevel()
static void IndentLevel()
static Int_t DecreaseDirLevel()
const char * Data() const
Bool_t IsWhitespace() const
Specifies a runfile according to run number and file index ,.
Definition: run_index.h:31
unsigned long long ULong64_t