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 "KVUnownedList.h"
27 #include "KVHashList.h"
28 #include "KVNameValueList.h"
29 #include "TSystem.h"
30 #ifdef WITH_RSQLITE
31 #include "SQLiteDB.h"
33 #else
34 using DataBase = TObject;
35 #endif
36 #include "run_index.h"
37 
38 class KVDBSystem;
39 class TList;
40 
93 class KVAvailableRunsFile: public KVBase {
94 
96  const KVDataSet* fDataSet = nullptr;
97 private:
99  {
100  TString selection = Form("run = %d", run.run());
101  if (run.has_index()) selection += Form(" AND index = %d", run.index());
102  else selection += " AND index IS NULL";
103  return selection;
104  }
105  TString SelectFileName(const KVString& filename)
106  {
107  return "filename = '" + filename + "'";
108  }
110  const KVBase* objs,
111  DataBase* RunListTable,
112  const run_index_t& run_num,
113  KVDBRun* run, bool with_version_and_username = false);
115  const KVString& filename,
116  const KVDatime& modt,
117  DataBase* RunListTable,
118  const run_index_t& run_num,
119  KVDBRun* run, bool with_version_and_username = false);
120 
121 protected:
122  KVString GetFileName() const;
123  KVString GetFilePath() const;
126  virtual std::unique_ptr<DataBase> OpenAvailableRunsFile(bool called_by_update = false);
127  bool making_new_db = false;
128 
129  virtual bool get_file_modification_date(KVDataRepository* repository, const KVBase* objs, KVDatime& modt);
130 public:
131  KVAvailableRunsFile() = default;
133  {
136  }
137  KVAvailableRunsFile(const Char_t* type, const KVDataSet* parent): KVBase(type), fDataSet{parent}
138  {
140  }
141 
143  {
145  }
146 
147  const Char_t* GetDataType() const
148  {
149  return GetName();
150  }
151  std::optional<run_index_t> IsRunFileName(const Char_t* filename);
152  static std::optional<run_index_t> IsRunFileName(const KVString& fmt, const KVString& filename, const KVString& separators = ".");
154  {
159 
160  TString fmt = fDataSet->GetDataSetEnv(Form("DataSet.RunFileName.%s", GetDataType()));
161  return ExtractDateFromFileName(fmt, name, date);
162  }
163  static Bool_t ExtractDateFromFileName(const TString& fmt, const Char_t* name, KVDatime& date);
164  virtual void Update(const std::unique_ptr<DataBase>& db_handle = {});
166  {
171 #ifdef WITH_RSQLITE
172  auto RunDB = OpenAvailableRunsFile();
173 
174  return (RunDB->count("Available_Runs", "*", SelectRunAndOrIndex(run), true) > 0);
175 #else
176  return false;
177 #endif
178  }
179  Int_t Count(const run_index_t& run)
180  {
184 #ifdef WITH_RSQLITE
185  auto RunDB = OpenAvailableRunsFile();
186 
187  return RunDB->count("Available_Runs", "*", SelectRunAndOrIndex(run));
188 #else
189  return 0;
190 #endif
191  }
192  Bool_t GetRunInfo(const run_index_t& run, TDatime& modtime,
193  TString& filename);
194  void GetRunInfos(const run_index_t& run, KVList& dates, KVList& names);
195 #ifdef WITH_RSQLITE
196  using runfile_info_t = std::pair<KVDatime, TString>;
197  std::vector<runfile_info_t> GetRunInfos(const run_index_t& run);
198  std::map<run_index_t, std::vector<runfile_info_t>> GetRunFileInfos(const run_index_list& runlist);
199  void PrintRunFileInfos(const run_index_list& runlist);
200 #endif
202  {
205 
206  TString fname;
207  TDatime dtime;
208  GetRunInfo(run, dtime, fname);
209  return fname;
210  }
214  run_index_list GetRunList(const KVDBSystem* system = 0);
215 
216  virtual void Remove(const run_index_t& run, const KVString& filename = "");
217  void UpdateInfos(const run_index_t& run, const KVString& filename, const KVString& kvversion, const KVString& username);
218  Bool_t InfosNeedUpdate(const run_index_t& run, const KVString& filename);
219  virtual void Add(const run_index_t& run, const KVString& filename);
220  const KVDataSet* GetDataSet() const
221  {
223  return fDataSet;
224  }
225 
226  void SetDataSet(const KVDataSet* d)
227  {
229  fDataSet = d;
230  }
231 
232  std::forward_list<run_index_t> CheckMultiRunfiles();
233  void RemoveDuplicateLines(KVNumberList lines_to_be_removed);
234 
235  ClassDef(KVAvailableRunsFile, 1) //Handles text files containing list of available runs for different datasets and types of data
236 };
237 
238 #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.
KVList GetListOfAvailableRunFilesForSystem(const KVDBSystem *systol)
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)
void GetRunInfos(const run_index_t &run, KVList &dates, KVList &names)
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)
void PrintRunFileInfos(const run_index_list &runlist)
For all runfiles in the run_index_list, print list of all filenames & dates from the DB.
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={})
KVUniqueNameList GetSystemsForRunFiles(const run_index_list &rl) const
std::pair< KVDatime, TString > runfile_info_t
const KVDataSet * fDataSet
Bool_t CheckAvailable(const run_index_t &run)
KVAvailableRunsFile(const Char_t *type, const KVDataSet *parent)
std::map< run_index_t, std::vector< runfile_info_t > > GetRunFileInfos(const run_index_list &runlist)
For all runfiles in the run_index_list, fill the map with the dates & filenames from the DB.
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)
KVUnownedList GetListOfAvailableSystems()
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)
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:51
Base class for managing repositories of experimental data.
Manage an experimental dataset corresponding to a given experiment or campaign.
Definition: KVDataSet.h:146
ValType GetDataSetEnv(const Char_t *type, const ValType &defval) const
Definition: KVDataSet.h:269
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:22
Strings used to represent a set of ranges of values.
Definition: KVNumberList.h:85
Interface to ROOT SQLite database backend.
Definition: SQLiteDB.h:473
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
Definition: KVString.h:73
Optimised list in which named objects can only be placed once.
Extended TList class which does not own its objects by default.
Definition: KVUnownedList.h:20
const char * GetName() const override
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
List of runfiles specified by run number and file index ,.
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