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