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 #define KV__GET_INT(__param) return (fParameters.HasIntParameter(__param) ? fParameters.GetIntValue(__param) : 0);
10 #define KV__GET_ULONG(__param) return (fParameters.HasValue64bit(__param) ? fParameters.GetValue64bit(__param) : 0);
11 #define KV__GET_DBL(__param) return (fParameters.HasDoubleParameter(__param) ? fParameters.GetDoubleValue(__param) : 0.);
12 #define KV__GET_STR(__param) return (fParameters.HasStringParameter(__param) ? fParameters.GetStringValue(__param) : "");
13 #define KV__SET_INT(__param,__val) fParameters.SetValue(__param,__val);
14 #define KV__SET_ULONG(__param,__val) fParameters.SetValue64bit(__param,__val);
15 #define KV__SET_DBL(__param,__val) fParameters.SetValue(__param,__val);
16 #define KV__SET_STR(__param,__val) fParameters.SetValue(__param,__val);
17 
36 class KVDBRunFile : public KVBase {
37  KVNameValueList fParameters;//list of named parameters for run
42  Int_t fIndex = -1;
43  bool fBadFile = false;
44 
45 public:
46  KVDBRunFile() = default;
47  KVDBRunFile(const KVString& filename, const run_index_t& run_index)
48  : KVBase(Form("run_%s", run_index.as_string().Data()), filename),
49  fRun(run_index.run()), fIndex(run_index.index())
50  {}
51 
54  Bool_t Has(const Char_t* param, Bool_t check_whitespace = kTRUE) const
55  {
56  if (check_whitespace && fParameters.HasStringParameter(param)) {
57  return !(fParameters.GetTStringValue(param).IsWhitespace());
58  }
60  }
61 
63  void SetScaler(const Char_t* name, Int_t val)
64  {
65  KV__SET_INT(name, val)
66  }
68  Int_t GetScaler(const Char_t* name) const
69  {
70  KV__GET_INT(name)
71  }
73  void SetScaler64(const Char_t* name, ULong64_t val)
74  {
75  KV__SET_ULONG(name, val)
76 
77  }
79  ULong64_t GetScaler64(const Char_t* name) const
80  {
81  KV__GET_ULONG(name)
82  }
84  void Set(const Char_t* param, Double_t val)
85  {
86  KV__SET_DBL(param, val)
87  }
89  Double_t Get(const Char_t* param) const
90  {
91  KV__GET_DBL(param)
92  }
94  void Set(const Char_t* param, const KVString& val)
95  {
96  KV__SET_STR(param, val)
97  }
99  const Char_t* GetString(const Char_t* param) const
100  {
101  KV__GET_STR(param)
102  }
103  void SetKVVersion(const Char_t* V)
104  {
105  fKVVersion = V;
106  }
107  const Char_t* GetKVVersion() const
108  {
109  return fKVVersion.Data();
110  }
111  void SetUserName(const Char_t* U)
112  {
113  fUserName = U;
114  }
115  const Char_t* GetUserName() const
116  {
117  return fUserName.Data();
118  }
119  const TDatime& GetDatime() const
120  {
121  return fDatime;
122  }
123  const Char_t* GetDatimeString() const
124  {
125  return fDatime.AsString();
126  }
127  void SetDatime(const TDatime& dat)
128  {
129  dat.Copy(fDatime);
130  }
132  {
133  return GetScaler64("Events");
134  }
136  {
137  return Get("Length (min.)");
138  }
140  {
141  return Get("Size (MB)");
142  }
143 
144  const Char_t* GetStartDate() const
145  {
146  return GetString("Start Date");
147  }
148  const Char_t* GetDate() const
149  {
150  return GetStartDate();
151  }
152  const Char_t* GetEndDate() const
153  {
154  return GetString("End Date");
155  }
156 
157  void SetEvents(ULong64_t evt_number)
158  {
159  SetScaler64("Events", evt_number);
160  }
161  void SetTime(Double_t time)
162  {
163  Set("Length (min.)", time);
164  }
166  {
167  Set("Size (MB)", s);
168  }
169 
170  void SetStartDate(const KVString& date)
171  {
172  Set("Start Date", date);
173  }
174  void SetDate(const KVString& d)
175  {
176  SetStartDate(d);
177  }
178  void SetEndDate(const KVString& d)
179  {
180  Set("End Date", d);
181  }
182 
184  {
185  return GetTitle();
186  }
187 
188  void ls(Option_t* = "") const override
189  {
190  std::cout << " runfile=" << run_index_t{fRun, fIndex}.as_string() << "\tevents=" << GetEvents()
191  << " start=" << GetStartDate();
192  if(IsBad()) std::cout << " (bad)";
193  std::cout << std::endl;
194  }
196  void SetBad(Bool_t is_bad = kTRUE)
197  {
198  fBadFile = is_bad;
199  }
201  Bool_t IsBad() const
202  {
203  return fBadFile;
204  }
205 
207 };
208 
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:36
Double_t GetSize() const
Definition: KVDBRunFile.h:139
const Char_t * GetKVVersion() const
Definition: KVDBRunFile.h:107
void ls(Option_t *="") const override
Definition: KVDBRunFile.h:188
Int_t GetScaler(const Char_t *name) const
Get value of scaler with the given name for this run.
Definition: KVDBRunFile.h:68
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:73
void SetEndDate(const KVString &d)
Definition: KVDBRunFile.h:178
const Char_t * GetDatimeString() const
Definition: KVDBRunFile.h:123
const Char_t * GetDate() const
Definition: KVDBRunFile.h:148
void SetDate(const KVString &d)
Definition: KVDBRunFile.h:174
void SetSize(Double_t s)
Definition: KVDBRunFile.h:165
void Set(const Char_t *param, Double_t val)
Set numerical (non-scaler) characteristic of run.
Definition: KVDBRunFile.h:84
const Char_t * GetStartDate() const
Definition: KVDBRunFile.h:144
ULong64_t GetEvents() const
Definition: KVDBRunFile.h:131
TDatime fDatime
Definition: KVDBRunFile.h:38
const Char_t * GetUserName() const
Definition: KVDBRunFile.h:115
void SetBad(Bool_t is_bad=kTRUE)
Declare this runfile to be 'bad', i.e. not to be used for analysis.
Definition: KVDBRunFile.h:196
void SetStartDate(const KVString &date)
Definition: KVDBRunFile.h:170
void SetKVVersion(const Char_t *V)
Definition: KVDBRunFile.h:103
Double_t GetTime() const
Definition: KVDBRunFile.h:135
const Char_t * GetEndDate() const
Definition: KVDBRunFile.h:152
void SetEvents(ULong64_t evt_number)
Definition: KVDBRunFile.h:157
TString fUserName
set dynamically with KaliVeda version used to generate ROOT file corresponding to run
Definition: KVDBRunFile.h:40
KVString GetFileName() const
Definition: KVDBRunFile.h:183
Int_t fIndex
Definition: KVDBRunFile.h:42
ULong64_t GetScaler64(const Char_t *name) const
Get value of 64-bit scaler with the given name for this run.
Definition: KVDBRunFile.h:79
const TDatime & GetDatime() const
Definition: KVDBRunFile.h:119
Bool_t Has(const Char_t *param, Bool_t check_whitespace=kTRUE) const
Definition: KVDBRunFile.h:54
KVDBRunFile()=default
void SetDatime(const TDatime &dat)
Definition: KVDBRunFile.h:127
Double_t Get(const Char_t *param) const
Get numerical (non-scaler) characteristic of run.
Definition: KVDBRunFile.h:89
KVNameValueList fParameters
Definition: KVDBRunFile.h:37
KVDBRunFile(const KVString &filename, const run_index_t &run_index)
Definition: KVDBRunFile.h:47
void Set(const Char_t *param, const KVString &val)
Set characteristic of run.
Definition: KVDBRunFile.h:94
Bool_t IsBad() const
Definition: KVDBRunFile.h:201
Int_t fRun
set dynamically with name of user who generated ROOT file corresponding to run
Definition: KVDBRunFile.h:41
bool fBadFile
Definition: KVDBRunFile.h:43
TString fKVVersion
set dynamically with date&time of ROOT file corresponding to run
Definition: KVDBRunFile.h:39
void SetScaler(const Char_t *name, Int_t val)
Set value for the scaler with the given name for this run.
Definition: KVDBRunFile.h:63
void SetUserName(const Char_t *U)
Definition: KVDBRunFile.h:111
const Char_t * GetString(const Char_t *param) const
Get characteristic of run.
Definition: KVDBRunFile.h:99
void SetTime(Double_t time)
Definition: KVDBRunFile.h:161
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
void Copy(TDatime &datime) const
const char * AsString() const
const char * GetTitle() const override
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