KaliVeda  1.12/06
Heavy-Ion Analysis Toolkit
KVBase.cpp
Go to the documentation of this file.
1 /***************************************************************************
2 $Id: KVBase.cpp,v 1.57 2009/04/22 09:38:39 franklan Exp $
3  kvbase.cpp - description
4  -------------------
5  begin : Thu May 16 2002
6  copyright : (C) 2002 by J.D. Frankland
7  email : frankland@ganil.fr
8  ***************************************************************************/
9 
10 /***************************************************************************
11  * *
12  * This program is free software; you can redistribute it and/or modify *
13  * it under the terms of the GNU General Public License as published by *
14  * the Free Software Foundation; either version 2 of the License, or *
15  * (at your option) any later version. *
16  * *
17  ***************************************************************************/
18 #include <cassert>
19 #include "Riostream.h"
20 #include "TMath.h"
21 #include "TFile.h"
22 #include "KVBase.h"
23 #include "TClass.h"
24 #include "KVString.h"
25 #include "TSystem.h"
26 #include "TInterpreter.h"
27 #include "TEnv.h"
28 #include "TPluginManager.h"
29 #include "KVNameValueList.h"
30 #include "TSystemDirectory.h"
31 #ifdef WITH_GIT_INFOS
32 #include "KVGitInfo.h"
33 #endif
34 #include "KVVersion.h"
35 #include "TROOT.h"
36 #include "TDatime.h"
37 #include "THashList.h"
38 #include "TError.h"
39 #include "TGMimeTypes.h"
40 #include "TGClient.h"
41 #include "TContextMenu.h"
42 #include <TEntryList.h>
43 #include <TEventList.h>
44 #include <TFileMerger.h>
45 #include <TGraph2D.h>
46 #include <TH1.h>
47 #include <TKey.h>
48 #include "TTree.h"
49 
50 using namespace std;
51 
53 
54 
55 
56 #define xstr(s) str(s)
57 #define str(s) #s
59 TString KVBase::fWorkingDirectory = "$(HOME)/.kaliveda";
61 
62 
64 
65 const Char_t* KVBase::GetETCDIRFilePath(const Char_t* namefile)
66 {
67  if (strcmp(namefile, "")) return Form("%s/%s", xstr(ETCDIR), namefile);
68  return Form("%s", xstr(ETCDIR));
69 }
70 
71 
73 
74 const Char_t* KVBase::GetDATADIRFilePath(const Char_t* namefile)
75 {
76  if (strcmp(namefile, "")) return Form("%s/%s", xstr(DATADIR), namefile);
77  return Form("%s", xstr(DATADIR));
78 }
79 
80 
82 
84 {
85  if (strcmp(namefile, "")) return Form("%s/%s", xstr(TEMPLATEDIR), namefile);
86  return Form("%s", xstr(TEMPLATEDIR));
87 }
88 
89 
91 
93 {
94  return Form("%s/db", fWorkingDirectory.Data());
95 }
96 
97 
99 
100 const Char_t* KVBase::GetLIBDIRFilePath(const Char_t* namefile)
101 {
102  if (strcmp(namefile, "")) return Form("%s/%s", xstr(LIBDIR), namefile);
103  return Form("%s", xstr(LIBDIR));
104 }
105 
106 
108 
109 const Char_t* KVBase::GetINCDIRFilePath(const Char_t* namefile)
110 {
111  if (strcmp(namefile, "")) return Form("%s/%s", xstr(INCDIR), namefile);
112  return Form("%s", xstr(INCDIR));
113 }
114 
115 
117 
118 const Char_t* KVBase::GetBINDIRFilePath(const Char_t* namefile)
119 {
120  if (strcmp(namefile, "")) return Form("%s/%s", xstr(BINDIR), namefile);
121  return Form("%s", xstr(BINDIR));
122 }
123 
124 
126 
127 const Char_t* KVBase::GetWORKDIRFilePath(const Char_t* namefile)
128 {
129  if (strcmp(namefile, "")) return Form("%s/%s", fWorkingDirectory.Data(), namefile);
130  return fWorkingDirectory;
131 }
132 
133 
134 
137 
139 {
140  //Default initialisation
141 
142  InitEnvironment();
143  fNumber = 0;
144  fNbObj++;
145  fLabel = "";
146  SetBit(kIsKaliVedaObject);
147 }
148 
149 
150 
180 
182 {
183  // STATIC method to Initialise KaliVeda environment
184  // Reads config files in <code>\$(pkgdatadir)/etc</code> and sets up environment
185  // (data repositories, datasets, etc. etc.).
186  // Adds directory where kaliveda shared libs are installed to the dynamic
187  // path - for finding and loading plugins.
188  // Resets the `gRandom` random number sequence using a clock-based seed
189  // (i.e. random sequences do not repeat).
190  //
191  // Normally, the first object created which inherits from KVBase will
192  // perform this initialisation; if you need to set up the environment before
193  // creating a KVBase object, or if you just want to be absolutely sure that
194  // the environment has been initialised, you can call this method.
195  //
196  // #### Note for GNU-style installations
197  // If KaliVeda is built with the cmake option `-Dgnuinstall=yes` then each
198  // user will have a working directory which will be used to store any files
199  // generated by KaliVeda at runtime.
200  //
201  // By default the location of user's working directory is set to
202  //~~~~~~~~~
203  // $(HOME)/.kaliveda
204  //~~~~~~~~~
205  // but can be changed with variable
206  //~~~~~~~~~
207  // KaliVeda.WorkingDirectory: [directory]
208  //~~~~~~~~~
209  // in configuration file `.kvrootrc`.
210  //`[directory]` must be an absolute pathname, but can use shell variables like <code>\$(HOME)</code>.
211 
212  if (!fEnvIsInit) {//test if environment already initialised
213 
214  // Add path to kaliveda libraries to dynamic loader path
215  // This is needed to find plugins
216  // and also to be able to compile with kaliveda in the interpreter
217  TString libdir = GetLIBDIRFilePath();
218  gSystem->AddDynamicPath(libdir);
219 #ifdef ADD_DYN_PATH
220  // add paths to utility libraries to dynamic path to avoid bug with on-demand class loading for ROOT5/CINT
221  KVString add_dyn_path(ADD_DYN_PATH);
222  add_dyn_path.Begin(";");
223  while (!add_dyn_path.End()) {
224  gSystem->AddDynamicPath(add_dyn_path.Next(kTRUE));
225  }
226 #endif
227  // force re-reading of rootmap files in new dynamic path
228  gInterpreter->LoadLibraryMap();
229  // Add path to kaliveda header files
230  // This is needed to be able to compile with kaliveda in the interpreter
231  TString incdir = GetINCDIRFilePath();
232  incdir.Prepend("-I");
233  gSystem->AddIncludePath(incdir);
234 
235  //set up environment using kvrootrc file
236  if (!gEnv->Defined("DataSet.DatabaseFile")) {
237  ReadConfigFiles();
238  }
239 #ifdef WITH_GNU_INSTALL
240  // set working directory & create if needed
241  fWorkingDirectory = gEnv->GetValue("KaliVeda.WorkingDirectory", "$(HOME)/.kaliveda");
242  gSystem->ExpandPathName(fWorkingDirectory);
243  gSystem->mkdir(fWorkingDirectory, kTRUE);
244 #else
245  // set environment variable used in database makefiles
246  fWorkingDirectory = KV_ROOT;
247 #endif
248  // set environment variable used in database makefiles
249  gSystem->Setenv("KV_WORK_DIR", fWorkingDirectory);
250 
251  //generate new seed from system clock
252  gRandom->SetSeed(0);
253 
254 //#ifdef USING_ROOT6
255 // // enable implicit multithreading
256 // // comment because not compatible with CC batch system
257 // ROOT::EnableImplicitMT();
258 //#endif
259 
260  // initialisation has been performed
261  fEnvIsInit = kTRUE;
262  }
263 }
264 
265 
266 
274 
276 {
277  // Read all configuration files
278  // System config files are read first in the order they appear in file
279  // ${ETCDIR}/config.files
280  // Then we read any of the following files if they exist:
281  // ${HOME}/.kvrootrc
282  // ${PWD}/.kvrootrc
283 
284  TString tmp = GetETCDIRFilePath("config.files");
285  ifstream conflist;
286  conflist.open(tmp.Data());
287  if (!conflist.good()) {
288  ::Fatal("KVBase::ReadConfigFiles", "Cannot open %s", tmp.Data());
289  return;
290  }
291  KVString file;
292  file.ReadLine(conflist);
293  conflist.close();
294  file.Begin(";");
295  while (!file.End()) {
296  tmp = GetETCDIRFilePath(file.Next().Data());
297  //skip over any missing files - this is needed when installing from
298  //e.g. ubuntu packages if not all packages are installed
299  if (!gSystem->AccessPathName(tmp.Data())) gEnv->ReadFile(tmp.Data(), kEnvChange);
300  }
301 
302  AssignAndDelete(tmp, gSystem->ConcatFileName(gSystem->Getenv("HOME"), ".kvrootrc"));
303  gEnv->ReadFile(tmp.Data(), kEnvChange);
304 
305  tmp = "./.kvrootrc";
306  gEnv->ReadFile(tmp.Data(), kEnvChange);
307 
308  // load plugin handlers
309  gROOT->GetPluginManager()->LoadHandlersFromEnv(gEnv);
310 
311  // load mime types/icon definitions when not in batch (i.e. GUI-less) mode
312  if (!gROOT->IsBatch()) ReadGUIMimeTypes();
313 }
314 
315 
316 
319 
321 {
322  //Default constructor.
323  init();
324 }
325 
326 
327 
330 
331 KVBase::KVBase(const Char_t* name, const Char_t* type): TNamed(name, type)
332 {
333  //Ctor for object with given name and type.
334  init();
335 }
336 
337 
338 
341 
342 KVBase::KVBase(const KVBase& obj) : TNamed()
343 {
344  //copy ctor
345  init();
346 #if ROOT_VERSION_CODE >= ROOT_VERSION(3,4,0)
347  obj.Copy(*this);
348 #else
349  ((KVBase&) obj).Copy(*this);
350 #endif
351 }
352 
353 
354 
357 
359 {
360  // copy assignment operator
361 
362  if (&other != this) {
363  other.Copy(*this);
364  }
365  return (*this);
366 }
367 
368 
369 
371 
372 KVBase::~KVBase()
373 {
374  fNbObj--;
375 }
376 
377 
378 
379 
382 
384 {
385  //Clear object properties : name, type/title, number, label
386  TNamed::Clear(opt);
387  fNumber = 0;
388  fLabel = "";
389 }
390 
391 
392 #if ROOT_VERSION_CODE >= ROOT_VERSION(3,4,0)
393 
396 
397 void KVBase::Copy(TObject& obj) const
398 #else
399 void KVBase::Copy(TObject& obj)
400 #endif
401 {
402  //Make a copy of this object
403 
404  TNamed::Copy(obj);
405  ((KVBase&) obj).SetNumber(fNumber);
406  ((KVBase&) obj).SetLabel(fLabel);
407 }
408 
409 
410 
412 
414 {
415  cout << "KVBase object: Name=" << GetName() << " Type=" << GetType();
416  if (fLabel != "")
417  cout << " Label=" << GetLabel();
418  if (fNumber != 0)
419  cout << " Number=" << GetNumber();
420  cout << endl;
421 }
422 
423 
424 
430 
431 void KVBase::Streamer(TBuffer& R__b)
432 {
433  //Backwards compatible streamer for KVBase objects
434  //Needed to handle 'fLabel' char array in class version 1
435  //Objects written with version < 3 did not have kIsKaliVedaObject bit set,
436  //we set it here when reading object.
437 
438  if (R__b.IsReading()) {
439  UInt_t R__s, R__c;
440  Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
441  if (R__v > 1) {
442  if (R__v < 4) {
443  TNamed::Streamer(R__b);
444  R__b >> fNumber;
445  R__b >> fLabel;
446  if (R__v < 3) SetBit(kIsKaliVedaObject);
447  R__b.CheckByteCount(R__s, R__c, KVBase::IsA());
448  }
449  else {
450  //AUTOMATIC STREAMER EVOLUTION FOR CLASS VERSION > 3
451  KVBase::Class()->ReadBuffer(R__b, this, R__v, R__s, R__c);
452  }
453  return;
454  }
455  //OLD STREAMER FOR CLASS VERSION 1
456  TNamed::Streamer(R__b);
457  R__b >> fNumber;
458  UInt_t LabelLength;
459  R__b >> LabelLength;
460  if (LabelLength) {
461  Char_t* Label = new Char_t[LabelLength];
462  R__b.ReadFastArray(Label, LabelLength);
463  fLabel = Label;
464  delete[]Label;
465  }
467  R__b.CheckByteCount(R__s, R__c, KVBase::IsA());
468  }
469  else {
470  KVBase::Class()->WriteBuffer(R__b, this);
471  }
472 }
473 
474 
475 
476 
488 
489 Bool_t SearchFile(const Char_t* name, TString& fullpath, int ndirs, ...)
490 {
491  //Search for file in an arbitrary number of locations, return kTRUE if file found and put full path to file in 'fullpath"
492  //
493  //'name' is a filename (not an absolute pathname) i.e. "toto.dat"
494  //'fullpath" will contain the full path to the file if it is found (if file not found, fullpath="")
495  //'ndirs" is the number of directories to search in
496  //the remaining arguments are the names of 'ndirs' paths to search in, i.e.
497  //
498  // SearchFile("toto.dat", fullpath, 2, gSystem->pwd(), gSystem->HomeDirectory());
499  //
500  //means: search for a file 'toto.dat' in current working directory, then user's home directory.
501 
502  if (ndirs <= 0)
503  return kFALSE;
504 
505  va_list args;
506  va_start(args, ndirs);
507 
508  for (; ndirs; ndirs--) { //loop over directories
509 
510  AssignAndDelete(fullpath,
511  gSystem->ConcatFileName(va_arg(args, const char*),
512  name));
513  if (!gSystem->AccessPathName(fullpath.Data())) {
514  va_end(args);
515  return kTRUE;
516  }
517 
518  }
519 
520  va_end(args);
521  fullpath = ""; //clear fullpath string to avoid using it by mistake
522  return kFALSE;
523 }
524 
525 
526 
540 
541 Bool_t KVBase::SearchKVFile(const Char_t* name, TString& fullpath,
542  const Char_t* kvsubdir)
543 {
544  //search for files in the following order:
545  // if 'name' = absolute path the function returns kTRUE if the file exists
546  // if name != absolute path:
547  // 1. a. if 'kvsubdir'="" (default) look for file in $(pkgdatadir) directory
548  // 1. b. if 'kvsubdir'!="":
549  // if 'kvsubdir' is an absolute pathname, look in 'kvsubdir'
550  // if 'kvsubdir' is not an absolute pathname,
551  // look in '$(pkdatadir)/kvsubdir'
552  // 2. look for file with this name in user's home directory
553  // 3. look for file with this name in working directory
554  //in all cases the function returns kTRUE if the file was found.
555  //'fullpath' then contains the absolute path to the file
556 
557  if (gSystem->IsAbsoluteFileName(name)) {
558  // absolute path
559  fullpath = name;
560  return !gSystem->AccessPathName(name);
561  }
562 
563  TString kvfile_dir;
564  if (strcmp(kvsubdir, "")) {
565  // subdirectory hint given
566  if (!gSystem->IsAbsoluteFileName(kvsubdir))
567  kvfile_dir = GetDATADIRFilePath(kvsubdir); // relative path - assume in $(pkgdatadir)
568  else
569  kvfile_dir = kvsubdir; // absolute path - use as is
570  }
571  else // no subdirectory hint given
572  kvfile_dir = GetDATADIRFilePath();
573 
574  return SearchFile(name, fullpath, 3, kvfile_dir.Data(),
576 }
577 
578 
579 
580 
600 
601 Bool_t KVBase::SearchAndOpenKVFile(const Char_t* name, ifstream& file, const Char_t* kvsubdir, KVLockfile* locks)
602 {
603  //Search and open for READING a file:
604  //
605  //search for ascii file (and open it, if found) in the following order:
606  // if 'name' = absolute path the function returns kTRUE if the file exists
607  // if name != absolute path:
608  // 1. a. if 'kvsubdir'="" (default) look for file in $(pkdatadir) directory
609  // 1. b. if 'kvsubdir'!="" look for file in $(pkdatadir)/'kvsubdir'
610  // if 'kvsubdir' is an absolute pathname, look in 'kvsubdir'
611  // if 'kvsubdir' is not an absolute pathname,
612  // look in '$(pkdatadir)/kvsubdir'
613  // 2. look for file with this name in user's home directory
614  // 3. look for file with this name in working directory
615  //if the file is not found, kFALSE is returned.
616  //if file is found and can be opened, 'file' is then an ifstream connected to the open (ascii) file
617  //
618  //LOCKFILE:
619  //If a KVLockfile pointer is given, we use it to get a lock on the file before opening it.
620  //If this lock is not successful, the file is not opened and we return an error message.
621 
622  TString fullpath;
623  if (SearchKVFile(name, fullpath, kvsubdir)) {
624  //put lock on file if required
625  if (locks && !locks->Lock(fullpath.Data())) return kFALSE;
626  file.open(fullpath.Data());
627  if (file.good()) {
628  //cout << "Opened file : " << fullpath.Data() << endl;
629  return kTRUE;
630  }
631  //unlock file if not opened successfully
632  if (locks) locks->Release();
633  }
634  return kFALSE;
635 }
636 
637 
638 
657 
658 Bool_t KVBase::SearchAndOpenKVFile(const Char_t* name, ofstream& file, const Char_t* kvsubdir, KVLockfile* locks)
659 {
660  //Search and CREATE i.e. open for WRITING a file:
661  //
662  //open for writing an ascii file in the location determined in the following way:
663  // if 'name' = absolute path we use the full path
664  // if name != absolute path:
665  // 1. a. if 'kvsubdir'="" (default) file will be in $(pkdatadir) directory
666  // 1. b. if 'kvsubdir'!="":
667  // if 'kvsubdir' is an absolute pathname, file in 'kvsubdir'
668  // if 'kvsubdir' is not an absolute pathname,
669  // file will be in '$(pkdatadir)/kvsubdir'
670  //if an existing file is found, a warning is printed and the existing file 'toto' is renamed
671  //"toto.date". where 'date' is created with TDatime::AsSQLDate
672  // file' is then an ofstream connected to the opened file
673  //
674  //LOCKFILE:
675  //If a KVLockfile pointer is given, we use it to get a lock on the file before opening it.
676  //If this lock is not successful, the file is not opened and we return an error message.
677 
678  KVString fullpath;
679  if (gSystem->IsAbsoluteFileName(name)) {
680  fullpath = name;
681  }
682  else if (gSystem->IsAbsoluteFileName(kvsubdir)) {
683  AssignAndDelete(fullpath,
684  gSystem->ConcatFileName(kvsubdir, name));
685  }
686  else if (strcmp(kvsubdir, "")) {
687  KVString path = GetDATADIRFilePath(kvsubdir);
688  AssignAndDelete(fullpath,
689  gSystem->ConcatFileName(path.Data(), name));
690  }
691  else {
692  fullpath = GetDATADIRFilePath(name);
693  }
694  //Backup file if necessary
695  BackupFileWithDate(fullpath.Data());
696  //put lock on file if required
697  if (locks && !locks->Lock(fullpath.Data())) return kFALSE;
698  file.open(fullpath.Data());
699  return kTRUE;
700 }
701 
702 
703 
704 
715 
717 {
718  //`path` gives the full path (can include environment variables, special symbols)
719  //to a file which will be renamed with an extension containing the current date and time
720  //(in SQL format).
721  //
722  //Example:
723  //
724  // KVBase::BackupFileWithDate("$(HOME)/toto.txt")
725  //
726  //The file `toto.txt` will be renamed `toto.txt.2007-05-02_16:22:37`
727 
728  KVString fullpath = path;
729  gSystem->ExpandPathName(fullpath);
730  if (!gSystem->AccessPathName(fullpath.Data())) {//does the file exist ?
731  //backup file
732  TDatime now;
733  KVString date(now.AsSQLString());
734  date.ReplaceAll(' ', '_');
735  TString backup = fullpath + "." + date;
736  //lock both files
737  KVLockfile lf1(fullpath.Data()), lf2(backup.Data());
738  if (lf1.Lock() && lf2.Lock()) {
739  gSystem->Rename(fullpath.Data(), backup.Data());
740  printf("Info in <KVBase::BackupFileWithDate(const Char_t *)> : Existing file %s renamed %s\n",
741  fullpath.Data(), backup.Data());
742  }
743  }
744 }
745 
746 
747 
748 
755 
757 {
758  //Load plugin library in order to extend capabilities of base class "base", depending on
759  //the given uri (these arguments are used to call TPluginManager::FindHandler).
760  //Returns pointer to TPluginHandler.
761  //Returns 0 in case of problems.
762 
763  //does plugin exist for given name ?
764  TPluginHandler* ph =
765  (TPluginHandler*) gROOT->GetPluginManager()->FindHandler(base,
766  uri);
767  if (!ph)
768  return 0;
769 
770  //check plugin library/macro is available
771  if (ph->CheckPlugin() != 0)
772  return 0;
773 
774  //load plugin module
775  if (ph->LoadPlugin() != 0)
776  return 0;
777 
778  return ph;
779 }
780 
781 
782 
783 
789 
790 void KVBase::OpenTempFile(TString& base, ofstream& fp)
791 {
792  //Opens a uniquely-named file in system temp directory (gSystem->TempDirectory)
793  //Name of file is "basexxxxxxxxxx" where "xxxxxxxxx" is current time as returned
794  //by gSystem->Now().
795  //After opening file, 'base' contains full path to file.
796 
797  GetTempFileName(base);
798  fp.open(base.Data());
799 }
800 
801 
802 
803 
810 
812 {
813  //When called with base="toto.dat", the returned value of 'base' is
814  //"/full/path/to/temp/dir/toto.dat15930693"
815  //i.e. the full path to a file in the system temp directory (gSystem->TempDirectory)
816  //appended with the current time as returned by gSystem->Now() in order to make
817  //its name unique
818 
819  TString tmp1;
820  AssignAndDelete(tmp1,
822  base.Data()));
823  long lnow = (long) gSystem->Now();
824  base = tmp1 + lnow;
825  //make sure no existing file with same name
826  while (!gSystem->AccessPathName(base)) {
827  base = tmp1 + (++lnow);
828  }
829 }
830 
831 
832 
833 
836 
838 {
839  //Returns KaliVeda version string
840  static TString tmp(KV_VERSION);
841  return tmp.Data();
842 }
843 
844 
845 
846 
849 
851 {
852  // Returns username of person who performed build
853  static TString tmp(KV_BUILD_USER);
854  return tmp.Data();
855 }
856 
857 
858 
859 
862 
864 {
865  //Returns KaliVeda build date
866  static TString tmp(KV_BUILD_DATE);
867  return tmp.Data();
868 }
869 
870 
871 
874 
876 {
877  //Returns KaliVeda build date
878  static TString tmp(KV_BUILD_TIME);
879  return tmp.Data();
880 }
881 
882 
883 
884 
887 
889 {
890  //Returns KaliVeda build type (cmake build: Release, Debug, RelWithDebInfo, ...)
891  static TString tmp(KV_BUILD_TYPE);
892  return tmp.Data();
893 }
894 
895 
896 
897 
900 
902 {
903  //Returns top-level directory of source tree used for build
904  static TString tmp(KV_SOURCE_DIR);
905  return tmp.Data();
906 }
907 
908 
909 
910 
913 
915 {
916  //Returns top-level directory used for build
917  static TString tmp(KV_BUILD_DIR);
918  return tmp.Data();
919 }
920 
921 
922 #ifdef WITH_GIT_INFOS
923 
926 
928 {
929  // Returns git branch of sources
930  static TString tmp(KV_GIT_BRANCH);
931  return tmp.Data();
932 }
933 
934 
935 
938 
940 {
941  // Returns last git commit of sources
942  static TString tmp(KV_GIT_COMMIT);
943  return tmp.Data();
944 }
945 
946 #endif
947 
948 
963 
965 {
966  //By default, `FindExecutable(exec)` will look for the executable named by `exec`
967  //in the directories contained in the environment variable `PATH`. You can override
968  //this by giving your own search `path` as second argument (remember to write
969  //environment variables as <code>\$(PATH)</code>, for cross-platform compatibility).
970  //
971  //If `exec` is not found, and if it does not end with `.exe`, we look for `exec.exe`
972  //This is for compatibility with Windows/cygwin environments.
973  //
974  //If the executable is found, returns `kTRUE` and `exec` then holds full path to executable.
975  //Returns `kFALSE` if `exec` not found in paths.
976  //
977  //If `exec` is an absolute pathname, we return `kTRUE` if the file exists
978  //(we do not use `path`).
979 
980  TString spath(path), backup(exec), backup2(exec), expandexec(exec);
981  gSystem->ExpandPathName(expandexec);
982  if (gSystem->IsAbsoluteFileName(expandexec.Data())) {
983  //executable given as absolute path
984  //we check if it exists
985  if (!gSystem->AccessPathName(expandexec)) {
986  exec = expandexec;
987  return kTRUE;
988  }
989  else {
990  //try with ".exe" in case of Windows system
991  if (!expandexec.EndsWith(".exe")) {
992  expandexec += ".exe";
993  if (!gSystem->AccessPathName(expandexec)) {
994  exec = expandexec;
995  return kTRUE;
996  }
997  }
998  }
999  exec = backup;
1000  return kFALSE;
1001  }
1002  gSystem->ExpandPathName(spath);
1003  if (KVBase::FindFile(spath.Data(), exec))
1004  return kTRUE;
1005  if (!backup.EndsWith(".exe")) {
1006  backup += ".exe";
1007  if (KVBase::FindFile(spath.Data(), backup)) {
1008  exec = backup;
1009  return kTRUE;
1010  }
1011  }
1012  exec = backup2;
1013  return kFALSE;
1014 }
1015 
1016 
1017 
1018 
1022 
1023 const Char_t* KVBase::FindFile(const Char_t* search, TString& wfil)
1024 {
1025  //Backwards compatible fix for `TSystem::FindFile` which only exists from ROOT version 5.12/00 onwards.
1026  //Use this method as a replacement for `gSystem->FindFile` (same arguments)
1027 #ifdef __WITHOUT_TSYSTEM_FINDFILE
1028  Char_t* result = gSystem->Which(search, wfil.Data());
1029  if (result) {
1030  wfil = result;
1031  delete[]result;
1032  }
1033  else {
1034  wfil = "";
1035  }
1036  return wfil.Data();
1037 #else
1038  return gSystem->FindFile(search, wfil);
1039 #endif
1040 }
1041 
1042 
1043 
1044 
1064 
1065 Bool_t KVBase::FindClassSourceFiles(const Char_t* class_name, KVString& imp_file, KVString& dec_file, const Char_t* dir_name)
1066 {
1067  //Look for the source files corresponding to `class_name`
1068  //i.e. taking class_name as a base, we look for one of
1069  //
1070  //~~~~~~~
1071  //class_name.C,class_name.cpp,class_name.cxx
1072  //~~~~~~~
1073  //
1074  //and one of
1075  //
1076  //~~~~~~~
1077  //class_name.h,class_name.hh,class_name.H
1078  //~~~~~~~
1079  //
1080  //By default we look in the current working directory, unless argument `dir_name`
1081  //is given
1082  //
1083  //If found, the names of the two files are written in `imp_file` and
1084  //`dec_file`
1085 
1086  KVNameValueList impl_alt;
1087  int i = 0;
1088  impl_alt.SetValue("%s.C", i);
1089  impl_alt.SetValue("%s.cpp", i);
1090  impl_alt.SetValue("%s.cxx", i);
1091  KVNameValueList decl_alt;
1092  decl_alt.SetValue("%s.h", i);
1093  decl_alt.SetValue("%s.hh", i);
1094  decl_alt.SetValue("%s.H", i);
1095 
1096  TString _dir_name = dir_name;
1097  gSystem->ExpandPathName(_dir_name);
1098  TSystemDirectory dir("LocDir", _dir_name.Data());
1099  TList* lf = dir.GetListOfFiles();
1100  Bool_t ok_imp, ok_dec;
1101  ok_imp = ok_dec = kFALSE;
1102 
1103  //look for implementation file
1104  for (i = 0; i < impl_alt.GetNpar(); i++) {
1105  if (lf->FindObject(Form(impl_alt.GetParameter(i)->GetName(), class_name))) {
1106  imp_file = Form(impl_alt.GetParameter(i)->GetName(), class_name);
1107  ok_imp = kTRUE;
1108  }
1109  }
1110  //look for header file
1111  for (i = 0; i < decl_alt.GetNpar(); i++) {
1112  if (lf->FindObject(Form(decl_alt.GetParameter(i)->GetName(), class_name))) {
1113  dec_file = Form(decl_alt.GetParameter(i)->GetName(), class_name);
1114  ok_dec = kTRUE;
1115  }
1116  }
1117  delete lf;
1118  return (ok_imp && ok_dec);
1119 }
1120 
1121 
1122 
1123 
1139 
1140 const Char_t* KVBase::GetPluginURI(const Char_t* base, const Char_t* derived)
1141 {
1142  //Inverse of `gPluginMgr->FindHandler(const Char_t* base, const Char_t* uri)`
1143  //
1144  //Given a base class `base` and a derived class `derived`, we search `gEnv` to find the
1145  //URI corresponding to this plugin.
1146  //
1147  //Example: given a plugin such as
1148  //
1149  //~~~~~~~~
1150  //Plugin.KVIDTelescope: ^PHOS$ KVIDPhoswich KVIndra "KVIDPhoswich()"
1151  //~~~~~~~~
1152  //
1153  //then calling `KVBase::GetPluginURI("KVIDTelescope", "KVIDPhoswich")` will return `"PHOS"`.
1154  //
1155  //Most of the code is copied from `TPluginManager::LoadHandlersFromEnv`
1156 
1157  TIter next(gEnv->GetTable());
1158  TEnvRec* er;
1159  static TString tmp;
1160 
1161  while ((er = (TEnvRec*) next())) {
1162  const char* s;
1163  if ((s = strstr(er->GetName(), "Plugin."))) {
1164  // use s, i.e. skip possible OS and application prefix to Plugin.
1165  // so that GetValue() takes properly care of returning the value
1166  // for the specified OS and/or application
1167  const char* val = gEnv->GetValue(s, (const char*)0);
1168  if (val) {
1169  Int_t cnt = 0;
1170  s += 7;
1171  //is it the right base class ?
1172  if (strcmp(s, base)) continue; //skip to next env var if not right base
1173 
1174  char* v = StrDup(val);
1175  while (1) {
1176  TString regexp = strtok(!cnt ? v : 0, "; ");
1177  if (regexp.IsNull()) break;
1178  TString clss = strtok(0, "; ");
1179  if (clss.IsNull()) break;
1180  TString plugin = strtok(0, "; ");
1181  if (plugin.IsNull()) break;
1182  TString ctor = strtok(0, ";\"");
1183  if (!ctor.Contains("("))
1184  ctor = strtok(0, ";\"");
1185  if (clss == derived) {
1186  //found the required plugin
1187  //we remove the 'regexp' operator '^' from the beginning
1188  //and '$' from the end of the URI, if necessary
1189  if (regexp.MaybeRegexp()) {
1190  regexp.Remove(TString::kBoth, '^');
1191  regexp.Remove(TString::kBoth, '$');
1192  }
1193  tmp = regexp;
1194  delete [] v;
1195  return tmp.Data();
1196  }
1197  cnt++;
1198  }
1199  delete [] v;
1200  }
1201  }
1202  }
1203  tmp = "";
1204  return tmp;
1205 }
1206 
1207 
1208 
1209 
1222 
1224 {
1225  // Return whitespace-separated list of all plugin classes defined for
1226  // the given base class.
1227  //
1228  // E.g. if plugins exist for BaseClass:
1229  //
1230  // Plugin.BaseClass: URI PluginClass PluginLibrary "PluginClassConstructor(arguments)"
1231  // +Plugin.BaseClass: URI2 PluginClass2 PluginLibrary2 "PluginClass2Constructor(arguments)"
1232  //
1233  // then KVBase::GetListOfPlugins("BaseClass") will return "PluginClass PluginClass2"
1234  //
1235  // Most of the code is copied from `TPluginManager::LoadHandlersFromEnv`
1236 
1237  TIter next(gEnv->GetTable());
1238  TEnvRec* er;
1239  static TString tmp;
1240  tmp = "";
1241  while ((er = (TEnvRec*) next())) {
1242  const char* s;
1243  if ((s = strstr(er->GetName(), "Plugin."))) {
1244  // use s, i.e. skip possible OS and application prefix to Plugin.
1245  // so that GetValue() takes properly care of returning the value
1246  // for the specified OS and/or application
1247  const char* val = gEnv->GetValue(s, (const char*)0);
1248  if (val) {
1249  Int_t cnt = 0;
1250  s += 7;
1251  //is it the right base class ?
1252  if (strcmp(s, base)) continue; //skip to next env var if not right base
1253 
1254  char* v = StrDup(val);
1255  while (1) {
1256  TString regexp = strtok(!cnt ? v : 0, "; ");
1257  if (regexp.IsNull()) break;
1258  TString clss = strtok(0, "; ");
1259  if (clss.IsNull()) break;
1260  TString plugin = strtok(0, "; ");
1261  if (plugin.IsNull()) break;
1262  TString ctor = strtok(0, ";\"");
1263  if (!ctor.Contains("("))
1264  ctor = strtok(0, ";\"");
1265  tmp += clss;
1266  tmp += " ";
1267  cnt++;
1268  }
1269  delete [] v;
1270  }
1271  }
1272  }
1273  //remove final trailing whitespace
1274  tmp.Remove(TString::kTrailing, ' ');
1275  return tmp;
1276 }
1277 
1278 
1279 
1289 
1291 {
1292  // For a given base class, return a whitespace-separated list of plugin identifiers
1293  // which are known/defined.
1294  // E.g. if plugins exist for BaseClass:
1295  //
1296  // Plugin.BaseClass: URI PluginClass PluginLibrary "PluginClassConstructor(arguments)"
1297  // +Plugin.BaseClass: URI2 PluginClass2 PluginLibrary2 "PluginClass2Constructor(arguments)"
1298  //
1299  // then KVBase::GetListOfPluginURIs("BaseClass") will return "URI URI2"
1300 
1301  static TString tmp;
1302  KVString plugs = KVBase::GetListOfPlugins(base);
1303  plugs.Begin(" ");
1304  tmp = "";
1305  while (!plugs.End()) {
1306  if (tmp != "") tmp += " ";
1307  tmp += KVBase::GetPluginURI(base, plugs.Next());
1308  }
1309  return tmp;
1310 }
1311 
1312 
1313 
1319 
1321 {
1322  // Returns kTRUE if 'uri' is the name of a defined plugin, in which case 'base'
1323  // is the name of the base class extended by this plugin.
1324  //
1325  // Most of the code is copied from `TPluginManager::LoadHandlersFromEnv`
1326 
1327  TIter next(gEnv->GetTable());
1328  TEnvRec* er;
1329  while ((er = (TEnvRec*) next())) {
1330  KVString ername = er->GetName();
1331  if (ername.BeginsWith("Plugin.")) {
1332  base = ername;
1333  base.Remove(0, 7);
1334  KVString erval = gEnv->GetValue(ername, "");
1335  erval.Begin(" ");
1336  while (!erval.End()) {
1337  if (erval.Next() == uri) return kTRUE;
1338  }
1339  }
1340  }
1341  return kFALSE;
1342 }
1343 
1344 
1345 
1346 
1359 
1361 {
1362  // Add to standard ROOT mime types some new ones defined in `.kvrootrc`
1363  // for icons associated with graphs, runs, etc. by lines such as:
1364  //
1365  //~~~~~~~~~
1366  // KaliVeda.GUI.MimeTypes : KVIDMap
1367  // KaliVeda.GUI.MimeTypes.KVIDMap.Icon : rootdb_t.xpm
1368  // +KaliVeda.GUI.MimeTypes : KVIDZAGrid
1369  // KaliVeda.GUI.MimeTypes.KVIDZAGrid.Icon : draw_t.xpm
1370  //~~~~~~~~~
1371  //
1372  // etc.
1373 
1374  KVString mimetypes = gEnv->GetValue("KaliVeda.GUI.MimeTypes", "");
1375  if (mimetypes != "") {
1376 
1377  mimetypes.Begin(" ");
1378  while (!mimetypes.End()) {
1379 
1380  KVString classname = mimetypes.Next(kTRUE);
1381  KVString icon = gEnv->GetValue(Form("KaliVeda.GUI.MimeTypes.%s.Icon", classname.Data()), "draw_t.xpm");
1382  KVString type = classname;
1383  type.ToLower();
1384 
1385  if (gClient) gClient->GetMimeTypeList()->AddType(Form("[kaliveda/%s]", type.Data()),
1386  classname.Data(), icon.Data(), icon.Data(), "");
1387 
1388  }
1389  }
1390 }
1391 
1392 
1393 
1404 
1406 {
1407  // \brief Comparison between two 64-bit floating-point values
1408  //
1409  // Returns `kTRUE` if the integer representations of the two values are within
1410  // `maxdif` of each other. By default `maxdif=1`, which means that we consider that `x==y` if the
1411  // difference between them is no greater than the precision of `Double_t`
1412  // variables, i.e. `4.94065645841246544e-324`
1413  //
1414  // Based on the function `AlmostEqual2sComplement(float, float, int)`
1415  // by Bruce Dawson http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm
1416 
1417  union converter {
1418  Double_t f;
1419  Long64_t i;
1420  } zero, val1, val2;
1421 
1422  assert(maxdif > 0);
1423 
1424  if (A == B) return true;
1425 
1426  /* rustine to obtain the (64-bit) constant value 0x8000000000000000
1427  even on 32-bit machines (there is probably an easier way!) */
1428  zero.i = 1;
1429  zero.f = -zero.f;
1430  zero.i -= 1;
1431 
1432  val1.f = A;
1433  val2.f = B;
1434  Long64_t Aint, Bint;
1435  Aint = val1.i;
1436  Bint = val2.i;
1437  if (Aint < 0) Aint = zero.i - Aint;
1438  if (Bint < 0) Bint = zero.i - Bint;
1439 
1440  Long64_t intDiff = abs(val1.i - val2.i);
1441 
1442  if (intDiff <= maxdif) return true;
1443 
1444  return false;
1445 }
1446 
1447 
1448 
1457 
1458 Bool_t KVBase::OpenContextMenu(const char* method, TObject* obj, const char* alt_method_name)
1459 {
1460  // Open context menu for given method of object *obj.
1461  // By default title of menu is 'obj->ClassName()::method'
1462  // You can give an alternative method name in 'alt_method_name'
1463  // Returns kFALSE if the given method is not defined for the class of object in question.
1464  //
1465  // WARNING: even if this method returns kTRUE, this is no guarantee that the method
1466  // has indeed been executed. The user may have pressed the 'Cancel' button...
1467 
1468  TMethod* m = obj->IsA()->GetMethodAllAny(method);
1469  if (!m) {
1470  obj->Warning("OpenContextMenu", "%s is not a method of %s", method, obj->ClassName());
1471  return kFALSE;
1472  }
1473  TString Method = alt_method_name;
1474  if (Method == "") Method = method;
1475  TContextMenu* cm = new TContextMenu(Method, Form("%s::%s", obj->ClassName(), Method.Data()));
1476  cm->Action(obj, m);
1477  delete cm;
1478  return kTRUE;
1479 }
1480 
1481 
1482 
1489 
1490 void KVBase::CombineFiles(const Char_t* file1, const Char_t* file2, const Char_t* newfilename, Bool_t keep)
1491 {
1492  // STATIC method which allows to combine the contents of two ROOT files
1493  // (file1 and file2) into a new ROOT file (newfilename).
1494  // All objects from the two files will be written in the new file.
1495  //
1496  // if keep=kFALSE, the two files will be deleted after the operation
1497 
1498  ::Info("KVBase::CombineFiles", "Copying all objects from %s and %s ===> into new file %s", file1, file2, newfilename);
1499 
1500  TFileMerger file_merge;
1501  file_merge.AddFile(file1, kFALSE);
1502  file_merge.AddFile(file2, kFALSE);
1503  file_merge.OutputFile(newfilename);
1504  file_merge.Merge();
1505 
1506  // remove physical files from disk if required
1507  if (!keep) {
1508  gSystem->Unlink(file1);
1509  gSystem->Unlink(file2);
1510  }
1511 }
1512 
1513 
1514 
1522 
1524 {
1525  // Dummy method (returns NULL).
1526  // This method may be used in 'container' classes used with KVListView.
1527  // In order to open the context menu of the 'contained' object,
1528  // GetLabel() should return the real class of the object,
1529  // and this method should return its address.
1530  // Then call KVListView::SetUseObjLabelAsRealClass(kTRUE).
1531  return nullptr;
1532 }
1533 
1534 
1535 
1536 
1539 
1540 const Char_t* KVBase::GetExampleFilePath(const Char_t* library, const Char_t* namefile)
1541 {
1542  // Return full path to example file for given library (="KVMultiDet", "BackTrack", etc.)
1543  static TString path;
1544  path = KVBase::GetDATADIRFilePath("examples/");
1545  path += library;
1546  path += "/";
1547  path += namefile;
1548  return path.Data();
1549 }
1550 
1551 
1552 
1555 
1557 {
1558  // Prints welcome message and infos on version etc.
1559 
1560  cout << "/----------------------------------------------------------------------\\" << endl;
1561  cout << "| Welcome to KaliVeda " << GetKVVersion() << " github:kaliveda-dev/kaliveda |" << endl;
1562  cout << "| (c) 2002-2022, The KaliVeda development team |" << endl;
1563  cout << "| |" << endl;
1564  cout << "| Built with ROOT " << KV_ROOT_VERSION << " on " << KVBase::GetKVBuildDate() << ", " << KVBase::GetKVBuildTime() << " |" << endl;
1565 #ifdef WITH_GIT_INFOS
1566  TString gitinfo;
1567  gitinfo.Form("%s@%s", gitBranch(), gitCommit());
1568  printf("| From %-63s |\n", gitinfo.Data());
1569 #endif
1570  cout << "| See http://indra.in2p3.fr/kaliveda for help |" << endl;
1571  cout << "\\----------------------------------------------------------------------/" << endl << endl;
1572 }
1573 
1574 
1575 
1581 
1582 const Char_t* KVBase::GetDataSetEnv(const Char_t* dataset, const Char_t* type, const Char_t* defval)
1583 {
1584  // Static method to interrogate dataset-specific variables in configuration
1585  // Will look for gEnv->GetValue "dataset.type"
1586  // then simply "type" if no dataset-specific value is found.
1587  // If neither resource is defined, return the "defval" default value (="" by default)
1588  TString temp;
1589  temp.Form("%s.%s", dataset, type);
1590  if (gEnv->Defined(temp.Data())) return gEnv->GetValue(temp.Data(), "");
1591  return gEnv->GetValue(type, defval);
1592 }
1593 
1594 
1595 
1601 
1602 Double_t KVBase::GetDataSetEnv(const Char_t* dataset, const Char_t* type, Double_t defval)
1603 {
1604  // Static method to interrogate dataset-specific variables in configuration
1605  // Will look for gEnv->GetValue "dataset.type"
1606  // then simply "type" if no dataset-specific value is found.
1607  // If neither resource is defined, return the "defval" default value
1608 
1609  TString temp;
1610  temp.Form("%s.%s", dataset, type);
1611  if (gEnv->Defined(temp.Data())) return gEnv->GetValue(temp.Data(), 0.0);
1612  return gEnv->GetValue(type, defval);
1613 }
1614 
1615 
1616 
1622 
1623 Bool_t KVBase::GetDataSetEnv(const Char_t* dataset, const Char_t* type, Bool_t defval)
1624 {
1625  // Static method to interrogate dataset-specific variables in configuration
1626  //Will look for gEnv->GetValue "dataset.type"
1627  //then simply "type" if no dataset-specific value is found.
1628  //If neither resource is defined, return the "defval" default value
1629 
1630  TString temp;
1631  temp.Form("%s.%s", dataset, type);
1632  if (gEnv->Defined(temp.Data())) return gEnv->GetValue(temp.Data(), kFALSE);
1633  return gEnv->GetValue(type, defval);
1634 }
1635 
1636 
1637 
1653 
1654 Double_t KVBase::ProtectedGetX(const TF1* func, Double_t val, int& status, Double_t xmin, Double_t xmax) const
1655 {
1656  // Since ROOT6, the TF1::GetX() method can no longer be used without precaution.
1657  //
1658  // In ROOT5, if the value val was larger or smaller than the maximum or minimum value of
1659  // the function (within its defined range) then TF1::GetX() would return X of the
1660  // maximum or minimum, respectively.
1661  //
1662  // In ROOT6, TF1::GetX() has been reimplemented so that, in the above case, it
1663  // prints out 3 warning messages and returns a TMath::QuietNaN()! Therefore we provide this
1664  // function in order to replicate the previous behaviour.
1665  //
1666  // The status = 0 if the value is within the limits of the function.
1667  // status = +1 if value is above the maximum, or status = -1 if value is below the minimum
1668  //
1669  // When compiled with ROOT5, this method just calls TF1::GetX() (and status = 0 always).
1670 
1671 #ifdef USING_ROOT6
1672  status = 0;
1673  if (val > func->GetMaximum(xmin, xmax)) {
1674  status = 1;
1675  return func->GetMaximumX(xmin, xmax);
1676  }
1677  else if (val < func->GetMinimum(xmin, xmax)) {
1678  status = -1;
1679  return func->GetMinimumX(xmin, xmax);
1680  }
1681  else
1682  return func->GetX(val, xmin, xmax);
1683 #else
1684  status = 0;
1685  return func->GetX(val, xmin, xmax);
1686 #endif
1687 }
1688 
1689 
1690 
1696 
1697 void KVBase::Deprecated(const char* where, const char* advice)
1698 {
1699  // Print a message to indicate when the called method is deprecated and give advice how to do better
1700  //
1701  // Don't call directly: use the macro Deprecate(advice) which will automatically fill in the method name
1702  // (see KVMacros.h)
1703 
1704  printf("Warning in <%s>: Method is deprecated in v%s and will be removed in future.\n%s\n",
1705  where, KVBase::GetKVVersion(), advice);
1706 }
1707 
1708 
1709 
int Int_t
unsigned int UInt_t
long
Bool_t SearchFile(const Char_t *name, TString &fullpath, int ndirs,...)
Search for file in an arbitrary number of locations, return kTRUE if file found and put full path to ...
Definition: KVBase.cpp:489
#define xstr(s)
Definition: KVBase.cpp:56
void AssignAndDelete(TString &target, char *tobedeleted)
ClassImp(KVPartitionList) void KVPartitionList
Initialisation.
#define f(i)
short Version_t
char Char_t
const Bool_t kFALSE
bool Bool_t
double Double_t
const Bool_t kTRUE
const char Option_t
R__EXTERN TEnv * gEnv
kEnvChange
#define gClient
int type
float xmin
float xmax
#define gInterpreter
#define gROOT
R__EXTERN TRandom * gRandom
char * Form(const char *fmt,...)
char * StrDup(const char *str)
R__EXTERN TSystem * gSystem
Base class for KaliVeda framework.
Definition: KVBase.h:135
static TString fWorkingDirectory
user working directory for e.g. database files
Definition: KVBase.h:145
static UInt_t fNbObj
Total number of KaliVeda objects (actually counts number of calls to default ctor)
Definition: KVBase.h:138
UInt_t fNumber
for numbering objects
Definition: KVBase.h:139
static Bool_t FindClassSourceFiles(const Char_t *class_name, KVString &imp_file, KVString &dec_file, const Char_t *dir_name=".")
Definition: KVBase.cpp:1065
static const Char_t * GetBINDIRFilePath(const Char_t *namefile="")
Definition: KVBase.cpp:118
static void OpenTempFile(TString &base, std::ofstream &fp)
Definition: KVBase.cpp:790
static const Char_t * GetDATADIRFilePath(const Char_t *namefile="")
Definition: KVBase.cpp:74
static const Char_t * GetDATABASEFilePath()
Definition: KVBase.cpp:92
static const Char_t * GetKVBuildDate()
Returns KaliVeda build date.
Definition: KVBase.cpp:863
static const Char_t * FindFile(const Char_t *search, TString &wfil)
Definition: KVBase.cpp:1023
static const Char_t * GetINCDIRFilePath(const Char_t *namefile="")
Definition: KVBase.cpp:109
static const Char_t * gitCommit()
Returns last git commit of sources.
Definition: KVBase.cpp:939
static const Char_t * GetWORKDIRFilePath(const Char_t *namefile="")
Definition: KVBase.cpp:127
void init()
Default initialisation.
Definition: KVBase.cpp:138
static Bool_t FindExecutable(TString &exec, const Char_t *path="$(PATH)")
Definition: KVBase.cpp:964
static const Char_t * GetKVBuildUser()
Returns username of person who performed build.
Definition: KVBase.cpp:850
static void BackupFileWithDate(const Char_t *path)
Definition: KVBase.cpp:716
static void ReadConfigFiles()
Definition: KVBase.cpp:275
static const Char_t * gitBranch()
Returns git branch of sources.
Definition: KVBase.cpp:927
static const Char_t * GetListOfPluginURIs(const Char_t *base)
Definition: KVBase.cpp:1290
TString fLabel
label for the object
Definition: KVBase.h:141
virtual void Clear(Option_t *opt="")
Clear object properties : name, type/title, number, label.
Definition: KVBase.cpp:383
KVBase()
Default constructor.
Definition: KVBase.cpp:320
static const Char_t * GetListOfPlugins(const Char_t *base)
Definition: KVBase.cpp:1223
static Bool_t fEnvIsInit
set when environment is initialised
Definition: KVBase.h:144
static Bool_t AreEqual(Double_t x, Double_t y, Long64_t maxdif=1)
Comparison between two 64-bit floating-point values.
Definition: KVBase.cpp:1405
KVBase & operator=(const KVBase &)
copy assignment operator
Definition: KVBase.cpp:358
static void CombineFiles(const Char_t *file1, const Char_t *file2, const Char_t *newfilename, Bool_t keep=kTRUE)
Definition: KVBase.cpp:1490
const Char_t * GetLabel() const
Definition: KVBase.h:192
const Char_t * GetType() const
Definition: KVBase.h:170
static const Char_t * GetTEMPLATEDIRFilePath(const Char_t *namefile="")
Definition: KVBase.cpp:83
static const Char_t * GetKVSourceDir()
Returns top-level directory of source tree used for build.
Definition: KVBase.cpp:901
static void InitEnvironment()
Definition: KVBase.cpp:181
virtual void Print(Option_t *option="") const
Definition: KVBase.cpp:413
static const Char_t * GetDataSetEnv(const Char_t *dataset, const Char_t *type, const Char_t *defval)
Definition: KVBase.cpp:1582
static const Char_t * GetKVBuildTime()
Returns KaliVeda build date.
Definition: KVBase.cpp:875
static void PrintSplashScreen()
Prints welcome message and infos on version etc.
Definition: KVBase.cpp:1556
static const Char_t * GetLIBDIRFilePath(const Char_t *namefile="")
Definition: KVBase.cpp:100
static const Char_t * GetExampleFilePath(const Char_t *library, const Char_t *namefile)
Return full path to example file for given library (="KVMultiDet", "BackTrack", etc....
Definition: KVBase.cpp:1540
Double_t ProtectedGetX(const TF1 *func, Double_t val, int &status, Double_t xmin=0.0, Double_t xmax=0.0) const
Definition: KVBase.cpp:1654
static const Char_t * GetKVBuildDir()
Returns top-level directory used for build.
Definition: KVBase.cpp:914
static Bool_t SearchAndOpenKVFile(const Char_t *name, std::ifstream &file, const Char_t *kvsubdir="", KVLockfile *locks=0)
Definition: KVBase.cpp:601
static void ReadGUIMimeTypes()
Definition: KVBase.cpp:1360
static Bool_t IsThisAPlugin(const TString &uri, TString &base)
Definition: KVBase.cpp:1320
@ kIsKaliVedaObject
Definition: KVBase.h:156
virtual TObject * GetObject() const
Definition: KVBase.cpp:1523
static void GetTempFileName(TString &base)
Definition: KVBase.cpp:811
static Bool_t SearchKVFile(const Char_t *name, TString &fullpath, const Char_t *kvsubdir="")
Definition: KVBase.cpp:541
static const Char_t * GetKVBuildType()
Returns KaliVeda build type (cmake build: Release, Debug, RelWithDebInfo, ...)
Definition: KVBase.cpp:888
static const Char_t * GetPluginURI(const Char_t *base, const Char_t *plugin)
Definition: KVBase.cpp:1140
static const Char_t * GetETCDIRFilePath(const Char_t *namefile="")
Definition: KVBase.cpp:65
static Bool_t OpenContextMenu(const char *method, TObject *obj, const char *alt_method_name="")
Definition: KVBase.cpp:1458
virtual void Copy(TObject &) const
Make a copy of this object.
Definition: KVBase.cpp:397
static TPluginHandler * LoadPlugin(const Char_t *base, const Char_t *uri="0")
Definition: KVBase.cpp:756
static const Char_t * GetKVVersion()
Returns KaliVeda version string.
Definition: KVBase.cpp:837
static void Deprecated(const char *method, const char *advice)
Definition: KVBase.cpp:1697
UInt_t GetNumber() const
Definition: KVBase.h:213
Interface to (Linux) system lockfile command.
Definition: KVLockfile.h:69
Bool_t Release()
Definition: KVLockfile.cpp:195
Bool_t Lock(const Char_t *filename="")
Definition: KVLockfile.cpp:165
Handles lists of named parameters with different types, a list of KVNamedParameter objects.
KVNamedParameter * GetParameter(Int_t idx) const
return the parameter object with index idx
void SetValue(const Char_t *name, value_type value)
Int_t GetNpar() const
return the number of stored parameters
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
virtual Version_t ReadVersion(UInt_t *start=0, UInt_t *bcnt=0, const TClass *cl=0)=0
virtual Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const char *classname)=0
virtual void ReadFastArray(Bool_t *b, Int_t n)=0
Bool_t IsReading() const
const char * AsSQLString() const
const char * GetName() const
virtual const char * GetValue(const char *name, const char *dflt) const
virtual Int_t ReadFile(const char *fname, EEnvLevel level)
Bool_t Defined(const char *name) const
THashList * GetTable() const
virtual Double_t GetMinimumX(Double_t xmin=0, Double_t xmax=0, Double_t epsilon=1.E-10, Int_t maxiter=100, Bool_t logx=false) const
virtual Double_t GetX(Double_t y, Double_t xmin=0, Double_t xmax=0, Double_t epsilon=1.E-10, Int_t maxiter=100, Bool_t logx=false) const
virtual Double_t GetMaximum(Double_t xmin=0, Double_t xmax=0, Double_t epsilon=1.E-10, Int_t maxiter=100, Bool_t logx=false) const
virtual Double_t GetMaximumX(Double_t xmin=0, Double_t xmax=0, Double_t epsilon=1.E-10, Int_t maxiter=100, Bool_t logx=false) const
virtual Bool_t OutputFile(const char *url, Bool_t force)
virtual Bool_t Merge(Bool_t=kTRUE)
virtual Bool_t AddFile(const char *url, Bool_t cpProgress=kTRUE)
virtual TObject * FindObject(const char *name) const
virtual const char * GetName() const
virtual void Copy(TObject &named) const
virtual void Clear(Option_t *option="")
void SetBit(UInt_t f)
virtual const char * ClassName() const
virtual void Warning(const char *method, const char *msgfmt,...) const
virtual void Info(const char *method, const char *msgfmt,...) const
Int_t CheckPlugin() const
Int_t LoadPlugin()
virtual void SetSeed(ULong_t seed=0)
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Bool_t MaybeRegexp() const
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
const char * Data() const
Bool_t IsNull() const
TString & Prepend(char c, Ssiz_t rep=1)
void Form(const char *fmt,...)
TString & Remove(EStripType s, char c)
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
TString & ReplaceAll(const char *s1, const char *s2)
virtual TList * GetListOfFiles() const
virtual void AddIncludePath(const char *includePath)
virtual const char * Getenv(const char *env)
virtual char * ConcatFileName(const char *dir, const char *name)
virtual const char * FindFile(const char *search, TString &file, EAccessMode mode=kFileExists)
virtual int mkdir(const char *name, Bool_t recursive=kFALSE)
const char * pwd()
virtual TTime Now()
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
virtual int Rename(const char *from, const char *to)
virtual Bool_t IsAbsoluteFileName(const char *dir)
virtual void AddDynamicPath(const char *pathname)
virtual char * ExpandPathName(const char *path)
virtual char * Which(const char *search, const char *file, EAccessMode mode=kFileExists)
virtual void Setenv(const char *name, const char *value)
virtual const char * HomeDirectory(const char *userName=nullptr)
virtual int Unlink(const char *name)
virtual const char * TempDirectory() const
long long Long64_t
RooCmdArg Label(const char *str)
const long double s
Definition: KVUnits.h:94
const long double cm
Definition: KVUnits.h:66
const long double m
Definition: KVUnits.h:70
const char * cnt
v