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 
64  KVDBRunFile& GetRunFile(const run_index_t& run_index)
65  {
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  }
73  const KVDBRunFile& GetRunFile(const run_index_t& run_index) const
74  {
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  }
89  {
90  return GetNRunFiles() > 1;
91  }
93  {
94  return *GetRunFile(0);
95  }
96  const KVDBRunFile& GetFirstFile() const
97  {
98  return *GetRunFile(0);
99  }
101  {
102  return *static_cast<KVDBRunFile*>(fRunFiles.Last());
103  }
104  const KVDBRunFile& GetLastFile() const
105  {
106  return *static_cast<const KVDBRunFile*>(fRunFiles.Last());
107  }
109  {
112  TIter next(&fRunFiles);
113  KVDBRunFile* rf;
114  while((rf = (KVDBRunFile*)next()))
115  rf->SetBad();
116  }
118  {
120  Int_t not_bad(0);
121  TIter next(&fRunFiles);
122  KVDBRunFile* rf;
123  while((rf = (KVDBRunFile*)next()))
124  not_bad += !rf->IsBad();
125  return not_bad;
126  }
127 
128  void Modified() // *SIGNAL*
129  {
131  if (!fBlockSignals) Emit("Modified()");
132  }
133  void BlockSignals(Bool_t yes = kTRUE)
134  {
137  fBlockSignals = yes;
138  }
139 
142  Bool_t Has(const Char_t* param, Bool_t check_whitespace = kTRUE) const
143  {
144  if (check_whitespace && fParameters.HasStringParameter(param)) {
145  return !(fParameters.GetTStringValue(param).IsWhitespace());
146  }
148  }
149 
150  void SetNumber(Int_t n) override
151  {
153  Modified();
154  }
156  {
160  ULong64_t tot = 0;
161  TIter it(&fRunFiles);
162  while (KVDBRunFile* dbr = (KVDBRunFile*)it()) {
163  if(!dbr->IsBad()) tot += dbr->GetEvents();
164  }
165  return tot;
166  }
167  const Char_t* GetStartDate() const
168  {
170  return GetFirstFile().GetStartDate();
171  }
172  const Char_t* GetEndDate() const
173  {
175  return GetLastFile().GetEndDate();
176  }
178  {
182  Double_t tot = 0;
183  TIter it(&fRunFiles);
184  while (KVDBRunFile* dbr = (KVDBRunFile*)it()) {
185  if(!dbr->IsBad()) tot += dbr->GetSize();
186  }
187  return tot;
188  }
190  {
194  Double_t tot = 0;
195  TIter it(&fRunFiles);
196  while (KVDBRunFile* dbr = (KVDBRunFile*)it()) {
197  if(!dbr->IsBad()) tot += dbr->GetTime();
198  }
199  return tot;
200  }
201 
202  void SetTrigger(Int_t trig)
203  {
204  SetScaler("Trigger multiplicity", trig);
205  }
206 
208  {
209  return GetScaler("Trigger multiplicity");
210  }
211  const Char_t* GetTriggerString() const
212  {
213  if (GetTrigger() > 0) return Form("M>=%d", GetTrigger());
214  else return Form("xxx");
215  }
216  KVDBSystem* GetSystem() const;
217  const Char_t* GetSystemName() const
218  {
219  return (GetSystem() ? GetSystem()->GetName() : "");
220  }
221  const Char_t* GetComments() const
222  {
223  return GetString("Comments");
224  }
227  {
228  return (GetSystem() ? GetSystem()->GetTarget() : 0);
229  }
230  void SetComments(const KVString& comments)
231  {
232  Set("Comments", comments);
233  }
234 
235  virtual void SetSystem(KVDBSystem* system);
236  virtual void UnsetSystem();
237 
238  void Print(Option_t* option = "") const override;
239 
240  virtual void WriteRunListLine(std::ostream&, Char_t delim = '|') const;
241  virtual void ReadRunListLine(const KVString&);
242  virtual void WriteRunListHeader(std::ostream&, Char_t delim = '|') const;
243 
245  virtual void SetScaler(const Char_t* name, Int_t val)
246  {
247  KV__SET_INT(name, val)
248  Modified();
249  };
251  virtual Int_t GetScaler(const Char_t* name) const
252  {
253  KV__GET_INT(name)
254  };
256  virtual void SetScaler64(const Char_t* name, ULong64_t val)
257  {
258  KV__SET_ULONG(name, val)
259  Modified();
260  };
262  virtual ULong64_t GetScaler64(const Char_t* name) const
263  {
264  KV__GET_ULONG(name)
265  };
267  void Set(const Char_t* param, Double_t val)
268  {
269  KV__SET_DBL(param, val)
270  Modified();
271  };
273  Double_t Get(const Char_t* param) const
274  {
275  KV__GET_DBL(param)
276  };
278  void Set(const Char_t* param, const KVString& val)
279  {
280  KV__SET_STR(param, val)
281  Modified();
282  };
284  const Char_t* GetString(const Char_t* param) const
285  {
286  KV__GET_STR(param)
287  };
288 
289 
290  ClassDefOverride(KVDBRun, 11) //Base class for an experiment run
291 };
292 #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:36
const Char_t * GetStartDate() const
Definition: KVDBRunFile.h:144
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
const Char_t * GetEndDate() const
Definition: KVDBRunFile.h:152
Bool_t IsBad() const
Definition: KVDBRunFile.h:201
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:251
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:256
void SetBadAllRunFiles()
Definition: KVDBRun.h:108
KVNameValueList fParameters
list of named parameters for run
Definition: KVDBRun.h:46
ULong64_t GetEvents() const
Definition: KVDBRun.h:155
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:262
const Char_t * GetSystemName() const
Definition: KVDBRun.h:217
KVTarget * GetTarget() const
Return target used for this run (actually target of KVDBSystem associated to run)
Definition: KVDBRun.h:226
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:73
void SetComments(const KVString &comments)
Definition: KVDBRun.h:230
KVDBSystem * GetSystem() const
Definition: KVDBRun.cpp:237
virtual void WriteRunListLine(std::ostream &, Char_t delim='|') const
Definition: KVDBRun.cpp:91
const Char_t * GetEndDate() const
Definition: KVDBRun.h:172
TObjArray fRunFiles
Definition: KVDBRun.h:45
void SetNumber(Int_t n) override
Definition: KVDBRun.h:150
Bool_t Has(const Char_t *param, Bool_t check_whitespace=kTRUE) const
Definition: KVDBRun.h:142
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:267
Bool_t IsMultiFile() const
Definition: KVDBRun.h:88
Int_t GetNGoodRunFiles() const
Definition: KVDBRun.h:117
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:273
const KVDBRunFile & GetFirstFile() const
Definition: KVDBRun.h:96
const Char_t * GetTriggerString() const
Definition: KVDBRun.h:211
Int_t GetTrigger() const
Definition: KVDBRun.h:207
Double_t GetSize() const
Definition: KVDBRun.h:177
void BlockSignals(Bool_t yes=kTRUE)
Definition: KVDBRun.h:133
const Char_t * GetStartDate() const
Definition: KVDBRun.h:167
void SetTrigger(Int_t trig)
Definition: KVDBRun.h:202
KVDBRunFile & GetLastFile()
Definition: KVDBRun.h:100
virtual void ReadRunListLine(const KVString &)
Definition: KVDBRun.cpp:138
const KVDBRunFile & GetLastFile() const
Definition: KVDBRun.h:104
Int_t GetNRunFiles() const
Definition: KVDBRun.h:84
void Modified()
Definition: KVDBRun.h:128
void Set(const Char_t *param, const KVString &val)
Set characteristic of run.
Definition: KVDBRun.h:278
KVDBRunFile & GetFirstFile()
Definition: KVDBRun.h:92
virtual void UnsetSystem()
Definition: KVDBRun.cpp:220
virtual Int_t GetScaler(const Char_t *name) const
Get value of scaler with the given name for this run.
Definition: KVDBRun.h:251
const Char_t * GetString(const Char_t *param) const
Get characteristic of run.
Definition: KVDBRun.h:284
KVDBRun()
default ctor
Definition: KVDBRun.cpp:33
const Char_t * GetComments() const
Definition: KVDBRun.h:221
Double_t GetTime() const
Definition: KVDBRun.h:189
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:245
KVDBRunFile & GetRunFile(const run_index_t &run_index)
Definition: KVDBRun.h:64
virtual void WriteRunListHeader(std::ostream &, Char_t delim='|') const
Write the version flag.
Definition: KVDBRun.cpp:206
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