10#include "KVDataRepository.h"
11#include "KVDataRepositoryManager.h"
12#include "KVDataSetManager.h"
16#include "KVDBSystem.h"
19#include "KVAvailableRunsFile.h"
20#include "KVNumberList.h"
110 fDBase.reset(
new TFile(full_path_to_dbfile,
"READ"));
136 static TString dbfile_fullpath;
148 return dbfile_fullpath.
Data();
167 if (envar !=
"") t->
SetTitle(envar);
218 Error(
"SaveDataBase",
"Cannot create directory %s required to save database",
225 Error(
"SaveDataBase",
"Cannot create directory %s required to save database, even though %s exists: check disk space ?",
231 Error(
"SaveDataBase",
"Cannot create directory %s required to save database",
263 Error(
"WriteDBFile",
"Database has not been built");
266 fDBase.reset(
new TFile(full_path_to_dbfile,
"recreate"));
303 if (_opt ==
"UPDATE") {
362 Info(
"OpenDataBase",
"Updating database file");
374 Info(
"OpenDataBase",
"No database defined for dataset");
387 Error(
"GetDataBase",
"Cannot load required plugin library");
408 cout <<
" [ AVAILABLE: ";
413 cout <<
" [UNAVAILABLE]";
434 cout <<
" *** No available analysis tasks ***"
441 cout <<
"\t" << i <<
". " << dat->
GetTitle() << endl;
503 if (data_types ==
"") {
504 Warning(
"CheckAvailable",
"No datatypes defined for this dataset: %s\nCheck value of KVDataSet.DataTypes or %s.KVDataSet.DataTypes",
510 data_types.
Begin(
" ");
511 while (!data_types.
End()) {
536 _type.
Remove(TString::kBoth,
' ');
560 TIter nxt(task_list);
640 Error(
"GetListOfAvailableSystems(const Char_t*)",
641 "No available runs file for type %s", datatype);
872 if (!strcmp(
type,
"raw") && !strcmp(
GetDataSetEnv(
"MFM.WithEbyedat",
""),
"yes")) {
874 ebydir +=
"/ebyedat";
875 gEnv->
SetValue(
"KVMFMDataFileReader.ActionsDirectory", ebydir);
876 if (strcmp(
GetDataSetEnv(
"MFM.EbyedatActionsExpName",
""),
""))
880 gEnv->
SetValue(
"KVMFMDataFileReader.ActionsDirectory",
"");
881 gEnv->
SetValue(
"KVMFMDataFileReader.ActionsExpName",
"");
932 Error(
"GetRunfileName",
933 "No data of type \"%s\" available for dataset %s",
type,
960 date.
Set(1995, 1, 1, 0, 0, 0);
963 Error(
"GetRunfileDate",
964 "No data of type \"%s\" available for dataset %s",
type,
971 Error(
"GetRunfileDate",
972 "Runfile not found for run %d (data type: %s)", run,
type);
992 Error(
"CheckRunfileAvailable",
993 "No data of type \"%s\" available for dataset %s",
type,
1051 Error(
"UpdateAvailableRuns",
1052 "No data of type \"%s\" available for dataset %s",
type,
1056 a->Update(!
a->FileExists());
1107 Error(
"DeleteRunfile",
"Run %d of type %s does not exist.", run,
type);
1113 if (doNotDelete ==
"all" || doNotDelete.
Contains(
type)) {
1114 Error(
"DeleteRunFile",
"%s files cannot be deleted",
type);
1173 if (!
min && !
max)
return 0;
1175 if (
min) printf(
"date minimum %s\n",
min->AsString());
1176 if (
max) printf(
"date maximum %s\n",
max->AsString());
1183 unique_ptr<TList> lrun;
1184 for (
Int_t nl = 0; nl < ll->GetEntries(); nl += 1) {
1188 for (
Int_t nr = 0; nr < lrun->GetEntries(); nr += 1) {
1197 if (*min < run->GetRun()->GetDatime()) {
1234 Info(
"GetRunList_StageSelection",
"No data available of type \"%s\"", ref_type);
1239 Info(
"GetRunList_StageSelection",
"No data available of type \"%s\" for system %s", ref_type, system->
GetName());
1244 Info(
"GetRunList_StageSelection",
"Liste des runs presents dans \"%s\" mais absent dans \"%s\"", ref_type,
type);
1253 if (system && sys != system)
continue;
1261 Info(
"GetRunList_StageSelection",
"\nKVDBSystem : %s --> %d runs manquants sur %d : %s",
1267 manquant.
Add(nsys_ref);
1288 TIter next(lrun.get());
1296 if (!ll.get() || !ll->GetEntries()) {
1298 Info(
"GetRunList_VersionSelection",
"No data available of type \"%s\"",
type);
1302 for (
Int_t nl = 0; nl < nsys; nl += 1) {
1305 TIter next(lrun.get());
1342 if (oldfile !=
"" && oldfile != newfile) {
1350 if (oldfile != newfile) {
1378 TIter next_name(toks.get());
1379 while ((group_name = (
TObjString*) next_name())) {
1431 cout <<
"OK. No runs appear more than once." << endl;
1434 cout <<
"Runs which appear more than once: " << doubles.
1435 AsString() << endl << endl;
1440 while (!doubles.
End()) {
1447 cout <<
"Run " << rr <<
" : " << dates.
1448 GetEntries() <<
" files >>>>>>" << endl;
1449 for (
int i = 0; i < dates.
GetEntries(); i++) {
1487 cout <<
"OK. No runs appear more than once." << endl;
1490 cout <<
"Runs which appear more than once: " << doubles.
1491 AsString() << endl << endl;
1496 while (!doubles.
End()) {
1503 TDatime most_recent(
"1998-12-25 00:00:00");
1504 Int_t i_most_recent = 0;
1505 cout <<
"Run " << rr <<
" : " << dates.
1506 GetEntries() <<
" files >>>>>>" << endl;
1507 for (
int i = 0; i < dates.
GetEntries(); i++) {
1511 if (rundate > most_recent) {
1513 most_recent = rundate;
1520 for (
int i = 0; i < dates.
GetEntries(); i++) {
1522 if (i == i_most_recent) {
1526 cout <<
"DELETE : ";
1531 if (i != i_most_recent) {
1535 String().Data(), confirm);
1568 Error(
"CheckRunfileUpToDate",
1569 "Dataset \"%s\" not found in repository \"%s\"",
GetName(),
1590 const Char_t* other_repos)
1602 Error(
"CheckRunfileUpToDate",
1603 "No data repository known with this name : %s", other_repos);
1615 const Char_t* other_repos)
1625 Error(
"CheckUpToDate",
1626 "No data repository known with this name : %s", other_repos);
1631 Int_t need_update = 0;
1632 while (!runlist.
End()) {
1636 cout <<
" *** run " << rr <<
" needs update ***" <<
1642 cout <<
"\t\tREPOSITORY: " << other_repos <<
"\tDATE: " << _or->
1643 GetDataSetManager()->GetDataSet(
GetName())->
1650 cout <<
" *** All runfiles are up to date for data type " <<
1663 const Char_t* other_repos)
1674 Error(
"CheckUpToDate",
1675 "No data repository known with this name : %s", other_repos);
1680 while (!runlist.
End()) {
1708 "No data of type %s available. Runlist will be empty.",
1817 if (!_task.
Contains(
"nalysis")) _task +=
" analysis";
1822 Error(
"MakeAnalysisClass",
1823 "called for unknown or unavailable analysis task : %s", _task.
Data());
1826 if (!dat->WithUserClass()) {
1827 Error(
"MakeAnalysisClass",
1828 "no user analysis class for analysis task : %s", dat->GetTitle());
1837 if (dat->CheckUserBaseClassIsLoaded()) cl = TClass::GetClass(dat->GetUserBaseClass());
1842 unique_ptr<TMethodCall> methcall(
new TMethodCall(cl,
"Make",
Form(
"\"%s\"", classname)));
1844 if (!methcall->IsValid()) {
1845 Error(
"MakeAnalysisClass",
"static Make(const Char_t*) method for class %s is not valid",
1851 methcall->Execute();
1885 abspath.
Form(
"%s/%s", datasetdir.
Data(), filename);
1920 ::Warning(
"KVDataSet::GetFullPathToDataSetFile",
"File %s not found in dataset subdirectory %s",
filename, datasetdir.
Data());
1980 Error(
"GetAnalysisTaskAny",
"No task found with the following keywords in its title : %s", keywords);
2006 Info(
"DataBaseNeedsUpdate",
"%s: Creating new dataset directory %s",
2010 Error(
"DataBaseNeedsUpdate",
2011 "%s: Dataset directory %s does not exist and cannot be created ?",
2020 of1 <<
"$(KV_WORK_DIR)/db/" <<
GetName() <<
"/DataBase.root : Runlist.csv Systems.dat" << endl;
2021 of1 <<
"\t@echo Database needs update" << endl;
2025 of2 <<
"# Automatically generated dummy Runlist.csv file" << endl;
2029 of3 <<
"# Automatically generated dummy Systems.dat file" << endl;
2096 while (!runs.
End()) {
2097 int run = runs.
Next();
2123 Error(
"CopyRunfilesToRepository",
"Unknown destination repository : %s", destrepo);
2124 gDataRepositoryManager->
Print();
2131 while (!runs.
End()) {
2132 int run = runs.
Next();
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 * Form(const char *fmt,...)
void AssignAndDelete(TString &target, char *tobedeleted)
R__EXTERN TSystem * gSystem
Handles lists of available runs for different datasets and types of data.
virtual void Add(Int_t run, const Char_t *filename)
KVNumberList CheckMultiRunfiles()
Returns a list with all runs which occur more than once in the available runs file.
virtual Bool_t CheckAvailable(Int_t run)
virtual KVNumberList GetRunList(const KVDBSystem *system=0)
const Char_t * GetFileName() const
virtual TList * GetListOfAvailableSystems(const KVDBSystem *systol=0)
virtual void Remove(Int_t run, const Char_t *filename="")
virtual void GetRunInfos(Int_t run, KVList *dates, KVList *names)
static const Char_t * GetDATADIRFilePath(const Char_t *namefile="")
static const Char_t * GetDATABASEFilePath()
static const Char_t * GetDataSetEnv(const Char_t *dataset, const Char_t *type, const Char_t *defval)
static Bool_t SearchKVFile(const Char_t *name, TString &fullpath, const Char_t *kvsubdir="")
static Bool_t SearchAndOpenKVFile(const Char_t *name, KVSQLite::database &dbfile, const Char_t *kvsubdir="")
static TPluginHandler * LoadPlugin(const Char_t *base, const Char_t *uri="0")
const TDatime & GetDatime() const
Database class used to store information on different colliding systems studied during an experiment....
Bool_t IsCollision() const
retourne kTRUE, si le systeme est une collision ie projectile+cible
Define and manage data analysis tasks.
virtual void SetDataAnalyser(const Char_t *d)
virtual void SetPrereq(const Char_t *p)
virtual void SetStatusUpdateInterval(Long64_t n)
virtual const Char_t * GetPrereq() const
void SetExtraAClicIncludes(const KVString &list)
virtual void SetUserBaseClass(const Char_t *d)
KVDataRepository * GetRepository(const Char_t *name) const
void Print(Option_t *opt="") const
Base class for managing repositories of experimental data.
virtual KVDataSetManager * GetDataSetManager() const
Return pointer to data set manager for this repository.
virtual TObject * OpenDataSetRunFile(const KVDataSet *ds, const Char_t *type, Int_t run, Option_t *opt="")
virtual void CopyFileFromRepository(const KVDataSet *dataset, const Char_t *datatype, const Char_t *filename, const Char_t *destination)
virtual Bool_t CheckFileStatus(const KVDataSet *dataset, const Char_t *datatype, const Char_t *runfile)
virtual Bool_t CheckSubdirExists(const Char_t *dir, const Char_t *subdir=0)
virtual KVAvailableRunsFile * NewAvailableRunsFile(const Char_t *, const KVDataSet *)
void CreateAllNeededSubdirectories(const KVDataSet *DataSet, const Char_t *DataType)
virtual void CommitFile(TFile *file, const Char_t *datatype, const KVDataSet *dataset)
virtual void DeleteFile(const KVDataSet *dataset, const Char_t *datatype, const Char_t *filename, Bool_t confirm=kTRUE)
virtual TFile * CreateNewFile(const KVDataSet *dataset, const Char_t *datatype, const Char_t *filename)
virtual const Char_t * GetFullPathToTransferFile(const KVDataSet *dataset, const Char_t *datatype, const Char_t *runfile)
virtual const Char_t * GetFullPathToOpenFile(const KVDataSet *dataset, const Char_t *datatype, const Char_t *runfile)
KVDataSet * GetDataSet(Int_t) const
Return pointer to DataSet using index in list of all datasets, index>=0.
Manage an experimental dataset corresponding to a given experiment or campaign.
TString fUserGroups
list of user groups allowed to read data
TString GetOutputRepository(const Char_t *taskname) const
virtual void OpenDBFile(const Char_t *full_path_to_dbfile) const
Open the database from a file on disk.
KVExpDB * fDataBase
pointer to dataset's database
KVNumberList GetRunList_VersionSelection(const Char_t *type, const Char_t *version, KVDBSystem *sys=0)
void CheckMultiRunfiles(const Char_t *data_type)
KVNumberList GetRunList_StageSelection(const Char_t *other_type, const Char_t *base_type, KVDBSystem *sys=0, Bool_t OnlyCol=kFALSE)
void CheckUpToDate(const Char_t *data_type, const Char_t *other_repos)
TString fDBName
name of database
const Char_t * GetDBName() const
KVDataRepository * GetRepository() const
Get pointer to data repository in which dataset is stored.
void CopyRunfilesToRepository(const Char_t *type, KVNumberList runs, const Char_t *destrepo)
const Char_t * GetDBFileName() const
const Char_t * GetDataSetDir() const
void DeleteRunfiles(const Char_t *type, KVNumberList lrun="", Bool_t confirm=kTRUE)
KVNumberList GetUpdatableRuns(const Char_t *data_type, const Char_t *other_repos)
Bool_t fDataBaseUpdateInProgress
virtual void ls(Option_t *opt="") const
Print dataset information.
void DeleteRunfile(const Char_t *type, Int_t run, Bool_t confirm=kTRUE)
KVAvailableRunsFile * GetAvailableRunsFile(const Char_t *type) const
virtual void AddAvailableDataType(const Char_t *)
virtual TList * GetListOfAvailableSystems(const Char_t *datatype, KVDBSystem *systol=0)
Bool_t CheckRunfileUpToDate(const Char_t *data_type, Int_t run, KVDataRepository *other_repos)
void SetName(const char *name)
KVDataAnalysisTask * GetAnalysisTask(Int_t) const
virtual const Char_t * GetBaseFileName(const Char_t *type, Int_t run) const
virtual const Char_t * GetDataPathSubdir() const
Returns name of top-level directory in data repository used to store data files for this dataset.
virtual void SaveDataBase() const
virtual KVDataAnalysisTask * GetAnalysisTaskAny(const Char_t *keywords) const
KVList fAvailableRuns
list of KVAvailableRunsFile objects used to read infos on available runs
virtual void SetAnalysisTasks(const KVSeqCollection *)
KVNumberList GetRunList_DateSelection(const Char_t *type, TDatime *min=0, TDatime *max=0)
virtual void CheckAvailable()
const Char_t * GetRunfileName(const Char_t *type, Int_t run) const
TDatime GetRunfileDate(const Char_t *type, Int_t run)
const Char_t * GetDataSetEnv(const Char_t *type, const Char_t *defval="") const
virtual Bool_t HasDataType(const Char_t *data_type) const
virtual Int_t GetNtasks() const
std::unique_ptr< TFile > fDBase
file containing database
KVNumberList GetRunList(const Char_t *data_type, const KVDBSystem *sys=0) const
TString GetFullPathToDataSetFile(const Char_t *filename)
TString GetFullPathToRunfile(const Char_t *type, Int_t run) const
TString fDBFileName
name of file in which database is stored on disk
void CopyRunfilesFromRepository(const Char_t *type, KVNumberList runs, const Char_t *destdir)
void UpdateAvailableRuns(const Char_t *type)
virtual Bool_t IsAvailable() const
Returns kTRUE if this dataset is available for analysis, i.e. if any associated data files are stored...
virtual void MakeAnalysisClass(const Char_t *task, const Char_t *classname)
TObject * open_runfile(const Char_t *type, Int_t run)
void CommitRunfile(const Char_t *type, Int_t run, TFile *file)
KVExpDB * GetDataBase(Option_t *opt="") const
virtual Bool_t DataBaseNeedsUpdate() const
Bool_t OpenDataSetFile(const Char_t *filename, std::ifstream &file)
void SetDataSetSpecificTaskParameters(KVDataAnalysisTask *) const
TString fDatatypes
list of types of data which are available for this dataset
virtual void SetAvailable(Bool_t yes=kTRUE)
virtual void WriteDBFile(const Char_t *full_path_to_dbfile) const
const Char_t * GetDataTypeSubdir(const Char_t *type) const
const Char_t * GetFullPathToDB() const
Returns full path to file where database is written on disk.
TFile * NewRunfile(const Char_t *type, Int_t run)
virtual Bool_t CheckUserCanAccess()
KVDataRepository * fRepository
repository in which dataset is stored
void SetRepository(KVDataRepository *)
Set pointer to data repository in which dataset is stored.
KVUniqueNameList fAllTasks
all data analysis tasks for this dataset
KVDataSet()
Default constructor.
void SetDBName(const Char_t *name)
void CleanMultiRunfiles(const Char_t *data_type, Bool_t confirm=kTRUE)
virtual void OpenDataBase(Option_t *opt="") const
TString fCalibDir
directory containing database, calibration, identification parameters etc. for dataset
virtual void Print(Option_t *opt="") const
static Bool_t FindDataSetFile(const TString &dataset, const Char_t *filename)
Bool_t CheckRunfileAvailable(const Char_t *type, Int_t run)
KVUniqueNameList fTasks
possible data analysis tasks for this dataset (available data only)
Extension of TDatime to handle various useful date formats.
Base class to describe database of an experiment ,,.
virtual void WriteObjects(TFile *)
virtual void ReadObjects(TFile *)
static KVExpDB * MakeDataBase(const Char_t *name, const Char_t *datasetdir)
Extended TList class which owns its objects by default.
Strings used to represent a set of ranges of values.
const Char_t * AsString(Int_t maxchars=0) const
void Remove(Int_t)
Remove value 'n' from the list.
void Add(Int_t)
Add value 'n' to the list.
Description of an individual run file in an experimental dataset.
Int_t GetRunNumber() const
const KVDBRun * GetRun() const
const Char_t * GetVersion() const
KaliVeda extensions to ROOT collection classes.
virtual void SetOwner(Bool_t enable=kTRUE)
virtual void Clear(Option_t *option="")
virtual Int_t GetSize() const
virtual TObject * FindObjectAny(const Char_t *att, const Char_t *keys, Bool_t contains_all=kFALSE, Bool_t case_sensitive=kTRUE) const
virtual TObject * FindObjectByName(const Char_t *name) const
virtual TObject * At(Int_t idx) const
virtual void Add(TObject *obj)
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
void Begin(TString delim) const
KVString Next(Bool_t strip_whitespace=kFALSE) const
virtual void Add(TObject *obj)
virtual Int_t GetEntries() const
const char * AsSQLString() const
const char * AsString() const
virtual const char * GetValue(const char *name, const char *dflt) const
virtual void SetValue(const char *name, const char *value, EEnvLevel level=kEnvChange, const char *type=nullptr)
Bool_t Defined(const char *name) const
TObject * FindObject(const char *name) const override
TObject * At(Int_t idx) const override
virtual void SetTitle(const char *title="")
const char * GetName() const override
const char * GetTitle() const override
virtual void SetName(const char *name)
virtual void Warning(const char *method, const char *msgfmt,...) const
virtual Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0)
virtual void Error(const char *method, const char *msgfmt,...) const
virtual void Info(const char *method, const char *msgfmt,...) const
const char * Data() const
TObjArray * Tokenize(const TString &delim) const
void Form(const char *fmt,...)
TString & Remove(EStripType s, char c)
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
TString & ReplaceAll(const char *s1, const char *s2)
Bool_t cd(const char *path)
virtual int Chmod(const char *file, UInt_t mode)
virtual const char * DirName(const char *pathname)
virtual char * ConcatFileName(const char *dir, const char *name)
virtual int mkdir(const char *name, Bool_t recursive=kFALSE)
virtual Int_t Exec(const char *shellcmd)
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
virtual const char * BaseName(const char *pathname)
virtual Bool_t IsAbsoluteFileName(const char *dir)
double min(double x, double y)
double max(double x, double y)