KaliVeda
Toolkit for HIC analysis
KVDataSet.h
1 /*
2 $Id: KVDataSet.h,v 1.26 2009/01/27 08:06:56 franklan Exp $
3 $Revision: 1.26 $
4 $Date: 2009/01/27 08:06:56 $
5 $Author: franklan $
6 */
7 
8 #ifndef __KVDATASET_H
9 #define __KVDATASET_H
10 
11 #include "KVString.h"
12 #include "KVBase.h"
13 #include "KVUniqueNameList.h"
14 #include "KVNumberList.h"
15 #include "TDatime.h"
16 #include "TFile.h"
17 #include "KVDataAnalysisTask.h"
18 #include "KVExpDB.h"
19 
20 class KVDataSetManager;
21 class KVDataRepository;
22 class KVDBSystem;
23 class TObjArray;
24 class KVDBRun;
26 
35 class KVDataSet: public KVBase {
36 
37  friend class KVAvailableRunsFile;
38  friend class KVDataSetManager;
39 
40 protected:
47  mutable std::unique_ptr<TFile> fDBase;
50  mutable KVExpDB* fDataBase;
52  enum {
53  kAvailable = BIT(14) //flag set if this dataset is physically present on local machine
54  };
56 
57  virtual const Char_t* GetBaseFileName(const Char_t* type, Int_t run) const;
58 
59  virtual void OpenDataBase(Option_t* opt = "") const;
60  virtual void OpenDBFile(const Char_t* full_path_to_dbfile) const;
61  virtual void WriteDBFile(const Char_t* full_path_to_dbfile) const;
62  void SetDBFileName(const Char_t* name)
63  {
64  fDBFileName = name;
65  }
66  const Char_t* GetDBFileName() const;
67  void SetDBName(const Char_t* name)
68  {
69  fDBName = name;
70  }
71  const Char_t* GetDBName() const;
72  const Char_t* GetFullPathToDB() const;
74  TObject* open_runfile(const Char_t* type, Int_t run);
75 
77 public:
79  {
81  }
82 
84 
85  KVDataSet();
86  virtual ~ KVDataSet() {}
87 
88  virtual Bool_t CheckUserCanAccess();
89 
90  virtual void SetDataPathSubdir(const Char_t* s)
91  {
92  SetLabel(s);
93  }
95  virtual const Char_t* GetDataPathSubdir() const
96  {
97  return GetLabel();
98  }
99  const Char_t* GetDataTypeSubdir(const Char_t* type) const
100  {
102  KVString snom;
103  snom.Form("KVDataSet.DataType.Subdir.%s", type);
104  return GetDataSetEnv(snom.Data(), type);
105  }
106  virtual const Char_t* GetAvailableDataTypes() const
107  {
108  return fDatatypes.Data();
109  }
110  virtual void AddAvailableDataType(const Char_t*);
111  virtual void SetUserGroups(const Char_t* groups)
112  {
113  fUserGroups = groups;
114  }
116  virtual Bool_t IsAvailable() const
117  {
118  return TestBit(kAvailable);
119  }
120  virtual void SetAvailable(Bool_t yes = kTRUE)
121  {
122  SetBit(kAvailable, yes);
123  }
124  virtual void CheckAvailable();
125 
126  virtual Bool_t HasDataType(const Char_t* data_type) const
127  {
130 
131  KVString _dt = data_type;
132  _dt.Remove(TString::kBoth, ' ');
133  return (_dt == "*" || fDatatypes.Contains(_dt));
134  }
135 
136  virtual void ls(Option_t* opt = "") const;
137  virtual void Print(Option_t* opt = "") const;
138 
139  virtual void SetAnalysisTasks(const KVSeqCollection*);
141  KVDataAnalysisTask* GetAnalysisTask(const Char_t* keywords) const;
142  virtual KVDataAnalysisTask* GetAnalysisTaskAny(const Char_t* keywords) const;
143  virtual Int_t GetNtasks() const;
144 
145  virtual TList* GetListOfAvailableSystems(const Char_t* datatype,
146  KVDBSystem* systol = 0);
148  KVDBSystem* systol = 0);
149 
150  void cd() const;
151 
152  const Char_t* GetDataSetDir() const;
153  void SetName(const char* name);
154 
155 
156  KVExpDB* GetDataBase(Option_t* opt = "") const;
157  virtual void SaveDataBase() const;
158 
159  const Char_t* GetDataSetEnv(const Char_t* type, const Char_t* defval = "") const;
160  Double_t GetDataSetEnv(const Char_t* type, Double_t defval) const;
161  Bool_t GetDataSetEnv(const Char_t* type, Bool_t defval) const;
162 
163  TString GetFullPathToRunfile(const Char_t* type, Int_t run) const;
164  const Char_t* GetRunfileName(const Char_t* type, Int_t run) const;
165  TDatime GetRunfileDate(const Char_t* type, Int_t run);
166  template <typename FileType>
167  FileType* OpenRunfile(const Char_t* type, Int_t run)
168  {
169  return dynamic_cast<FileType*>(open_runfile(type, run));
170  }
171  TObject* OpenRunfile(const Char_t* type, Int_t run)
172  {
173  return open_runfile(type, run);
174  }
175 
176  Bool_t CheckRunfileAvailable(const Char_t* type, Int_t run);
177  void UpdateAvailableRuns(const Char_t* type);
178  TFile* NewRunfile(const Char_t* type, Int_t run);
179  void CommitRunfile(const Char_t* type, Int_t run, TFile* file);
180 
181  void CopyRunfilesFromRepository(const Char_t* type, KVNumberList runs, const Char_t* destdir);
182 
183  void DeleteRunfile(const Char_t* type, Int_t run, Bool_t confirm = kTRUE);
184  void DeleteRunfiles(const Char_t* type, KVNumberList lrun = "", Bool_t confirm = kTRUE);
185  KVNumberList GetRunList_DateSelection(const Char_t* type, TDatime* min = 0, TDatime* max = 0);
186  KVNumberList GetRunList_StageSelection(const Char_t* other_type, const Char_t* base_type, KVDBSystem* sys = 0, Bool_t OnlyCol = kFALSE);
187  KVNumberList GetRunList_VersionSelection(const Char_t* type, const Char_t* version, KVDBSystem* sys = 0);
190 
191  void CheckMultiRunfiles(const Char_t* data_type);
192  void CleanMultiRunfiles(const Char_t* data_type, Bool_t confirm = kTRUE);
193 
194  Bool_t CheckRunfileUpToDate(const Char_t* data_type, Int_t run,
195  KVDataRepository* other_repos);
196  Bool_t CheckRunfileUpToDate(const Char_t* data_type, Int_t run,
197  const Char_t* other_repos);
198  void CheckUpToDate(const Char_t* data_type,
199  const Char_t* other_repos);
200  KVNumberList GetUpdatableRuns(const Char_t* data_type,
201  const Char_t* other_repos);
202 
203  KVNumberList GetRunList(const Char_t* data_type,
204  const KVDBSystem* sys = 0) const;
205 
206  virtual void MakeAnalysisClass(const Char_t* task, const Char_t* classname);
207 
208  Bool_t OpenDataSetFile(const Char_t* filename, std::ifstream& file);
209  static Bool_t OpenDataSetFile(const TString& dataset, const Char_t* filename, std::ifstream& file);
210  TString GetFullPathToDataSetFile(const Char_t* filename);
211  static TString GetFullPathToDataSetFile(const TString& dataset, const Char_t* filename);
212  static Bool_t FindDataSetFile(const TString& dataset, const Char_t* filename);
213  Bool_t FindDataSetFile(const Char_t* filename);
214 
215  virtual Bool_t DataBaseNeedsUpdate() const;
216 
217  virtual const Char_t* GetReconstructedEventClassName() const
218  {
225 
226  return GetDataSetEnv("ReconstructedEventClassName", "KVReconstructedEvent");
227  }
228 
229  TString GetOutputRepository(const Char_t* taskname) const;
230  void CopyRunfilesToRepository(const Char_t* type, KVNumberList runs, const Char_t* destrepo);
231 
233  {
238  return GetDataSetEnv("HasCalibIdentInfos", kTRUE);
239  }
240 
241  ClassDef(KVDataSet, 3) //Describes a set of experimental data which may be analysed with KaliVeda
242 };
243 
245 R__EXTERN KVDataSet* gDataSet;
246 
247 #endif
int Int_t
#define R__EXTERN
bool Bool_t
char Char_t
double Double_t
constexpr Bool_t kTRUE
const char Option_t
#define ClassDef(name, id)
#define BIT(n)
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]
Handles lists of available runs for different datasets and types of data.
Base class for KaliVeda framework.
Definition: KVBase.h:142
void SetLabel(const Char_t *lab)
Definition: KVBase.h:195
const Char_t * GetLabel() const
Definition: KVBase.h:199
Description of an experimental run in database ,,.
Definition: KVDBRun.h:36
Database class used to store information on different colliding systems studied during an experiment....
Definition: KVDBSystem.h:52
Define and manage data analysis tasks.
Base class for managing repositories of experimental data.
Manage all datasets contained in a given data repository.
Manage an experimental dataset corresponding to a given experiment or campaign.
Definition: KVDataSet.h:35
virtual ~ KVDataSet()
Definition: KVDataSet.h:86
virtual void SetUserGroups(const Char_t *groups)
Definition: KVDataSet.h:111
TString fUserGroups
list of user groups allowed to read data
Definition: KVDataSet.h:55
TString GetOutputRepository(const Char_t *taskname) const
Definition: KVDataSet.cpp:2058
virtual void OpenDBFile(const Char_t *full_path_to_dbfile) const
Open the database from a file on disk.
Definition: KVDataSet.cpp:105
KVExpDB * fDataBase
pointer to dataset's database
Definition: KVDataSet.h:50
KVNumberList GetRunList_VersionSelection(const Char_t *type, const Char_t *version, KVDBSystem *sys=0)
Definition: KVDataSet.cpp:1280
void CheckMultiRunfiles(const Char_t *data_type)
Definition: KVDataSet.cpp:1422
KVNumberList GetRunList_StageSelection(const Char_t *other_type, const Char_t *base_type, KVDBSystem *sys=0, Bool_t OnlyCol=kFALSE)
Definition: KVDataSet.cpp:1223
void CheckUpToDate(const Char_t *data_type, const Char_t *other_repos)
Definition: KVDataSet.cpp:1614
TString fDBName
name of database
Definition: KVDataSet.h:48
virtual void SetDataPathSubdir(const Char_t *s)
Definition: KVDataSet.h:90
void SetDBFileName(const Char_t *name)
Definition: KVDataSet.h:62
virtual const Char_t * GetAvailableDataTypes() const
Definition: KVDataSet.h:106
const Char_t * GetDBName() const
Definition: KVDataSet.cpp:89
KVDataRepository * GetRepository() const
Get pointer to data repository in which dataset is stored.
Definition: KVDataSet.cpp:1408
void CopyRunfilesToRepository(const Char_t *type, KVNumberList runs, const Char_t *destrepo)
Definition: KVDataSet.cpp:2113
@ kAvailable
Definition: KVDataSet.h:53
const Char_t * GetDBFileName() const
Definition: KVDataSet.cpp:72
const Char_t * GetDataSetDir() const
Definition: KVDataSet.cpp:729
void DeleteRunfiles(const Char_t *type, KVNumberList lrun="", Bool_t confirm=kTRUE)
Definition: KVDataSet.cpp:1136
KVNumberList GetUpdatableRuns(const Char_t *data_type, const Char_t *other_repos)
Definition: KVDataSet.cpp:1662
Bool_t fDataBaseUpdateInProgress
Definition: KVDataSet.h:76
virtual void ls(Option_t *opt="") const
Print dataset information.
Definition: KVDataSet.cpp:403
void DeleteRunfile(const Char_t *type, Int_t run, Bool_t confirm=kTRUE)
Definition: KVDataSet.cpp:1092
KVAvailableRunsFile * GetAvailableRunsFile(const Char_t *type) const
Definition: KVDataSet.cpp:50
virtual void AddAvailableDataType(const Char_t *)
Definition: KVDataSet.cpp:532
virtual TList * GetListOfAvailableSystems(const Char_t *datatype, KVDBSystem *systol=0)
Definition: KVDataSet.cpp:623
Bool_t CheckRunfileUpToDate(const Char_t *data_type, Int_t run, KVDataRepository *other_repos)
Definition: KVDataSet.cpp:1555
FileType * OpenRunfile(const Char_t *type, Int_t run)
Definition: KVDataSet.h:167
void SetName(const char *name)
Definition: KVDataSet.cpp:697
KVDataAnalysisTask * GetAnalysisTask(Int_t) const
Definition: KVDataSet.cpp:598
virtual const Char_t * GetBaseFileName(const Char_t *type, Int_t run) const
Definition: KVDataSet.cpp:1013
virtual void SaveDataBase() const
Definition: KVDataSet.cpp:194
virtual KVDataAnalysisTask * GetAnalysisTaskAny(const Char_t *keywords) const
Definition: KVDataSet.cpp:1968
KVList fAvailableRuns
list of KVAvailableRunsFile objects used to read infos on available runs
Definition: KVDataSet.h:51
virtual void SetAnalysisTasks(const KVSeqCollection *)
Definition: KVDataSet.cpp:549
KVNumberList GetRunList_DateSelection(const Char_t *type, TDatime *min=0, TDatime *max=0)
Definition: KVDataSet.cpp:1165
Bool_t HasCalibIdentInfos() const
Definition: KVDataSet.h:232
virtual void CheckAvailable()
Definition: KVDataSet.cpp:475
const Char_t * GetRunfileName(const Char_t *type, Int_t run) const
Definition: KVDataSet.cpp:923
TDatime GetRunfileDate(const Char_t *type, Int_t run)
Definition: KVDataSet.cpp:951
const Char_t * GetDataSetEnv(const Char_t *type, const Char_t *defval="") const
Definition: KVDataSet.cpp:767
virtual const Char_t * GetDataPathSubdir() const
Returns name of top-level directory in data repository used to store data files for this dataset.
Definition: KVDataSet.h:95
virtual Bool_t HasDataType(const Char_t *data_type) const
Definition: KVDataSet.h:126
virtual Int_t GetNtasks() const
Definition: KVDataSet.cpp:583
std::unique_ptr< TFile > fDBase
file containing database
Definition: KVDataSet.h:47
KVNumberList GetRunList(const Char_t *data_type, const KVDBSystem *sys=0) const
Definition: KVDataSet.cpp:1699
TString GetFullPathToDataSetFile(const Char_t *filename)
Definition: KVDataSet.cpp:1898
TString GetFullPathToRunfile(const Char_t *type, Int_t run) const
Definition: KVDataSet.cpp:897
TString fDBFileName
name of file in which database is stored on disk
Definition: KVDataSet.h:49
void CopyRunfilesFromRepository(const Char_t *type, KVNumberList runs, const Char_t *destdir)
Definition: KVDataSet.cpp:2089
void UpdateAvailableRuns(const Char_t *type)
Definition: KVDataSet.cpp:1045
virtual Bool_t IsAvailable() const
Returns kTRUE if this dataset is available for analysis, i.e. if any associated data files are stored...
Definition: KVDataSet.h:116
virtual void MakeAnalysisClass(const Char_t *task, const Char_t *classname)
Definition: KVDataSet.cpp:1802
TObject * open_runfile(const Char_t *type, Int_t run)
Definition: KVDataSet.cpp:842
void CommitRunfile(const Char_t *type, Int_t run, TFile *file)
Definition: KVDataSet.cpp:1321
KVExpDB * GetDataBase(Option_t *opt="") const
Definition: KVDataSet.cpp:289
virtual Bool_t DataBaseNeedsUpdate() const
Definition: KVDataSet.cpp:1994
Bool_t OpenDataSetFile(const Char_t *filename, std::ifstream &file)
void SetDataSetSpecificTaskParameters(KVDataAnalysisTask *) const
Definition: KVDataSet.cpp:159
TString fDatatypes
list of types of data which are available for this dataset
Definition: KVDataSet.h:42
virtual void SetAvailable(Bool_t yes=kTRUE)
Definition: KVDataSet.h:120
void cd() const
Definition: KVDataSet.cpp:745
virtual void WriteDBFile(const Char_t *full_path_to_dbfile) const
Definition: KVDataSet.cpp:255
const Char_t * GetFullPathToDB() const
Returns full path to file where database is written on disk.
Definition: KVDataSet.cpp:131
TFile * NewRunfile(const Char_t *type, Int_t run)
Definition: KVDataSet.cpp:1067
virtual Bool_t CheckUserCanAccess()
Definition: KVDataSet.cpp:1365
Bool_t fDBBuild
has the database been built by us ?
Definition: KVDataSet.h:46
KVDataRepository * fRepository
repository in which dataset is stored
Definition: KVDataSet.h:41
const Char_t * GetDataTypeSubdir(const Char_t *type) const
Definition: KVDataSet.h:99
void SetRepository(KVDataRepository *)
Set pointer to data repository in which dataset is stored.
Definition: KVDataSet.cpp:1396
Bool_t DataBaseUpdateInProgress() const
Definition: KVDataSet.h:78
virtual const Char_t * GetReconstructedEventClassName() const
Definition: KVDataSet.h:217
KVUniqueNameList fAllTasks
all data analysis tasks for this dataset
Definition: KVDataSet.h:43
KVDataSet()
Default constructor.
Definition: KVDataSet.cpp:35
TObject * OpenRunfile(const Char_t *type, Int_t run)
Definition: KVDataSet.h:171
void SetDBName(const Char_t *name)
Definition: KVDataSet.h:67
void CleanMultiRunfiles(const Char_t *data_type, Bool_t confirm=kTRUE)
Definition: KVDataSet.cpp:1472
virtual void OpenDataBase(Option_t *opt="") const
Definition: KVDataSet.cpp:335
static Bool_t OpenDataSetFile(const TString &dataset, const Char_t *filename, std::ifstream &file)
TString fCalibDir
directory containing database, calibration, identification parameters etc. for dataset
Definition: KVDataSet.h:45
virtual void Print(Option_t *opt="") const
Definition: KVDataSet.cpp:424
static Bool_t FindDataSetFile(const TString &dataset, const Char_t *filename)
Definition: KVDataSet.cpp:1932
Bool_t CheckRunfileAvailable(const Char_t *type, Int_t run)
Definition: KVDataSet.cpp:985
KVUniqueNameList fTasks
possible data analysis tasks for this dataset (available data only)
Definition: KVDataSet.h:44
Base class to describe database of an experiment ,,.
Definition: KVExpDB.h:20
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
KaliVeda extensions to ROOT collection classes.
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.
void SetBit(UInt_t f)
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
const char * Data() const
void Form(const char *fmt,...)
TString & Remove(EStripType s, char c)
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const