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 
92 class KVAvailableRunsFile: public KVBase {
93 
95  const KVDataSet* fDataSet = nullptr;
96 private:
98  {
99  TString selection = Form("run = %d", run.run());
100  if (run.has_index()) selection += Form(" AND index = %d", run.index());
101  else selection += " AND index IS NULL";
102  return selection;
103  }
104  TString SelectFileName(const KVString& filename)
105  {
106  return "filename = '" + filename + "'";
107  }
109  const KVBase* objs,
110  DataBase* RunListTable,
111  const run_index_t& run_num,
112  KVDBRun* run, bool with_version_and_username = false);
114  const KVString& filename,
115  const KVDatime& modt,
116  DataBase* RunListTable,
117  const run_index_t& run_num,
118  KVDBRun* run, bool with_version_and_username = false);
119 
120 protected:
121  KVString GetFileName() const;
122  KVString GetFilePath() const;
125  virtual std::unique_ptr<DataBase> OpenAvailableRunsFile(bool called_by_update = false);
126  bool making_new_db = false;
127 
128  virtual bool get_file_modification_date(KVDataRepository* repository, const KVBase* objs, KVDatime& modt);
129 public:
130  KVAvailableRunsFile() = default;
132  {
135  }
136  KVAvailableRunsFile(const Char_t* type, const KVDataSet* parent): KVBase(type), fDataSet{parent}
137  {
139  }
140 
142  {
144  }
145 
146  const Char_t* GetDataType() const
147  {
148  return GetName();
149  }
150  std::optional<run_index_t> IsRunFileName(const Char_t* filename);
151  static std::optional<run_index_t> IsRunFileName(const KVString& fmt, const KVString& filename, const KVString& separators = ".");
153  {
158 
159  TString fmt = fDataSet->GetDataSetEnv(Form("DataSet.RunFileName.%s", GetDataType()));
160  return ExtractDateFromFileName(fmt, name, date);
161  }
162  static Bool_t ExtractDateFromFileName(const TString& fmt, const Char_t* name, KVDatime& date);
163  virtual void Update(const std::unique_ptr<DataBase>& db_handle = {});
165  {
170 #ifdef WITH_RSQLITE
171  auto RunDB = OpenAvailableRunsFile();
172 
173  return (RunDB->count("Available_Runs", "*", SelectRunAndOrIndex(run), true) > 0);
174 #else
175  return false;
176 #endif
177  }
178  Int_t Count(const run_index_t& run)
179  {
183 #ifdef WITH_RSQLITE
184  auto RunDB = OpenAvailableRunsFile();
185 
186  return RunDB->count("Available_Runs", "*", SelectRunAndOrIndex(run));
187 #else
188  return 0;
189 #endif
190  }
191  Bool_t GetRunInfo(const run_index_t& run, TDatime& modtime,
192  TString& filename);
193  void GetRunInfos(const run_index_t& run, KVList* dates, KVList* names);
195  {
198 
199  TString fname;
200  TDatime dtime;
201  GetRunInfo(run, dtime, fname);
202  return fname;
203  }
204  std::unique_ptr<TList> GetListOfAvailableSystems(const KVDBSystem* systol = 0);
205  run_index_list GetRunList(const KVDBSystem* system = 0);
206 
207  virtual void Remove(const run_index_t& run, const KVString& filename = "");
208  void UpdateInfos(const run_index_t& run, const KVString& filename, const KVString& kvversion, const KVString& username);
209  Bool_t InfosNeedUpdate(const run_index_t& run, const KVString& filename);
210  virtual void Add(const run_index_t& run, const KVString& filename);
211  const KVDataSet* GetDataSet() const
212  {
214  return fDataSet;
215  }
216 
217  void SetDataSet(const KVDataSet* d)
218  {
220  fDataSet = d;
221  }
222 
223  std::forward_list<run_index_t> CheckMultiRunfiles();
224  void RemoveDuplicateLines(KVNumberList lines_to_be_removed);
225 
226  ClassDef(KVAvailableRunsFile, 1) //Handles text files containing list of available runs for different datasets and types of data
227 };
228 
229 #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:146
ValType GetDataSetEnv(const Char_t *type, const ValType &defval) const
Definition: KVDataSet.h:268
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