KaliVeda  1.13/01
Heavy-Ion Analysis Toolkit
KVExpSetUpDB.cpp
Go to the documentation of this file.
1 //Created by KVClassFactory on Fri Jul 20 15:49:04 2018
2 //Author: eindra
3 
4 #include "KVExpSetUpDB.h"
5 #include "KVDataSet.h"
6 #include "KVMultiDetArray.h"
7 
8 #include <TKey.h>
9 
11 
12 
13 
21 void KVExpSetUpDB::ReadOoODetectors(const TString&)
22 {
23  // Overrides base class method.
24  //
25  // Calls KVExpDB::ReadOoODetectors for each multidetector in the KVExpSetUp in turn with the
26  // name of the array as value of the argument.
27  //
28  // This will create a table for each multidetector with names: NAME1.OoO Detectors, NAME2.OoODetectors, etc.
29 
30 }
31 
32 
33 
36 
38  : KVExpDB()
39 {
40  // Default constructor
41 }
42 
43 
44 
45 
48 
50  : KVExpDB(name)
51 {
52  // Constructor inherited from KVExpDB
53 }
54 
55 
56 
57 
60 
61 KVExpSetUpDB::KVExpSetUpDB(const Char_t* name, const Char_t* title)
62  : KVExpDB(name, title)
63 {
64  // Constructor inherited from KVExpDB
65 }
66 
67 
68 
69 
72 
74 {
75  // Destructor
76 }
77 
78 
79 
86 
88 {
89  // Build the database.
90  // Runs & Systems tables are handled by us, calibrations are handled by each multidetector
91  //
92  // If no run infos are available (perhaps no data yet available for dataset), we make a dummy
93  // database with runs numbered from 1 to 100.
94 
95  try {
96  FillRunsTable();
97  }
98  catch (...) {
99  Info("Build", "No informations on dataset runs available");
100  Info("Build", "Dummy database runs numbered from 1 to 100 will be created");
101  for (int i = 1; i <= 100; ++i) {
102  AddRun(new KVDBRun(i, "Dummy database run"));
103  }
104  }
105 
106  ReadComments();
107  ReadSystemList();
108  ReadScalerInfos();
109 
112 }
113 
114 
115 
119 
121 {
122  // Look for file scalers.root and read scalers from it
123  // scalers are assumed to be stored as 64-bit parameters in the list
124 
125  TString runinfos = KVDataSet::GetFullPathToDataSetFile(fDataSet, "scalers.root");
126  if (runinfos == "") return;
127 
128  Info("ReadScalerInfos", "Reading scaler infos from %s", runinfos.Data());
129  TFile runinfos_file(runinfos);
130  TIter it_run(GetRuns());
131  KVDBRun* run;
132  while ((run = (KVDBRun*)it_run())) {
133  KVNameValueList* scalist = (KVNameValueList*)runinfos_file.Get(Form("run_%06d", run->GetNumber()));
134  if (scalist) {
135  int npar = scalist->GetNpar();
136  for (int i = 0; i < npar; i += 2) {
137  TString parname = scalist->GetParameter(i)->GetName();
138  parname.Remove(parname.Index("_hi"), 3);
139  run->SetScaler64(parname, scalist->GetValue64bit(parname));
140  }
141  }
142  }
143 }
144 
145 
146 
154 
156 {
157  // Fill the Runs table using the informations in file runinfos.root
158  // (which can be generated using KVRunListCreator).
159  //
160  // If there are no run infos available (perhaps because no data yet exists for the dataset),
161  // this method throws an exception and the database will have a dummy list of runs
162  // numbered from 1 to 100
163 
164  TString runinfos = KVDataSet::GetFullPathToDataSetFile(fDataSet, "runinfos.root");
165 
166  if (runinfos == "")
167  throw std::runtime_error("run infos file not found");
168 
169  Info("FillRunsTable", "Reading run infos from %s", runinfos.Data());
170  TFile runinfos_file(runinfos);
171  TIter it(runinfos_file.GetListOfKeys());
172  TKey* run_key;
173  KVList garbage;
174  while ((run_key = (TKey*)it())) {
175  if (TString(run_key->GetClassName()) == "KVNameValueList") {
176  // make sure we only use the highest cycle number of each key
177  if (run_key->GetCycle() == runinfos_file.GetKey(run_key->GetName())->GetCycle()) {
178  KVNameValueList* run = (KVNameValueList*)run_key->ReadObj();
179  garbage.Add(run);
180  KVDBRun* dbrun = new KVDBRun;
181  dbrun->SetNumber(run->GetIntValue("Run"));
182  dbrun->SetStartDate(run->GetStringValue("Start"));
183  dbrun->SetEndDate(run->GetStringValue("End"));
184  if (run->HasValue64bit("Size"))
185  dbrun->SetSize(run->GetValue64bit("Size") / 1024. / 1024.);
186  else
187  dbrun->SetSize(run->GetIntValue("Size") / 1024. / 1024.);
188 
189  if (run->HasValue64bit("Events")) {
190  dbrun->SetEvents(run->GetValue64bit("Events"));
191  }
192  else
193  dbrun->SetEvents(run->GetIntValue("Events"));
194  AddRun(dbrun);
195  }
196  }
197  }
198 }
199 
200 
201 //____________________________________________________________________________//
202 
203 
KVMultiDetArray * gMultiDetArray
ClassImp(KVPartitionList) void KVPartitionList
Initialisation.
char Char_t
char * Form(const char *fmt,...)
virtual Int_t GetNumber() const
Definition: KVDBRecord.h:72
Description of an experimental run in database ,.
Definition: KVDBRun.h:35
void SetEvents(ULong64_t evt_number)
Definition: KVDBRun.h:169
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:219
void SetSize(Double_t s)
Definition: KVDBRun.h:177
void SetStartDate(const KVString &date)
Definition: KVDBRun.h:185
void SetEndDate(const KVString &d)
Definition: KVDBRun.h:193
void SetNumber(Int_t n)
Definition: KVDBRun.h:92
TString GetFullPathToDataSetFile(const Char_t *filename)
Definition: KVDataSet.cpp:1887
Base class to describe database of an experiment ,.
Definition: KVExpDB.h:19
virtual void ReadComments()
Definition: KVExpDB.cpp:677
virtual void ReadSystemList()
Definition: KVExpDB.cpp:249
void AddRun(KVDBRun *r)
Definition: KVExpDB.h:66
virtual KVSeqCollection * GetRuns() const
Definition: KVExpDB.h:71
TString fDataSet
the name of the dataset to which this database is associated
Definition: KVExpDB.h:22
Calibration database for experiments using coupled detector arrays.
Definition: KVExpSetUpDB.h:16
void FillRunsTable()
KVExpSetUpDB()
Default constructor.
virtual ~KVExpSetUpDB()
Destructor.
void ReadScalerInfos()
Extended TList class which owns its objects by default.
Definition: KVList.h:27
virtual void MakeCalibrationTables(KVExpDB *)
static KVMultiDetArray * MakeMultiDetector(const Char_t *dataset_name, Int_t run=-1, TString classname="KVMultiDetArray")
Handles lists of named parameters with different types, a list of KVNamedParameter objects.
KVNamedParameter * GetParameter(Int_t idx) const
return the parameter object with index idx
Int_t GetIntValue(const Char_t *name) const
Bool_t HasValue64bit(const Char_t *name) const
Int_t GetNpar() const
return the number of stored parameters
ULong64_t GetValue64bit(const Char_t *name) const
const Char_t * GetStringValue(const Char_t *name) const
virtual void Add(TObject *obj)
TKey * GetKey(const char *name, Short_t cycle=9999) const override
TList * GetListOfKeys() const override
T * Get(const char *namecycle)
virtual const char * GetClassName() const
Short_t GetCycle() const
virtual TObject * ReadObj()
virtual const char * GetName() const
virtual void Info(const char *method, const char *msgfmt,...) const
const char * Data() const
TString & Remove(EStripType s, char c)
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const