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  KVDBRunFile& GetRunFile(const run_index_t& run_index)
63  {
66  auto rf = GetRunFile(run_index.index(0));
67  if(!rf)
68  throw std::runtime_error(Form("<KVDBRun::GetRunFile>: no file for run_index_t %s",run_index.as_string().Data()));
69  return *rf;
70  }
71  const KVDBRunFile& GetRunFile(const run_index_t& run_index) const
72  {
75  auto rf = GetRunFile(run_index.index(0));
76  if(!rf)
77  throw std::runtime_error(Form("<KVDBRun::GetRunFile>: no file for run_index_t %s",run_index.as_string().Data()));
78  return *rf;
79  }
81  {
82  fRunFiles.Add(rf);
83  }
85  {
86  return fRunFiles.GetEntries();
87  }
88  run_index_list GetRunIndexList() const
89  {
91  run_index_list l;
92  TIter next(&fRunFiles);
93  KVDBRunFile* rf;
94  while((rf = (KVDBRunFile*)next()))
95  l.Add(rf->GetRunIndex());
96  return l;
97  }
99  {
100  return GetNRunFiles() > 1;
101  }
103  {
104  return *GetRunFile(0);
105  }
106  const KVDBRunFile& GetFirstFile() const
107  {
108  return *GetRunFile(0);
109  }
111  {
112  return *static_cast<KVDBRunFile*>(fRunFiles.Last());
113  }
114  const KVDBRunFile& GetLastFile() const
115  {
116  return *static_cast<const KVDBRunFile*>(fRunFiles.Last());
117  }
119  {
122  TIter next(&fRunFiles);
123  KVDBRunFile* rf;
124  while((rf = (KVDBRunFile*)next()))
125  rf->SetBad();
126  }
128  {
130  Int_t not_bad(0);
131  TIter next(&fRunFiles);
132  KVDBRunFile* rf;
133  while((rf = (KVDBRunFile*)next()))
134  not_bad += !rf->IsBad();
135  return not_bad;
136  }
137 
138  void Modified() // *SIGNAL*
139  {
141  if (!fBlockSignals) Emit("Modified()");
142  }
143  void BlockSignals(Bool_t yes = kTRUE)
144  {
147  fBlockSignals = yes;
148  }
149 
152  Bool_t Has(const Char_t* param, Bool_t check_whitespace = kTRUE) const
153  {
154  if (check_whitespace && fParameters.HasStringParameter(param)) {
155  return !(fParameters.GetTStringValue(param).IsWhitespace());
156  }
158  }
159 
160  void SetNumber(Int_t n) override
161  {
163  Modified();
164  }
166  {
170  ULong64_t tot = 0;
171  TIter it(&fRunFiles);
172  while (KVDBRunFile* dbr = (KVDBRunFile*)it()) {
173  if(!dbr->IsBad()) tot += dbr->GetEvents();
174  }
175  return tot;
176  }
177  const Char_t* GetStartDate() const
178  {
180  return GetFirstFile().GetStartDate();
181  }
182  const Char_t* GetEndDate() const
183  {
185  return GetLastFile().GetEndDate();
186  }
188  {
192  Double_t tot = 0;
193  TIter it(&fRunFiles);
194  while (KVDBRunFile* dbr = (KVDBRunFile*)it()) {
195  if(!dbr->IsBad()) tot += dbr->GetSize();
196  }
197  return tot;
198  }
200  {
204  Double_t tot = 0;
205  TIter it(&fRunFiles);
206  while (KVDBRunFile* dbr = (KVDBRunFile*)it()) {
207  if(!dbr->IsBad()) tot += dbr->GetTime();
208  }
209  return tot;
210  }
211 
212  void SetTrigger(Int_t trig)
213  {
214  SetScaler("Trigger multiplicity", trig);
215  }
216 
218  {
219  return GetScaler("Trigger multiplicity");
220  }
221  const Char_t* GetTriggerString() const
222  {
223  if (GetTrigger() > 0) return Form("M>=%d", GetTrigger());
224  else return Form("xxx");
225  }
226  KVDBSystem* GetSystem() const;
227  const Char_t* GetSystemName() const
228  {
229  return (GetSystem() ? GetSystem()->GetName() : "");
230  }
231  const Char_t* GetComments() const
232  {
233  return GetString("Comments");
234  }
237  {
238  return (GetSystem() ? GetSystem()->GetTarget() : 0);
239  }
240  void SetComments(const KVString& comments)
241  {
242  Set("Comments", comments);
243  }
244 
245  virtual void SetSystem(KVDBSystem* system);
246  virtual void UnsetSystem();
247 
248  void Print(Option_t* option = "") const override;
249 
250  virtual void WriteRunListLine(std::ostream&, Char_t delim = '|') const;
251  virtual void ReadRunListLine(const KVString&);
252  virtual void WriteRunListHeader(std::ostream&, Char_t delim = '|') const;
253 
255  virtual void SetScaler(const Char_t* name, Int_t val)
256  {
257  KV__SET_INT(name, val)
258  Modified();
259  };
261  virtual Int_t GetScaler(const Char_t* name) const
262  {
263  KV__GET_INT(name)
264  };
266  virtual void SetScaler64(const Char_t* name, ULong64_t val)
267  {
268  KV__SET_ULONG(name, val)
269  Modified();
270  };
272  virtual ULong64_t GetScaler64(const Char_t* name) const
273  {
274  KV__GET_ULONG(name)
275  };
277  void Set(const Char_t* param, Double_t val)
278  {
279  KV__SET_DBL(param, val)
280  Modified();
281  };
283  Double_t Get(const Char_t* param) const
284  {
285  KV__GET_DBL(param)
286  };
288  void Set(const Char_t* param, const KVString& val)
289  {
290  KV__SET_STR(param, val)
291  Modified();
292  };
294  const Char_t* GetString(const Char_t* param) const
295  {
296  KV__GET_STR(param)
297  };
298 
299 
300  ClassDefOverride(KVDBRun, 11) //Base class for an experiment run
301 };
302 #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:161
run_index_t GetRunIndex() const
Definition: KVDBRunFile.h:64
void SetBad(Bool_t is_bad=kTRUE)
Definition: KVDBRunFile.h:217
const Char_t * GetEndDate() const
Definition: KVDBRunFile.h:169
Bool_t IsBad() const
Definition: KVDBRunFile.h:222
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:266
void SetBadAllRunFiles()
Definition: KVDBRun.h:118
KVNameValueList fParameters
list of named parameters for run
Definition: KVDBRun.h:46
ULong64_t GetEvents() const
Definition: KVDBRun.h:165
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:272
const Char_t * GetSystemName() const
Definition: KVDBRun.h:227
KVTarget * GetTarget() const
Return target used for this run (actually target of KVDBSystem associated to run)
Definition: KVDBRun.h:236
KVDBRunFile * GetRunFile(int index)
Definition: KVDBRun.h:48
void AddRunFile(KVDBRunFile *rf)
Definition: KVDBRun.h:80
const KVDBRunFile & GetRunFile(const run_index_t &run_index) const
Definition: KVDBRun.h:71
void SetComments(const KVString &comments)
Definition: KVDBRun.h:240
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:182
TObjArray fRunFiles
Definition: KVDBRun.h:45
void SetNumber(Int_t n) override
Definition: KVDBRun.h:160
Bool_t Has(const Char_t *param, Bool_t check_whitespace=kTRUE) const
Definition: KVDBRun.h:152
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:277
Bool_t IsMultiFile() const
Definition: KVDBRun.h:98
Int_t GetNGoodRunFiles() const
Definition: KVDBRun.h:127
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:283
const KVDBRunFile & GetFirstFile() const
Definition: KVDBRun.h:106
const Char_t * GetTriggerString() const
Definition: KVDBRun.h:221
Int_t GetTrigger() const
Definition: KVDBRun.h:217
Double_t GetSize() const
Definition: KVDBRun.h:187
void BlockSignals(Bool_t yes=kTRUE)
Definition: KVDBRun.h:143
const Char_t * GetStartDate() const
Definition: KVDBRun.h:177
void SetTrigger(Int_t trig)
Definition: KVDBRun.h:212
KVDBRunFile & GetLastFile()
Definition: KVDBRun.h:110
virtual void ReadRunListLine(const KVString &)
Definition: KVDBRun.cpp:141
const KVDBRunFile & GetLastFile() const
Definition: KVDBRun.h:114
Int_t GetNRunFiles() const
Definition: KVDBRun.h:84
void Modified()
Definition: KVDBRun.h:138
void Set(const Char_t *param, const KVString &val)
Set characteristic of run.
Definition: KVDBRun.h:288
KVDBRunFile & GetFirstFile()
Definition: KVDBRun.h:102
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:261
run_index_list GetRunIndexList() const
Definition: KVDBRun.h:88
const Char_t * GetString(const Char_t *param) const
Get characteristic of run.
Definition: KVDBRun.h:294
KVDBRun()
default ctor
Definition: KVDBRun.cpp:33
const Char_t * GetComments() const
Definition: KVDBRun.h:231
Double_t GetTime() const
Definition: KVDBRun.h:199
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:255
KVDBRunFile & GetRunFile(const run_index_t &run_index)
Definition: KVDBRun.h:62
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