KaliVeda
Toolkit for HIC analysis
KVAvailableRunsFile.h
1 /*
2 $Id: KVAvailableRunsFile.h,v 1.5 2008/02/07 09:25:39 franklan Exp $
3 $Revision: 1.5 $
4 $Date: 2008/02/07 09:25:39 $
5 */
6 
9 
10 #ifndef __KVAVAILABLERUNSFILE_H
11 #define __KVAVAILABLERUNSFILE_H
12 
13 #include <forward_list>
14 #include <optional>
15 
16 #include <KVBase.h>
17 #include "Riostream.h"
18 
19 #include "TDatime.h"
20 #include "TString.h"
21 #include "KVNumberList.h"
22 #include "KVLockfile.h"
23 #include "KVDatime.h"
24 #include "KVDataSet.h"
25 #include "KVList.h"
26 #include "KVHashList.h"
27 #include "KVNameValueList.h"
28 #include "TSystem.h"
29 #ifdef WITH_RSQLITE
30 #include "SQLiteDB.h"
32 #else
33 using DataBase = TObject;
34 #endif
35 #include "run_index.h"
36 
37 class KVDBSystem;
38 class TList;
39 
58 class KVAvailableRunsFile: public KVBase {
59 
61  const KVDataSet* fDataSet = nullptr;
62 private:
64  {
65  TString selection = Form("run = %d", run.run());
66  if (run.has_index()) selection += Form(" AND index = %d", run.index());
67  else selection += " AND index IS NULL";
68  return selection;
69  }
70  TString SelectFileName(const KVString& filename)
71  {
72  return "filename = '" + filename + "'";
73  }
75  const KVBase* objs,
76  DataBase* RunListTable,
77  const run_index_t& run_num,
78  KVDBRun* run, bool with_version_and_username = false);
80  const KVString& filename,
81  const KVDatime& modt,
82  DataBase* RunListTable,
83  const run_index_t& run_num,
84  KVDBRun* run, bool with_version_and_username = false);
85 
86 protected:
87  KVString GetFileName() const;
88  KVString GetFilePath() const;
91  virtual std::unique_ptr<DataBase> OpenAvailableRunsFile(bool called_by_update = false);
92  bool making_new_db = false;
93 
94  virtual bool get_file_modification_date(KVDataRepository* repository, const KVBase* objs, KVDatime& modt);
95 public:
96  KVAvailableRunsFile() = default;
98  {
101  }
102  KVAvailableRunsFile(const Char_t* type, const KVDataSet* parent): KVBase(type), fDataSet{parent}
103  {
105  }
106 
108  {
110  }
111 
112  const Char_t* GetDataType() const
113  {
114  return GetName();
115  }
116  std::optional<run_index_t> IsRunFileName(const Char_t* filename);
117  static std::optional<run_index_t> IsRunFileName(const KVString& fmt, const KVString& filename, const KVString& separators = ".");
119  {
124 
125  TString fmt = fDataSet->GetDataSetEnv(Form("DataSet.RunFileName.%s", GetDataType()));
126  return ExtractDateFromFileName(fmt, name, date);
127  }
128  static Bool_t ExtractDateFromFileName(const TString& fmt, const Char_t* name, KVDatime& date);
129  virtual void Update(const std::unique_ptr<DataBase>& db_handle = {});
131  {
136 #ifdef WITH_RSQLITE
137  auto RunDB = OpenAvailableRunsFile();
138 
139  return (RunDB->count("Available_Runs", "*", SelectRunAndOrIndex(run), true) > 0);
140 #else
141  return false;
142 #endif
143  }
144  Int_t Count(const run_index_t& run)
145  {
149 #ifdef WITH_RSQLITE
150  auto RunDB = OpenAvailableRunsFile();
151 
152  return RunDB->count("Available_Runs", "*", SelectRunAndOrIndex(run));
153 #else
154  return 0;
155 #endif
156  }
157  Bool_t GetRunInfo(const run_index_t& run, TDatime& modtime,
158  TString& filename);
159  void GetRunInfos(const run_index_t& run, KVList* dates, KVList* names);
161  {
164 
165  TString fname;
166  TDatime dtime;
167  GetRunInfo(run, dtime, fname);
168  return fname;
169  }
170  std::unique_ptr<TList> GetListOfAvailableSystems(const KVDBSystem* systol = 0);
171  run_index_list GetRunList(const KVDBSystem* system = 0);
172 
173  virtual void Remove(const run_index_t& run, const KVString& filename = "");
174  void UpdateInfos(const run_index_t& run, const KVString& filename, const KVString& kvversion, const KVString& username);
175  Bool_t InfosNeedUpdate(const run_index_t& run, const KVString& filename);
176  virtual void Add(const run_index_t& run, const KVString& filename);
177  const KVDataSet* GetDataSet() const
178  {
180  return fDataSet;
181  }
182 
183  void SetDataSet(const KVDataSet* d)
184  {
186  fDataSet = d;
187  }
188 
189  std::forward_list<run_index_t> CheckMultiRunfiles();
190  void RemoveDuplicateLines(KVNumberList lines_to_be_removed);
191 
192  ClassDef(KVAvailableRunsFile, 1) //Handles text files containing list of available runs for different datasets and types of data
193 };
194 
195 #endif
int Int_t
#define d(i)
bool Bool_t
char Char_t
#define ClassDef(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 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 filename
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 name[80]
char * Form(const char *fmt,...)
R__EXTERN TSystem * gSystem
Handles lists of available runs for different datasets and types of data.
Bool_t CheckDirectoryForAvailableRunsFile()
virtual std::unique_ptr< DataBase > OpenAvailableRunsFile(bool called_by_update=false)
Bool_t InfosNeedUpdate(const run_index_t &run, const KVString &filename)
bool insert_runfile_into_database(KVDataRepository *repository, const KVBase *objs, DataBase *RunListTable, const run_index_t &run_num, KVDBRun *run, bool with_version_and_username=false)
virtual void Remove(const run_index_t &run, const KVString &filename="")
Remove from the db ALL entries corresponding to the given run/index (and filename if given)
void UpdateInfos(const run_index_t &run, const KVString &filename, const KVString &kvversion, const KVString &username)
TString GetFileName(const run_index_t &run)
Bool_t ExtractDateFromFileName(const Char_t *name, KVDatime &date)
const Char_t * GetDataType() const
TString SelectRunAndOrIndex(const run_index_t &run)
dataset to which this file belongs
void SetDataSet(const KVDataSet *d)
std::forward_list< run_index_t > CheckMultiRunfiles()
Returns a list with all run/indexes for which more than one file is in the available runs db.
virtual void Update(const std::unique_ptr< DataBase > &db_handle={})
const KVDataSet * fDataSet
Bool_t CheckAvailable(const run_index_t &run)
KVAvailableRunsFile(const Char_t *type, const KVDataSet *parent)
void GetRunInfos(const run_index_t &run, KVList *dates, KVList *names)
KVString GetFileName() const
const KVDataSet * GetDataSet() const
KVString GetFullPathToAvailableRunsFile() const
KVAvailableRunsFile(const Char_t *type)
KVAvailableRunsFile()=default
run_index_list GetRunList(const KVDBSystem *system=0)
std::optional< run_index_t > IsRunFileName(const Char_t *filename)
TString SelectFileName(const KVString &filename)
KVString GetFilePath() const
static KVString date_read_from_filename
virtual bool get_file_modification_date(KVDataRepository *repository, const KVBase *objs, KVDatime &modt)
virtual void Add(const run_index_t &run, const KVString &filename)
Int_t Count(const run_index_t &run)
std::unique_ptr< TList > GetListOfAvailableSystems(const KVDBSystem *systol=0)
void RemoveDuplicateLines(KVNumberList lines_to_be_removed)
Bool_t GetRunInfo(const run_index_t &run, TDatime &modtime, TString &filename)
Base class for KaliVeda framework.
Definition: KVBase.h:139
Description of an experimental run in database ,,.
Definition: KVDBRun.h:41
Database class used to store information on different colliding systems studied during an experiment....
Definition: KVDBSystem.h:52
Base class for managing repositories of experimental data.
Manage an experimental dataset corresponding to a given experiment or campaign.
Definition: KVDataSet.h:130
ValType GetDataSetEnv(const Char_t *type, const ValType &defval) const
Definition: KVDataSet.h:252
Extension of TDatime to handle various useful date formats.
Definition: KVDatime.h:33
Extended TList class which owns its objects by default.
Definition: KVList.h:28
Strings used to represent a set of ranges of values.
Definition: KVNumberList.h:85
Interface to ROOT SQLite database backend.
Definition: SQLiteDB.h:477
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
Definition: KVString.h:73
const char * GetName() const override
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Specifies a runfile according to run number and file index ,.
Definition: run_index.h:31
int run() const
Definition: run_index.h:50
int index(int no_index=-1) const
Definition: run_index.h:55
bool has_index() const
Definition: run_index.h:59