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;
46 
47 public:
48  KVDBRunFile() = default;
49  KVDBRunFile(const KVString& filename, const run_index_t& run_index)
50  : KVBase(Form("run_%s", run_index.as_string().Data()), filename),
51  fRun(run_index.run()), fIndex(run_index.index())
52  {}
53 
54  Int_t GetRun() const
55  {
57  return fRun;
58  }
59  Int_t GetIndex() const
60  {
62  return fIndex;
63  }
65  {
67  return {fRun,fIndex};
68  }
71  Bool_t Has(const Char_t* param, Bool_t check_whitespace = kTRUE) const
72  {
73  if (check_whitespace && fParameters.HasStringParameter(param)) {
74  return !(fParameters.GetTStringValue(param).IsWhitespace());
75  }
77  }
78 
80  void SetScaler(const Char_t* name, Int_t val)
81  {
82  KV__SET_INT(name, val)
83  }
85  Int_t GetScaler(const Char_t* name) const
86  {
87  KV__GET_INT(name)
88  }
90  void SetScaler64(const Char_t* name, ULong64_t val)
91  {
92  KV__SET_ULONG(name, val)
93 
94  }
96  ULong64_t GetScaler64(const Char_t* name) const
97  {
98  KV__GET_ULONG(name)
99  }
101  void Set(const Char_t* param, Double_t val)
102  {
103  KV__SET_DBL(param, val)
104  }
106  Double_t Get(const Char_t* param) const
107  {
108  KV__GET_DBL(param)
109  }
111  void Set(const Char_t* param, const KVString& val)
112  {
113  KV__SET_STR(param, val)
114  }
116  const Char_t* GetString(const Char_t* param) const
117  {
118  KV__GET_STR(param)
119  }
120  void SetKVVersion(const Char_t* V)
121  {
122  fKVVersion = V;
123  }
124  const Char_t* GetKVVersion() const
125  {
126  return fKVVersion.Data();
127  }
128  void SetUserName(const Char_t* U)
129  {
130  fUserName = U;
131  }
132  const Char_t* GetUserName() const
133  {
134  return fUserName.Data();
135  }
136  const TDatime& GetDatime() const
137  {
138  return fDatime;
139  }
140  const Char_t* GetDatimeString() const
141  {
142  return fDatime.AsString();
143  }
144  void SetDatime(const TDatime& dat)
145  {
146  dat.Copy(fDatime);
147  }
149  {
150  return GetScaler64("Events");
151  }
153  {
154  return Get("Length (min.)");
155  }
157  {
158  return Get("Size (MB)");
159  }
160 
161  const Char_t* GetStartDate() const
162  {
163  return GetString("Start Date");
164  }
165  const Char_t* GetDate() const
166  {
167  return GetStartDate();
168  }
169  const Char_t* GetEndDate() const
170  {
171  return GetString("End Date");
172  }
173 
174  void SetEvents(ULong64_t evt_number)
175  {
176  SetScaler64("Events", evt_number);
177  }
178  void SetTime(Double_t time)
179  {
180  Set("Length (min.)", time);
181  }
183  {
184  Set("Size (MB)", s);
185  }
186 
187  void SetStartDate(const KVString& date)
188  {
189  Set("Start Date", date);
190  }
191  void SetDate(const KVString& d)
192  {
193  SetStartDate(d);
194  }
195  void SetEndDate(const KVString& d)
196  {
197  Set("End Date", d);
198  }
199 
201  {
202  return GetTitle();
203  }
204 
205  void ls(Option_t* = "") const override
206  {
208  std::cout << "runfile=" << run_index_t{fRun, fIndex}.as_string() << "\tevents=" << GetEvents()
209  << " start=" << GetStartDate();
210  if(IsBad()) std::cout << " (bad)";
211  std::cout << std::endl;
214  fParameters.Print("64bit|Events");
216  }
217  void SetBad(Bool_t is_bad = kTRUE)
218  {
220  fBadFile = is_bad;
221  }
222  Bool_t IsBad() const
223  {
225  return fBadFile;
226  }
228  {
230  return fParameters;
231  }
232 
234 };
235 
int Int_t
#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:156
const Char_t * GetKVVersion() const
Definition: KVDBRunFile.h:124
void ls(Option_t *="") const override
Definition: KVDBRunFile.h:205
Int_t GetScaler(const Char_t *name) const
Get value of scaler with the given name for this run.
Definition: KVDBRunFile.h:85
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:90
void SetEndDate(const KVString &d)
Definition: KVDBRunFile.h:195
const Char_t * GetDatimeString() const
Definition: KVDBRunFile.h:140
const Char_t * GetDate() const
Definition: KVDBRunFile.h:165
void SetDate(const KVString &d)
Definition: KVDBRunFile.h:191
void SetSize(Double_t s)
Definition: KVDBRunFile.h:182
void Set(const Char_t *param, Double_t val)
Set numerical (non-scaler) characteristic of run.
Definition: KVDBRunFile.h:101
const Char_t * GetStartDate() const
Definition: KVDBRunFile.h:161
ULong64_t GetEvents() const
Definition: KVDBRunFile.h:148
Int_t GetRun() const
Definition: KVDBRunFile.h:54
TDatime fDatime
Definition: KVDBRunFile.h:40
const Char_t * GetUserName() const
Definition: KVDBRunFile.h:132
run_index_t GetRunIndex() const
Definition: KVDBRunFile.h:64
void SetBad(Bool_t is_bad=kTRUE)
Definition: KVDBRunFile.h:217
void SetStartDate(const KVString &date)
Definition: KVDBRunFile.h:187
void SetKVVersion(const Char_t *V)
Definition: KVDBRunFile.h:120
const KVNameValueList & GetParameters() const
Definition: KVDBRunFile.h:227
Double_t GetTime() const
Definition: KVDBRunFile.h:152
const Char_t * GetEndDate() const
Definition: KVDBRunFile.h:169
Int_t GetIndex() const
Definition: KVDBRunFile.h:59
void SetEvents(ULong64_t evt_number)
Definition: KVDBRunFile.h:174
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:200
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:96
const TDatime & GetDatime() const
Definition: KVDBRunFile.h:136
Bool_t Has(const Char_t *param, Bool_t check_whitespace=kTRUE) const
Definition: KVDBRunFile.h:71
KVDBRunFile()=default
void SetDatime(const TDatime &dat)
Definition: KVDBRunFile.h:144
Double_t Get(const Char_t *param) const
Get numerical (non-scaler) characteristic of run.
Definition: KVDBRunFile.h:106
KVNameValueList fParameters
Definition: KVDBRunFile.h:39
KVDBRunFile(const KVString &filename, const run_index_t &run_index)
Definition: KVDBRunFile.h:49
void Set(const Char_t *param, const KVString &val)
Set characteristic of run.
Definition: KVDBRunFile.h:111
Bool_t IsBad() const
Definition: KVDBRunFile.h:222
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:80
void SetUserName(const Char_t *U)
Definition: KVDBRunFile.h:128
const Char_t * GetString(const Char_t *param) const
Get characteristic of run.
Definition: KVDBRunFile.h:116
void SetTime(Double_t time)
Definition: KVDBRunFile.h:178
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
void Print(Option_t *opt="") const override
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