KaliVeda  1.12/06
Heavy-Ion Analysis Toolkit
KVAvailableRunsFile.cpp
Go to the documentation of this file.
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 {
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  KVRunFile* rf = new KVRunFile(a_run, filename, fDatime, kvversion, username);
962  sys_list->Add(rf);
963  }
964  }
965  }
966  }
967  fLine.ReadLine(fRunlist);
968  }
969 
970  //sort list of systems in order of increasing run number
971  //sort list of runs in order of increasing run number
972  if (sys_list && sys_list->GetSize() > 1)
973  sys_list->Sort();
974 
975  if (!good_lines) {
976  Error("GetListOfAvailableSystems",
977  "Available runs file is empty or absent");
978  }
980  return sys_list;
981 
982 }
983 
984 
985 
991 
992 void KVAvailableRunsFile::UpdateInfos(Int_t run, const Char_t* filename, const Char_t* kvversion, const Char_t* username)
993 {
994  // Call this mehod to update informations on the file "filename" corresponding to run,
995  // by adding/replacing the KV version and username read from the file itself (not necessarily
996  // corresponding to current KV version and username)
997 
998  //does runlist exist ?
999  if (!OpenAvailableRunsFile()) {
1000  Error("UpdateInfos", "Error opening available runs file");
1001  return;
1002  }
1003  //open temporary file
1004  TString tmp_file_path(GetFileName());
1005  ofstream tmp_file;
1006  KVBase::OpenTempFile(tmp_file_path, tmp_file);
1007 
1008  TString FileName(filename);
1009  //loop over lines in fRunlist file
1010  //all lines which do not begin with 'run'| are directly copied to temp file
1011  TString line;
1012  line.ReadLine(fRunlist);
1013  while (fRunlist.good()) {
1014  //filename was specified: we copy everything up to the line
1015  //with the right filename & number
1016  if (line.BeginsWith(Form("%d|", run))) {
1017 
1018  unique_ptr<TObjArray> toks(line.Tokenize('|')); // split into fields
1019  TString ReadFileName = ((TObjString*) toks->At(2))->String();
1020 
1021  if (ReadFileName != FileName) {
1022  //copy line
1023  tmp_file << line.Data() << endl;
1024  }
1025  else {
1026  // replace existing infos
1027  tmp_file << run << "|" << ((TObjString*) toks->At(1))->String() << "|" << filename << "|" << kvversion << "|" << username << endl;
1028  }
1029 
1030  }
1031  else {
1032  //copy line
1033  tmp_file << line.Data() << endl;
1034  }
1035  line.ReadLine(fRunlist);
1036  }
1037 
1039  TString fRunlist_path = GetFullPathToAvailableRunsFile();
1040 
1041  //keep lock on runsfile
1042  if (!runlist_lock.Lock(fRunlist_path.Data())) return;
1043 
1044  //close temp file
1045  tmp_file.close();
1046 
1047  //copy temporary file to KVFiles directory, overwrite previous
1048  gSystem->CopyFile(tmp_file_path, fRunlist_path, kTRUE);
1049  //set access permissions to 664
1050  gSystem->Chmod(fRunlist_path.Data(), CHMODE(6, 6, 4));
1051  //delete temp file
1052  gSystem->Unlink(tmp_file_path);
1053  //unlock runsfile
1055 }
1056 
1057 
1058 
1065 
1066 void KVAvailableRunsFile::Remove(Int_t run, const Char_t* filename)
1067 {
1068  //Remove from the file the entry corresponding to this run
1069  //By default, the first occurrence of the run number in the file will be removed.
1070  //If "filename" is given, we look for a line corresponding to both the run number
1071  //and the filename (important if run appears more than once !!!) ;-)
1072 
1073  //does runlist exist ?
1074  if (!OpenAvailableRunsFile()) {
1075  Error("Remove", "Error opening available runs file");
1076  return;
1077  }
1078  //open temporary file
1079  TString tmp_file_path(GetFileName());
1080  ofstream tmp_file;
1081  KVBase::OpenTempFile(tmp_file_path, tmp_file);
1082 
1083  TString FileName(filename);
1084  Bool_t withFileName = (FileName != "");
1085  //loop over lines in fRunlist file
1086  //all lines which do not begin with 'run'| are directly copied to temp file
1087  TString line;
1088  line.ReadLine(fRunlist);
1089  while (fRunlist.good()) {
1090  if (!withFileName) {
1091  //filename not specified : we copy everything up to the first line
1092  //which begins with the run number we want
1093  if (!line.BeginsWith(Form("%d|", run))) {
1094  //copy line
1095  tmp_file << line.Data() << endl;
1096  }
1097  }
1098  else {
1099  //filename was specified: we copy everything up to the line
1100  //with the right filename & number
1101  if (line.BeginsWith(Form("%d|", run))) {
1102 
1103  unique_ptr<TObjArray> toks(line.Tokenize('|')); // split into fields
1104  TString ReadFileName;
1105  ReadFileName = ((TObjString*) toks->At(2))->String();
1106 
1107  if (ReadFileName != FileName) {
1108  //copy line
1109  tmp_file << line.Data() << endl;
1110  }
1111 
1112  }
1113  else {
1114  //copy line
1115  tmp_file << line.Data() << endl;
1116  }
1117  }
1118  line.ReadLine(fRunlist);
1119  }
1120 
1122  TString fRunlist_path = GetFullPathToAvailableRunsFile();
1123 
1124  //keep lock on runsfile
1125  if (!runlist_lock.Lock(fRunlist_path.Data())) return;
1126 
1127  //close temp file
1128  tmp_file.close();
1129 
1130  //copy temporary file to KVFiles directory, overwrite previous
1131  gSystem->CopyFile(tmp_file_path, fRunlist_path, kTRUE);
1132  //set access permissions to 664
1133  gSystem->Chmod(fRunlist_path.Data(), CHMODE(6, 6, 4));
1134  //delete temp file
1135  gSystem->Unlink(tmp_file_path);
1136  //unlock runsfile
1138 }
1139 
1140 
1141 
1142 
1148 
1149 void KVAvailableRunsFile::Add(Int_t run, const Char_t* filename)
1150 {
1151  //Add to the file an entry corresponding to this run, assumed to be present in the repository
1152  //with the given filename.
1153  //write in temporary runlist file '[run number]|[date of modification]|[name of file]|KaliVeda version|username
1154 
1155  //does runlist exist ?
1156  if (!OpenAvailableRunsFile()) {
1157  Error("Add", "Error opening available runs file");
1158  return;
1159  }
1160  //open temporary file
1161  TString tmp_file_path(GetFileName());
1162  ofstream tmp_file;
1163  KVBase::OpenTempFile(tmp_file_path, tmp_file);
1164 
1165  //copy all lines in runlist file
1166  TString line;
1167  line.ReadLine(fRunlist);
1168  while (fRunlist.good()) {
1169  tmp_file << line.Data() << endl;
1170  line.ReadLine(fRunlist);
1171  }
1172 
1174  TString runlist_path = GetFullPathToAvailableRunsFile();
1175 
1176  // keep lock on runsfile
1177  if (!runlist_lock.Lock(runlist_path.Data())) return;
1178 
1179  //add entry for run
1180  FileStat_t fs;
1181  //get file modification date
1182  if (fDataSet->GetRepository()->
1183  GetFileInfo(fDataSet, GetDataType(), filename,
1184  fs)) {
1185  //runfile exists in repository
1186  //write in temporary runlist file '[run number]|[date of modification]|[name of file]|KaliVeda version|username
1187  TDatime modt(fs.fMtime);
1188  UserGroup_t* userinfo = gSystem->GetUserInfo();
1189  tmp_file << run << '|' << modt.
1190  AsSQLString() << '|' << filename << '|' << GetKVVersion() << '|' << userinfo->fUser << endl;
1191  delete userinfo;
1192  }
1193  //close temp file
1194  tmp_file.close();
1195 
1196  //copy temporary file to KVFiles directory, overwrite previous
1197  gSystem->CopyFile(tmp_file_path, runlist_path, kTRUE);
1198  //set access permissions to 664
1199  gSystem->Chmod(runlist_path.Data(), CHMODE(6, 6, 4));
1200  //delete temp file
1201  gSystem->Unlink(tmp_file_path);
1202  //unlock runsfile
1204 }
1205 
1206 
1207 
1208 
1215 
1217 {
1218  //Initialise fRunlist so that it can be used to read the available runs file,
1219  //opens the file containing the list of available runs for the current dataset.
1220  //If the file does not exist, call Update() to create it.
1221  //
1222  //Returns kFALSE in case of problems.
1223 
1225 
1226  fRunlist.clear(); // clear any error flags (EOF etc.) before trying to open file
1227  if (!SearchAndOpenKVFile(runlist, fRunlist, "", &runlist_lock)) {
1228  //no runlist exists. we therefore have to create it.
1229  Warning("OpenAvailableRunsFile", "runlist file does not exist...");
1230  Update(kTRUE);
1231  if (!SearchAndOpenKVFile(runlist, fRunlist, "", &runlist_lock)) {
1232  Error("OpenAvailableRunsFile",
1233  "Something weird: I just made the available runlist file, but I still can't open it!");
1234  return kFALSE;
1235  }
1236  }
1237 
1238  return kTRUE;
1239 }
1240 
1241 
1242 
1243 
1248 
1250 {
1251  //Must be called after each operation which calls OpenAvailableRunsFile
1252  //Not only do we close the file stream, we remove the file lock put in place
1253  //by OpenAvailableRunsFile in order to allow others to read/write the file.
1254  fRunlist.close();
1255  fRunlist.clear();
1257 }
1258 
1259 
1260 
1261 
1264 
1266 {
1267  //Returns a list with all runs which occur more than once in the available runs file.
1268 
1269  ReadFile();
1270  KVNumberList multiruns;
1271  TIter next(fAvailableRuns);
1272  KVNameValueList* run;
1273  while ((run = (KVNameValueList*)next())) {
1274 
1275  if (run->GetIntValue("Occurs") > 1) multiruns.Add(run->GetName());
1276 
1277  }
1278  return multiruns;
1279 }
1280 
1281 
1282 
1283 
1288 
1290 {
1291  //Returns list of available run numbers for this data type.
1292  //If 'sys' gives the address of a valid database reaction system, only runs
1293  //corresponding to the system will be included.
1294 
1295  KVNumberList runs;
1296 
1297  //does runlist exist ?
1298  if (!OpenAvailableRunsFile()) {
1299  Error("GetRunList", "Cannot open available runs file");
1300  return runs;
1301  }
1302 
1303  TString fLine;
1304  fLine.ReadLine(fRunlist);
1305 
1306  Int_t fRunNumber;
1307  KVExpDB* db = fDataSet->GetDataBase();
1308  unique_ptr<KVExpDB> garbage_db;
1309  if (!db) {
1310  db = new KVExpDB;
1311  garbage_db.reset(db);
1312  }
1313 
1314  while (fRunlist.good()) {
1315 
1316  TObjArray* toks = fLine.Tokenize('|'); // split into fields
1317  KVString kvs(((TObjString*) toks->At(0))->GetString());
1318  fRunNumber = kvs.Atoi();
1319  delete toks;
1320 
1321  if (sys) {
1322  // check run is from right system
1323  KVDBRun* a_run = db->GetDBRun(fRunNumber);
1324  if (a_run) {
1325  if (a_run->GetSystem() == sys)
1326  runs.Add(fRunNumber);
1327  }
1328  }
1329  else {
1330  // add all runs to list
1331  runs.Add(fRunNumber);
1332  }
1333 
1334  fLine.ReadLine(fRunlist);
1335  }
1336 
1338  return runs;
1339 }
1340 
1341 
1342 
1343 
1358 
1360 {
1361  // Read all infos in available runs file and store as KVNameValueList objects in fAvailableRuns.
1362  // For each run in the file we add a KVNameValueList with the following fields:
1363  //
1364  // Name = run number
1365  // Occurs = number of times run appears in file
1366  // Filename[0] = name of first file for run
1367  // Filename[1] =
1368  // ...
1369  // Filename[Occurs-1] = name of last file for run
1370  // Date[0] = date & time of generation of first file etc.
1371  // KVVersion[0] = name of KaliVeda version used to generate first file etc. (if known)
1372  // Username[0] = name of user who generated first file etc. (if known)
1373 
1374  //does runlist exist ?
1375  if (!OpenAvailableRunsFile()) {
1376  Error("ReadFile", "Cannot open available runs file");
1377  return;
1378  }
1379 
1380  if (fAvailableRuns) delete fAvailableRuns;
1381  fAvailableRuns = new KVHashList;
1383 
1384  TString fLine;
1385  Int_t line_number = 1;
1386  fLine.ReadLine(fRunlist);
1387 
1388  KVNumberList duplicate_lines;
1389 
1390  Int_t fRunNumber;
1391 
1392  while (fRunlist.good()) {
1393 
1394  unique_ptr<TObjArray> toks(fLine.Tokenize('|')); // split into fields
1395 
1396  // number of fields can vary
1397  // nfields = 2: run number, date
1398  // nfields = 3: run number, date, filename
1399  // nfields = 5: run number, date, filename, KaliVeda version, username
1400  Int_t nfields = toks->GetEntries();
1401  KVString kvs(((TObjString*) toks->At(0))->GetString());
1402  if (kvs.Contains("/")) {
1403  Warning("ReadFile", "Strange '/' symbol in run number (line:%d)!!!", line_number);
1404  toks->ls();
1405  fLine.ReadLine(fRunlist);
1406  continue;
1407  }
1408 
1409  fRunNumber = kvs.Atoi();
1410  if (nfields < 2) {
1411  Warning("ReadFile", "Less than 2 fields in entry for run %d (line:%d)???", fRunNumber, line_number);
1412  toks->ls();
1413  fLine.ReadLine(fRunlist);
1414  continue;
1415  }
1416  //get date string
1417  KVString datestring(((TObjString*) toks->At(1))->GetString());
1418 
1419  // is run already in list ?
1421  Int_t Occurs = (NVL ? NVL->GetIntValue("Occurs") : 0);
1422  if (!NVL) {
1423  NVL = new KVNameValueList(kvs);
1424  fAvailableRuns->Add(NVL);
1425  }
1426  else {
1427  // check date for run is different to any others
1428  Bool_t ok = kTRUE;
1429  for (Int_t ii = 0; ii < Occurs; ii++) {
1430  KVString olddate = NVL->GetStringValue(Form("Date[%d]", ii));
1431  if (olddate == datestring) {
1432  ok = kFALSE;
1433  duplicate_lines.Add(line_number);
1434  break;
1435  }
1436  }
1437  if (!ok) {
1438  line_number++;
1439  fLine.ReadLine(fRunlist);
1440  continue;
1441  }
1442  }
1443  Occurs++;
1444  NVL->SetValue("Occurs", Occurs);
1445 
1446  NVL->SetValue(Form("Date[%d]", Occurs - 1), datestring.Data());
1447 
1448  KVString filename = ((TObjString*) toks->At(2))->GetString();
1449  NVL->SetValue(Form("Filename[%d]", Occurs - 1), filename.Data());
1450  KVString kvversion, username;
1451  if (nfields > 4) {
1452  kvversion = ((TObjString*) toks->At(3))->GetString();
1453  username = ((TObjString*) toks->At(4))->GetString();
1454  NVL->SetValue(Form("KVVersion[%d]", Occurs - 1), kvversion.Data());
1455  NVL->SetValue(Form("Username[%d]", Occurs - 1), username.Data());
1456  }
1457 
1458  line_number++;
1459  fLine.ReadLine(fRunlist);
1460  }
1461 
1463 
1464  if (duplicate_lines.GetNValues()) {
1465  Info("ReadFile", "There were %d duplicate entries in available runs file, they will be removed", duplicate_lines.GetNValues());
1466  RemoveDuplicateLines(duplicate_lines);
1467  }
1468 
1469 }
1470 
1471 
1472 
1479 
1481 {
1482  // look in previously read infos (see ReadFile) to see if, for a given run, there is a file with the
1483  // given name and modification date/time
1484  // if so, returns the address of the KVNameValueList for the run & sets OccNum to the index number of
1485  // the corresponding entry (in case of several files for the run)
1486  // if not, returns NULL
1487 
1488  if (!fAvailableRuns) return NULL;
1489  // is run already in list ?
1491  if (!NVL) return NULL;
1492  Int_t Occurs = NVL->GetIntValue("Occurs");
1493  for (OccNum = 0; OccNum < Occurs; OccNum++) {
1494  if (NVL->IsValue(Form("Filename[%d]", OccNum), filename) && NVL->IsValue(Form("Date[%d]", OccNum), modtime.AsSQLString())) return NVL;
1495  }
1496  return NULL;
1497 }
1498 
1499 
1500 
1505 
1507 {
1508  // return kTRUE if the given file for this run is lacking some information
1509  // e.g. the KV version and username
1510  // N.B.: if no file is known for this run, we return kFALSE
1511 
1512  ReadFile();
1513  // is run already in list ?
1515  if (!NVL) return kFALSE;
1516  Int_t Occurs = NVL->GetIntValue("Occurs");
1517  for (Int_t OccNum = 0; OccNum < Occurs; OccNum++) {
1518  if (NVL->IsValue(Form("Filename[%d]", OccNum), filename)) {
1519  // infos need update if no KV version has been set
1520  return (!NVL->HasParameter(Form("KVVersion[%d]", OccNum)));
1521  }
1522  }
1523  return kFALSE;
1524 }
1525 
1526 
1527 
1528 
1532 
1534 {
1535  // Remove from available runs file all lines whose numbers are in the list
1536 
1537  //does runlist exist ?
1538  if (!OpenAvailableRunsFile()) {
1539  Error("Remove", "Error opening available runs file");
1540  return;
1541  }
1542  //open temporary file
1543  TString tmp_file_path(GetFileName());
1544  ofstream tmp_file;
1545  KVBase::OpenTempFile(tmp_file_path, tmp_file);
1546 
1547  //loop over lines in fRunlist file
1548  //all lines which are not in list are directly copied to temp file
1549  TString line;
1550  Int_t line_number = 1;
1551  line.ReadLine(fRunlist);
1552 
1553  lines_to_be_removed.Begin();
1554  Int_t next_line_to_remove = 0;
1555  if (!lines_to_be_removed.End()) next_line_to_remove = lines_to_be_removed.Next();
1556 
1557  while (fRunlist.good()) {
1558 
1559  if (line_number != next_line_to_remove)
1560  tmp_file << line.Data() << endl;
1561  else {
1562  if (!lines_to_be_removed.End()) next_line_to_remove = lines_to_be_removed.Next();
1563  }
1564  line_number++;
1565  line.ReadLine(fRunlist);
1566 
1567  }
1568 
1570  TString fRunlist_path = GetFullPathToAvailableRunsFile();
1571 
1572  //keep lock on runsfile
1573  if (!runlist_lock.Lock(fRunlist_path.Data())) return;
1574 
1575  //close temp file
1576  tmp_file.close();
1577 
1578  //copy temporary file to KVFiles directory, overwrite previous
1579  gSystem->CopyFile(tmp_file_path, fRunlist_path, kTRUE);
1580  //set access permissions to 664
1581  gSystem->Chmod(fRunlist_path.Data(), CHMODE(6, 6, 4));
1582  //delete temp file
1583  gSystem->Unlink(tmp_file_path);
1584  //unlock runsfile
1586 }
1587 
1588 
1589 //__________________________________________________________________________________________________________________
1590 
int Int_t
#define CHMODE(u, g, o)
void AssignAndDelete(TString &target, char *tobedeleted)
ClassImp(KVPartitionList) void KVPartitionList
Initialisation.
#define SafeDelete(p)
char Char_t
const Bool_t kFALSE
bool Bool_t
const Bool_t kTRUE
R__EXTERN TEnv * gEnv
int type
char * Form(const char *fmt,...)
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:135
static void OpenTempFile(TString &base, std::ofstream &fp)
Definition: KVBase.cpp:790
static const Char_t * GetWORKDIRFilePath(const Char_t *namefile="")
Definition: KVBase.cpp:127
static bool is_gnuinstall()
Definition: KVBase.h:266
static const Char_t * GetDataSetEnv(const Char_t *dataset, const Char_t *type, const Char_t *defval)
Definition: KVBase.cpp:1582
static Bool_t SearchAndOpenKVFile(const Char_t *name, std::ifstream &file, const Char_t *kvsubdir="", KVLockfile *locks=0)
Definition: KVBase.cpp:601
static const Char_t * GetKVVersion()
Returns KaliVeda version string.
Definition: KVBase.cpp:837
virtual Int_t GetNumber() const
Definition: KVDBRecord.h:72
Description of an experimental run in database ,.
Definition: KVDBRun.h:35
void SetDatime(TDatime &dat)
Definition: KVDBRun.h:121
void SetUserName(const Char_t *U)
Definition: KVDBRun.h:57
void SetKVVersion(const Char_t *V)
Definition: KVDBRun.h:49
KVDBSystem * GetSystem() const
Definition: KVDBRun.cpp:242
Database class used to store information on different colliding systems studied during an experiment.
Definition: KVDBSystem.h:51
Int_t GetNumberRuns()
Definition: KVDBSystem.h:139
void SetNumberRuns(Int_t n)
set number of runs associated to this system
Definition: KVDBSystem.h:132
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:207
KVDataRepository * GetRepository() const
Get pointer to data repository in which dataset is stored.
Definition: KVDataSet.cpp:1398
const Char_t * GetDataSetDir() const
Definition: KVDataSet.cpp:719
const Char_t * GetDataSetEnv(const Char_t *type, const Char_t *defval="") const
Definition: KVDataSet.cpp:757
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:261
KVExpDB * GetDataBase(Option_t *opt="") const
Definition: KVDataSet.cpp:286
const Char_t * GetDataTypeSubdir(const Char_t *type) const
Definition: KVDataSet.h:265
Extension of TDatime to handle various useful date formats.
Definition: KVDatime.h:32
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:18
KVDBRun * GetDBRun(Int_t number) const
Definition: KVExpDB.h:74
Extended version of ROOT THashList.
Definition: KVHashList.h:28
Extended TList class which owns its objects by default.
Definition: KVList.h:27
void SetSleeptime(int s)
Definition: KVLockfile.h:89
Bool_t Release()
Definition: KVLockfile.cpp:195
void SetTimeout(int t)
Definition: KVLockfile.h:97
Bool_t Lock(const Char_t *filename="")
Definition: KVLockfile.cpp:165
void SetSuspend(int s)
Definition: KVLockfile.h:101
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:83
Bool_t End(void) const
Definition: KVNumberList.h:196
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:18
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:72
void Begin(TString delim) const
Definition: KVString.cpp:562
Bool_t End() const
Definition: KVString.cpp:625
KVString Next(Bool_t strip_whitespace=kFALSE) const
Definition: KVString.cpp:675
Int_t GetNValues(TString delim) const
Definition: KVString.cpp:859
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
virtual const char * GetValue(const char *name, const char *dflt) const
virtual void Add(TObject *obj)
virtual void Sort(Bool_t order=kSortAscending)
virtual const char * GetName() const
TObject * At(Int_t idx) const
const char * GetName() const
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
Bool_t IsDigit() const
void ToUpper()
TObjArray * Tokenize(const TString &delim) const
const char * Data() 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
const long double s
Definition: KVUnits.h:94
Double_t Max(Double_t a, Double_t b)
const char * String
Long_t fMtime
TString fUser