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 #include "SQLiteDB.h"
30 #include "run_index.h"
31 
32 class KVDBSystem;
33 class TList;
34 
53 class KVAvailableRunsFile: public KVBase {
54 
56  const KVDataSet* fDataSet = nullptr;
57 private:
59  {
60  TString selection = Form("run = %d", run.run());
61  if (run.has_index()) selection += Form(" AND index = %d", run.index());
62  else selection += " AND index IS NULL";
63  return selection;
64  }
65  TString SelectFileName(const KVString& filename)
66  {
67  return "filename = '" + filename + "'";
68  }
70  const KVBase* objs,
71  KVSQLite::database* RunListTable,
72  const run_index_t& run_num,
73  KVDBRun* run, bool with_version_and_username = false);
75  const KVString& filename,
76  const KVDatime& modt,
77  KVSQLite::database* RunListTable,
78  const run_index_t& run_num,
79  KVDBRun* run, bool with_version_and_username = false);
80 
81 protected:
82  KVString GetFileName() const;
83  KVString GetFilePath() const;
86  virtual std::unique_ptr<KVSQLite::database> OpenAvailableRunsFile(bool called_by_update = false);
87  bool making_new_db = false;
88 
89  virtual bool get_file_modification_date(KVDataRepository* repository, const KVBase* objs, KVDatime& modt);
90 public:
91  KVAvailableRunsFile() = default;
93  {
96  }
97  KVAvailableRunsFile(const Char_t* type, const KVDataSet* parent): KVBase(type), fDataSet{parent}
98  {
100  }
101 
103  {
105  }
106 
107  const Char_t* GetDataType() const
108  {
109  return GetName();
110  }
111  std::optional<run_index_t> IsRunFileName(const Char_t* filename);
112  static std::optional<run_index_t> IsRunFileName(const KVString& fmt, const KVString& filename, const KVString& separators = ".");
114  {
119 
120  TString fmt = fDataSet->GetDataSetEnv(Form("DataSet.RunFileName.%s", GetDataType()));
121  return ExtractDateFromFileName(fmt, name, date);
122  }
123  static Bool_t ExtractDateFromFileName(const TString& fmt, const Char_t* name, KVDatime& date);
124  virtual void Update(const std::unique_ptr<KVSQLite::database>& db_handle = {});
126  {
131 
132  auto RunDB = OpenAvailableRunsFile();
133 
134  return (RunDB->count("Available_Runs", "*", SelectRunAndOrIndex(run), true) > 0);
135  }
136  Int_t Count(const run_index_t& run)
137  {
141 
142  auto RunDB = OpenAvailableRunsFile();
143 
144  return RunDB->count("Available_Runs", "*", SelectRunAndOrIndex(run));
145  }
146  Bool_t GetRunInfo(const run_index_t& run, TDatime& modtime,
147  TString& filename);
148  void GetRunInfos(const run_index_t& run, KVList* dates, KVList* names);
150  {
153 
154  TString fname;
155  TDatime dtime;
156  GetRunInfo(run, dtime, fname);
157  return fname;
158  }
159  std::unique_ptr<TList> GetListOfAvailableSystems(const KVDBSystem* systol = 0);
160  run_index_list GetRunList(const KVDBSystem* system = 0);
161 
162  virtual void Remove(const run_index_t& run, const KVString& filename = "");
163  void UpdateInfos(const run_index_t& run, const KVString& filename, const KVString& kvversion, const KVString& username);
164  Bool_t InfosNeedUpdate(const run_index_t& run, const KVString& filename);
165  virtual void Add(const run_index_t& run, const KVString& filename);
166  const KVDataSet* GetDataSet() const
167  {
169  return fDataSet;
170  }
171 
172  void SetDataSet(const KVDataSet* d)
173  {
175  fDataSet = d;
176  }
177 
178  std::forward_list<run_index_t> CheckMultiRunfiles();
179  void RemoveDuplicateLines(KVNumberList lines_to_be_removed);
180 
181  ClassDef(KVAvailableRunsFile, 1) //Handles text files containing list of available runs for different datasets and types of data
182 };
183 
184 #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()
Bool_t InfosNeedUpdate(const run_index_t &run, const KVString &filename)
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.
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)
virtual void Update(const std::unique_ptr< KVSQLite::database > &db_handle={})
KVString GetFileName() const
virtual std::unique_ptr< KVSQLite::database > OpenAvailableRunsFile(bool called_by_update=false)
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)
bool insert_runfile_into_database(KVDataRepository *repository, const KVBase *objs, KVSQLite::database *RunListTable, const run_index_t &run_num, KVDBRun *run, bool with_version_and_username=false)
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:40
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:36
KVString GetDataSetEnv(const Char_t *type, const Char_t *defval="") const
Definition: KVDataSet.cpp:784
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:33
int run() const
Definition: run_index.h:52
int index(int no_index=-1) const
Definition: run_index.h:57
bool has_index() const
Definition: run_index.h:61