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