KaliVeda
Toolkit for HIC analysis
KVDataSet.cpp
1 /*
2 $Id: KVDataSet.cpp,v 1.41 2009/03/11 14:22:41 franklan Exp $
3 $Revision: 1.41 $
4 $Date: 2009/03/11 14:22:41 $
5 $Author: franklan $
6 */
7 
8 #include "TMethodCall.h"
9 #include "KVDataSet.h"
10 #include "KVDataRepository.h"
11 #include "KVDataRepositoryManager.h"
12 #include "KVDataSetManager.h"
13 #include "TSystem.h"
14 #include "TObjArray.h"
15 #include "TObjString.h"
16 #include "KVDBSystem.h"
17 #include "KVDBRun.h"
18 #include "TEnv.h"
19 #include "KVAvailableRunsFile.h"
20 #include "KVNumberList.h"
21 #include "TPluginManager.h"
22 #include "TClass.h"
23 #include "KVRunFile.h"
24 
25 using namespace std;
26 
28 
29 KVDataSet* gDataSet;
30 
31 
34 
36 {
37  //Default constructor
38  fRepository = nullptr;
39  fDataBase = nullptr;
40  fAllTasks.SetOwner(kTRUE);
41  fTasks.SetOwner(kFALSE);
42 }
43 
44 
45 
50 
52 {
53  // \param type name of data type ('raw', 'recon', ...)
54  // \returns pointer to available runs file object for given data type
55  // \note if no data repository is associated with dataset, returns nullptr
56  if (!fRepository) return nullptr;
57  KVAvailableRunsFile* avrf =
58  (KVAvailableRunsFile*) fAvailableRuns.FindObjectByName(type);
59  if (!avrf) {
60  avrf = fRepository->NewAvailableRunsFile(type, this);
61  fAvailableRuns.Add(avrf);
62  }
63  return avrf;
64 }
65 
66 
67 
83 
85 {
86  //Returns name of file containing database for dataset.
87  //
88  //This is fixed as `DataBase.root.M.m.p` where
89  // - `M` is the current major version number
90  // - `m` is the current minor version number
91  // - `p` is the current patch number
92  //
93  //(fixed to be consistent with CMake function INSTALL_KALIVEDA_DATASETS which sets up
94  //the Makefile for each dataset which automatically triggers rebuilding of the ROOT file
95  //when source files change: thus we must have the right file name!)
96  //
97  //This in order to avoid problems if several different versions of KaliVeda
98  //use the same working directory (in user's `$HOME/.kaliveda`) to write the
99  //database files, which are often incompatible between versions
100 
101  TString n = "DataBase.root";
102  n.Append(Form(".%d.%d.%d", GetKVMajorVersion(),
103  GetKVMinorVersion(), GetKVPatchVersion()));
104  return n;
105 }
106 
107 
108 
113 
115 {
116  //\returns name of database object in database file.
117  //
118  //If this is not set explicitly with SetDBName(), we use the name of the dataset by default
119 
120  return (fDBName != "" ? fDBName.Data() : GetName());
121 }
122 
123 
124 
125 
128 
129 void KVDataSet::OpenDBFile(const Char_t* full_path_to_dbfile) const
130 {
131  //Open the database from a file on disk.
132 
133  TDirectory* work_dir = gDirectory; //keep pointer to current directory
134  fDBase.reset(new TFile(full_path_to_dbfile, "READ"));
135 
136  if (fDBase->IsOpen()) {
137  fDataBase = dynamic_cast<KVExpDB*>(fDBase->Get(GetDBName()));
138  if (!fDataBase) {
139  Error("OpenDBFile", "%s not found in file %s", GetDBName().Data(),
140  GetDBFileName().Data());
141  }
142  else {
143  fDataBase->ReadObjects(fDBase.get()); // read any associated objects
144  }
145  work_dir->cd(); //back to initial working directory
146  }
147 }
148 
149 
150 
151 
154 
156 {
157  // \returns full path to file where database is written on disk
158 
159  TString dbfile = GetDBFileName();
160  TString dbfile_fullpath;
161  TString tmp;
162 
163  // If this dataset is just an alias for another dataset i.e. if DataSet.Directory
164  // is set with just the name of another dataset (not a full path to dataset files)
165  // then the database file should be written/found under the name of the alias.
166  TString dataset_alias = GetDataSetEnv("DataSet.Directory", GetName());
167  TString db_alias = GetName();
168  if (!gSystem->IsAbsoluteFileName(dataset_alias)) db_alias = dataset_alias;
169 
170  AssignAndDelete(tmp, gSystem->ConcatFileName(GetDATABASEFilePath(), db_alias.Data()));
171  AssignAndDelete(dbfile_fullpath, gSystem->ConcatFileName(tmp.Data(), dbfile.Data()));
172  return dbfile_fullpath;
173 }
174 
175 
176 
179 
181 {
182  //Check configuration variables to see if the task parameters have been "tweaked" for the dataset.
183 
184  auto envar = GetDataSetEnv<KVString>(Form("%s.DataAnalysisTask.Title", t->GetName()));
185  if (envar != "") t->SetTitle(envar);
186  envar = GetDataSetEnv<KVString>(Form("%s.DataAnalysisTask.Analyser", t->GetName()));
187  if (envar != "") t->SetDataAnalyser(envar);
188  envar = GetDataSetEnv<KVString>(Form("%s.DataAnalysisTask.UserClass.Base", t->GetName()));
189  if (envar != "") t->SetUserBaseClass(envar);
190  envar = GetDataSetEnv<KVString>(Form("%s.DataAnalysisTask.Prereq", t->GetName()));
191  if (envar != "") t->SetPrereq(envar);
192  envar = GetDataSetEnv<KVString>(Form("%s.DataAnalysisTask.UserClass.ExtraACliCIncludes", t->GetName()));
193  if (envar != "") t->SetExtraAClicIncludes(envar);
194  auto nev = GetDataSetEnv<int>(Form("%s.DataAnalysisTask.StatusUpdateInterval", t->GetName()));
195  if (nev > 0) t->SetStatusUpdateInterval(nev);
196 }
197 
198 
199 
200 
204 
206 {
207  // Write the experiment database for this dataset to disk (ROOT file), creating and setting
208  // permissions for any required directories
209 
210  TString dbfile_fullpath = GetFullPathToDB();
211  TString tmp = gSystem->DirName(dbfile_fullpath.Data()); //full path to directory $KVROOT/db/[dataset name]
212 
213  if (gSystem->AccessPathName(tmp.Data())) { // directory $KVROOT/db/[dataset name] does not exist
214 
215  if (gSystem->mkdir(tmp.Data()) == -1) { // problem creating $KVROOT/db/[dataset name]
216 
217  TString tmp2 = gSystem->DirName(tmp.Data());// full path to directory $KVROOT/db
218 
219  if (gSystem->AccessPathName(tmp2.Data())) { // directory $KVROOT/db does not exist
220 
221  if (gSystem->mkdir(tmp2.Data()) == -1) { // problem creating $KVROOT/db
222  Error("SaveDataBase", "Cannot create directory %s required to save database",
223  tmp2.Data());
224  return;
225  }
226  gSystem->Chmod(tmp2.Data(), 0775);
227  }
228  else {
229  Error("SaveDataBase", "Cannot create directory %s required to save database, even though %s exists: check disk space ?",
230  tmp.Data(), tmp2.Data());
231  return;
232  }
233  //try again
234  if (gSystem->mkdir(tmp.Data()) == -1) {
235  Error("SaveDataBase", "Cannot create directory %s required to save database",
236  tmp.Data());
237  return;
238  }
239  else {
240  gSystem->Chmod(tmp.Data(), 0775);
241  }
242  }
243  else {
244  gSystem->Chmod(tmp.Data(), 0775);
245  }
246  }
247 
248  WriteDBFile(dbfile_fullpath.Data());
249 }
250 
251 
252 
253 
256 
257 void KVDataSet::WriteDBFile(const Char_t* full_path_to_dbfile) const
258 {
259  //Write the database to disk.
260 
261  TDirectory* work_dir = gDirectory; //keep pointer to current directory
262  if (!fDataBase) {
263  Error("WriteDBFile", "Database has not been built");
264  return;
265  }
266  fDBase.reset(new TFile(full_path_to_dbfile, "recreate"));
267  fDBase->cd(); //set as current directory (maybe not necessary)
268  fDataBase->Write(GetDBName()); //write database to file with given name
269  fDataBase->WriteObjects(fDBase.get()); //write any associated objects
270  fDBase->Write(); // write file header etc.
271  fDBase->Close(); // close file
272  gSystem->Chmod(full_path_to_dbfile, 0664); // set permissions to rw-rw-r--
273  work_dir->cd(); //back to initial working directory
274 }
275 
276 
277 
289 
291 {
292  //\returns pointer to database associated with this dataset.
293  //
294  //Opens, updates or creates database file if necessary
295  //(the database is automatically rebuilt if the source files are
296  //more recent than the last database file).
297  //
298  //\param[in] opt optional option string:
299  // - if opt="update": force regeneration of the database from source files in dataset directory
300  // - if opt="minimal": if database not built/out of date, only build runs/systems database
301  // - note that both options can be given to force update of minimal database
302 
303  OpenDataBase(opt);
304  return fDataBase;
305 }
306 
307 
308 
320 
321 void KVDataSet::OpenDataBase(const TString& opt) const
322 {
323  //Open the database for this dataset.
324  //
325  //If the database does not exist or is older than the source files
326  //the database is automatically rebuilt (see DataBaseNeedUpdate()).
327  //
328  //\param[in] opt build option
329  //
330  // - if opt="update" we force rebuilding of the database
331  // - if opt="minimal" only a minimal database of runs & systems for the dataset is built
332  // - note that both options can be given to force update of minimal database
333 
334  TString _opt(opt);
335  _opt.ToUpper();
336  auto update = (_opt.Contains("UPDATE"));
337  auto minimal = (_opt.Contains("MINIMAL"));
338 
339  auto rebuild_database = [&](bool start_from_minimal = false) {
340  start_from_minimal = false;//never start from minimal
341  if(start_from_minimal)
342  Info("OpenDataBase", "Updating existing minimal database...");
343  else
344  {
345  if(minimal)
346  Info("OpenDataBase", "Creating a new minimal database...");
347  else
348  Info("OpenDataBase", "Creating a new full database...");
349  }
350 
351  fDataBaseUpdateInProgress = true;
352  //check if it is the currently active database (gDataBase),
353  //in which case we must 'cd()' to it after rebuilding
354  auto is_glob_db = (fDataBase == gExpDB);
355  if(!start_from_minimal)
356  {
357  if (fDataBase) {
358  delete fDataBase;
359  fDataBase = 0;
360  }
361  fDataBase = KVExpDB::MakeDataBase(GetDBName(), GetDataSetDir(), minimal);
362  if (!fDataBase) {
363  // no database defined for dataset
364  Info("OpenDataBase", "No database defined for dataset");
365  fDataBaseUpdateInProgress = false;
366  return;
367  }
368  }
369  else
370  fDataBase->CompleteDataBase();
371  SaveDataBase();
372  if (fDataBase && is_glob_db) fDataBase->cd();
373  fDataBaseUpdateInProgress = false;
374  };
375 
376  if (update || DataBaseNeedsUpdate()) {
377  //if option="update" or database out of date or does not exist, (re)build the database
378  rebuild_database();
379  }
380  else if (!fDataBase) {
381  // if database is not in memory at this point, we need to
382  // open the database file and read in the database
383 
384  //load plugin for database
385  if (!LoadPlugin("KVExpDB", GetDBName())) {
386  Error("GetDataBase", "Cannot load required plugin library");
387  return;
388  }
389  //look for database file in dataset subdirectory
390  TString dbfile_fullpath = GetFullPathToDB();
391  //open database file
392  OpenDBFile(dbfile_fullpath.Data());
393 
394  // if the previously built database was minimal but nobody asked for
395  // a minimal database (=> they want the full monty), we rebuild a full database
396  if (fDataBase && fDataBase->IsMinimal() && !minimal)
397  rebuild_database(true);
398  }
399  else if (fDataBase && fDataBase->IsMinimal() && !minimal) {
400  // database is already open, but was only a minimal build
401  // now we want the full monty!
402  rebuild_database(true);
403  }
404 }
405 
406 
407 
408 
411 
413 {
414  //Print dataset information
415  cout << "Dataset name=" << GetName() << " (" << GetTitle() << ")";
416  if (IsAvailable()) {
417  cout << " [ AVAILABLE: ";
418  cout << fDatatypes.Data();
419  cout << "]";
420  }
421  else
422  cout << " [UNAVAILABLE]";
423  cout << endl;
424 }
425 
426 
427 
434 
435 void KVDataSet::Print(Option_t* opt) const
436 {
437  //Print dataset information
438  //
439  //param[in] opt select optional output formats:
440  // - if string contains "tasks", print numbered list of tasks that can be performed
441  // - if string contains "data", print list of available data types
442 
443  TString Sopt(opt);
444  Sopt.ToUpper();
445  if (Sopt.Contains("TASK")) {
446  if (!GetNtasks()) {
447  cout << " *** No available analysis tasks ***"
448  << endl;
449  return;
450  }
451  else {
452  for (int i = 1; i <= GetNtasks(); i++) {
453  KVDataAnalysisTask* dat = GetAnalysisTask(i);
454  cout << "\t" << i << ". " << dat->GetTitle() << endl;
455  }
456  }
457  cout << endl;
458  }
459  else if (Sopt.Contains("DATA")) {
460  cout << "Available data types: " << fDatatypes.Data() << endl;
461  }
462  else {
463  ls(opt);
464  }
465 }
466 
467 
468 
477 
479 {
480  //Check if this data set is physically present and available for analysis.
481  //
482  //In other words we check if the value of GetDataPathSubdir() is a subdirectory
483  //of the current data repository.
484  //If so, we proceed to check for the existence of sudirectories corresponding
485  // to any of the datatypes associated with the dataset.
486  //
487 
488  if (!fRepository) // for a stand-alone KVDataSetManager not linked to a KVDataRepository,
489  SetAvailable(); // all known datasets are 'available'
490  else
491  SetAvailable(fRepository->CheckSubdirExists(GetDataPathSubdir()));
492  if (!IsAvailable())
493  return;
494  //check subdirectories
495  auto data_types = GetDataSetEnv<KVString>("KVDataSet.DataTypes");
496  if (data_types == "") {
497  Warning("CheckAvailable", "No datatypes defined for this dataset: %s\nCheck value of KVDataSet.DataTypes or %s.KVDataSet.DataTypes",
498  GetName(), GetName());
499  SetAvailable(kFALSE);
500  }
501  fDatatypes = "";
502  // loop over data types
503  data_types.Begin(" ");
504  while (!data_types.End()) {
505  KVString type = data_types.Next(kTRUE);
506  if (!fRepository ||
507  (fRepository && fRepository->CheckSubdirExists(GetDataPathSubdir(), GetDataTypeSubdir(type.Data())))
508  ) {
509  AddAvailableDataType(type.Data());
510  }
511  }
512  //check at least one datatype exists
513  SetAvailable(fDatatypes != "");
514  //check user name against allowed groups
515  if (!CheckUserCanAccess()) {
516  SetAvailable(kFALSE);
517  return;
518  }
519 }
520 
521 
522 
524 
526 {
527  if (fDatatypes != "") fDatatypes += " ";
528  KVString _type = type;
529  _type.Remove(TString::kBoth, ' '); //strip whitespace
530  fDatatypes += _type;
531 }
532 
533 
534 
541 
543 {
544  // Add to fAllTasks list any data analysis task in list 'task_list'
545  //
546  // Add to fTasks list any data analysis task in list 'task_list' whose pre-requisite datatype is present for this dataset.
547  //
548  // Any dataset-specific "tweaking" of the task (including the prerequisite datatype) is done here.
549 
550  TString availables = gEnv->GetValue(Form("%s.DataAnalysisTask", GetName()), "");
551  fAllTasks.Clear();
552  fTasks.Clear();
553  TIter nxt(task_list);
554  KVDataAnalysisTask* dat;
555  while ((dat = (KVDataAnalysisTask*) nxt())) {
556  //make new copy of default analysis task
557  if (availables == "" || availables.Contains(dat->GetName())) {
558  KVDataAnalysisTask* new_task = new KVDataAnalysisTask(*dat);
559  //check if any dataset-specific parameters need to be changed
560  SetDataSetSpecificTaskParameters(new_task);
561  fAllTasks.Add(new_task);
562  // add tasks with available prerequisite data to fTasks
563  if (HasDataType(new_task->GetPrereq())) {
564  fTasks.Add(new_task);
565  }
566  }
567  }
568 }
569 
570 
571 
575 
577 {
578  //Returns the number of tasks associated to dataset which are compatible
579  //with the available data
580 
581  return fTasks.GetSize();
582 }
583 
584 
585 
590 
592 {
593  //Return kth analysis task in list of available tasks.
594  //
595  //\param[in] k task number in range [1, GetNtasks()]. Corresponds to the number shown next to the title of the task when Print("tasks") is called
596  return (KVDataAnalysisTask*) fTasks.At(k - 1);
597 }
598 
599 
600 
605 
607 {
608  //\returns list of available systems for this dataset and the given datatype
609  //
610  //\param[in] datatype type of data
611 
612  if (!GetAvailableRunsFile(datatype)) {
613  Error("GetListOfAvailableSystems(const Char_t*)",
614  "No available runs file for type %s", datatype.Data());
615  return {};
616  }
617  return GetAvailableRunsFile(datatype)->GetListOfAvailableSystems();
618 }
619 
620 
621 
626 
628 {
629  //\returns list of available systems for this dataset and the prerequisite datatype for the given analysis task
630  //
631  //\param[in] datan data analysis task
632 
633  return GetListOfAvailableSystems(datan->GetPrereq());
634 }
635 
636 
637 
645 
647 {
648  //\returns list of available runfiles for this dataset and the given datatype and system.
649  //
650  //\param[in] datatype type of data
651  //\param[in] systol pointer to system
652  //
653  //If no systems are defined for the dataset then we return a list of available runfiles for the given datatype
654 
655  if (!GetAvailableRunsFile(datatype)) {
656  Error("GetListOfAvailableSystems(const Char_t*)",
657  "No available runs file for type %s", datatype.Data());
658  return {};
659  }
660  return GetAvailableRunsFile(datatype)->GetListOfAvailableRunFilesForSystem(systol);
661 }
662 
663 
664 
672 
674 {
675  //\returns list of available runfiles for this dataset, given system, and the prerequisite datatype for the given analysis task
676  //
677  //\param[in] datan data analysis task
678  //\param[in] pointer to system
679  //
680  //If no systems are defined for the dataset then we return a list of available runfiles for the given datatype
681 
682  return GetListOfAvailableRunFilesForSystem(datan->GetPrereq(), systol);
683 }
684 
685 
686 
689 
691 {
692  // \returns the list of systems corresponding to the given list of runfiles & datatype
693 
694  if (!GetAvailableRunsFile(datatype)) {
695  Error("GetSystemsForRunFiles",
696  "No available runs file for type %s", datatype.Data());
697  return {};
698  }
699  return GetAvailableRunsFile(datatype)->GetSystemsForRunFiles(rl);
700 }
701 
702 
703 
724 
725 void KVDataSet::SetName(const char* name)
726 {
727  // Set name of dataset
728  //
729  // Also sets path to directory containing database informations
730  // for this dataset, i.e. list of runs, systems, calibration files etc.
731  //
732  // By default, just the name of the dataset is used, i.e.
733  // `[DATADIR]/name`
734  // (where `DATADIR` = path given by KVBase::GetDATADIRFilePath())
735  //
736  // However, if the variable
737  //~~~
738  // [name].DataSet.Directory: [path]
739  //~~~
740  // has been set, the value of `[path]` will be used:
741  // - if [path] is an absolute path name, it will be used as such
742  // - if [path] is an incomplete or relative path, it will be prepended with `[DATADIR]/`
743  //
744  // This allows to use one dataset as an alias for another, by setting `DataSet.Directory`
745  // to the name of an existing dataset
747  TString path = GetDataSetEnv("DataSet.Directory", name);
748  if (gSystem->IsAbsoluteFileName(path)) fCalibDir = path;
749  else {
750  // in this case (not an absolute path but just the name of another dataset)
751  // this dataset is an alias for another dataset.
752  fCalibDir = GetDATADIRFilePath(path);
753  // the name of the database object is the name of the "true" dataset
754  SetDBName(path);
755  }
756 }
757 
758 
759 
762 
764 {
765  //\returns full path to directory containing database and calibration/identification parameters etc. for this dataset.
766 
767  return fCalibDir.Data();
768 }
769 
770 
771 
784 
785 void KVDataSet::cd() const
786 {
787  // Makes this dataset the "currently active" or default dataset.
788  //
789  //At the same time, the database and data repository associated with
790  //this dataset also become the "currently active" ones:
791  //
792  // | global pointer | represents | base class |
793  // |----------------|------------|------------|
794  // | `gDataSet` | active dataset | KVDataSet |
795  // | `gExpDB` | associated experimental database | KVExpDB |
796  // | `gDataRepository` | repository containing runfiles | KVDataRepository |
797  //
798 
799  gDataSet = const_cast<KVDataSet*>(this);
800  if (fRepository) fRepository->cd();
801  KVExpDB* db = GetDataBase();
802  if (db) db->cd();
803 }
804 
805 
806 
834 
836 {
837  // Open file containing data of given datatype for given run number of this dataset.
838  //
839  // \returns a pointer to the opened file; if the file is not available, we return nullptr.
840  //
841  // The user must cast the returned pointer to the correct class, which will
842  // depend on the data type and the dataset
843  //
844  // **SPECIAL CASE: MFM data with EBYEDAT frames**
845  //
846  // If the variable
847  //
848  //~~~~~~~~~~~~~~~~~~~~~~~~~
849  // [dataset].MFM.WithEbyedat: yes
850  //~~~~~~~~~~~~~~~~~~~~~~~~~
851  //
852  // is set, then we expect to find the necessary `ACTIONS_*` files in the dataset directory
853  // in subdirectory `ebyedat` (they should have the same names as the data files prefixed by
854  // `ACTIONS_[expname].CHC_PAR.`).
855  //
856  // If in addition the variable
857  //
858  //~~~~~~~~~~~~~~~~~~~~~~~~~
859  // [dataset].MFM.EbyedatActionsExpName: [expname]
860  //~~~~~~~~~~~~~~~~~~~~~~~~~
861  //
862  // is set, then we use the same `ACTIONS` file for all runs, with name `ACTIONS_[expname].CHC_PAR`
863 
864 
865  if (type=="raw" && GetDataSetEnv<KVString>("MFM.WithEbyedat")=="yes") {
866  TString ebydir = GetDataSetDir();
867  ebydir += "/ebyedat";
868  gEnv->SetValue("KVMFMDataFileReader.ActionsDirectory", ebydir);
869  if (GetDataSetEnv<KVString>("MFM.EbyedatActionsExpName")!="")
870  gEnv->SetValue("KVMFMDataFileReader.ActionsExpName", GetDataSetEnv<KVString>("MFM.EbyedatActionsExpName"));
871  TObject* f = GetRepository()->OpenDataSetRunFile(this, type, run, GetName());
872  // reset in case another dataset opens a raw MFM file without EBYEDAT data
873  gEnv->SetValue("KVMFMDataFileReader.ActionsDirectory", "");
874  gEnv->SetValue("KVMFMDataFileReader.ActionsExpName", "");
875  return f;
876  }
877  return GetRepository()->OpenDataSetRunFile(this, type, run, GetName());
878 }
879 
880 
881 
882 
886 
888  const run_index_t& run) const
889 {
890  //\return full path to file containing data of given datatype for given run/index of this dataset
891  // \note only works for available run files, if their is no file in the repository for this run, the returned path will be empty
892 
893  TString file("");
894  if (fRepository) file = GetRunfileName(type, run);
895  if (file == "")
896  return file.Data();
897  return fRepository->GetFullPathToOpenFile(this, type, file.Data());
898 }
899 
900 
901 
902 
906 
908 {
909  //\return name of file containing data of given datatype for given run/index of this dataset
910  //\note only works for available run files, if there is no file in the repository for this run, the returned path will be empty
911 
912  if (!HasDataType(type)) {
913  Error("GetRunfileName",
914  "No data of type \"%s\" available for dataset %s", (const char*)type,
915  GetName());
916  return 0;
917  }
918  //get name of file from available runs file
919  return GetAvailableRunsFile(type)->GetFileName(run);
920 }
921 
922 
923 
924 
930 
931 std::optional<TDatime> KVDataSet::GetRunfileDate(const KVString& type, const run_index_t& run)
932 {
933  //\return date of file containing data of given datatype for given run/index of this dataset
934  //
935  //\note only works for available runfiles, if there is no file in the repository for this run/index,
936  //an error will be printed and std::optional will not contain a value
937 
938  if (!HasDataType(type)) {
939  Error("GetRunfileDate",
940  "No data of type \"%s\" available for dataset %s", (const char*)type,
941  GetName());
942  return std::nullopt;
943  }
944  //get date of file from available runs file
945  TDatime date;
947  if (!GetAvailableRunsFile(type)->GetRunInfo(run, date, filename)) {
948  Error("GetRunfileDate",
949  "Runfile not found for run %d index %d (data type: %s)", run.run(), run.index(), (const char*)type);
950  return std::nullopt;
951  }
952  return date;
953 }
954 
955 
956 
979 
980 std::optional<run_index_t> KVDataSet::GetRunNumberFromFileName(const TString& datatype, const TString& filename)
981 {
982  // \returns run number and eventual index by parsing the name of a runfile for given datatype. if filename does not have correct format, returns std::nullopt
983  //
984  // If the runfile in question was generated using an index multiplier, e.g. if it contains the number
985  // '17001' when the index multiplier defined for the dataset is 1000, we return '17' as the
986  // run number and '1' as the index.
987  //
988  // Usage examples (using global pointer gDataSet to currently 'active' dataset):
989  //~~~{.cpp}
990  //auto run = gDataSet->GetRunNumberFromFileName(filename);
991  //
992  //if(!run) // no value (std::nullopt) returned
993  //{
994  // std::cerr << "Filename " << filename << " is not right format\n";
995  //}
996  //else
997  //{
998  // std::cout << "Filename " << filename << " corresponds to run number " << run.value().run();
999  // if(run.has_index()) std::cout << ", file index = " << run.index();
1000  // std::cout << std::endl;
1001  //}
1002  //~~~
1003 
1004  auto arf = GetAvailableRunsFile(datatype);
1005  auto v = arf->IsRunFileName(filename);
1006  if (!v) return v;
1007  // if the returned value has a non-null index, there is nothing more to do
1008  if (v.value().has_index()) return v;
1009  int r = v.value().run();
1010  // check if returned run number actually consists of run*multiplier+index
1011  auto db = GetDataBase("minimal");
1012  if (db->HasIndexMultiplier() && r > db->GetIndexMultiplier()) {
1013  r /= db->GetIndexMultiplier();
1014  int i = v.value().run() % db->GetIndexMultiplier();
1015  return run_index_t{r, i};
1016  }
1017  return v;
1018 }
1019 
1020 
1021 
1022 
1027 
1029 {
1030  //We check the availability of the run by looking in the available runs file associated
1031  //with the given datatype.
1032 
1033  //check data type is available
1034  if (!HasDataType(type)) {
1035  Error("CheckRunfileAvailable",
1036  "No data of type \"%s\" available for dataset %s", (const char*)type,
1037  GetName());
1038  return 0;
1039  }
1040  return GetAvailableRunsFile(type)->CheckAvailable(run);
1041 }
1042 
1043 
1044 
1045 
1060 
1062 {
1063  //PRIVATE METHOD: Returns base name of data file containing data for the run of given datatype.
1064  //The filename corresponds to one of the formats defined in $KVROOT/KVFiles/.kvrootrc
1065  //by variables like:
1066  //
1067  //~~~
1068  //[dataset].DataSet.RunFileName.[type]: run%R.dat
1069  //~~~
1070  //
1071  //%R will be replaced with the run number
1072  //
1073  //IF the format contains '%D' it will be replaced with the current date and time
1074  //
1075  // Any index will be appended at the end: ".index"
1076 
1077  TString tmp;
1078  //get format string
1079  auto fmt = GetDataSetEnv<TString>(Form("DataSet.RunFileName.%s", type));
1080  TString run_num(Form("%d", run.run()));
1081  KVDatime now;
1082  TString date(now.AsSQLString());
1083  tmp = fmt;
1084  tmp.ReplaceAll("%R", run_num);
1085  if (fmt.Contains("%D")) {
1086  tmp.ReplaceAll("%D", date);
1087  }
1088  if (run.has_index()) tmp += Form(".%d", run.index());
1089  return tmp;
1090 }
1091 
1092 
1093 
1094 
1104 
1106 {
1107  //Update list of available runs for given data 'type'
1108  //
1109  //As we never clear the sqlite database of any previously existing runfiles
1110  //beforehand, it is possible that newer versions of said files have been
1111  //added and that we will therefore end up with multiple copies of files in the
1112  //database. Therefore we perform an automatic 'CleanRunfileDataBase' afterwards,
1113  //but only to remove runfiles which no longer physically exist
1114 
1115  //check data type is available
1116  if (!HasDataType(type)) {
1117  Error("UpdateAvailableRuns",
1118  "No data of type \"%s\" available for dataset %s", (const char*)type,
1119  GetName());
1120  }
1121  KVAvailableRunsFile* a = GetAvailableRunsFile(type);
1122  a->Update();
1123  CleanRunfileDataBase(type);
1124 }
1125 
1126 
1127 
1128 
1133 
1135 {
1136  // Create a new runfile for the dataset of given datatype.
1137  // (only if this dataset is associated with a data repository)
1138  // Once the file has been filled, use CommitRunfile to submit it to the repository.
1139 
1140  if (!fRepository) return nullptr;
1141  TString tmp = GetBaseFileName(type, run);
1142  //turn any spaces into "_"
1143  tmp.ReplaceAll(" ", "_");
1144  return fRepository->CreateNewFile(this, type, tmp.Data());
1145 }
1146 
1147 
1148 
1149 
1158 
1159 void KVDataSet::DeleteRunfile(const KVString& type, const run_index_t& run, Bool_t confirm)
1160 {
1161  // Delete the file for the given run/index of data type "type" from the repository.
1162  // By default, confirm=kTRUE, which means that the user will be asked to confirm
1163  // that the file should be deleted. If confirm=kFALSE, no confirmation will be asked
1164  // for and the file will be deleted straight away.
1165  //
1166  // WARNING: this really does DELETE files in the repository, they cannot be
1167  // retrieved once they have been deleted.
1168 
1169  if (!fRepository) return;
1170 
1171  //get name of file to delete
1172  TString filename = GetAvailableRunsFile(type)->GetFileName(run);
1173  if (filename == "") {
1174  Error("DeleteRunfile", "Run %s of type %s does not exist.",
1175  run.as_string().Data(), (const char*)type);
1176  return;
1177  }
1178  //delete file
1179  //prevent accidental deletion of certain types of runfiles
1180  auto doNotDelete = GetDataSetEnv<KVString>("DataSet.RunFile.DoNotDelete", "all");
1181  if (doNotDelete == "all" || doNotDelete.Contains(type)) {
1182  Error("DeleteRunFile", "%s files cannot be deleted", (const char*)type);
1183  return;
1184  }
1185  fRepository->DeleteFile(this, type, filename.Data(), confirm);
1186  //was file deleted ? if so, remove entry from available runs file
1187  if (!fRepository->CheckFileStatus(this, type, filename.Data()))
1188  GetAvailableRunsFile(type)->Remove(run);
1189 }
1190 
1191 
1192 
1193 
1205 
1206 void KVDataSet::DeleteRunfiles(const Char_t* type, const run_index_list& nl, Bool_t confirm)
1207 {
1208  // Delete files corresponding to a list of runs/index of data type "type" from the repository.
1209  //
1210  // By default, confirm=kTRUE, which means that the user will be asked to confirm
1211  // that each file should be deleted.
1212  //
1213  // If confirm=kFALSE, no confirmation will be asked for and the file will be deleted straight away.
1214  //
1215  // if "nl" is empty (default value) all runs of the dataset corresponding to the given type will be deleted
1216  //
1217  // WARNING: this really does DELETE files in the repository, they cannot be retrieved once they have been deleted.
1218 
1219  auto NL = nl;
1220  if (NL.IsEmpty()) NL = GetRunList(type);
1221  if (NL.IsEmpty()) return;
1222  for (auto& r : NL)
1223  DeleteRunfile(type, r, confirm);
1224 }
1225 
1226 
1227 
1228 
1236 
1237 run_index_list KVDataSet::GetRunList_DateSelection(const TString& type, const KVUnownedList& systems, std::optional<KVDatime> min_date, std::optional<KVDatime> max_date)
1238 {
1239  // Prints out and returns list of runs after date / time selection
1240  //
1241  // Runs generated between ]min;max[ are selected
1242  // - if min=NULL runs with date <max are selected
1243  // - if max=NULL runs with date >min are selected
1244  // - if max and min are NULL returns empty list
1245 
1246  if (!min_date && !max_date) return {};
1247 
1248  if (min_date) printf("date minimum %s\n", min_date.value().AsString());
1249  if (max_date) printf("date maximum %s\n", max_date.value().AsString());
1250 
1251  run_index_list numb;
1252 
1253  for (auto _sys : systems) {
1254  auto sys = (KVDBSystem*)_sys;
1255  auto lrun = GetListOfAvailableRunFilesForSystem(type, sys);
1256 
1257  for (auto _run : lrun) {
1258  auto run = (KVRunFile*)_run;
1259 
1260  if (min_date && max_date) {
1261  if (min_date.value() < run->GetFileWrittenDatime() && run->GetFileWrittenDatime() < max_date.value()) {
1262  numb.Add(run->GetRunIndex());
1263  }
1264  }
1265  else if (min_date) {
1266  if (min_date.value() < run->GetFileWrittenDatime()) {
1267  numb.Add(run->GetRunIndex());
1268  }
1269  }
1270  else if (max_date) {
1271  if (run->GetFileWrittenDatime() < max_date.value()) {
1272  numb.Add(run->GetRunIndex());
1273  }
1274  }
1275  }
1276  }
1277  return numb;
1278 
1279 }
1280 
1281 
1282 
1283 
1290 
1292 {
1293  // Returns list of runs which are present for data type "base_type" but not for "other_type"
1294  //
1295  // If pointer to system is given, only runs for the system are considered.
1296  //
1297  // If OnlyCol=kTRUE (kFALSE default) only systems with KVDBSystem::IsCollision()=kTRUE are considered
1298 
1299  run_index_list manquant;
1300  auto ll = GetListOfAvailableSystems(ref_type);
1301  if (ll.IsEmpty()) {
1302  //numb.Clear();
1303  Info("GetRunList_StageSelection", "No data available of type \"%s\"", ref_type.Data());
1304  return manquant;
1305  }
1306  if (system && !ll.FindObject(system)) {
1307  Info("GetRunList_StageSelection", "No data available of type \"%s\" for system %s", ref_type.Data(), system->GetName());
1308  return manquant;
1309  }
1310 
1311  Info("GetRunList_StageSelection", "Liste des runs presents dans \"%s\" mais absent dans \"%s\"", ref_type.Data(), type.Data());
1312 
1313  KVDBSystem* sys = 0;
1314 
1315  for (Int_t nl = 0; nl < ll.GetEntries(); nl += 1) {
1316 
1317  sys = (KVDBSystem*)ll.At(nl);
1318  if (system && sys != system) continue;
1319  if (OnlyCol && !sys->IsCollision()) continue;
1320  auto nsys = GetRunList(type, sys);
1321  auto nsys_ref = GetRunList(ref_type, sys);
1322  Int_t nref = nsys_ref.GetNValues();
1323 
1324  nsys_ref.Remove(nsys);
1325 
1326  Info("GetRunList_StageSelection", "\nKVDBSystem : %s --> %d runs manquants sur %d : %s",
1327  sys->GetName(),
1328  nsys_ref.GetNValues(),
1329  nref,
1330  nsys_ref.AsString().Data()
1331  );
1332  manquant.Add(nsys_ref);
1333  }
1334  return manquant;
1335 }
1336 
1337 
1338 
1344 
1345 run_index_list KVDataSet::GetRunList_StageSelection(const TString& type, const TString& ref_type, const KVUnownedList& systems, Bool_t OnlyCol)
1346 {
1347  // \returns list of runfiless which are present for data type "base_type" but not for "other_type"
1348  // for the systems (KVDBSystem pointers) in the list.
1349  //
1350  // If OnlyCol=kTRUE (kFALSE default) only systems with KVDBSystem::IsCollision()=kTRUE are considered
1351 
1352  run_index_list manquant;
1353  auto ll = GetListOfAvailableSystems(ref_type);
1354  if (ll.IsEmpty()) {
1355  //numb.Clear();
1356  Info("GetRunList_StageSelection", "No data available of type \"%s\"", ref_type.Data());
1357  return manquant;
1358  }
1359 
1360  Info("GetRunList_StageSelection", "Liste des runs presents dans \"%s\" mais absent dans \"%s\"", ref_type.Data(), type.Data());
1361 
1362  KVDBSystem* sys = 0;
1363 
1364  for (Int_t nl = 0; nl < ll.GetEntries(); nl += 1) {
1365 
1366  sys = (KVDBSystem*)ll.At(nl);
1367  if (!systems.Contains(sys)) continue;
1368  if (OnlyCol && !sys->IsCollision()) continue;
1369  auto nsys = GetRunList(type, sys);
1370  auto nsys_ref = GetRunList(ref_type, sys);
1371  Int_t nref = nsys_ref.GetNValues();
1372 
1373  nsys_ref.Remove(nsys);
1374 
1375  Info("GetRunList_StageSelection", "\nKVDBSystem : %s --> %d runs manquants sur %d : %s",
1376  sys->GetName(),
1377  nsys_ref.GetNValues(),
1378  nref,
1379  nsys_ref.AsString().Data()
1380  );
1381  manquant.Add(nsys_ref);
1382  }
1383  return manquant;
1384 }
1385 
1386 
1387 
1392 
1394 {
1395  // Returns list of runs of given type that were created with the given version of KaliVeda.
1396  //
1397  // If system!="" then only runs for the given system are considered
1398 
1399  run_index_list runs;
1400  if (sys) {
1401  auto lrun = GetListOfAvailableRunFilesForSystem(type, sys);
1402  TIter next(&lrun);
1403  KVRunFile* run;
1404  while ((run = (KVRunFile*)next())) {
1405  if (!strcmp(run->GetVersion(), version)) runs.Add(run->GetRunIndex());
1406  }
1407  return runs;
1408  }
1409  auto ll = GetListOfAvailableSystems(type);
1410  if (ll.IsEmpty()) {
1411  //numb.Clear();
1412  Info("GetRunList_VersionSelection", "No data available of type \"%s\"", type.Data());
1413  return runs;
1414  }
1415  Int_t nsys = ll.GetEntries();
1416  for (Int_t nl = 0; nl < nsys; nl += 1) {
1417  sys = (KVDBSystem*)ll.At(nl);
1418  auto lrun = GetListOfAvailableRunFilesForSystem(type, sys);
1419  TIter next(&lrun);
1420  KVRunFile* run;
1421  while ((run = (KVRunFile*)next())) {
1422  if (!strcmp(run->GetVersion(), version)) runs.Add(run->GetRunIndex());
1423  }
1424  }
1425  return runs;
1426 }
1427 
1428 
1429 
1434 
1435 void KVDataSet::CommitRunfile(const KVString& type, const run_index_t& run, TFile* file)
1436 {
1437  // Commit a runfile previously created with NewRunfile() to the repository.
1438  // Any previous version of the runfile will be deleted.
1439  // The available runs list for this data 'type' is updated.
1440 
1441  if (!fRepository) return;
1442 
1443  //keep name of file for updating available runs list
1444  TString newfile = gSystem->BaseName(file->GetName());
1445 
1446  fRepository->CommitFile(file, type, this);
1447  //update list of available datatypes of dataset,
1448  //in case this addition has created a new subdirectory
1449  CheckAvailable();
1450  //check if previous version of file exists
1451  //get name of file from available runs file
1452  //note that when the file is the first of a new subdirectory, GetAvailableRunsFile->GetFileName
1453  //will cause the available runs file to be created, and it will contain one entry:
1454  //the new file!
1455  TString oldfile = GetAvailableRunsFile(type)->GetFileName(run);
1456  if (oldfile != "" && oldfile != newfile) {
1457  //delete previous version - no confirmation
1458  fRepository->DeleteFile(this, type, oldfile.Data(),
1459  kFALSE);
1460  //was file deleted ? if so, remove entry from available runs file
1461  if (!fRepository->CheckFileStatus(this, type, oldfile.Data()))
1462  GetAvailableRunsFile(type)->Remove(run);
1463  }
1464  if (oldfile != newfile) {
1465  //add entry for new run in available runs file
1466  GetAvailableRunsFile(type)->Add(run, newfile.Data());
1467  }
1468 }
1469 
1470 
1471 
1472 
1478 
1480 {
1481  //if fUserGroups has been set with SetUserGroups(), we check that the current user's name
1482  //(gSystem->GetUserInfo()->fUser) appears in at least one of the groups in the list.
1483  //Returns kFALSE if user's name is not found in any of the groups.
1484  //if fUserGroups="" (default), we return kTRUE for all users.
1485 
1486  if (fUserGroups == "")
1487  return kTRUE; /* no groups set, all users have access */
1488 
1489  //split into array of group names
1490  unique_ptr<TObjArray> toks(fUserGroups.Tokenize(' '));
1491  TObjString* group_name;
1492  TIter next_name(toks.get());
1493  while ((group_name = (TObjString*) next_name())) {
1494  //for each group_name, we check if the user's name appears in the group
1495  if (!fRepository || (fRepository && fRepository->GetDataSetManager()->
1496  CheckUser(group_name->String().Data()))
1497  ) {
1498  return kTRUE;
1499  }
1500  }
1501  return kFALSE;
1502 }
1503 
1504 
1505 
1506 
1509 
1511 {
1512  //Set pointer to data repository in which dataset is stored
1513  fRepository = dr;
1514 }
1515 
1516 
1517 
1518 
1521 
1523 {
1524  //Get pointer to data repository in which dataset is stored
1525  return fRepository;
1526 }
1527 
1528 
1529 
1530 
1535 
1537 {
1538  //Check all runs for a given datatype and make sure that only one version
1539  //exists for each runfile. If not, we print a report on the runfiles which occur
1540  //multiple times, with the associated date and file name.
1541 
1542  auto doubles = GetAvailableRunsFile(data_type)->CheckMultiRunfiles();
1543  if (doubles.empty()) {
1544  cout << "OK. No runs appear more than once." << endl;
1545  }
1546  else {
1547  cout << "Runs which appear more than once: " << endl << endl;
1548  //print dates and filenames for each run
1549 
1550  for (auto& rr : doubles) {
1551  KVList filenames, dates;
1552 
1553  //get infos for current run
1554  GetAvailableRunsFile(data_type)->GetRunInfos(rr, dates, filenames);
1555 
1556  cout << "Run " << rr << " : " << dates.GetEntries() << " files >>>>>>" << endl;
1557  for (int i = 0; i < dates.GetEntries(); i++) {
1558 
1559  cout << "\t" << ((TObjString*) filenames.At(i))->String().
1560  Data() << "\t" << ((TObjString*) dates.At(i))->String().
1561  Data() << endl;
1562 
1563  }
1564  }
1565  }
1566 }
1567 
1568 
1569 
1570 
1581 
1582 void KVDataSet::CleanMultiRunfiles(const Char_t* data_type, Bool_t confirm)
1583 {
1584  // Check all runs for a given datatype and make sure that only one version
1585  // exists for each run. If not, we print a report on the runfiles which occur
1586  // multiple times, with the associated date and file name, and then we
1587  // destroy all but the most recent version of the file in the repository, and
1588  // update the runlist accordingly.
1589  //
1590  // By default, we ask for confirmation before deleting each file.
1591  //
1592  // Call with confirm=kFALSE to delete WITHOUT CONFIRMATION (DANGER!! WARNING!!!)
1593 
1594  if (!fRepository) return;
1595 
1596  KVAvailableRunsFile* ARF = GetAvailableRunsFile(data_type);
1597  auto doubles = ARF->CheckMultiRunfiles();
1598  if (doubles.empty()) {
1599  cout << "OK. No runs appear more than once." << endl;
1600  }
1601  else {
1602  cout << "Runs which appear more than once: " << endl << endl;
1603  //print dates and filenames for each run
1604 
1605  KVList filenames, dates;
1606  for (auto& rr : doubles) {
1607  //get infos for current run
1608  ARF->GetRunInfos(rr, dates, filenames);
1609  TDatime most_recent("1998-12-25 00:00:00");
1610  Int_t i_most_recent = 0;
1611  cout << "Run " << rr << " : " << dates.GetEntries() << " files >>>>>>" << endl;
1612  for (int i = 0; i < dates.GetEntries(); i++) {
1613  //check if run is most recent
1614  TDatime rundate(((TObjString*) dates.At(i))->String().Data());
1615  if (rundate > most_recent) {
1616  most_recent = rundate;
1617  i_most_recent = i;
1618  }
1619  }
1620  //Now, we loop over the list again, this time we destroy all but the most recent
1621  //version of the runfile
1622  for (int i = 0; i < dates.GetEntries(); i++) {
1623  if (i == i_most_recent) {
1624  cout << "KEEP : ";
1625  }
1626  else {
1627  cout << "DELETE : ";
1628  }
1629  cout << "\t" << ((TObjString*) filenames.At(i))->String().
1630  Data() << "\t" << ((TObjString*) dates.At(i))->String().
1631  Data() << endl;
1632  if (i != i_most_recent) {
1633  //delete file from repository forever and ever
1634  fRepository->DeleteFile(this, data_type,
1635  ((TObjString*) filenames.At(i))->
1636  String().Data(), confirm);
1637  //remove file entry from available runlist
1638  ARF->Remove(rr,
1639  ((TObjString*) filenames.At(i))->String());
1640  }
1641  }
1642  }
1643  }
1644 }
1645 
1646 
1647 
1652 
1654 {
1655  // Similar to CleanMultiRunfiles(), but here the aim is only to remove from the
1656  // sqlite database any runfiles which are no longer physically present in the
1657  // repository i.e. they have already been deleted but our database was not updated.
1658 
1659  if (!fRepository) return;
1660 
1661  Info("CleanRunfileDataBase", "Checking for spurious duplicates (non-existent files)...");
1662 
1663  KVAvailableRunsFile* ARF = GetAvailableRunsFile(data_type);
1664 
1665  auto doubles = ARF->CheckMultiRunfiles();
1666  if (!doubles.empty()) {
1667  for (auto& ri : doubles) {
1668  // for each run/index, get full list of available files
1669  KVList dates, files;
1670  ARF->GetRunInfos(ri, dates, files);
1671  // now check that each file is physically present
1672  for (auto f : files) {
1673  TString fname = dynamic_cast<TObjString*>(f)->GetString();
1674  if (!fRepository->CheckFileStatus(this, data_type, fname)) {
1675  Info("CleanRunfileDataBase", "File %s does not exist : remove from database...", fname.Data());
1676  ARF->Remove(ri, fname);
1677  }
1678  }
1679  }
1680  }
1681  else
1682  Info("CleanRunfileDataBase", "Database is apparently consistent");
1683 }
1684 
1685 
1686 
1687 
1694 
1696  KVDataRepository* other_repos)
1697 {
1698  //Use this method to check whether the file of type "data_type" for run number "run"
1699  //in the data repository "other_repos" is more recent than the file contained in the data
1700  //repository corresponding to this dataset.
1701  //
1702  //Returns kFALSE if file in other repository is more recent.
1703 
1704  if (!other_repos)
1705  return kTRUE;
1706  //get dataset with same name as this one from dataset manager of other repository
1707  KVDataSet* ds = other_repos->GetDataSetManager()->GetDataSet(GetName());
1708  if (!ds) {
1709  Error("CheckRunfileUpToDate",
1710  "Dataset \"%s\" not found in repository \"%s\"", GetName(),
1711  other_repos->GetName());
1712  return kFALSE;
1713  }
1714  //compare dates of the two runfiles
1715  if (GetRunfileDate(data_type, run) < ds->GetRunfileDate(data_type, run))
1716  return kFALSE;
1717  return kTRUE;
1718 }
1719 
1720 
1721 
1722 
1729 
1731  const KVString& other_repos)
1732 {
1733  //Use this method to check whether the file of type "data_type" for run number "run"
1734  //in the data repository "other_repos" is more recent than the file contained in the data
1735  //repository corresponding to this dataset.
1736  //Returns kTRUE if no repository with name "other_repos" exists.
1737  //Returns kFALSE if file in other repository is more recent.
1738 
1739  KVDataRepository* _or =
1740  gDataRepositoryManager->GetRepository(other_repos);
1741  if (_or)
1742  return CheckRunfileUpToDate(data_type, run, _or);
1743  Error("CheckRunfileUpToDate",
1744  "No data repository known with this name : %s", (const char*) other_repos);
1745  return kTRUE;
1746 }
1747 
1748 
1749 
1750 
1754 
1755 void KVDataSet::CheckUpToDate(const Char_t* data_type,
1756  const Char_t* other_repos)
1757 {
1758  //Check whether all files of type "data_type" for run number "run" in the data repository
1759  //are up to date (i.e. at least as recent) as compared to the files in data repository "other_repos".
1760 
1761  if (!fRepository) return;
1762 
1763  KVDataRepository* _or =
1764  gDataRepositoryManager->GetRepository(other_repos);
1765  if (!_or) {
1766  Error("CheckUpToDate",
1767  "No data repository known with this name : %s", other_repos);
1768  return;
1769  }
1770  auto runlist = GetAvailableRunsFile(data_type)->GetRunList();
1771  Int_t need_update = 0;
1772  for (auto& rr : runlist) {
1773  //check run
1774  if (!CheckRunfileUpToDate(data_type, rr, _or)) {
1775  cout << " *** run " << rr << " needs update ***" <<
1776  endl;
1777  cout << "\t\tREPOSITORY: " << fRepository->
1778  GetName() << "\tDATE: " << GetRunfileDate(data_type, rr).value().AsString() << endl;
1779  cout << "\t\tREPOSITORY: " << other_repos << "\tDATE: " << _or->
1780  GetDataSetManager()->GetDataSet(GetName())->
1781  GetRunfileDate(data_type, rr).value().AsString() << endl;
1782  need_update++;
1783  }
1784  }
1785  if (!need_update) {
1786  cout << " *** All runfiles are up to date for data type " <<
1787  data_type << endl;
1788  }
1789 }
1790 
1791 
1792 
1793 
1797 
1799  const Char_t* other_repos)
1800 {
1801  //Returns list of all runs of type "data_type" which may be updated
1802  //from the repository named "other_repos". See CheckUpToDate().
1803 
1804  run_index_list updates;
1805  if (!fRepository) return updates;
1806 
1807  KVDataRepository* _or =
1808  gDataRepositoryManager->GetRepository(other_repos);
1809  if (!_or) {
1810  Error("CheckUpToDate",
1811  "No data repository known with this name : %s", other_repos);
1812  return updates;
1813  }
1814  auto runlist = GetAvailableRunsFile(data_type)->GetRunList();
1815  for (auto& rr : runlist) {
1816  //check run
1817  if (!CheckRunfileUpToDate(data_type, rr, _or)) {
1818  //run is out of date
1819  updates.Add(rr);
1820  }
1821  }
1822  return updates;
1823 }
1824 
1825 
1826 
1827 
1832 
1834  const KVDBSystem* system) const
1835 {
1836  //Returns list of all files available for given "data_type"
1837  //
1838  //If a pointer to a reaction system is given, only files for the given system will be included in the list.
1839 
1840  if (!fRepository || !HasDataType(data_type)) {
1841  Error("GetRunList",
1842  "No data of type %s available. Runlist will be empty.",
1843  data_type);
1844  return {};
1845  }
1846 
1847  return GetAvailableRunsFile(data_type)->GetRunList(system);
1848 }
1849 
1850 
1851 
1852 
1883 
1885 {
1886  //This method returns a pointer to the available analysis task whose description (title) contains
1887  //all of the whitespace-separated keywords (which may be regular expressions)
1888  //given in the string "keywords". The comparison is case-insensitive.
1889  //
1890  //WARNING: this method can only be used to access analysis tasks that are
1891  //available for this dataset, i.e. for which the corresponding prerequisite data type
1892  //is available in the repository.
1893  //For unavailable data/tasks, use GetAnalysisTaskAny(const Char_t*).
1894  //
1895  //EXAMPLES
1896  //Let us suppose that the current dataset has the following list of tasks:
1897  //~~~
1898  // root [2] gDataSet->Print("tasks")
1899  // 1. Event reconstruction from raw data (raw->recon)
1900  // 2. Analysis of raw data
1901  // 3. Identification of reconstructed events (recon->ident)
1902  // 4. Analysis of reconstructed events (recon)
1903  // 5. Analysis of partially identified & calibrated reconstructed events (ident)
1904  // 6. Analysis of fully calibrated physical data (root)
1905  //~~~
1906  //Then the following will occur:
1907  //~~~
1908  // root [14] gDataSet->GetAnalysisTask("raw->recon")->Print()
1909  // KVDataAnalysisTask : Event reconstruction from raw data (raw->recon)
1910  //
1911  // root [10] gDataSet->GetAnalysisTask("analysis root")->Print()
1912  // KVDataAnalysisTask : Analysis of fully calibrated physical data (root)
1913  //~~~
1914 
1915  //case-insensitive search for matches in list based on 'title' attribute
1916  return (KVDataAnalysisTask*)fTasks.FindObjectAny("title", keywords, kTRUE, kFALSE);
1917 }
1918 
1919 
1920 
1921 
1923 
1925 {
1926  if (!dat->WithUserClass()) {
1927  Error("MakeAnalysisClass",
1928  "No user class required for analysis task \"%s\"", dat->GetTitle());
1929  return false;
1930  }
1931 
1932  //all analysis base classes must define a static Make(const Char_t * classname)
1933  //which generates the skeleton class files.
1934 
1935  TClass* cl = nullptr;
1936  //has the user base class for the task been compiled and loaded ?
1938  else
1939  return false;
1940 
1941  //set up call to static Make method
1942  unique_ptr<TMethodCall> methcall(new TMethodCall(cl, "Make", Form("\"%s\"", classname)));
1943 
1944  if (!methcall->IsValid()) {
1945  Error("MakeAnalysisClass", "static Make(const Char_t*) method for class %s is not valid",
1946  cl->GetName());
1947  return false;
1948  }
1949 
1950  //generate skeleton class
1951  methcall->Execute();
1952 
1953  return true;
1954 }
1955 
1956 
1957 
1970 
1971 bool KVDataSet::MakeAnalysisClass(const Char_t* task, const Char_t* classname)
1972 {
1973  //Create a skeleton analysis class to be used for analysis of the data belonging to this dataset.
1974  //
1975  // task = keywords contained in title of analysis task (see GetAnalysisTask(const Char_t*))
1976  // (you do not need to include 'analysis', it is added automatically)
1977  // classname = name of new analysis class
1978  //
1979  //Example:
1980  // MakeAnalysisClass("raw", "MyRawDataAnalysis")
1981  // --> make skeleton raw data analysis class in files MyRawDataAnalysis.cpp & MyRawDataAnalysis.h
1982  // MakeAnalysisClass("fully calibrated", "MyDataAnalysis")
1983  // --> make skeleton data analysis class in files MyDataAnalysis.cpp & MyDataAnalysis.h
1984 
1985  KVString _task = task;
1986  if (!_task.Contains("nalysis")) _task += " analysis";
1987  //We want to be able to write analysis classes even when we don't have any data
1988  //to analyse. Therefore we use GetAnalysisTaskAny.
1989  auto dat = GetAnalysisTaskAny(_task.Data());
1990  if (!dat) {
1991  Error("MakeAnalysisClass",
1992  "called for unknown or unavailable analysis task : %s", _task.Data());
1993  return false;
1994  }
1995  return make_analysis_class(dat, classname);
1996 }
1997 
1998 
1999 
2006 
2007 bool KVDataSet::MakeAnalysisClass(int task, const Char_t* classname)
2008 {
2009  //Create a skeleton analysis class to be used for analysis of the data belonging to this dataset.
2010  //
2011  // task = index of analysis task as shown in KVDataSet::Print("tasks")
2012  // classname = name of new analysis class
2013  //
2014 
2015  auto dat = GetAnalysisTask(task);
2016  if (!dat) {
2017  Error("MakeAnalysisClass",
2018  "called for unknown or unavailable analysis task index : %d", task);
2019  return false;
2020  }
2021  return make_analysis_class(dat, classname);
2022 }
2023 
2024 
2025 
2026 
2030 
2031 Bool_t KVDataSet::OpenDataSetFile(const Char_t* filename, ifstream& file)
2032 {
2033  // Look for (and open for reading, if found) the named file in the directory which
2034  // contains the files for this dataset (given by GetDataSetDir())
2035 
2036  return OpenDataSetFile(GetName(), filename, file);
2037 }
2038 
2039 
2040 
2044 
2045 Bool_t KVDataSet::OpenDataSetFile(const TString& dataset, const Char_t* filename, ifstream& file)
2046 {
2047  // Static method to look for (and open for reading, if found) the named file in the directory which
2048  // contains the files for the dataset
2049 
2050  TString datasetdir = KVBase::GetDataSetEnv(dataset, "DataSet.Directory", dataset);
2051  if (gSystem->IsAbsoluteFileName(datasetdir)) {
2052  // dataset directory is outside of standard KV installation directories
2053  // use absolute path to search for file
2054  TString abspath;
2055  abspath.Form("%s/%s", datasetdir.Data(), filename);
2056  return SearchAndOpenKVFile(abspath, file);
2057  }
2058  // dataset directory is a subdirectory of GetDATADIRFilePath()
2059  return SearchAndOpenKVFile(filename, file, datasetdir);
2060 }
2061 
2062 
2063 
2067 
2069 {
2070  // Find a file in the dataset directory (given by GetDataSetDir())
2071  // Returns full path to file if found, empty string if not
2072 
2073  return GetFullPathToDataSetFile(GetName(), filename);
2074 }
2075 
2076 
2077 
2082 
2084 {
2085  // Static method to find a file in the dataset directory (given by GetDataSetDir())
2086  //
2087  // Returns full path to file if found, empty string if not
2088 
2089  TString fullpath;
2090  TString datasetdir = KVBase::GetDataSetEnv(dataset, "DataSet.Directory", dataset);
2091  if (!SearchKVFile(filename, fullpath, datasetdir)) {
2092  KVBase b;
2093  b.Warning("KVDataSet::GetFullPathToDataSetFile", "File %s not found in dataset subdirectory %s", filename, datasetdir.Data());
2094  fullpath = "";
2095  }
2096  return fullpath;
2097 }
2098 
2099 
2100 
2104 
2105 Bool_t KVDataSet::FindDataSetFile(const TString& dataset, const Char_t* filename)
2106 {
2107  // Static method to find a file in the dataset directory (given by GetDataSetDir())
2108  // Returns kTRUE if found, kFALSE if not
2109 
2110  TString fullpath;
2111  TString datasetdir = KVBase::GetDataSetEnv(dataset, "DataSet.Directory", dataset);
2112  return SearchKVFile(filename, fullpath, datasetdir);
2113 }
2114 
2115 
2116 
2120 
2122 {
2123  // Find a file in the dataset directory (given by GetDataSetDir())
2124  // Returns kTRUE if found, kFALSE if not
2125 
2126  return FindDataSetFile(GetName(), filename);
2127 }
2128 
2129 
2130 
2131 
2140 
2142 {
2143  //This method returns the analysis task whose description (title) contains
2144  //all of the whitespace-separated keywords (which may be regular expressions)
2145  //given in the string "keywords". The comparison is case-insensitive.
2146  //The analysis task does not need to be "available", i.e. the associated prerequisite
2147  //data type does not have to be present in the repository (see GetAnalysisTask).
2148  //
2149  // If no task is found, returns nullptr
2150 
2151  KVDataAnalysisTask* tsk = (KVDataAnalysisTask*)fAllTasks.FindObjectAny("title", keywords, kTRUE, kFALSE);
2152  if (!tsk) {
2153  Error("GetAnalysisTaskAny", "No task found with the following keywords in its title : %s", keywords);
2154  }
2155  return tsk;
2156 }
2157 
2158 
2159 
2160 
2167 
2169 {
2170  // Returns kTRUE if database needs to be regenerated from source files,
2171  // i.e. if source files are more recent than DataBase.root
2172  //
2173  // In case no directory exists for dataset (dataset added 'on the fly')
2174  // we create the directory and fill it with dummy files (Makefile, Runlist.csv, Systems.dat)
2175 
2176  TString pwd = gSystem->pwd();
2177 
2178  TString path = "";
2179  if (!SearchKVFile(GetDataSetDir(), path)) {
2180  // dataset directory doesn't exist - create it
2181  Info("DataBaseNeedsUpdate", "%s: Creating new dataset directory %s",
2182  GetName(), GetDataSetDir());
2183  if (gSystem->mkdir(GetDataSetDir())) {
2184  // problem creating directory
2185  Error("DataBaseNeedsUpdate",
2186  "%s: Dataset directory %s does not exist and cannot be created ?",
2187  GetName(), GetDataSetDir());
2188  return kFALSE;
2189  }
2190  // create dummy files
2191  SearchKVFile(GetDataSetDir(), path); // get full path
2192  path += "/";
2193  TString filename = path + "Makefile";
2194  ofstream of1(filename.Data());
2195  of1 << "$(KV_WORK_DIR)/db/" << GetName() << "/DataBase.root : Runlist.csv Systems.dat" << endl;
2196  of1 << "\t@echo Database needs update" << endl;
2197  of1.close();
2198  filename = path + "Runlist.csv";
2199  ofstream of2(filename.Data());
2200  of2 << "# Automatically generated dummy Runlist.csv file" << endl;
2201  of2.close();
2202  filename = path + "Systems.dat";
2203  ofstream of3(filename.Data());
2204  of3 << "# Automatically generated dummy Systems.dat file" << endl;
2205  of3.close();
2206  }
2207  gSystem->cd(GetDataSetDir());
2208  TString cmd = "make -q";
2209  Int_t ret = gSystem->Exec(cmd.Data());
2210  gSystem->cd(pwd.Data());
2211  return (ret != 0);
2212 }
2213 
2214 
2215 
2232 
2234 {
2235  // Returns name of output repository for given task.
2236  // By default it is the name of the repository associated with this dataset,
2237  // but can be changed by the following environment variables:
2238  //
2239  // [repository].DefaultOutputRepository: [other repository]
2240  // - this means that all tasks carried out on data in [repository]
2241  // will have their output files placed in [other repository]
2242  //
2243  // [taskname].DataAnalysisTask.OutputRepository: [other repository]
2244  // - this means that for [taskname], any output files will
2245  // be placed in [other repository]
2246  //
2247  // [dataset].[taskname].DataAnalysisTask.OutputRepository: [other repository]
2248  // - this means that for given [dataset] & [taskname],
2249  // any output files will be placed in [other repository]
2250 
2251  if (gEnv->Defined(Form("%s.DataRepository.DefaultOutputRepository", GetRepository()->GetName())))
2252  return TString(gEnv->GetValue(Form("%s.DataRepository.DefaultOutputRepository", GetRepository()->GetName()), ""));
2253  TString orep = GetDataSetEnv(Form("%s.DataAnalysisTask.OutputRepository", taskname), GetRepository()->GetName());
2254  return orep;
2255 }
2256 
2257 
2258 
2259 
2262 
2263 void KVDataSet::CopyRunfilesFromRepository(const Char_t* type, const run_index_list& runs, const Char_t* destdir)
2264 {
2265  // Copies the runfiles of given "type" into the local directory "destdir".
2266 
2267  KVDataRepository* repo = GetRepository();
2268  for (auto& run : runs) {
2269  TString filename = GetRunfileName(type, run);
2270  TString destpath;
2271  AssignAndDelete(destpath, gSystem->ConcatFileName(destdir, filename));
2272  repo->CopyFileFromRepository(this, type, filename, destpath);
2273  }
2274 }
2275 
2276 
2277 
2278 
2282 
2283 void KVDataSet::CopyRunfilesToRepository(const Char_t* type, const run_index_list& runs, const Char_t* destrepo)
2284 {
2285  // Copies the runfiles of given "type" from the data repository associated
2286  // with this dataset into the local repository "destrepo".
2287 
2288  KVDataRepository* repo = GetRepository();
2289  KVDataRepository* dest_repo = gDataRepositoryManager->GetRepository(destrepo);
2290 
2291  if (!dest_repo) {
2292  Error("CopyRunfilesToRepository", "Unknown destination repository : %s", destrepo);
2293  gDataRepositoryManager->Print();
2294  return;
2295  }
2296 
2297  KVDataSet* dest_ds = dest_repo->GetDataSetManager()->GetDataSet(GetName());
2298  dest_repo->CreateAllNeededSubdirectories(dest_ds, type);
2299  for (auto& run : runs) {
2300  TString filename = GetRunfileName(type, run);
2301  TString destpath = dest_repo->GetFullPathToTransferFile(dest_ds, type, filename);
2302  repo->CopyFileFromRepository(this, type, filename, destpath);
2303  }
2304 }
2305 
2306 
int Int_t
ROOT::R::TRInterface & r
#define f(i)
bool Bool_t
char Char_t
constexpr Bool_t kFALSE
constexpr Bool_t kTRUE
const char Option_t
#define gDirectory
R__EXTERN TEnv * gEnv
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 b
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,...)
void AssignAndDelete(TString &target, char *tobedeleted)
R__EXTERN TSystem * gSystem
Handles lists of available runs for different datasets and types of data.
void GetRunInfos(const run_index_t &run, KVList &dates, KVList &names)
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)
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 Add(const run_index_t &run, const KVString &filename)
Base class for KaliVeda framework.
Definition: KVBase.h:139
static ValType GetDataSetEnv(const KVString &dataset, const KVString &type, const ValType &defval={})
Definition: KVBase.h:305
Database class used to store information on different colliding systems studied during an experiment....
Definition: KVDBSystem.h:51
Bool_t IsCollision() const
retourne kTRUE, si le systeme est une collision ie projectile+cible
Definition: KVDBSystem.cpp:128
Define and manage data analysis tasks.
virtual void SetDataAnalyser(const Char_t *d)
virtual Bool_t WithUserClass() const
virtual void SetPrereq(const Char_t *p)
virtual void SetStatusUpdateInterval(Long64_t n)
virtual const Char_t * GetUserBaseClass() const
virtual Bool_t CheckUserBaseClassIsLoaded() const
void SetExtraAClicIncludes(const KVString &list)
virtual const Char_t * GetPrereq() const
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 void CopyFileFromRepository(const KVDataSet *dataset, const Char_t *datatype, const Char_t *filename, const Char_t *destination)
void CreateAllNeededSubdirectories(const KVDataSet *DataSet, const Char_t *DataType)
virtual const Char_t * GetFullPathToTransferFile(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.
Definition: KVDataSet.h:146
std::optional< TDatime > GetRunfileDate(const KVString &type, const run_index_t &run)
Definition: KVDataSet.cpp:931
TString GetFullPathToRunfile(const KVString &type, const run_index_t &run) const
Definition: KVDataSet.cpp:887
TString GetFullPathToDB() const
Definition: KVDataSet.cpp:155
void ls(Option_t *opt="") const override
Print dataset information.
Definition: KVDataSet.cpp:412
TString GetOutputRepository(const Char_t *taskname) const
Definition: KVDataSet.cpp:2233
virtual void OpenDBFile(const Char_t *full_path_to_dbfile) const
Open the database from a file on disk.
Definition: KVDataSet.cpp:129
TString GetDBName() const
Definition: KVDataSet.cpp:114
void CheckMultiRunfiles(const Char_t *data_type)
Definition: KVDataSet.cpp:1536
Bool_t CheckRunfileAvailable(const KVString &type, const run_index_t &run)
Definition: KVDataSet.cpp:1028
void CleanRunfileDataBase(const Char_t *data_type)
Definition: KVDataSet.cpp:1653
void CheckUpToDate(const Char_t *data_type, const Char_t *other_repos)
Definition: KVDataSet.cpp:1755
run_index_list GetRunList(const Char_t *data_type, const KVDBSystem *sys=0) const
Definition: KVDataSet.cpp:1833
virtual void OpenDataBase(const TString &="") const
Definition: KVDataSet.cpp:321
TString GetFullPathToDataSetFile(const Char_t *filename) const
Definition: KVDataSet.cpp:2068
void CopyRunfilesFromRepository(const Char_t *type, const run_index_list &runs, const Char_t *destdir)
Copies the runfiles of given "type" into the local directory "destdir".
Definition: KVDataSet.cpp:2263
KVDataRepository * GetRepository() const
Get pointer to data repository in which dataset is stored.
Definition: KVDataSet.cpp:1522
run_index_list GetRunList_DateSelection(const TString &type, const KVUnownedList &systems, std::optional< KVDatime > min_date=std::nullopt, std::optional< KVDatime > max_date=std::nullopt)
Definition: KVDataSet.cpp:1237
const Char_t * GetDataSetDir() const
Definition: KVDataSet.cpp:763
void CommitRunfile(const KVString &type, const run_index_t &run, TFile *file)
Definition: KVDataSet.cpp:1435
virtual void AddAvailableDataType(const Char_t *)
Definition: KVDataSet.cpp:525
KVUniqueNameList GetSystemsForRunFiles(const TString &datatype, const run_index_list &) const
Definition: KVDataSet.cpp:690
bool make_analysis_class(const KVDataAnalysisTask *, const Char_t *classname)
Definition: KVDataSet.cpp:1924
KVDataAnalysisTask * GetAnalysisTask(Int_t) const
Definition: KVDataSet.cpp:591
KVAvailableRunsFile * GetAvailableRunsFile(const TString &type) const
Definition: KVDataSet.cpp:51
virtual void SaveDataBase() const
Definition: KVDataSet.cpp:205
virtual KVDataAnalysisTask * GetAnalysisTaskAny(const Char_t *keywords) const
Definition: KVDataSet.cpp:2141
virtual TString GetBaseFileName(const Char_t *type, const run_index_t &run) const
Definition: KVDataSet.cpp:1061
virtual void SetAnalysisTasks(const KVSeqCollection *)
Definition: KVDataSet.cpp:542
TFile * NewRunfile(const KVString &type, const run_index_t &run)
Definition: KVDataSet.cpp:1134
KVList GetListOfAvailableRunFilesForSystem(const TString &datatype, KVDBSystem *systol)
Definition: KVDataSet.cpp:646
Bool_t CheckRunfileUpToDate(const KVString &data_type, const run_index_t &run, KVDataRepository *other_repos)
Definition: KVDataSet.cpp:1695
virtual void CheckAvailable()
Definition: KVDataSet.cpp:478
void DeleteRunfile(const KVString &type, const run_index_t &run, Bool_t confirm=kTRUE)
Definition: KVDataSet.cpp:1159
virtual Int_t GetNtasks() const
Definition: KVDataSet.cpp:576
run_index_list GetRunList_VersionSelection(const TString &type, const TString &version, KVDBSystem *sys=0)
Definition: KVDataSet.cpp:1393
KVExpDB * GetDataBase(const TString &opt="") const
Definition: KVDataSet.cpp:290
void DeleteRunfiles(const Char_t *type, const run_index_list &lrun={}, Bool_t confirm=kTRUE)
Definition: KVDataSet.cpp:1206
TObject * open_runfile(const KVString &type, const run_index_t &run)
Definition: KVDataSet.cpp:835
void CopyRunfilesToRepository(const Char_t *type, const run_index_list &runs, const Char_t *destrepo)
Definition: KVDataSet.cpp:2283
KVString GetRunfileName(const KVString &type, const run_index_t &run) const
Definition: KVDataSet.cpp:907
virtual Bool_t DataBaseNeedsUpdate() const
Definition: KVDataSet.cpp:2168
Bool_t OpenDataSetFile(const Char_t *filename, std::ifstream &file)
void SetDataSetSpecificTaskParameters(KVDataAnalysisTask *) const
Check configuration variables to see if the task parameters have been "tweaked" for the dataset.
Definition: KVDataSet.cpp:180
run_index_list GetRunList_StageSelection(const TString &other_type, const TString &base_type, KVDBSystem *sys=0, Bool_t OnlyCol=kFALSE)
Definition: KVDataSet.cpp:1291
void cd() const
Definition: KVDataSet.cpp:785
virtual void WriteDBFile(const Char_t *full_path_to_dbfile) const
Write the database to disk.
Definition: KVDataSet.cpp:257
void Print(Option_t *opt="") const override
Definition: KVDataSet.cpp:435
void SetName(const char *name) override
Definition: KVDataSet.cpp:725
virtual Bool_t CheckUserCanAccess()
Definition: KVDataSet.cpp:1479
void UpdateAvailableRuns(const KVString &type)
Definition: KVDataSet.cpp:1105
run_index_list GetUpdatableRuns(const Char_t *data_type, const Char_t *other_repos)
Definition: KVDataSet.cpp:1798
void SetRepository(KVDataRepository *)
Set pointer to data repository in which dataset is stored.
Definition: KVDataSet.cpp:1510
bool MakeAnalysisClass(const Char_t *task, const Char_t *classname)
Definition: KVDataSet.cpp:1971
KVDataSet()
Default constructor.
Definition: KVDataSet.cpp:35
std::optional< run_index_t > GetRunNumberFromFileName(const TString &datatype, const TString &filename)
Definition: KVDataSet.cpp:980
void CleanMultiRunfiles(const Char_t *data_type, Bool_t confirm=kTRUE)
Definition: KVDataSet.cpp:1582
static Bool_t FindDataSetFile(const TString &dataset, const Char_t *filename)
Definition: KVDataSet.cpp:2105
KVUnownedList GetListOfAvailableSystems(const TString &datatype)
Definition: KVDataSet.cpp:606
TString GetDBFileName() const
Definition: KVDataSet.cpp:84
Extension of TDatime to handle various useful date formats.
Definition: KVDatime.h:33
Base class to describe database of an experiment ,,.
Definition: KVExpDB.h:61
virtual void cd()
Definition: KVExpDB.cpp:762
static KVExpDB * MakeDataBase(const Char_t *name, const Char_t *datasetdir, Bool_t minimal=false)
Definition: KVExpDB.cpp:783
Extended TList class which owns its objects by default.
Definition: KVList.h:22
Description of an individual data file in an experimental dataset.
Definition: KVRunFile.h:19
const Char_t * GetVersion() const
Definition: KVRunFile.h:84
const run_index_t & GetRunIndex() const
Definition: KVRunFile.h:56
KaliVeda extensions to ROOT collection classes.
TObject * At(Int_t idx) const override
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
static TClass * GetClass(Bool_t load=kTRUE, Bool_t silent=kFALSE)
virtual Int_t GetEntries() const
Bool_t Contains(const char *name) const
const char * AsSQLString() const
virtual Bool_t cd()
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
virtual void SetTitle(const char *title="")
const char * GetName() const override
const char * GetTitle() const override
virtual void SetName(const char *name)
TString & String()
const char * Data() const
void ToUpper()
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)
const char * pwd()
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)
List of runfiles specified by run number and file index ,.
Int_t GetEntries() const
void Add(const run_index_t &r)
Specifies a runfile according to run number and file index ,.
Definition: run_index.h:31
int run() const
Definition: run_index.h:50
TString as_string() const
Definition: run_index.h:95
int index(int no_index=-1) const
Definition: run_index.h:55
bool has_index() const
Definition: run_index.h:59
const Int_t n
void Error(const char *location, const char *fmt,...)
void Info(const char *location, const char *fmt,...)
void Warning(const char *location, const char *fmt,...)
void update(const LAYERDATA &prevLayerData, LAYERDATA &currLayerData, double factorWeightDecay, EnumRegularization regularization)
const char * String
v
TArc a
ClassImp(TPyArg)