5 #include "KVDBSystem.h"
6 #include "KVNumberList.h"
8 #include <KVFileReader.h>
11 #include "KVUnownedList.h"
27 fRuns = AddTable(
"Runs",
"List of available runs");
28 fRuns->SetDefaultFormat(
"Run %d");
29 fSystems = AddTable(
"Systems",
"List of available systems");
31 with_index_multiplier = index_multiplier != 1;
144 TString beam_fp, target_fp, reaction_fp;
145 if (!(FindCalibFile(
"Beams", beam_fp) && FindCalibFile(
"Targets", target_fp) && FindCalibFile(
"Reactions", reaction_fp))) {
146 Error(
"read_beams_targets_reactions",
147 "One or more files not found:\nFull path to %s = %s\nFull path to %s = %s\nFull path to %s = %s",
148 GetCalibFileName(
"Beams").Data(), beam_fp.
Data(),
149 GetCalibFileName(
"Targets").Data(), target_fp.
Data(),
150 GetCalibFileName(
"Reactions").Data(), reaction_fp.
Data());
154 Info(
"read_beams_targets_reactions",
"Reading files:\nFull path to %s = %s\nFull path to %s = %s\nFull path to %s = %s",
155 GetCalibFileName(
"Beams").Data(), beam_fp.
Data(),
156 GetCalibFileName(
"Targets").Data(), target_fp.
Data(),
157 GetCalibFileName(
"Reactions").Data(), reaction_fp.
Data());
159 KVEnv beams_v(beam_fp), targets_v(target_fp), reactions_v(reaction_fp);
162 if (!reactions_v.
HasValue(react,
"Target"))
167 auto nlayers = targets_v.GetValueOf(targ,
"Layers").Default(1);
172 for (
int ilay = 1; ilay <= nlayers; ++ilay) {
173 T->AddLayer(targets_v.GetValueOf(targ,
"Layer", ilay,
"Material").Default<
KVString>(),
174 targets_v.GetValueOf(targ,
"Layer", ilay,
"AreaDensity").Default(0.));
177 else if (targets_v.HasValue(targ,
"Material"))
179 T->AddLayer(targets_v.GetValueOf(targ,
"Material").Default<
KVString>(),
180 targets_v.GetValueOf(targ,
"AreaDensity").Default(0.));
183 T->SetAngleToBeam(targets_v.GetValueOf(targ,
"Angle").Default(0.));
184 if (targets_v.HasValue(targ,
"Name"))
185 T->SetName(targets_v.GetValueOf(targ,
"Name").Default<
KVString>());
189 auto get_beam_properties = [&](
const KVString & react) {
192 beams_v.GetValueOf(beam,
"Energy").Default(0.));
194 auto get_target_properties = [&](
const KVString & react) {
196 if (targets_v.HasValue(targ,
"TargetNucleus"))
197 return KVNucleus(targets_v.GetValueOf(targ,
"TargetNucleus").Default<
KVString>());
200 auto get_target_name = [&](
const KVString & react) {
202 return targets_v.GetValueOf(targ,
"Name").Default<
KVString>(
"");
206 reactions.
Begin(
" ");
207 while (!reactions.
End()) {
208 auto R = reactions.
Next();
215 sys =
new KVDBSystem(get_beam_properties(
R), get_target_properties(
R), get_target_name(
R));
218 auto targ = make_target(
R);
274 if (gExpDB ==
this) gExpDB =
nullptr;
293 std::map<int, int> one_shot;
294 for (
UInt_t ii = first_run; ii <= last_run; ii++) {
316 std::map<int, int> one_shot;
334 rec->AddLink(
"Runs", run);
358 for (
UInt_t i = 0; i < rr_number; i++) {
374 Error(
"LinkListToRunRanges",
375 "NULL pointer passed for parameter TList");
379 Error(
"LinkListToRunRanges(TList*,UInt_t,UInt_t*)",
380 "The list is empty");
399 Error(
"LinkListToRunRange",
400 "NULL pointer passed for parameter TList");
404 Error(
"LinkListToRunRange(TList*,KVNumberList)",
405 "The list is empty");
432 Info(
"ReadSystemList",
"Reading reaction parameters...");
458 Info(
"ReadSystemList()",
"Reading Systems parameters ...");
462 char next_char = fin.peek();
463 while (next_char !=
'+' && fin.good()) {
465 next_char = fin.peek();
468 while (fin.good() && !fin.eof() && next_char ==
'+') {
472 next_char = fin.peek();
477 Error(
"ReadSystemList()",
"Could not open file %s",
486 while ((run = (
KVDBRun*)nextRun())) {
522 sysfile <<
"# " <<
GetDBEnv(
"Systems") <<
" file written by "
524 cout <<
GetDBEnv(
"Systems") <<
" file written by "
527 if (strcmp(sys->
GetName(),
"[unknown]")) {
574 rlistf <<
"# " <<
GetDBEnv(
"Runlist") <<
" file written by "
576 cout <<
GetDBEnv(
"Runlist") <<
" file written by "
583 while ((run = (
KVDBRun*) next_run())) {
590 Warning(
"WriteRunListFile()",
"run list is empty !!!");
701 if (cal_file_name.IsNull())
return kFALSE;
704 if (!array_name.
IsNull()) {
705 cal_file_name.Prepend(
Form(
"%s.", array_name.
Data()));
741 printf(
"RUN\tSYSTEM\t\t\t\tTRIGGER\t\tEVENTS\t\tCOMMENTS\n");
742 printf(
"------------------------------------------------------------------------------------------------------------------\n");
747 printf(
"%4d\t%-30s\t%s\t\t%llu\t\t%s\n",
798 mda->SetDataSetDir(datasetdir);
819 while ((dbr = (
KVDBRun*)next())) {
821 if ((last_run > 0 && dbr->
GetNumber() <= last_run)
822 || last_run == -1) total += dbr->
GetEvents();
838 Error(
"GetTotalEvents",
"No system with name : %s", system.
Data());
843 total +=
dynamic_cast<KVDBRun*
>(dbr)->GetEvents();
872 for (
auto& ri :
r->GetRunIndexList()) {
946 _the_list.
Begin(
" ,");
947 while (!_the_list.
End()) {
952 std::vector<int> limits(2);
953 for (
int i = 0; i < 2; ++i) {
955 if (titbit.Contains(
".")) {
969 for (
int ri = limits[0]; ri <= limits[1]; ++ri)
981 for (
int i =
GetDBRun(run_num)->GetFirstGoodFile().
value().get().GetGlobalRunFileNumber();
1060 if (comments_file ==
"")
return;
1063 Info(
"ReadComments",
"Reading run comments in file %s...", fullpath.
Data());
1067 Error(
"ReadComments",
"Problem opening file %s", fullpath.
Data());
1087 while (!lruns.
End()) {
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize fs
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
char * Form(const char *fmt,...)
static ValType GetDataSetEnv(const KVString &dataset, const KVString &type, const ValType &defval)
static Bool_t SearchKVFile(const Char_t *name, TString &fullpath, const Char_t *kvsubdir="")
static Bool_t SearchAndOpenKVFile(const Char_t *name, KVSQLite::database &dbfile, const Char_t *kvsubdir="")
static TPluginHandler * LoadPlugin(const Char_t *base, const Char_t *uri="0")
Record folder for the database.
virtual Int_t GetNumber() const
Int_t GetGlobalRunFileNumber() const
Description of an experimental run in database ,,.
ULong64_t GetEvents() const
std::optional< std::reference_wrapper< const KVDBRunFile > > GetFirstGoodFile() const
std::optional< std::reference_wrapper< const KVDBRunFile > > GetLastGoodFile() const
void SetComments(const KVString &comments)
KVDBSystem * GetSystem() const
virtual void WriteRunListLine(std::ostream &, Char_t delim='|') const
const Char_t * GetTriggerString() const
const Char_t * GetComments() const
Database class used to store information on different colliding systems studied during an experiment....
void Save(std::ostream &) const
void SetRuns(const KVNumberList &, int=1)
void AddRun(KVDBRecord *)
void SetTarget(KVTarget *targ)
void Load(std::istream &, int=1)
virtual KVDBRecord * GetRecord(const Char_t *rec_name) const
Simple cross-referenced database structure.
ValueType Default(ValueType v=ValueType{}) const
Extension of TEnv to allow the writing of comments in the file.
Bool_t HasValue(const KVString &val) const
Value GetValueOf(Ts... args) const
Base class to describe database of an experiment ,,.
void AddSystem(KVDBSystem *r)
std::map< int, run_index_t > fMapGlobRunFileNumberToRunIndex
cannot be saved, no streamer for run_index_t
run_index_list SetRunIndexListFromString(const TString &) const
run_index_t GetRunIndexFromGlobalRunFileNumber(int glob_runfile) const
virtual ~KVExpDB()
Destructor.
virtual KVDBSystem * GetSystem(const Char_t *system) const
virtual void ReadComments()
virtual void ReadSystemList()
KVDBTable * fRuns
table of runs
virtual void LinkRecordToRun(KVDBRecord *rec, Int_t run)
KVDBRun * GetDBRun(Int_t number) const
virtual KVSeqCollection * GetRuns() const
TString GetCalibFileName(const Char_t *type) const
virtual void LinkListToRunRanges(TList *list, UInt_t rr_number, UInt_t run_ranges[][2])
Link the records contained in the list to the set of runs (see LinkRecordToRunRanges).
KVDBTable * fSystems
table of systems
virtual void PrintRuns(KVNumberList &) const
ULong64_t GetTotalEvents(int first_run, int last_run=-1) const
virtual KVSeqCollection * GetSystems() const
virtual void Save(const Char_t *)
const KVDBRunFile & GetDBRunFile(const run_index_t &r) const
TString fDBType
used by GetDBEnv
virtual void LinkRecordToRunRanges(KVDBRecord *rec, UInt_t rr_number, UInt_t run_ranges[][2])
virtual void LinkListToRunRange(TList *list, const KVNumberList &nl)
Link the records contained in the list to the set of runs (see LinkRecordToRunRanges).
void WriteSystemsFile() const
KVExpDB()
Default constructor.
const Char_t * GetDataSetDir() const
void init()
default initialisations
virtual void LinkRecordToRunRange(KVDBRecord *rec, UInt_t first_run, UInt_t last_run)
void WriteRunListFile() const
virtual TString GetDBEnv(const Char_t *) const
Bool_t OpenCalibFile(const Char_t *type, std::ifstream &fs) const
static KVExpDB * MakeDataBase(const Char_t *name, const Char_t *datasetdir, Bool_t minimal=false)
void read_beams_targets_reactions()
TString fDataSet
the name of the dataset to which this database is associated
Bool_t FindCalibFile(const Char_t *type, TString &fullpath, const TString &array_name="") const
Handle reading columns of numeric data in text files.
KVString GetCurrentLine()
ReadStatus ReadLine(const KVString &pattern="")
Int_t GetNparRead() const
KVString GetReadPar(Int_t pos) const
Bool_t OpenFileToRead(const KVString &filename)
Description of properties and kinematics of atomic nuclei.
Strings used to represent a set of ranges of values.
TObject * At(Int_t idx) const override
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
void Begin(TString delim) const
KVString Next(Bool_t strip_whitespace=kFALSE) const
Int_t GetNValues(TString delim) const
Calculation/correction of energy losses of particles through an experimental target.
virtual Int_t GetSize() const
const char * AsString() const
virtual const char * GetValue(const char *name, const char *dflt) const
const char * GetName() const override
virtual const char * ClassName() const
virtual void Warning(const char *method, const char *msgfmt,...) const
virtual void Error(const char *method, const char *msgfmt,...) const
virtual void Info(const char *method, const char *msgfmt,...) const
Longptr_t ExecPlugin(int nargs)
const char * Data() const
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
List of runfiles specified by run number and file index ,.
void Add(const run_index_t &r)
Specifies a runfile according to run number and file index ,.
unsigned long long ULong64_t