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  KVNameValueList fParameters;//list of named parameters for run
44  Int_t fIndex = -1;
45  bool fBadFile = false;
47 
48 public:
49  KVDBRunFile() = default;
50  KVDBRunFile(const KVString& filename, const run_index_t& run_index)
51  : KVBase(Form("run_%s", run_index.as_string().Data()), filename),
52  fRun(run_index.run()), fIndex(run_index.index())
53  {}
54 
55  Int_t GetRun() const
56  {
58  return fRun;
59  }
60  Int_t GetIndex() const
61  {
63  return fIndex;
64  }
66  {
68  return {fRun, fIndex};
69  }
72  Bool_t Has(const Char_t* param, Bool_t check_whitespace = kTRUE) const
73  {
74  if (check_whitespace && fParameters.HasStringParameter(param)) {
75  return !(fParameters.GetTStringValue(param).IsWhitespace());
76  }
78  }
79 
81  void SetScaler(const Char_t* name, Int_t val)
82  {
83  KV__SET_INT(name, val)
84  }
86  Int_t GetScaler(const Char_t* name) const
87  {
88  KV__GET_INT(name)
89  }
91  void SetScaler64(const Char_t* name, ULong64_t val)
92  {
93  KV__SET_ULONG(name, val)
94 
95  }
97  ULong64_t GetScaler64(const Char_t* name) const
98  {
99  KV__GET_ULONG(name)
100  }
102  void Set(const Char_t* param, Double_t val)
103  {
104  KV__SET_DBL(param, val)
105  }
107  Double_t Get(const Char_t* param) const
108  {
109  KV__GET_DBL(param)
110  }
112  void Set(const Char_t* param, const KVString& val)
113  {
114  KV__SET_STR(param, val)
115  }
117  const Char_t* GetString(const Char_t* param) const
118  {
119  KV__GET_STR(param)
120  }
121  void SetKVVersion(const Char_t* V)
122  {
123  fKVVersion = V;
124  }
125  const Char_t* GetKVVersion() const
126  {
127  return fKVVersion.Data();
128  }
129  void SetUserName(const Char_t* U)
130  {
131  fUserName = U;
132  }
133  const Char_t* GetUserName() const
134  {
135  return fUserName.Data();
136  }
137  const TDatime& GetDatime() const
138  {
139  return fDatime;
140  }
141  const Char_t* GetDatimeString() const
142  {
143  return fDatime.AsString();
144  }
145  void SetDatime(const TDatime& dat)
146  {
147  dat.Copy(fDatime);
148  }
150  {
151  return GetScaler64("Events");
152  }
154  {
155  return Get("Length (min.)");
156  }
158  {
159  return Get("Size (MB)");
160  }
161 
162  const Char_t* GetStartDate() const
163  {
164  return GetString("Start Date");
165  }
166  const Char_t* GetDate() const
167  {
168  return GetStartDate();
169  }
170  const Char_t* GetEndDate() const
171  {
172  return GetString("End Date");
173  }
174 
175  void SetEvents(ULong64_t evt_number)
176  {
177  SetScaler64("Events", evt_number);
178  }
179  void SetTime(Double_t time)
180  {
181  Set("Length (min.)", time);
182  }
184  {
185  Set("Size (MB)", s);
186  }
187 
188  void SetStartDate(const KVString& date)
189  {
190  Set("Start Date", date);
191  }
192  void SetDate(const KVString& d)
193  {
194  SetStartDate(d);
195  }
196  void SetEndDate(const KVString& d)
197  {
198  Set("End Date", d);
199  }
200 
202  {
203  return GetTitle();
204  }
205 
206  void ls(Option_t* = "") const override
207  {
209  std::cout << "runfile=" << run_index_t{fRun, fIndex}.as_string() << "\tevents=" << GetEvents()
210  << " start=" << GetStartDate();
211  if (IsBad()) std::cout << " (bad)";
212  std::cout << std::endl;
215  std::cout << fParameters.List("64bit|Events") << std::endl;
217  }
218  void Print(Option_t* = "") const override
219  {
220  ls();
221  }
222  void SetBad(Bool_t is_bad = kTRUE)
223  {
225  fBadFile = is_bad;
226  }
227  Bool_t IsBad() const
228  {
230  return fBadFile;
231  }
233  {
235  return fParameters;
236  }
238  {
241  return fGlobalRunFileNumber;
242  }
244  {
246  }
247 
249 };
250 
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:38
Double_t GetSize() const
Definition: KVDBRunFile.h:157
const Char_t * GetKVVersion() const
Definition: KVDBRunFile.h:125
void ls(Option_t *="") const override
Definition: KVDBRunFile.h:206
Int_t GetScaler(const Char_t *name) const
Get value of scaler with the given name for this run.
Definition: KVDBRunFile.h:86
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:91
void SetEndDate(const KVString &d)
Definition: KVDBRunFile.h:196
const Char_t * GetDatimeString() const
Definition: KVDBRunFile.h:141
const Char_t * GetDate() const
Definition: KVDBRunFile.h:166
void SetDate(const KVString &d)
Definition: KVDBRunFile.h:192
void SetSize(Double_t s)
Definition: KVDBRunFile.h:183
void Print(Option_t *="") const override
Definition: KVDBRunFile.h:218
void Set(const Char_t *param, Double_t val)
Set numerical (non-scaler) characteristic of run.
Definition: KVDBRunFile.h:102
const Char_t * GetStartDate() const
Definition: KVDBRunFile.h:162
void SetGlobalRunFileNumber(Int_t r)
Definition: KVDBRunFile.h:243
ULong64_t GetEvents() const
Definition: KVDBRunFile.h:149
Int_t GetRun() const
Definition: KVDBRunFile.h:55
TDatime fDatime
Definition: KVDBRunFile.h:40
const Char_t * GetUserName() const
Definition: KVDBRunFile.h:133
run_index_t GetRunIndex() const
Definition: KVDBRunFile.h:65
void SetBad(Bool_t is_bad=kTRUE)
Definition: KVDBRunFile.h:222
void SetStartDate(const KVString &date)
Definition: KVDBRunFile.h:188
void SetKVVersion(const Char_t *V)
Definition: KVDBRunFile.h:121
const KVNameValueList & GetParameters() const
Definition: KVDBRunFile.h:232
Double_t GetTime() const
Definition: KVDBRunFile.h:153
Int_t GetGlobalRunFileNumber() const
Definition: KVDBRunFile.h:237
const Char_t * GetEndDate() const
Definition: KVDBRunFile.h:170
Int_t GetIndex() const
Definition: KVDBRunFile.h:60
void SetEvents(ULong64_t evt_number)
Definition: KVDBRunFile.h:175
TString fUserName
set dynamically with KaliVeda version used to generate ROOT file corresponding to run
Definition: KVDBRunFile.h:42
KVString GetFileName() const
Definition: KVDBRunFile.h:201
Int_t fGlobalRunFileNumber
Definition: KVDBRunFile.h:46
Int_t fIndex
Definition: KVDBRunFile.h:44
ULong64_t GetScaler64(const Char_t *name) const
Get value of 64-bit scaler with the given name for this run.
Definition: KVDBRunFile.h:97
const TDatime & GetDatime() const
Definition: KVDBRunFile.h:137
Bool_t Has(const Char_t *param, Bool_t check_whitespace=kTRUE) const
Definition: KVDBRunFile.h:72
KVDBRunFile()=default
void SetDatime(const TDatime &dat)
Definition: KVDBRunFile.h:145
Double_t Get(const Char_t *param) const
Get numerical (non-scaler) characteristic of run.
Definition: KVDBRunFile.h:107
KVNameValueList fParameters
Definition: KVDBRunFile.h:39
KVDBRunFile(const KVString &filename, const run_index_t &run_index)
Definition: KVDBRunFile.h:50
void Set(const Char_t *param, const KVString &val)
Set characteristic of run.
Definition: KVDBRunFile.h:112
Bool_t IsBad() const
Definition: KVDBRunFile.h:227
Int_t fRun
set dynamically with name of user who generated ROOT file corresponding to run
Definition: KVDBRunFile.h:43
bool fBadFile
Definition: KVDBRunFile.h:45
TString fKVVersion
set dynamically with date&time of ROOT file corresponding to run
Definition: KVDBRunFile.h:41
void SetScaler(const Char_t *name, Int_t val)
Set value for the scaler with the given name for this run.
Definition: KVDBRunFile.h:81
void SetUserName(const Char_t *U)
Definition: KVDBRunFile.h:129
const Char_t * GetString(const Char_t *param) const
Get characteristic of run.
Definition: KVDBRunFile.h:117
void SetTime(Double_t time)
Definition: KVDBRunFile.h:179
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:33
unsigned long long ULong64_t