KaliVeda  1.12/06
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 
83 
85 {
86  // Build the database.
87  // Runs & Systems tables are handled by us, calibrations are handled by each multidetector
88 
89  FillRunsTable();
90  ReadComments();
93 
96 }
97 
98 
99 
103 
105 {
106  // Look for file scalers.root and read scalers from it
107  // scalers are assumed to be stored as 64-bit parameters in the list
108 
109  TString runinfos = KVDataSet::GetFullPathToDataSetFile(fDataSet, "scalers.root");
110  if (runinfos == "") return;
111 
112  Info("ReadScalerInfos", "Reading scaler infos from %s", runinfos.Data());
113  TFile runinfos_file(runinfos);
114  TIter it_run(GetRuns());
115  KVDBRun* run;
116  while ((run = (KVDBRun*)it_run())) {
117  KVNameValueList* scalist = (KVNameValueList*)runinfos_file.Get(Form("run_%06d", run->GetNumber()));
118  if (scalist) {
119  int npar = scalist->GetNpar();
120  for (int i = 0; i < npar; i += 2) {
121  TString parname = scalist->GetParameter(i)->GetName();
122  parname.Remove(parname.Index("_hi"), 3);
123  run->SetScaler64(parname, scalist->GetValue64bit(parname));
124  }
125  }
126  }
127 }
128 
129 
130 
134 
136 {
137  // Fill the Runs table using the informations in file runinfos.root
138  // (which can be generated using KVRunListCreator).
139 
140  TString runinfos = KVDataSet::GetFullPathToDataSetFile(fDataSet, "runinfos.root");
141  Info("FillRunsTable", "Reading run infos from %s", runinfos.Data());
142  TFile runinfos_file(runinfos);
143  TIter it(runinfos_file.GetListOfKeys());
144  TKey* run_key;
145  KVList garbage;
146  while ((run_key = (TKey*)it())) {
147  if (TString(run_key->GetClassName()) == "KVNameValueList") {
148  // make sure we only use the highest cycle number of each key
149  if (run_key->GetCycle() == runinfos_file.GetKey(run_key->GetName())->GetCycle()) {
150  KVNameValueList* run = (KVNameValueList*)run_key->ReadObj();
151  garbage.Add(run);
152  KVDBRun* dbrun = new KVDBRun;
153  dbrun->SetNumber(run->GetIntValue("Run"));
154  dbrun->SetStartDate(run->GetStringValue("Start"));
155  dbrun->SetEndDate(run->GetStringValue("End"));
156  if (run->HasValue64bit("Size"))
157  dbrun->SetSize(run->GetValue64bit("Size") / 1024. / 1024.);
158  else
159  dbrun->SetSize(run->GetIntValue("Size") / 1024. / 1024.);
160 
161  if (run->HasValue64bit("Events")) {
162  dbrun->SetEvents(run->GetValue64bit("Events"));
163  }
164  else
165  dbrun->SetEvents(run->GetIntValue("Events"));
166  AddRun(dbrun);
167  }
168  }
169  }
170 }
171 
172 
173 //____________________________________________________________________________//
174 
175 
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:1886
Base class to describe database of an experiment ,.
Definition: KVExpDB.h:18
virtual void ReadComments()
Definition: KVExpDB.cpp:676
virtual void ReadSystemList()
Definition: KVExpDB.cpp:248
void AddRun(KVDBRun *r)
Definition: KVExpDB.h:65
virtual KVSeqCollection * GetRuns() const
Definition: KVExpDB.h:70
TString fDataSet
the name of the dataset to which this database is associated
Definition: KVExpDB.h:21
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