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 "KVDBRunFile.h"
19 #include <RQ_OBJECT.h>
20 
40 class KVDBRun: public KVDBRecord {
41 
42  RQ_OBJECT("KVDBRun")
44 
47 
48  KVDBRunFile* GetRunFile(int index)
49  {
50  return static_cast<KVDBRunFile*>(fRunFiles[index]);
51  }
52  const KVDBRunFile* GetRunFile(int index) const
53  {
54  return static_cast<const KVDBRunFile*>(fRunFiles[index]);
55  }
56 
57 public:
58 
59  KVDBRun();
60  KVDBRun(Int_t number, const Char_t* title);
61 
62  Bool_t HasRunFile(const run_index_t& run_index) const
63  {
64  return GetRunFile(run_index.index(0))!=nullptr;
65  }
66  KVDBRunFile& GetRunFile(const run_index_t& run_index)
67  {
70  auto rf = GetRunFile(run_index.index(0));
71  if(!rf)
72  throw std::runtime_error(Form("<KVDBRun::GetRunFile>: no file for run_index_t %s",run_index.as_string().Data()));
73  return *rf;
74  }
75  const KVDBRunFile& GetRunFile(const run_index_t& run_index) const
76  {
79  auto rf = GetRunFile(run_index.index(0));
80  if(!rf)
81  throw std::runtime_error(Form("<KVDBRun::GetRunFile>: no file for run_index_t %s",run_index.as_string().Data()));
82  return *rf;
83  }
85  {
86  fRunFiles.Add(rf);
87  }
89  {
90  return fRunFiles.GetEntries();
91  }
92  run_index_list GetRunIndexList() const
93  {
95  run_index_list l;
96  TIter next(&fRunFiles);
97  KVDBRunFile* rf;
98  while((rf = (KVDBRunFile*)next()))
99  l.Add(rf->GetRunIndex());
100  return l;
101  }
103  {
104  return GetNRunFiles() > 1;
105  }
107  {
108  return *GetRunFile(0);
109  }
110  const KVDBRunFile& GetFirstFile() const
111  {
112  return *GetRunFile(0);
113  }
115  {
116  return *static_cast<KVDBRunFile*>(fRunFiles.Last());
117  }
118  const KVDBRunFile& GetLastFile() const
119  {
120  return *static_cast<const KVDBRunFile*>(fRunFiles.Last());
121  }
123  {
126  TIter next(&fRunFiles);
127  KVDBRunFile* rf;
128  while((rf = (KVDBRunFile*)next()))
129  rf->SetBad();
130  }
132  {
134  Int_t not_bad(0);
135  TIter next(&fRunFiles);
136  KVDBRunFile* rf;
137  while((rf = (KVDBRunFile*)next()))
138  not_bad += !rf->IsBad();
139  return not_bad;
140  }
141 
142  void Modified() // *SIGNAL*
143  {
145  if (!fBlockSignals) Emit("Modified()");
146  }
147  void BlockSignals(Bool_t yes = kTRUE)
148  {
151  fBlockSignals = yes;
152  }
153 
156  Bool_t Has(const Char_t* param, Bool_t check_whitespace = kTRUE) const
157  {
158  if (check_whitespace && fParameters.HasStringParameter(param)) {
159  return !(fParameters.GetTStringValue(param).IsWhitespace());
160  }
162  }
163 
164  void SetNumber(Int_t n) override
165  {
167  Modified();
168  }
170  {
174  ULong64_t tot = 0;
175  TIter it(&fRunFiles);
176  while (KVDBRunFile* dbr = (KVDBRunFile*)it()) {
177  if(!dbr->IsBad()) tot += dbr->GetEvents();
178  }
179  return tot;
180  }
181  const Char_t* GetStartDate() const
182  {
184  return GetFirstFile().GetStartDate();
185  }
186  const Char_t* GetEndDate() const
187  {
189  return GetLastFile().GetEndDate();
190  }
192  {
196  Double_t tot = 0;
197  TIter it(&fRunFiles);
198  while (KVDBRunFile* dbr = (KVDBRunFile*)it()) {
199  if(!dbr->IsBad()) tot += dbr->GetSize();
200  }
201  return tot;
202  }
204  {
208  Double_t tot = 0;
209  TIter it(&fRunFiles);
210  while (KVDBRunFile* dbr = (KVDBRunFile*)it()) {
211  if(!dbr->IsBad()) tot += dbr->GetTime();
212  }
213  return tot;
214  }
215 
216  void SetTrigger(Int_t trig)
217  {
218  SetScaler("Trigger multiplicity", trig);
219  }
220 
222  {
223  return GetScaler("Trigger multiplicity");
224  }
225  const Char_t* GetTriggerString() const
226  {
227  if (GetTrigger() > 0) return Form("M>=%d", GetTrigger());
228  else return Form("xxx");
229  }
230  KVDBSystem* GetSystem() const;
231  const Char_t* GetSystemName() const
232  {
233  return (GetSystem() ? GetSystem()->GetName() : "");
234  }
235  const Char_t* GetComments() const
236  {
237  return GetString("Comments");
238  }
241  {
242  return (GetSystem() ? GetSystem()->GetTarget() : 0);
243  }
244  void SetComments(const KVString& comments)
245  {
246  Set("Comments", comments);
247  }
248 
249  virtual void SetSystem(KVDBSystem* system);
250  virtual void UnsetSystem();
251 
252  void Print(Option_t* option = "") const override;
253 
254  virtual void WriteRunListLine(std::ostream&, Char_t delim = '|') const;
255  virtual void ReadRunListLine(const KVString&);
256  virtual void WriteRunListHeader(std::ostream&, Char_t delim = '|') const;
257 
259  virtual void SetScaler(const Char_t* name, Int_t val)
260  {
261  KV__SET_INT(name, val)
262  Modified();
263  };
265  virtual Int_t GetScaler(const Char_t* name) const
266  {
267  KV__GET_INT(name)
268  };
270  virtual void SetScaler64(const Char_t* name, ULong64_t val)
271  {
272  KV__SET_ULONG(name, val)
273  Modified();
274  };
276  virtual ULong64_t GetScaler64(const Char_t* name) const
277  {
278  KV__GET_ULONG(name)
279  };
281  void Set(const Char_t* param, Double_t val)
282  {
283  KV__SET_DBL(param, val)
284  Modified();
285  };
287  Double_t Get(const Char_t* param) const
288  {
289  KV__GET_DBL(param)
290  };
292  void Set(const Char_t* param, const KVString& val)
293  {
294  KV__SET_STR(param, val)
295  Modified();
296  };
298  const Char_t* GetString(const Char_t* param) const
299  {
300  KV__GET_STR(param)
301  };
302 
303 
304  ClassDefOverride(KVDBRun, 11) //Base class for an experiment run
305 };
306 #endif
int Int_t
#define RQ_OBJECT(sender_class)
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 index
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
A single raw data file associated with an experimental run ,,.
Definition: KVDBRunFile.h:38
const Char_t * GetStartDate() const
Definition: KVDBRunFile.h:162
run_index_t GetRunIndex() const
Definition: KVDBRunFile.h:65
void SetBad(Bool_t is_bad=kTRUE)
Definition: KVDBRunFile.h:222
const Char_t * GetEndDate() const
Definition: KVDBRunFile.h:170
Bool_t IsBad() const
Definition: KVDBRunFile.h:227
Description of an experimental run in database ,,.
Definition: KVDBRun.h:40
void Print(Option_t *option="") const override
Definition: KVDBRun.cpp:61
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:254
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:270
void SetBadAllRunFiles()
Definition: KVDBRun.h:122
KVNameValueList fParameters
list of named parameters for run
Definition: KVDBRun.h:46
ULong64_t GetEvents() const
Definition: KVDBRun.h:169
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:276
const Char_t * GetSystemName() const
Definition: KVDBRun.h:231
KVTarget * GetTarget() const
Return target used for this run (actually target of KVDBSystem associated to run)
Definition: KVDBRun.h:240
KVDBRunFile * GetRunFile(int index)
Definition: KVDBRun.h:48
void AddRunFile(KVDBRunFile *rf)
Definition: KVDBRun.h:84
const KVDBRunFile & GetRunFile(const run_index_t &run_index) const
Definition: KVDBRun.h:75
void SetComments(const KVString &comments)
Definition: KVDBRun.h:244
KVDBSystem * GetSystem() const
Definition: KVDBRun.cpp:240
virtual void WriteRunListLine(std::ostream &, Char_t delim='|') const
Definition: KVDBRun.cpp:94
const Char_t * GetEndDate() const
Definition: KVDBRun.h:186
TObjArray fRunFiles
Definition: KVDBRun.h:45
void SetNumber(Int_t n) override
Definition: KVDBRun.h:164
Bool_t Has(const Char_t *param, Bool_t check_whitespace=kTRUE) const
Definition: KVDBRun.h:156
Bool_t fBlockSignals
Definition: KVDBRun.h:43
void Set(const Char_t *param, Double_t val)
Set numerical (non-scaler) characteristic of run.
Definition: KVDBRun.h:281
Bool_t IsMultiFile() const
Definition: KVDBRun.h:102
Bool_t HasRunFile(const run_index_t &run_index) const
Definition: KVDBRun.h:62
Int_t GetNGoodRunFiles() const
Definition: KVDBRun.h:131
const KVDBRunFile * GetRunFile(int index) const
Definition: KVDBRun.h:52
Double_t Get(const Char_t *param) const
Get numerical (non-scaler) characteristic of run.
Definition: KVDBRun.h:287
const KVDBRunFile & GetFirstFile() const
Definition: KVDBRun.h:110
const Char_t * GetTriggerString() const
Definition: KVDBRun.h:225
Int_t GetTrigger() const
Definition: KVDBRun.h:221
Double_t GetSize() const
Definition: KVDBRun.h:191
void BlockSignals(Bool_t yes=kTRUE)
Definition: KVDBRun.h:147
const Char_t * GetStartDate() const
Definition: KVDBRun.h:181
void SetTrigger(Int_t trig)
Definition: KVDBRun.h:216
KVDBRunFile & GetLastFile()
Definition: KVDBRun.h:114
virtual void ReadRunListLine(const KVString &)
Definition: KVDBRun.cpp:141
const KVDBRunFile & GetLastFile() const
Definition: KVDBRun.h:118
Int_t GetNRunFiles() const
Definition: KVDBRun.h:88
void Modified()
Definition: KVDBRun.h:142
void Set(const Char_t *param, const KVString &val)
Set characteristic of run.
Definition: KVDBRun.h:292
KVDBRunFile & GetFirstFile()
Definition: KVDBRun.h:106
virtual void UnsetSystem()
Definition: KVDBRun.cpp:223
virtual Int_t GetScaler(const Char_t *name) const
Get value of scaler with the given name for this run.
Definition: KVDBRun.h:265
run_index_list GetRunIndexList() const
Definition: KVDBRun.h:92
const Char_t * GetString(const Char_t *param) const
Get characteristic of run.
Definition: KVDBRun.h:298
KVDBRun()
default ctor
Definition: KVDBRun.cpp:33
const Char_t * GetComments() const
Definition: KVDBRun.h:235
Double_t GetTime() const
Definition: KVDBRun.h:203
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:259
KVDBRunFile & GetRunFile(const run_index_t &run_index)
Definition: KVDBRun.h:66
virtual void WriteRunListHeader(std::ostream &, Char_t delim='|') const
Write the version flag.
Definition: KVDBRun.cpp:209
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:128
const char * GetName() const override
TObject * Last() const override
Int_t GetEntries() const override
void Add(TObject *obj) override
const char * Data() const
Bool_t IsWhitespace() const
Specifies a runfile according to run number and file index ,.
Definition: run_index.h:33
TString as_string() const
Definition: run_index.h:94
int index(int no_index=-1) const
Definition: run_index.h:57
unsigned long long ULong64_t
const Int_t n
TLine l