KaliVeda
Toolkit for HIC analysis
KVAvailableRunsFile.cpp
1 /*
2 $Id: KVAvailableRunsFile.cpp,v 1.18 2009/03/12 14:01:02 franklan Exp $
3 $Revision: 1.18 $
4 $Date: 2009/03/12 14:01:02 $
5 */
6 
7 //Created by KVClassFactory on Fri May 5 10:46:40 2006
8 //Author: franklan
9 
10 #include "KVAvailableRunsFile.h"
11 #include "KVDBRun.h"
12 #include "TObjArray.h"
13 #include "TObjString.h"
14 #include "KVString.h"
15 #include "KVList.h"
16 #include "KVDataRepository.h"
17 #include "KVRunFile.h"
18 
19 //macro converting octal filemode to decimal value
20 //to convert e.g. 664 (=u+rw, g+rw, o+r) use CHMODE(6,6,4)
21 #define CHMODE(u,g,o) ((u << 6) + (g << 3) + o)
22 
23 using namespace std;
24 
26 
28 
29 
30 
34  const KVDataSet* parent): KVBase(type)
35 {
36  //Constructor with name of datatype and pointer to dataset to which this file belongs
37  fDataSet = parent;
38  //runlist lockfile
39  runlist_lock.SetTimeout(60); // 60-second timeout in case of problems
40  runlist_lock.SetSuspend(5); // suspension after timeout
41  runlist_lock.SetSleeptime(1); // try lock every second
42 
43  fAvailableRuns = 0;
44 }
45 
46 
47 
51 
53 {
54  //Constructor with name of datatype
55  //Dataset must be set straight away with SetDataSet(KVDataSet*)
56  fDataSet = 0;
57  //runlist lockfile
58  runlist_lock.SetTimeout(60); // 60-second timeout in case of problems
59  runlist_lock.SetSuspend(5); // suspension after timeout
60  runlist_lock.SetSleeptime(1); // try lock every second
61 
62  fAvailableRuns = 0;
63 }
64 
65 
66 
69 
71 {
72  //Default ctor
73  fDataSet = 0;
74  //runlist lockfile
75  runlist_lock.SetTimeout(60); // 60-second timeout in case of problems
76  runlist_lock.SetSuspend(5); // suspension after timeout
77  runlist_lock.SetSleeptime(1); // try lock every second
78 
79  fAvailableRuns = 0;
80 }
81 
82 
83 
87 
88 KVAvailableRunsFile::~KVAvailableRunsFile()
89 {
90  //Destructor
91  //cout << "KVAvailableRunsFile::~KVAvailableRunsFile()" << endl;
93 }
94 
95 
96 
97 
104 
106 {
107  // Filename of text file containing information on available runs
108  // i.e. [repository].available_runs.[dataset subdir].[dattype subdir]
109  //
110  // If [dataset subdir] contains "/" (i.e. if data is grouped into subdirectories)
111  // we replace them by "_"
112 
113  static TString filename;
114  if (!fDataSet) {
115  Error("GetFileName", "Dataset has not been set for this file.");
116  filename = "";
117  }
118  else {
119  KVString datapath = fDataSet->GetDataPathSubdir();
120  datapath.ReplaceAll("/", "_");
121  filename.Form("%s.available_runs.%s.%s", fDataSet->GetRepository()->GetName(), datapath.Data(),
123  }
124  return filename.Data();
125 }
126 
127 
128 
143 
145 {
146  // Returns the full path to the directory where the available runs file is stored.
147  // This is by default the same directory where the dataset files are stored.
148  // However, if KaliVeda was installed using a GNU-style directory layout
149  // (possibly in the system directories, e.g. Ubuntu packages)
150  // then the path will be the user's working directory + dataset name
151  //
152  // Alternatively, by setting the config variable
153  // KVAvailableRunsFile.RunFileDirectory: /some/path
154  //
155  // files will be stored/looked for in
156  // /some/path/[dataset]
157  //
158  // You can use environment variables - $(VAR) - in the path
159 
160  static TString filepath;
161  if (!fDataSet) {
162  Error("GetFilePath", "Dataset has not been set for this file.");
163  filepath = "";
164  }
165  else {
166  TString p = gEnv->GetValue("KVAvailableRunsFile.RunFileDirectory", "");
167  if (p == "") {
168  // no user-defined run file directory
169  if (is_gnuinstall()) {
170  // GNU-style install: use working directory
171  filepath = GetWORKDIRFilePath(fDataSet->GetName());
172  }
173  else
174  filepath = fDataSet->GetDataSetDir();
175  }
176  else {
178  AssignAndDelete(filepath, gSystem->ConcatFileName(p.Data(), fDataSet->GetName()));
179  }
180  }
181  return filepath.Data();
182 }
183 
184 
185 
189 
191 {
192  // Return the full path on the local machine to the text file
193  // used to store information on available runs
194 
195  static TString path;
197  return path.Data();
198 }
199 
200 
201 
206 
208 {
209  // Check that the directory given by GetFilePath() exists and is writable
210  // If it does not exist, it will be created if possible
211  // If it exists but is not writable, or cannot be created, returns kFALSE.
212 
213  if (gSystem->AccessPathName(GetFilePath(), kFileExists)) { // directory does not exist
214  if (gSystem->mkdir(GetFilePath(), kTRUE) == -1) {
215  Error("CheckDirectoryForAvailableRunsFile", "cannot create directory %s - check access permissions", GetFilePath());
216  return kFALSE;
217  }
218  // set access permissions on created directory
219  gSystem->Chmod(GetFilePath(), CHMODE(7, 7, 5));
220  }
221  if (gSystem->AccessPathName(GetFilePath(), kWritePermission)) { // directory is not writable
222  Error("CheckDirectoryForAvailableRunsFile", "directory %s is not writable - check access permissions", GetFilePath());
223  return kFALSE;
224  }
225  return kTRUE;
226 }
227 
228 
229 
230 
244 
246 {
247  // This method tests the string given as 'filename' to see if it could be the name of a runfile
248  // of the datatype of this available runs file (GetDataType()), for its parent dataset, fDataSet.
249  // Any protocol and/or path information in the filename is first removed.
250  //
251  // The format for a given dataset is defined by variable
252  //
253  // [dataset].DataSet.RunFileName.[datatype]: [format]
254  //
255  // If this format contains an index ("%I" field) then you must also define the multiplier
256  // used to generate effective run numbers: run = run_number*multiplier+index:
257  //
258  // [dataset].DataSet.RunFileIndexMultiplier.[datatype]: [integer]
259 
260  TString fmt = fDataSet->GetDataSetEnv(Form("DataSet.RunFileName.%s", GetDataType()), ""); //get format string for current dataset
261  if (fmt == "") {
262  Error("IsRunFileName", "No default format set for datatype: %s",
263  GetDataType());
264  return 0;
265  }
266  int imult = fDataSet->GetDataSetEnv(Form("DataSet.RunFileIndexMultiplier.%s", GetDataType()), -1.0);
267  if (fmt.Contains("%I") && (imult < 0)) {
268  Error("IsRunFileName", "No index multiplier set for datatype: %s with format: %s",
269  GetDataType(), fmt.Data());
270  return 0;
271  }
272  return IsRunFileName(fmt, filename, imult);
273 }
274 
275 
276 
312 
313 Int_t KVAvailableRunsFile::IsRunFileName(const KVString& fmt, const Char_t* filename, Int_t index_multiplier, const Char_t* separators)
314 {
315  // This method tests the string given as 'filename' to see if it could be the name of a runfile.
316  // Any protocol and/or path information in the filename is first removed.
317  // The decision as to whether the filename is valid or not is based on whether it corresponds
318  // to the given format string, e.g. run_%04d.dat
319  // If good, we return the run number for the file (may be an effective run number in case
320  // of files with an index; see below)
321  // If not, we return 0.
322  //
323  // KNOWN CASES:
324  //
325  // dataset example filename format
326  // ======= ================ =====================
327  // INDRA_camp1 run127.raw run%R.raw
328  // INDRA_camp2 run127.raw run%R.raw
329  // INDRA_camp4 run127.raw run%R.raw
330  // INDRA_camp5 run127.raw run%R.raw
331  // INDRA_e416a Run356_06-Oct-05_12_44_12.dat Run%R_%D.dat
332  // INDRA_e475s run_0085.dat.13-Mar-06.12:46:24 run_%R.dat.%D1.%D2
333  // INDRA_e494s run_0026.dat.04-May-07.20:33:00 run_%R.dat.%D1.%D2
334  // INDRA_e503 run_0026.dat.04-May-07.20:33:00 run_%R.dat.%D1.%D2
335  // INDRA_e613 run_0022.dat.08Sep11_00h54m47s run_%R.dat.%D
336  // INDRAFAZIA.E789 run_0017.dat.04-04-19_08h25m57s.1 run_%R.dat.%D.%I
337  // FAZIA* run000345 run%R
338  //
339  // %R : run number
340  // %D : date and time
341  // %D1.%D2 : date and time separated by '.'
342  // %I : file index number. WARNING: the first file has NO index, the
343  // second file has index '1', etc. In this case the index_multiplier
344  // will be used to generate (and return) an effective run number,
345  // given by index_multiplier*run + index
346  //
347  // The filename will be broken up according to the separators (default: ".")
348  // Then the different parts will be analysed according to the given format string
349 
350  KVString _file(gSystem->BaseName(filename)); //Remove protocol and/or path
351 
352  // the filename should contain the same number of "."-separated parts as the format
353  // string, unless the format contains "%I", in which case it can have one less part
354  // (case of first file for run with no index)
355  int np_fmt = fmt.GetNValues(separators);
356  bool with_index = fmt.Contains("%I");
357  bool two_part_date = false;
358  bool got_date = false;
359  int np_fn = _file.GetNValues(separators);
361 
362  if (np_fmt == np_fn || (with_index && np_fn == np_fmt - 1)) {
363  _file.Begin(separators);
364  fmt.Begin(separators);
365  int index(0), run(0);
366  char date1[100], date2[100];
367  if (fmt.Contains("%D1") && fmt.Contains("%D2")) two_part_date = true;
368 
369  while (!_file.End()) {
370  KVString run_part = _file.Next();
371  KVString fmt_part = fmt.Next();
372 
373  if (fmt_part.Contains("%R")) {
374  fmt_part.ReplaceAll("%R", "%d");
375  if (fmt_part.Contains("%D")) {
376  fmt_part.ReplaceAll("%D", "%s");
377  sscanf(run_part.Data(), fmt_part.Data(), &run, date1);
378  got_date = true;
379  }
380  else
381  sscanf(run_part.Data(), fmt_part.Data(), &run);
382  }
383  else if (fmt_part.Contains("%I")) {
384  fmt_part.ReplaceAll("%I", "%d");
385  sscanf(run_part.Data(), fmt_part.Data(), &index);
386  }
387  else if (fmt_part.Contains("%D1")) {
388  fmt_part.ReplaceAll("%D1", "%s");
389  sscanf(run_part.Data(), fmt_part.Data(), date1);
390  got_date = true;
391  }
392  else if (fmt_part.Contains("%D2")) {
393  fmt_part.ReplaceAll("%D2", "%s");
394  sscanf(run_part.Data(), fmt_part.Data(), date2);
395  got_date = true;
396  }
397  else if (fmt_part.Contains("%D")) {
398  fmt_part.ReplaceAll("%D", "%s");
399  sscanf(run_part.Data(), fmt_part.Data(), date1);
400  got_date = true;
401  }
402  }
403  if (with_index) run = index_multiplier * run + index;
404  if (got_date) {
405  if (two_part_date) date_read_from_filename.Form("%s.%s", date1, date2);
406  else date_read_from_filename = date1;
407  }
408  return run;
409  }
410 // else {
411 // ::Warning("KVAvailableRunsFile::IsRunFileName",
412 // "%s is not a runfile name according to format %s [separators: %s]",
413 // _file.Data(), fmt.Data(), separators);
414 // }
415  return 0;
416 }
417 
418 
419 
420 
427 
429 {
430  // We assume that 'name' is the name of a run of the type of this available runs file
431  // (see KVAvailableRunsFile::IsRunFileName for accepted formats for runfile names with dates).
432  // We attempt several methods to try to extract a date from 'name'.
433  // If successful, we return kTRUE and 'date' contains the result.
434 
435  //get format string for current dataset
436  TString fmt =
437  fDataSet->
438  GetDataSetEnv(Form("DataSet.RunFileName.%s", GetDataType()));
439  return ExtractDateFromFileName(fmt, name, date);
440 }
441 
442 
443 
449 
451 {
452  // We assume that 'name' is the name of a runfile according to given format 'fmt'.
453  // (see KVAvailableRunsFile::IsRunFileName for accepted formats for runfile names with dates).
454  // We attempt several methods to try to extract a date from 'name'.
455  // If successful, we return kTRUE and 'date' contains the result.
456 
457  Int_t run = IsRunFileName(fmt, name);
458  if (!run) return kFALSE;
459  // if runfile name contains a date, it is now in variable date_read_from_filename
460  if (date_read_from_filename == "") return kFALSE;
465  return kTRUE;
466  }
467  else {
471  return kTRUE;
472  }
475  return kTRUE;
476  }
479  return kTRUE;
480  }
481  }
482  return kFALSE;
483 }
484 
485 
486 
487 
499 
500 void KVAvailableRunsFile::Update(Bool_t no_existing_file)
501 {
502  // Examine the contents of the repository directory corresponding to this datatype
503  // for parent dataset fDataSet.
504  // For each file found which was not already in the list of available runs and
505  // which corresponds to a run in the database gDataBase,
506  // we add an entry to the available runlist file:
507  // [run number]|[date of modification]|[name of file]
508  // For "old" runs we keep the existing informations (including KV version & username)
509  //
510  // When no_existing_file=kTRUE we are making an available runs file
511  // for the first time. There is no pre-existing file.
512 
513 
515 
516  if (!no_existing_file) {
517  // read all existing informations
518  ReadFile();
519  //use "lockfile" to make sure nobody else tries to modify available_runs file
520  //while we are working on it
521  if (!runlist_lock.Lock(runlist.Data())) return;
522  }
523  //open temporary file
524  TString tmp_file_path(GetFileName());
525  ofstream tmp_file;
526  KVBase::OpenTempFile(tmp_file_path, tmp_file);
527 
528  KVDataRepository* repository = fDataSet->GetRepository();
529 
530  cout << endl << "Updating runlist : " << flush;
531  //get directory listing from repository
532  KVUniqueNameList* dir_list =
533  repository->GetDirectoryListing(fDataSet, GetDataType());
534  if (!dir_list)
535  return;
536 
537  TIter next(dir_list);
538  KVBase* objs;
539  //progress bar
540  Int_t ntot = dir_list->GetSize();
541  Int_t n5pc = TMath::Max(ntot / 20, 1);
542  Int_t ndone = 0;
543  unique_ptr<KVExpDB> db_garbage;
544  KVExpDB* db = fDataSet->GetDataBase();
545  if (!db) {
546  db = new KVExpDB();
547  db_garbage.reset(db);//clean up
548  }
549  while ((objs = (KVBase*) next())) { // loop over all entries in directory
550 
551  Int_t run_num;
552  //is this the correct name of a run in the repository ?
553  if ((run_num = IsRunFileName(objs->GetName()))) {
554 
555  KVDBRun* run = db->GetDBRun(run_num);
556  if (run) {
557  FileStat_t fs;
558  //get file modification date
559  if (repository->
560  GetFileInfo(fDataSet, GetDataType(),
561  objs->GetName(), fs)) {
562  //runfile exists in repository
563  TDatime modt(fs.fMtime);
564  if (!no_existing_file) {
565  // was there already an entry for exactly the same file in the previous file ?
566  Int_t occIdx = 0;
567  KVNameValueList* prevEntry = RunHasFileWithDateAndName(run->GetNumber(), objs->GetName(), modt, occIdx);
568  if (prevEntry) {
569  // copy infos of previous entry
570  tmp_file << run->GetNumber() << '|' << modt.AsSQLString() << '|' << objs->GetName();
571  if (prevEntry->HasParameter(Form("KVVersion[%d]", occIdx))) {
572  tmp_file << "|" << prevEntry->GetStringValue(Form("KVVersion[%d]", occIdx)) << "|" << prevEntry->GetStringValue(Form("Username[%d]", occIdx));
573  }
574  tmp_file << endl;
575  }
576  else {
577  // New Entry - write in temporary runlist file '[run number]|[date of modification]|[name of file]
578  tmp_file << run->GetNumber() << '|' << modt.AsSQLString() << '|' << objs->GetName() << endl;
579  }
580  }
581  else { // no previous existing file
582  // New Entry in a new file - write in temporary runlist file '[run number]|[date of modification]|[name of file]
583  tmp_file << run->GetNumber() << '|' << modt.AsSQLString() << '|' << objs->GetName() << endl;
584  }
585  }
586  }
587  else {
588  Info("Update", "the current run [%s] is not in database", objs->GetName());
589  FileStat_t fs;
590  if (repository->GetFileInfo(fDataSet, GetDataType(), objs->GetName(), fs)) {
591  TDatime modt(fs.fMtime);
592  // New Entry in a new file - write in temporary runlist file '[run number]|[date of modification]|[name of file]
593  tmp_file << run_num << '|' << modt.AsSQLString() << '|' << objs->GetName() << endl;
594  }
595  else {
596  Warning("Update", "%s GetFileInfo return kFALSE", objs->GetName());
597  }
598  }
599  }
600 
601  ndone++;
602  if (!(ndone % n5pc))
603  cout << '>' << flush;
604  }
605 
606  cout << " DONE" << endl;
607  delete dir_list;
608  //close temp file
609  tmp_file.close();
610 
611  if (CheckDirectoryForAvailableRunsFile()) {
612 
613  if (no_existing_file) {
614  //use "lockfile" to make sure nobody else tries to modify available_runs file
615  //while we are working on it
616  if (!runlist_lock.Lock(runlist.Data())) return;
617  }
618 
619  //copy temporary file to available runs file directory, overwrite previous
620  gSystem->CopyFile(tmp_file_path, runlist, kTRUE);
621  //set access permissions to 664
622  gSystem->Chmod(runlist.Data(), CHMODE(6, 6, 4));
623  }
624 
625  //remove lockfile
626  runlist_lock.Release();
627 
628  //delete temp file
629  gSystem->Unlink(tmp_file_path);
630 }
631 
632 
633 
634 
641 
642 Bool_t KVAvailableRunsFile::GetRunInfo(Int_t run, TDatime& modtime,
643  TString& filename)
644 {
645  //Look for a given run number in the file, and read the file's modification date/time and filename
646  //If run not found, returns kFALSE
647  //If available runs file does not exist, Update() is called to create it.
648  //If there are multiple versions of the same run (abnormal situation),
649  //we print a warning and give info on the most recent file.
650 
651  KVList filenames, dates;
652  //get infos for all versions of run
653  GetRunInfos(run, &dates, &filenames);
654  if (filenames.GetEntries() == 1) { //only one version
655  filename = ((TObjString*) filenames.First())->String();
656  modtime = ((TObjString*) dates.First())->String().Data();
657  return kTRUE;
658  }
659  else if (filenames.GetEntries() > 1) { //several versions
660  Warning("GetRunInfo",
661  "Multiple versions of this runfile exist in the repository. Infos for most recent file will be returned.");
662  Warning("GetRunInfo",
663  "You should clean the repository using KVDataSet::CleanMultiRunfiles.");
664  //find most recent version
665  TDatime most_recent("1998-12-25 00:00:00");
666  Int_t i_most_recent = 0;
667  for (int i = 0; i < dates.GetEntries(); i++) {
668  //check if run is most recent
669  TDatime rundate(((TObjString*) dates.At(i))->String().Data());
670  if (rundate > most_recent) {
671  most_recent = rundate;
672  i_most_recent = i;
673  }
674  }
675  filename = ((TObjString*) filenames.At(i_most_recent))->String();
676  modtime = ((TObjString*) dates.At(i_most_recent))->String().Data();
677  return kTRUE;
678  }
679  return kFALSE;
680 }
681 
682 
683 
684 
693 
695  KVList* files)
696 {
697  //Look for a given run number in the file, and read the file's modification date/time and filename
698  //These informations are stored in the two TList as TObjString objects (these objects belong to the
699  //lists and will be deleted by them).
700  //We do not stop at the first run found, but continue until the end of the file, adding
701  //informations for every occurence of the run in the file.
702  //If available runs file does not exist, Update() is called to create it.
703 
704  //does runlist exist ?
705  if (!OpenAvailableRunsFile()) {
706  Error("GetRunInfos", "Error opening available runs file");
707  return;
708  }
709  //clear lists - delete objects
710  dates->Delete();
711  files->Delete();
712 
713  //loop over lines in fRunlist file
714  //look for line beginning with 'run|'
715  TString line;
716  line.ReadLine(fRunlist);
717  while (fRunlist.good()) {
718  if (line.BeginsWith(Form("%d|", run))) {
719 
720  //found it
721  unique_ptr<TObjArray> toks(line.Tokenize('|')); // split into fields
722  // check date is not identical to a previous entry
723  // i.e. there are spurious duplicate entries
724  TObjString* rundate = (TObjString*)toks->At(1)->Clone();
725  if (dates->FindObject(rundate->GetName())) {
726  delete rundate;
727  line.ReadLine(fRunlist);
728  continue;
729  }
730  //add date string
731  dates->Add(toks->At(1)->Clone());
732  //add filename
733  files->Add(toks->At(2)->Clone());
734  }
735  line.ReadLine(fRunlist);
736  }
738 }
739 
740 
741 
742 
748 
750 {
751  //Look for a given run number in the file
752  //If run not found, returns kFALSE
753  //If available runs file does not exist, Update() is called to create it.
754 
755  //does runlist exist ?
756  if (!OpenAvailableRunsFile()) {
757  Error("CheckAvailable", "Error opening available runs file");
758  return kFALSE;
759  }
760  //loop over lines in runlist file
761  //look for line beginning with 'run|'
762  Bool_t found = kFALSE;
763  TString line;
764  line.ReadLine(fRunlist);
765  while (fRunlist.good()) {
766  if (line.BeginsWith(Form("%d|", run))) {
768  return kTRUE;
769  }
770  line.ReadLine(fRunlist);
771  }
773  return found;
774 }
775 
776 
777 
778 
800 
802 {
803  //Count the number of times a given run number appears in the file
804  //If available runs file does not exist, Update() is called to create it.
805 
806 // //does runlist exist ?
807 // if (!OpenAvailableRunsFile()) {
808 // Error("Count", "Error opening available runs file");
809 // return 0;
810 // }
811 // //loop over lines in runlist file
812 // //look for line beginning with 'run|'
813 // TString line;
814 // Int_t occurs = 0;
815 // line.ReadLine(fRunlist);
816 // while (fRunlist.good()) {
817 // if (line.BeginsWith(Form("%d|", run))) {
818 // occurs++;
819 // }
820 // line.ReadLine(fRunlist);
821 // }
822 // CloseAvailableRunsFile();
823 // return occurs;
824  ReadFile();
826  if (nvlrun) return nvlrun->GetIntValue("Occurs");
827  return 0;
828 }
829 
830 
831 
832 
836 
838 {
839  //Read from available runs list the name of the file used for this run
840  //If run is not available, filename will be empty
841 
842  static TString fname;
843  static TDatime dtime;
844  if (GetRunInfo(run, dtime, fname)) {
845  return fname.Data();
846  }
847 
848  fname = "";
849  return fname.Data();
850 }
851 
852 
853 
854 
866 
868  systol)
869 {
870  //Create and fill a sorted list of available systems based on the runs in the available runs file.
871  //If systol!=0 then create and fill a list of available runs (KVRunFile objects) for the given system.
872  //USER MUST DELETE THE LIST AFTER USE.
873  // N.B. in case of list of KVRunFile, the list is the owner of the objects and will
874  // destroy them when it is destroyed
875  //
876  //For each system in the list we set the number of available runs : this number
877  //can be retrieved with KVDBSystem::GetNumberRuns()
878  //
879  //If available runs file does not exist, Update() is called to create it.
880 
881  ReadFile(); // this will sanitize the file if necessary (remove duplicates)
882 
883  //does runlist exist ?
884  if (!OpenAvailableRunsFile()) {
885  Error("GetListOfAvailableSystems",
886  "Error opening available runs file");
887  return 0;
888  }
889 
890  TString fLine;
891  TList* sys_list = 0;
892  Int_t good_lines = 0;
893  fLine.ReadLine(fRunlist);
894 
895  Int_t fRunNumber;
896  TDatime fDatime;
897  TString kvversion, username, filename;
898  KVExpDB* db = fDataSet->GetDataBase();
899  unique_ptr<KVExpDB> garbage_db;
900  if (!db) {
901  db = new KVExpDB;
902  garbage_db.reset(db);//clean up
903  }
904 
905  while (fRunlist.good()) {
906 
907  unique_ptr<TObjArray> toks(fLine.Tokenize('|')); // split into fields
908  if (toks->GetSize()) {
909 
910  KVString kvs(((TObjString*) toks->At(0))->GetString());
911 
912  if (kvs.IsDigit()) {
913 
914  good_lines++;
915 
916  fRunNumber = kvs.Atoi();
917  kvversion = username = "";
918  TString tmp = ((TObjString*) toks->At(1))->GetString();
919  fDatime = TDatime(tmp.Data());
920  filename = ((TObjString*) toks->At(2))->String();
921 
922  if (toks->GetEntries() > 3) {
923  kvversion = ((TObjString*) toks->At(3))->GetString();
924  username = ((TObjString*) toks->At(4))->GetString();
925  }
926 
927  KVDBRun* a_run = db->GetDBRun(fRunNumber);
928 
929  KVDBSystem* sys = 0;
930  if (a_run) {
931  sys = a_run->GetSystem();
932  }
933  if (!systol) {
934  //making a systems list
935  if (!sys_list)
936  sys_list = new TList;
937  if (sys) {
938 
939  a_run->SetDatime(fDatime);
940  a_run->SetKVVersion(kvversion);
941  a_run->SetUserName(username);
942 
943  if (!sys_list->Contains(sys)) {
944  //new system
945  sys_list->Add(sys);
946  sys->SetNumberRuns(1); //set run count to 1
947  }
948  else {
949  //another run for this system
950  sys->SetNumberRuns(sys->GetNumberRuns() + 1);
951  }
952  }
953  }
954  else {
955  //making a runlist
956  if (systol == sys) { //run belongs to same system
957  if (!sys_list) {
958  sys_list = new TList;
959  sys_list->SetOwner(kTRUE);//will delete objects
960  }
961  if (IsCalled("raw")) {
962  // for raw data files, use the actual date/time of the start of data taking in the database
963  TString start_date = a_run->GetStartDate();
964  if (start_date != "") fDatime.Set(start_date);
965  }
966  sys_list->Add(new KVRunFile(a_run, filename, fDatime, kvversion, username));
967  }
968  }
969  }
970  }
971  fLine.ReadLine(fRunlist);
972  }
973 
974  //sort list of systems in order of increasing run number
975  //sort list of runs in order of increasing run number
976  if (sys_list && sys_list->GetSize() > 1)
977  sys_list->Sort();
978 
979  if (!good_lines) {
980  Error("GetListOfAvailableSystems",
981  "Available runs file is empty or absent");
982  }
984  return sys_list;
985 
986 }
987 
988 
989 
995 
996 void KVAvailableRunsFile::UpdateInfos(Int_t run, const Char_t* filename, const Char_t* kvversion, const Char_t* username)
997 {
998  // Call this mehod to update informations on the file "filename" corresponding to run,
999  // by adding/replacing the KV version and username read from the file itself (not necessarily
1000  // corresponding to current KV version and username)
1001 
1002  //does runlist exist ?
1003  if (!OpenAvailableRunsFile()) {
1004  Error("UpdateInfos", "Error opening available runs file");
1005  return;
1006  }
1007  //open temporary file
1008  TString tmp_file_path(GetFileName());
1009  ofstream tmp_file;
1010  KVBase::OpenTempFile(tmp_file_path, tmp_file);
1011 
1012  TString FileName(filename);
1013  //loop over lines in fRunlist file
1014  //all lines which do not begin with 'run'| are directly copied to temp file
1015  TString line;
1016  line.ReadLine(fRunlist);
1017  while (fRunlist.good()) {
1018  //filename was specified: we copy everything up to the line
1019  //with the right filename & number
1020  if (line.BeginsWith(Form("%d|", run))) {
1021 
1022  unique_ptr<TObjArray> toks(line.Tokenize('|')); // split into fields
1023  TString ReadFileName = ((TObjString*) toks->At(2))->String();
1024 
1025  if (ReadFileName != FileName) {
1026  //copy line
1027  tmp_file << line.Data() << endl;
1028  }
1029  else {
1030  // replace existing infos
1031  tmp_file << run << "|" << ((TObjString*) toks->At(1))->String() << "|" << filename << "|" << kvversion << "|" << username << endl;
1032  }
1033 
1034  }
1035  else {
1036  //copy line
1037  tmp_file << line.Data() << endl;
1038  }
1039  line.ReadLine(fRunlist);
1040  }
1041 
1043  TString fRunlist_path = GetFullPathToAvailableRunsFile();
1044 
1045  //keep lock on runsfile
1046  if (!runlist_lock.Lock(fRunlist_path.Data())) return;
1047 
1048  //close temp file
1049  tmp_file.close();
1050 
1051  //copy temporary file to KVFiles directory, overwrite previous
1052  gSystem->CopyFile(tmp_file_path, fRunlist_path, kTRUE);
1053  //set access permissions to 664
1054  gSystem->Chmod(fRunlist_path.Data(), CHMODE(6, 6, 4));
1055  //delete temp file
1056  gSystem->Unlink(tmp_file_path);
1057  //unlock runsfile
1059 }
1060 
1061 
1062 
1069 
1070 void KVAvailableRunsFile::Remove(Int_t run, const Char_t* filename)
1071 {
1072  //Remove from the file the entry corresponding to this run
1073  //By default, the first occurrence of the run number in the file will be removed.
1074  //If "filename" is given, we look for a line corresponding to both the run number
1075  //and the filename (important if run appears more than once !!!) ;-)
1076 
1077  //does runlist exist ?
1078  if (!OpenAvailableRunsFile()) {
1079  Error("Remove", "Error opening available runs file");
1080  return;
1081  }
1082  //open temporary file
1083  TString tmp_file_path(GetFileName());
1084  ofstream tmp_file;
1085  KVBase::OpenTempFile(tmp_file_path, tmp_file);
1086 
1087  TString FileName(filename);
1088  Bool_t withFileName = (FileName != "");
1089  //loop over lines in fRunlist file
1090  //all lines which do not begin with 'run'| are directly copied to temp file
1091  TString line;
1092  line.ReadLine(fRunlist);
1093  while (fRunlist.good()) {
1094  if (!withFileName) {
1095  //filename not specified : we copy everything up to the first line
1096  //which begins with the run number we want
1097  if (!line.BeginsWith(Form("%d|", run))) {
1098  //copy line
1099  tmp_file << line.Data() << endl;
1100  }
1101  }
1102  else {
1103  //filename was specified: we copy everything up to the line
1104  //with the right filename & number
1105  if (line.BeginsWith(Form("%d|", run))) {
1106 
1107  unique_ptr<TObjArray> toks(line.Tokenize('|')); // split into fields
1108  TString ReadFileName;
1109  ReadFileName = ((TObjString*) toks->At(2))->String();
1110 
1111  if (ReadFileName != FileName) {
1112  //copy line
1113  tmp_file << line.Data() << endl;
1114  }
1115 
1116  }
1117  else {
1118  //copy line
1119  tmp_file << line.Data() << endl;
1120  }
1121  }
1122  line.ReadLine(fRunlist);
1123  }
1124 
1126  TString fRunlist_path = GetFullPathToAvailableRunsFile();
1127 
1128  //keep lock on runsfile
1129  if (!runlist_lock.Lock(fRunlist_path.Data())) return;
1130 
1131  //close temp file
1132  tmp_file.close();
1133 
1134  //copy temporary file to KVFiles directory, overwrite previous
1135  gSystem->CopyFile(tmp_file_path, fRunlist_path, kTRUE);
1136  //set access permissions to 664
1137  gSystem->Chmod(fRunlist_path.Data(), CHMODE(6, 6, 4));
1138  //delete temp file
1139  gSystem->Unlink(tmp_file_path);
1140  //unlock runsfile
1142 }
1143 
1144 
1145 
1146 
1152 
1153 void KVAvailableRunsFile::Add(Int_t run, const Char_t* filename)
1154 {
1155  //Add to the file an entry corresponding to this run, assumed to be present in the repository
1156  //with the given filename.
1157  //write in temporary runlist file '[run number]|[date of modification]|[name of file]|KaliVeda version|username
1158 
1159  //does runlist exist ?
1160  if (!OpenAvailableRunsFile()) {
1161  Error("Add", "Error opening available runs file");
1162  return;
1163  }
1164  //open temporary file
1165  TString tmp_file_path(GetFileName());
1166  ofstream tmp_file;
1167  KVBase::OpenTempFile(tmp_file_path, tmp_file);
1168 
1169  //copy all lines in runlist file
1170  TString line;
1171  line.ReadLine(fRunlist);
1172  while (fRunlist.good()) {
1173  tmp_file << line.Data() << endl;
1174  line.ReadLine(fRunlist);
1175  }
1176 
1178  TString runlist_path = GetFullPathToAvailableRunsFile();
1179 
1180  // keep lock on runsfile
1181  if (!runlist_lock.Lock(runlist_path.Data())) return;
1182 
1183  //add entry for run
1184  FileStat_t fs;
1185  //get file modification date
1186  if (fDataSet->GetRepository()->
1187  GetFileInfo(fDataSet, GetDataType(), filename,
1188  fs)) {
1189  //runfile exists in repository
1190  //write in temporary runlist file '[run number]|[date of modification]|[name of file]|KaliVeda version|username
1191  TDatime modt(fs.fMtime);
1192  UserGroup_t* userinfo = gSystem->GetUserInfo();
1193  tmp_file << run << '|' << modt.
1194  AsSQLString() << '|' << filename << '|' << GetKVVersion() << '|' << userinfo->fUser << endl;
1195  delete userinfo;
1196  }
1197  //close temp file
1198  tmp_file.close();
1199 
1200  //copy temporary file to KVFiles directory, overwrite previous
1201  gSystem->CopyFile(tmp_file_path, runlist_path, kTRUE);
1202  //set access permissions to 664
1203  gSystem->Chmod(runlist_path.Data(), CHMODE(6, 6, 4));
1204  //delete temp file
1205  gSystem->Unlink(tmp_file_path);
1206  //unlock runsfile
1208 }
1209 
1210 
1211 
1212 
1219 
1221 {
1222  //Initialise fRunlist so that it can be used to read the available runs file,
1223  //opens the file containing the list of available runs for the current dataset.
1224  //If the file does not exist, call Update() to create it.
1225  //
1226  //Returns kFALSE in case of problems.
1227 
1229 
1230  fRunlist.clear(); // clear any error flags (EOF etc.) before trying to open file
1231  if (!SearchAndOpenKVFile(runlist, fRunlist, "", &runlist_lock)) {
1232  //no runlist exists. we therefore have to create it.
1233  Warning("OpenAvailableRunsFile", "runlist file does not exist...");
1234  Update(kTRUE);
1235  if (!SearchAndOpenKVFile(runlist, fRunlist, "", &runlist_lock)) {
1236  Error("OpenAvailableRunsFile",
1237  "Something weird: I just made the available runlist file, but I still can't open it!");
1238  return kFALSE;
1239  }
1240  }
1241 
1242  return kTRUE;
1243 }
1244 
1245 
1246 
1247 
1252 
1254 {
1255  //Must be called after each operation which calls OpenAvailableRunsFile
1256  //Not only do we close the file stream, we remove the file lock put in place
1257  //by OpenAvailableRunsFile in order to allow others to read/write the file.
1258  fRunlist.close();
1259  fRunlist.clear();
1261 }
1262 
1263 
1264 
1265 
1268 
1270 {
1271  //Returns a list with all runs which occur more than once in the available runs file.
1272 
1273  ReadFile();
1274  KVNumberList multiruns;
1275  TIter next(fAvailableRuns);
1276  KVNameValueList* run;
1277  while ((run = (KVNameValueList*)next())) {
1278 
1279  if (run->GetIntValue("Occurs") > 1) multiruns.Add(run->GetName());
1280 
1281  }
1282  return multiruns;
1283 }
1284 
1285 
1286 
1287 
1292 
1294 {
1295  //Returns list of available run numbers for this data type.
1296  //If 'sys' gives the address of a valid database reaction system, only runs
1297  //corresponding to the system will be included.
1298 
1299  KVNumberList runs;
1300 
1301  //does runlist exist ?
1302  if (!OpenAvailableRunsFile()) {
1303  Error("GetRunList", "Cannot open available runs file");
1304  return runs;
1305  }
1306 
1307  TString fLine;
1308  fLine.ReadLine(fRunlist);
1309 
1310  Int_t fRunNumber;
1311  KVExpDB* db = fDataSet->GetDataBase();
1312  unique_ptr<KVExpDB> garbage_db;
1313  if (!db) {
1314  db = new KVExpDB;
1315  garbage_db.reset(db);
1316  }
1317 
1318  while (fRunlist.good()) {
1319 
1320  TObjArray* toks = fLine.Tokenize('|'); // split into fields
1321  KVString kvs(((TObjString*) toks->At(0))->GetString());
1322  fRunNumber = kvs.Atoi();
1323  delete toks;
1324 
1325  if (sys) {
1326  // check run is from right system
1327  KVDBRun* a_run = db->GetDBRun(fRunNumber);
1328  if (a_run) {
1329  if (a_run->GetSystem() == sys)
1330  runs.Add(fRunNumber);
1331  }
1332  }
1333  else {
1334  // add all runs to list
1335  runs.Add(fRunNumber);
1336  }
1337 
1338  fLine.ReadLine(fRunlist);
1339  }
1340 
1342  return runs;
1343 }
1344 
1345 
1346 
1347 
1362 
1364 {
1365  // Read all infos in available runs file and store as KVNameValueList objects in fAvailableRuns.
1366  // For each run in the file we add a KVNameValueList with the following fields:
1367  //
1368  // Name = run number
1369  // Occurs = number of times run appears in file
1370  // Filename[0] = name of first file for run
1371  // Filename[1] =
1372  // ...
1373  // Filename[Occurs-1] = name of last file for run
1374  // Date[0] = date & time of generation of first file etc.
1375  // KVVersion[0] = name of KaliVeda version used to generate first file etc. (if known)
1376  // Username[0] = name of user who generated first file etc. (if known)
1377 
1378  //does runlist exist ?
1379  if (!OpenAvailableRunsFile()) {
1380  Error("ReadFile", "Cannot open available runs file");
1381  return;
1382  }
1383 
1384  if (fAvailableRuns) delete fAvailableRuns;
1385  fAvailableRuns = new KVHashList;
1387 
1388  TString fLine;
1389  Int_t line_number = 1;
1390  fLine.ReadLine(fRunlist);
1391 
1392  KVNumberList duplicate_lines;
1393 
1394  Int_t fRunNumber;
1395 
1396  while (fRunlist.good()) {
1397 
1398  unique_ptr<TObjArray> toks(fLine.Tokenize('|')); // split into fields
1399 
1400  // number of fields can vary
1401  // nfields = 2: run number, date
1402  // nfields = 3: run number, date, filename
1403  // nfields = 5: run number, date, filename, KaliVeda version, username
1404  Int_t nfields = toks->GetEntries();
1405  KVString kvs(((TObjString*) toks->At(0))->GetString());
1406  if (kvs.Contains("/")) {
1407  Warning("ReadFile", "Strange '/' symbol in run number (line:%d)!!!", line_number);
1408  toks->ls();
1409  fLine.ReadLine(fRunlist);
1410  continue;
1411  }
1412 
1413  fRunNumber = kvs.Atoi();
1414  if (nfields < 2) {
1415  Warning("ReadFile", "Less than 2 fields in entry for run %d (line:%d)???", fRunNumber, line_number);
1416  toks->ls();
1417  fLine.ReadLine(fRunlist);
1418  continue;
1419  }
1420  //get date string
1421  KVString datestring(((TObjString*) toks->At(1))->GetString());
1422 
1423  // is run already in list ?
1425  Int_t Occurs = (NVL ? NVL->GetIntValue("Occurs") : 0);
1426  if (!NVL) {
1427  NVL = new KVNameValueList(kvs);
1428  fAvailableRuns->Add(NVL);
1429  }
1430  else {
1431  // check date for run is different to any others
1432  Bool_t ok = kTRUE;
1433  for (Int_t ii = 0; ii < Occurs; ii++) {
1434  KVString olddate = NVL->GetStringValue(Form("Date[%d]", ii));
1435  if (olddate == datestring) {
1436  ok = kFALSE;
1437  duplicate_lines.Add(line_number);
1438  break;
1439  }
1440  }
1441  if (!ok) {
1442  line_number++;
1443  fLine.ReadLine(fRunlist);
1444  continue;
1445  }
1446  }
1447  Occurs++;
1448  NVL->SetValue("Occurs", Occurs);
1449 
1450  NVL->SetValue(Form("Date[%d]", Occurs - 1), datestring.Data());
1451 
1452  KVString filename = ((TObjString*) toks->At(2))->GetString();
1453  NVL->SetValue(Form("Filename[%d]", Occurs - 1), filename.Data());
1454  KVString kvversion, username;
1455  if (nfields > 4) {
1456  kvversion = ((TObjString*) toks->At(3))->GetString();
1457  username = ((TObjString*) toks->At(4))->GetString();
1458  NVL->SetValue(Form("KVVersion[%d]", Occurs - 1), kvversion.Data());
1459  NVL->SetValue(Form("Username[%d]", Occurs - 1), username.Data());
1460  }
1461 
1462  line_number++;
1463  fLine.ReadLine(fRunlist);
1464  }
1465 
1467 
1468  if (duplicate_lines.GetNValues()) {
1469  Info("ReadFile", "There were %d duplicate entries in available runs file, they will be removed", duplicate_lines.GetNValues());
1470  RemoveDuplicateLines(duplicate_lines);
1471  }
1472 
1473 }
1474 
1475 
1476 
1483 
1485 {
1486  // look in previously read infos (see ReadFile) to see if, for a given run, there is a file with the
1487  // given name and modification date/time
1488  // if so, returns the address of the KVNameValueList for the run & sets OccNum to the index number of
1489  // the corresponding entry (in case of several files for the run)
1490  // if not, returns NULL
1491 
1492  if (!fAvailableRuns) return NULL;
1493  // is run already in list ?
1495  if (!NVL) return NULL;
1496  Int_t Occurs = NVL->GetIntValue("Occurs");
1497  for (OccNum = 0; OccNum < Occurs; OccNum++) {
1498  if (NVL->IsValue(Form("Filename[%d]", OccNum), filename) && NVL->IsValue(Form("Date[%d]", OccNum), modtime.AsSQLString())) return NVL;
1499  }
1500  return NULL;
1501 }
1502 
1503 
1504 
1509 
1511 {
1512  // return kTRUE if the given file for this run is lacking some information
1513  // e.g. the KV version and username
1514  // N.B.: if no file is known for this run, we return kFALSE
1515 
1516  ReadFile();
1517  // is run already in list ?
1519  if (!NVL) return kFALSE;
1520  Int_t Occurs = NVL->GetIntValue("Occurs");
1521  for (Int_t OccNum = 0; OccNum < Occurs; OccNum++) {
1522  if (NVL->IsValue(Form("Filename[%d]", OccNum), filename)) {
1523  // infos need update if no KV version has been set
1524  return (!NVL->HasParameter(Form("KVVersion[%d]", OccNum)));
1525  }
1526  }
1527  return kFALSE;
1528 }
1529 
1530 
1531 
1532 
1536 
1538 {
1539  // Remove from available runs file all lines whose numbers are in the list
1540 
1541  //does runlist exist ?
1542  if (!OpenAvailableRunsFile()) {
1543  Error("Remove", "Error opening available runs file");
1544  return;
1545  }
1546  //open temporary file
1547  TString tmp_file_path(GetFileName());
1548  ofstream tmp_file;
1549  KVBase::OpenTempFile(tmp_file_path, tmp_file);
1550 
1551  //loop over lines in fRunlist file
1552  //all lines which are not in list are directly copied to temp file
1553  TString line;
1554  Int_t line_number = 1;
1555  line.ReadLine(fRunlist);
1556 
1557  lines_to_be_removed.Begin();
1558  Int_t next_line_to_remove = 0;
1559  if (!lines_to_be_removed.End()) next_line_to_remove = lines_to_be_removed.Next();
1560 
1561  while (fRunlist.good()) {
1562 
1563  if (line_number != next_line_to_remove)
1564  tmp_file << line.Data() << endl;
1565  else {
1566  if (!lines_to_be_removed.End()) next_line_to_remove = lines_to_be_removed.Next();
1567  }
1568  line_number++;
1569  line.ReadLine(fRunlist);
1570 
1571  }
1572 
1574  TString fRunlist_path = GetFullPathToAvailableRunsFile();
1575 
1576  //keep lock on runsfile
1577  if (!runlist_lock.Lock(fRunlist_path.Data())) return;
1578 
1579  //close temp file
1580  tmp_file.close();
1581 
1582  //copy temporary file to KVFiles directory, overwrite previous
1583  gSystem->CopyFile(tmp_file_path, fRunlist_path, kTRUE);
1584  //set access permissions to 664
1585  gSystem->Chmod(fRunlist_path.Data(), CHMODE(6, 6, 4));
1586  //delete temp file
1587  gSystem->Unlink(tmp_file_path);
1588  //unlock runsfile
1590 }
1591 
1592 
1593 //__________________________________________________________________________________________________________________
1594 
int Int_t
#define SafeDelete(p)
bool Bool_t
char Char_t
constexpr Bool_t kFALSE
constexpr Bool_t kTRUE
R__EXTERN TEnv * gEnv
winID h TVirtualViewer3D TVirtualGLPainter p
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 index
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize fs
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)
kFileExists
kWritePermission
R__EXTERN TSystem * gSystem
Handles lists of available runs for different datasets and types of data.
virtual void CloseAvailableRunsFile()
Bool_t CheckDirectoryForAvailableRunsFile()
virtual void Add(Int_t run, const Char_t *filename)
virtual Bool_t GetRunInfo(Int_t run, TDatime &modtime, TString &filename)
Bool_t ExtractDateFromFileName(const Char_t *name, KVDatime &date)
const Char_t * GetDataType() const
KVNumberList CheckMultiRunfiles()
Returns a list with all runs which occur more than once in the available runs file.
const KVDataSet * fDataSet
dataset to which this file belongs
virtual Bool_t CheckAvailable(Int_t run)
virtual void Update(Bool_t no_existing_file=kFALSE)
KVHashList * fAvailableRuns
temporary list used to store infos when updating
virtual KVNumberList GetRunList(const KVDBSystem *system=0)
const Char_t * GetFileName() const
KVLockfile runlist_lock
for locking runlist file
KVNameValueList * RunHasFileWithDateAndName(Int_t run, const Char_t *filename, TDatime modtime, Int_t &OccNum)
virtual TList * GetListOfAvailableSystems(const KVDBSystem *systol=0)
virtual Int_t Count(Int_t run)
static KVString date_read_from_filename
virtual void UpdateInfos(Int_t run, const Char_t *filename, const Char_t *kvversion, const Char_t *username)
const Char_t * GetFullPathToAvailableRunsFile() const
virtual void Remove(Int_t run, const Char_t *filename="")
KVAvailableRunsFile()
Default ctor.
virtual void GetRunInfos(Int_t run, KVList *dates, KVList *names)
virtual Bool_t InfosNeedUpdate(Int_t run, const Char_t *filename)
std::ifstream fRunlist
for reading runlist file
Int_t IsRunFileName(const Char_t *filename)
virtual Bool_t OpenAvailableRunsFile()
const Char_t * GetFilePath() const
void RemoveDuplicateLines(KVNumberList lines_to_be_removed)
Base class for KaliVeda framework.
Definition: KVBase.h:142
static void OpenTempFile(TString &base, std::ofstream &fp)
Definition: KVBase.cpp:827
static const Char_t * GetWORKDIRFilePath(const Char_t *namefile="")
Definition: KVBase.cpp:127
static bool is_gnuinstall()
Definition: KVBase.h:277
static const Char_t * GetDataSetEnv(const Char_t *dataset, const Char_t *type, const Char_t *defval)
Definition: KVBase.cpp:1619
virtual Bool_t IsCalled(const Char_t *name) const
Definition: KVBase.h:190
static Bool_t SearchAndOpenKVFile(const Char_t *name, KVSQLite::database &dbfile, const Char_t *kvsubdir="")
Definition: KVBase.cpp:649
static const Char_t * GetKVVersion()
Returns KaliVeda version string.
Definition: KVBase.cpp:874
virtual Int_t GetNumber() const
Definition: KVDBRecord.h:73
Description of an experimental run in database ,,.
Definition: KVDBRun.h:36
void SetDatime(TDatime &dat)
Definition: KVDBRun.h:122
void SetUserName(const Char_t *U)
Definition: KVDBRun.h:58
void SetKVVersion(const Char_t *V)
Definition: KVDBRun.h:50
KVDBSystem * GetSystem() const
Definition: KVDBRun.cpp:242
const Char_t * GetStartDate() const
Definition: KVDBRun.h:151
Database class used to store information on different colliding systems studied during an experiment....
Definition: KVDBSystem.h:52
Int_t GetNumberRuns()
Definition: KVDBSystem.h:140
void SetNumberRuns(Int_t n)
set number of runs associated to this system
Definition: KVDBSystem.h:133
Base class for managing repositories of experimental data.
virtual KVUniqueNameList * GetDirectoryListing(const KVDataSet *dataset, const Char_t *datatype="", const Char_t *subdir="")
virtual Bool_t GetFileInfo(const KVDataSet *dataset, const Char_t *datatype, const Char_t *runfile, FileStat_t &fs)
Manage an experimental dataset corresponding to a given experiment or campaign.
Definition: KVDataSet.h:35
KVDataRepository * GetRepository() const
Get pointer to data repository in which dataset is stored.
Definition: KVDataSet.cpp:1408
const Char_t * GetDataSetDir() const
Definition: KVDataSet.cpp:729
const Char_t * GetDataSetEnv(const Char_t *type, const Char_t *defval="") const
Definition: KVDataSet.cpp:767
virtual const Char_t * GetDataPathSubdir() const
Returns name of top-level directory in data repository used to store data files for this dataset.
Definition: KVDataSet.h:95
KVExpDB * GetDataBase(Option_t *opt="") const
Definition: KVDataSet.cpp:289
const Char_t * GetDataTypeSubdir(const Char_t *type) const
Definition: KVDataSet.h:99
Extension of TDatime to handle various useful date formats.
Definition: KVDatime.h:33
static Bool_t IsGANACQFormat(const Char_t *date)
Definition: KVDatime.cpp:433
static Bool_t IsSQLFormat(const Char_t *date)
Definition: KVDatime.cpp:496
static Bool_t IsGANACQ2010Format(const Char_t *date)
Definition: KVDatime.cpp:455
void SetSQLDate(const Char_t *SQLDateString)
Definition: KVDatime.cpp:204
void SetGanacqNarvalDate(const Char_t *GanacqDateString)
Definition: KVDatime.cpp:297
static Bool_t IsGANACQNarvalFormat(const Char_t *date)
Definition: KVDatime.cpp:476
void SetGanacq2010Date(const Char_t *GanacqDateString)
Definition: KVDatime.cpp:273
void SetGanacqDate(const Char_t *GanacqDateString)
Definition: KVDatime.cpp:323
Base class to describe database of an experiment ,,.
Definition: KVExpDB.h:20
KVDBRun * GetDBRun(Int_t number) const
Definition: KVExpDB.h:76
Extended version of ROOT THashList.
Definition: KVHashList.h:29
Extended TList class which owns its objects by default.
Definition: KVList.h:28
void SetSleeptime(int s)
Definition: KVLockfile.h:90
Bool_t Release()
Definition: KVLockfile.cpp:195
void SetTimeout(int t)
Definition: KVLockfile.h:98
Bool_t Lock(const Char_t *filename="")
Definition: KVLockfile.cpp:165
void SetSuspend(int s)
Definition: KVLockfile.h:102
Handles lists of named parameters with different types, a list of KVNamedParameter objects.
Int_t GetIntValue(const Char_t *name) const
void SetValue(const Char_t *name, value_type value)
Bool_t IsValue(const Char_t *name, value_type value) const
const Char_t * GetStringValue(const Char_t *name) const
Bool_t HasParameter(const Char_t *name) const
Strings used to represent a set of ranges of values.
Definition: KVNumberList.h:85
Bool_t End(void) const
Definition: KVNumberList.h:199
Int_t GetNValues() const
void Begin(void) const
void Add(Int_t)
Add value 'n' to the list.
Int_t Next(void) const
Description of an individual run file in an experimental dataset.
Definition: KVRunFile.h:19
virtual void SetOwner(Bool_t enable=kTRUE)
virtual Int_t GetSize() const
virtual void Add(TObject *obj)
virtual void Delete(Option_t *option="")
virtual TObject * FindObject(const char *name) const
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
Int_t GetNValues(TString delim) const
Definition: KVString.cpp:886
Optimised list in which named objects can only be placed once.
virtual void SetOwner(Bool_t enable=kTRUE)
Bool_t Contains(const char *name) const
virtual Int_t GetSize() const
const char * AsSQLString() const
void Set()
virtual const char * GetValue(const char *name, const char *dflt) const
void Add(TObject *obj) override
virtual void Sort(Bool_t order=kSortAscending)
const char * GetName() const override
TObject * At(Int_t idx) const override
const char * GetName() const override
virtual TObject * Clone(const char *newname="") const
virtual void Warning(const char *method, const char *msgfmt,...) const
virtual void Error(const char *method, const char *msgfmt,...) const
virtual void Info(const char *method, const char *msgfmt,...) const
Int_t Atoi() const
const char * Data() const
Bool_t IsDigit() const
void ToUpper()
TObjArray * Tokenize(const TString &delim) const
void Form(const char *fmt,...)
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
TString & ReplaceAll(const char *s1, const char *s2)
std::istream & ReadLine(std::istream &str, Bool_t skipWhite=kTRUE)
virtual int Chmod(const char *file, UInt_t mode)
virtual int CopyFile(const char *from, const char *to, Bool_t overwrite=kFALSE)
virtual char * ConcatFileName(const char *dir, const char *name)
virtual int mkdir(const char *name, Bool_t recursive=kFALSE)
virtual UserGroup_t * GetUserInfo(const char *user=nullptr)
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
virtual const char * BaseName(const char *pathname)
virtual char * ExpandPathName(const char *path)
virtual int Unlink(const char *name)
TLine * line
Double_t Max(Double_t a, Double_t b)
const char * String
TString fUser
ClassImp(TPyArg)