KaliVeda
Toolkit for HIC analysis
KVBase.cpp
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 "KVBase.h"
20 #include "TClass.h"
21 #include "KVString.h"
22 #include "TRandom.h"
23 #include "TSystem.h"
24 #include "TInterpreter.h"
25 #include "TPluginManager.h"
26 #include "KVNameValueList.h"
27 #include "KVSystemDirectory.h"
28 #include "KVVersion.h"
29 #ifdef WITH_GIT_INFOS
30 #include "KVGitInfo.h"
31 #endif
32 #ifdef WITH_RSQLITE
33 #include "SQLiteDB.h"
34 #endif
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 <TFileMerger.h>
43 #include <TH1.h>
44 #include <TKey.h>
45 #include <fstream>
46 
47 using namespace std;
48 
50 
51 // for multithread safety
52 std::mutex _kvbase_mutex;
53 TString KVBase::fWorkingDirectory = "$(HOME)/.kaliveda";
55 
56 
58 
59 const Char_t* KVBase::GetETCDIRFilePath(const Char_t* namefile)
60 {
61  if (strcmp(namefile, "")) return Form("%s/%s", kaliveda::build_infos::ETCDIR.c_str(), namefile);
62  return kaliveda::build_infos::ETCDIR.c_str();
63 }
64 
65 
67 
68 const Char_t* KVBase::GetDATADIRFilePath(const Char_t* namefile)
69 {
70  if (strcmp(namefile, "")) return Form("%s/%s", kaliveda::build_infos::DATADIR.c_str(), namefile);
71  return kaliveda::build_infos::DATADIR.c_str();
72 }
73 
74 
76 
78 {
79  if (strcmp(namefile, "")) return Form("%s/%s", kaliveda::build_infos::TEMPLATEDIR.c_str(), namefile);
81 }
82 
83 
85 
87 {
88  return Form("%s/db", fWorkingDirectory.Data());
89 }
90 
91 
93 
94 const Char_t* KVBase::GetLIBDIRFilePath(const Char_t* namefile)
95 {
96  if (strcmp(namefile, "")) return Form("%s/%s", kaliveda::build_infos::LIBDIR.c_str(), namefile);
97  return kaliveda::build_infos::LIBDIR.c_str();
98 }
99 
100 
102 
103 const Char_t* KVBase::GetINCDIRFilePath(const Char_t* namefile)
104 {
105  if (strcmp(namefile, "")) return Form("%s/%s", kaliveda::build_infos::INCDIR.c_str(), namefile);
106  return kaliveda::build_infos::INCDIR.c_str();
107 }
108 
109 
111 
112 const Char_t* KVBase::GetBINDIRFilePath(const Char_t* namefile)
113 {
114  if (strcmp(namefile, "")) return Form("%s/%s", kaliveda::build_infos::BINDIR.c_str(), namefile);
115  return kaliveda::build_infos::BINDIR.c_str();
116 }
117 
118 
120 
121 const Char_t* KVBase::GetWORKDIRFilePath(const Char_t* namefile)
122 {
123  if (strcmp(namefile, "")) return Form("%s/%s", fWorkingDirectory.Data(), namefile);
124  return fWorkingDirectory;
125 }
126 
127 
129 
131 {
133 }
134 
135 
137 
139 {
141 }
142 
143 
146 
148 {
149  //Default initialisation
150 
151  InitEnvironment();
152  fNumber = 0;
153  fLabel = "";
154  SetBit(kIsKaliVedaObject);
155 }
156 
157 
158 
188 
190 {
191  // STATIC method to Initialise KaliVeda environment
192  // Reads config files in <code>\$(pkgdatadir)/etc</code> and sets up environment
193  // (data repositories, datasets, etc. etc.).
194  // Adds directory where kaliveda shared libs are installed to the dynamic
195  // path - for finding and loading plugins.
196  // Resets the `gRandom` random number sequence using a clock-based seed
197  // (i.e. random sequences do not repeat).
198  //
199  // Normally, the first object created which inherits from KVBase will
200  // perform this initialisation; if you need to set up the environment before
201  // creating a KVBase object, or if you just want to be absolutely sure that
202  // the environment has been initialised, you can call this method.
203  //
204  // #### Note for GNU-style installations
205  // If KaliVeda is built with the cmake option `-Dgnuinstall=yes` then each
206  // user will have a working directory which will be used to store any files
207  // generated by KaliVeda at runtime.
208  //
209  // By default the location of user's working directory is set to
210  //~~~~~~~~~
211  // $(HOME)/.kaliveda
212  //~~~~~~~~~
213  // but can be changed with variable
214  //~~~~~~~~~
215  // KaliVeda.WorkingDirectory: [directory]
216  //~~~~~~~~~
217  // in configuration file `.kvrootrc`.
218  //`[directory]` must be an absolute pathname, but can use shell variables like <code>\$(HOME)</code>.
219 
220  std::lock_guard<std::mutex> lk(_kvbase_mutex); // prevent multiple initialisation in different threads
221 
222  if (!fEnvIsInit) {//test if environment already initialised
223 
224  // enable ROOT thread safety
226 
227  // Add path to kaliveda libraries to dynamic loader path
228  // This is needed to find plugins
229  // and also to be able to compile with kaliveda in the interpreter
230  TString libdir = GetLIBDIRFilePath();
231  gSystem->AddDynamicPath(libdir);
232  // force re-reading of rootmap files in new dynamic path
233  gInterpreter->LoadLibraryMap();
234  // Add path to kaliveda header files
235  // This is needed to be able to compile with kaliveda in the interpreter
236  TString incdir = GetINCDIRFilePath();
237  incdir.Prepend("-I");
238  gSystem->AddIncludePath(incdir);
239 
240  //set up environment using kvrootrc file
241  if (!gEnv->Defined("DataSet.DatabaseFile")) {
242  ReadConfigFiles();
243  }
244 #ifdef WITH_GNU_INSTALL
245  // set working directory & create if needed
246  fWorkingDirectory = gEnv->GetValue("KaliVeda.WorkingDirectory", "$(HOME)/.kaliveda");
247  gSystem->ExpandPathName(fWorkingDirectory);
248  gSystem->mkdir(fWorkingDirectory, kTRUE);
249 #else
250  // set environment variable used in database makefiles
251  fWorkingDirectory = KV_ROOT;
252 #endif
253  // set environment variable used in database makefiles
254  gSystem->Setenv("KV_WORK_DIR", fWorkingDirectory);
255 
256  //generate new seed from system clock
257  gRandom->SetSeed(0);
258 
259  // initialisation has been performed
260  fEnvIsInit = kTRUE;
261  }
262 }
263 
264 
265 
273 
275 {
276  // Read all configuration files
277  // System config files are read first in the order they appear in file
278  // ${ETCDIR}/config.files
279  // Then we read any of the following files if they exist:
280  // ${HOME}/.kvrootrc
281  // ${PWD}/.kvrootrc (if PWD!=HOME)
282 
283  TString tmp = GetETCDIRFilePath("config.files");
284  ifstream conflist;
285  conflist.open(tmp.Data());
286  if (!conflist.good()) {
287  ::Fatal("KVBase::ReadConfigFiles", "Cannot open %s", tmp.Data());
288  return;
289  }
290  KVString file;
291  file.ReadLine(conflist);
292  conflist.close();
293  file.Begin(";");
294  while (!file.End()) {
295  tmp = GetETCDIRFilePath(file.Next().Data());
296  //skip over any missing files - this is needed when installing from
297  //e.g. ubuntu packages if not all packages are installed
298  if (!gSystem->AccessPathName(tmp.Data())) gEnv->ReadFile(tmp.Data(), kEnvChange);
299  }
300 
301  AssignAndDelete(tmp, gSystem->ConcatFileName(gSystem->Getenv("HOME"), ".kvrootrc"));
302  gEnv->ReadFile(tmp.Data(), kEnvChange);
303 
304  if (TString(gSystem->pwd()) != gSystem->HomeDirectory()) {
305  tmp = "./.kvrootrc";
306  gEnv->ReadFile(tmp.Data(), kEnvChange);
307  }
308 
309  // load plugin handlers
310  gROOT->GetPluginManager()->LoadHandlersFromEnv(gEnv);
311 
312  // load mime types/icon definitions when not in batch (i.e. GUI-less) mode
313  if (!gROOT->IsBatch()) ReadGUIMimeTypes();
314 }
315 
316 
317 
320 
322 {
323  //Default constructor.
324  init();
325 }
326 
327 
328 
331 
332 KVBase::KVBase(const Char_t* name, const Char_t* type): TNamed(name, type)
333 {
334  //Ctor for object with given name and type.
335  init();
336 }
337 
338 
339 
342 
343 KVBase::KVBase(const KVBase& obj) : TNamed()
344 {
345  //copy ctor
346  init();
347 #if ROOT_VERSION_CODE >= ROOT_VERSION(3,4,0)
348  obj.Copy(*this);
349 #else
350  ((KVBase&) obj).Copy(*this);
351 #endif
352 }
353 
354 
355 
358 
360 {
361  // copy assignment operator
362 
363  if (&other != this) {
364  other.Copy(*this);
365  }
366  return (*this);
367 }
368 
369 
370 
371 
374 
376 {
377  //Clear object properties : name, type/title, number, label
378  TNamed::Clear(opt);
379  fNumber = 0;
380  fLabel = "";
381 }
382 
383 
384 #if ROOT_VERSION_CODE >= ROOT_VERSION(3,4,0)
385 
388 
389 void KVBase::Copy(TObject& obj) const
390 #else
391 void KVBase::Copy(TObject& obj)
392 #endif
393 {
394  //Make a copy of this object
395 
396  TNamed::Copy(obj);
397  ((KVBase&) obj).SetNumber(fNumber);
398  ((KVBase&) obj).SetLabel(fLabel);
399 }
400 
401 
402 
404 
406 {
407  cout << "KVBase object: Name=" << GetName() << " Type=" << GetType();
408  if (fLabel != "")
409  cout << " Label=" << GetLabel();
410  if (fNumber != 0)
411  cout << " Number=" << GetNumber();
412  cout << endl;
413 }
414 
415 
416 
422 
423 void KVBase::Streamer(TBuffer& R__b)
424 {
425  //Backwards compatible streamer for KVBase objects
426  //Needed to handle 'fLabel' char array in class version 1
427  //Objects written with version < 3 did not have kIsKaliVedaObject bit set,
428  //we set it here when reading object.
429 
430  if (R__b.IsReading()) {
431  UInt_t R__s, R__c;
432  Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
433  if (R__v > 1) {
434  if (R__v < 4) {
435  TNamed::Streamer(R__b);
436  R__b >> fNumber;
437  R__b >> fLabel;
438  if (R__v < 3) SetBit(kIsKaliVedaObject);
439  R__b.CheckByteCount(R__s, R__c, KVBase::IsA());
440  }
441  else {
442  //AUTOMATIC STREAMER EVOLUTION FOR CLASS VERSION > 3
443  KVBase::Class()->ReadBuffer(R__b, this, R__v, R__s, R__c);
444  }
445  return;
446  }
447  //OLD STREAMER FOR CLASS VERSION 1
448  TNamed::Streamer(R__b);
449  R__b >> fNumber;
450  UInt_t LabelLength;
451  R__b >> LabelLength;
452  if (LabelLength) {
453  Char_t* Label = new Char_t[LabelLength];
454  R__b.ReadFastArray(Label, LabelLength);
455  fLabel = Label;
456  delete[]Label;
457  }
459  R__b.CheckByteCount(R__s, R__c, KVBase::IsA());
460  }
461  else {
462  KVBase::Class()->WriteBuffer(R__b, this);
463  }
464 }
465 
466 
467 
468 
480 
481 Bool_t SearchFile(const Char_t* name, TString& fullpath, int ndirs, ...)
482 {
483  //Search for file in an arbitrary number of locations, return kTRUE if file found and put full path to file in 'fullpath"
484  //
485  //'name' is a filename (not an absolute pathname) i.e. "toto.dat"
486  //'fullpath" will contain the full path to the file if it is found (if file not found, fullpath="")
487  //'ndirs" is the number of directories to search in
488  //the remaining arguments are the names of 'ndirs' paths to search in, i.e.
489  //
490  // SearchFile("toto.dat", fullpath, 2, gSystem->pwd(), gSystem->HomeDirectory());
491  //
492  //means: search for a file 'toto.dat' in current working directory, then user's home directory.
493 
494  if (ndirs <= 0)
495  return kFALSE;
496 
497  va_list args;
498  va_start(args, ndirs);
499 
500  for (; ndirs; ndirs--) { //loop over directories
501 
502  AssignAndDelete(fullpath,
503  gSystem->ConcatFileName(va_arg(args, const char*),
504  name));
505  if (!gSystem->AccessPathName(fullpath.Data())) {
506  va_end(args);
507  return kTRUE;
508  }
509 
510  }
511 
512  va_end(args);
513  fullpath = ""; //clear fullpath string to avoid using it by mistake
514  return kFALSE;
515 }
516 
517 
518 
532 
533 Bool_t KVBase::SearchKVFile(const Char_t* name, TString& fullpath,
534  const Char_t* kvsubdir)
535 {
536  //search for files in the following order:
537  // if 'name' = absolute path the function returns kTRUE if the file exists
538  // if name != absolute path:
539  // 1. a. if 'kvsubdir'="" (default) look for file in $(pkgdatadir) directory
540  // 1. b. if 'kvsubdir'!="":
541  // if 'kvsubdir' is an absolute pathname, look in 'kvsubdir'
542  // if 'kvsubdir' is not an absolute pathname,
543  // look in '$(pkdatadir)/kvsubdir'
544  // 2. look for file with this name in user's home directory
545  // 3. look for file with this name in working directory
546  //in all cases the function returns kTRUE if the file was found.
547  //'fullpath' then contains the absolute path to the file
548 
550  // absolute path
551  fullpath = name;
552  return !gSystem->AccessPathName(name);
553  }
554 
555  TString kvfile_dir;
556  if (strcmp(kvsubdir, "")) {
557  // subdirectory hint given
558  if (!gSystem->IsAbsoluteFileName(kvsubdir))
559  kvfile_dir = GetDATADIRFilePath(kvsubdir); // relative path - assume in $(pkgdatadir)
560  else
561  kvfile_dir = kvsubdir; // absolute path - use as is
562  }
563  else // no subdirectory hint given
564  kvfile_dir = GetDATADIRFilePath();
565 
566  return SearchFile(name, fullpath, 3, kvfile_dir.Data(),
568 }
569 
570 
571 
572 
592 
593 Bool_t KVBase::SearchAndOpenKVFile(const Char_t* name, ifstream& file, const Char_t* kvsubdir, KVLockfile* locks)
594 {
595  //Search and open for READING a file:
596  //
597  //search for ascii file (and open it, if found) in the following order:
598  // if 'name' = absolute path the function returns kTRUE if the file exists
599  // if name != absolute path:
600  // 1. a. if 'kvsubdir'="" (default) look for file in $(pkdatadir) directory
601  // 1. b. if 'kvsubdir'!="" look for file in $(pkdatadir)/'kvsubdir'
602  // if 'kvsubdir' is an absolute pathname, look in 'kvsubdir'
603  // if 'kvsubdir' is not an absolute pathname,
604  // look in '$(pkdatadir)/kvsubdir'
605  // 2. look for file with this name in user's home directory
606  // 3. look for file with this name in working directory
607  //if the file is not found, kFALSE is returned.
608  //if file is found and can be opened, 'file' is then an ifstream connected to the open (ascii) file
609  //
610  //LOCKFILE:
611  //If a KVLockfile pointer is given, we use it to get a lock on the file before opening it.
612  //If this lock is not successful, the file is not opened and we return an error message.
613 
614  TString fullpath;
615  if (SearchKVFile(name, fullpath, kvsubdir)) {
616  //put lock on file if required
617  if (locks && !locks->Lock(fullpath.Data())) return kFALSE;
618  file.open(fullpath.Data());
619  if (file.good()) {
620  //cout << "Opened file : " << fullpath.Data() << endl;
621  return kTRUE;
622  }
623  //unlock file if not opened successfully
624  if (locks) locks->Release();
625  }
626  return kFALSE;
627 }
628 
629 
630 #ifdef WITH_RSQLITE
631 
643 
644 Bool_t KVBase::SearchAndOpenKVFile(const Char_t* name, KVSQLite::database& dbfile, const Char_t* kvsubdir)
645 {
646  //Search and open for reading/writing a sqlite database file:
647  //
648  //search for file (and open it, if found) in the following order:
649  // if 'name' = absolute path the function returns kTRUE if the file exists
650  // if name != absolute path:
651  // 1. a. if 'kvsubdir'="" (default) look for file in $(pkdatadir) directory
652  // 1. b. if 'kvsubdir'!="" look for file in $(pkdatadir)/'kvsubdir'
653  // 2. look for file with this name in user's home directory
654  // 3. look for file with this name in working directory
655  //if the file is not found, kFALSE is returned.
656 
657  TString fullpath;
658  if (SearchKVFile(name, fullpath, kvsubdir)) {
659  dbfile.open(fullpath);
660  if (dbfile.good()) {
661  //cout << "Opened file : " << fullpath.Data() << endl;
662  return kTRUE;
663  }
664  }
665  return kFALSE;
666 }
667 
668 #endif
669 
670 
689 
690 Bool_t KVBase::SearchAndOpenKVFile(const Char_t* name, ofstream& file, const Char_t* kvsubdir, KVLockfile* locks)
691 {
692  //Search and CREATE i.e. open for WRITING a file:
693  //
694  //open for writing an ascii file in the location determined in the following way:
695  // if 'name' = absolute path we use the full path
696  // if name != absolute path:
697  // 1. a. if 'kvsubdir'="" (default) file will be in $(pkdatadir) directory
698  // 1. b. if 'kvsubdir'!="":
699  // if 'kvsubdir' is an absolute pathname, file in 'kvsubdir'
700  // if 'kvsubdir' is not an absolute pathname,
701  // file will be in '$(pkdatadir)/kvsubdir'
702  //if an existing file is found, a warning is printed and the existing file 'toto' is renamed
703  //"toto.date". where 'date' is created with TDatime::AsSQLDate
704  // file' is then an ofstream connected to the opened file
705  //
706  //LOCKFILE:
707  //If a KVLockfile pointer is given, we use it to get a lock on the file before opening it.
708  //If this lock is not successful, the file is not opened and we return an error message.
709 
710  KVString fullpath;
711  if (gSystem->IsAbsoluteFileName(name)) {
712  fullpath = name;
713  }
714  else if (gSystem->IsAbsoluteFileName(kvsubdir)) {
715  AssignAndDelete(fullpath,
716  gSystem->ConcatFileName(kvsubdir, name));
717  }
718  else if (strcmp(kvsubdir, "")) {
719  KVString path = GetDATADIRFilePath(kvsubdir);
720  AssignAndDelete(fullpath,
721  gSystem->ConcatFileName(path.Data(), name));
722  }
723  else {
724  fullpath = GetDATADIRFilePath(name);
725  }
726  //Backup file if necessary
727  BackupFileWithDate(fullpath.Data());
728  //put lock on file if required
729  if (locks && !locks->Lock(fullpath.Data())) return kFALSE;
730  file.open(fullpath.Data());
731  return kTRUE;
732 }
733 
734 
735 
736 
747 
749 {
750  //`path` gives the full path (can include environment variables, special symbols)
751  //to a file which will be renamed with an extension containing the current date and time
752  //(in SQL format).
753  //
754  //Example:
755  //
756  // KVBase::BackupFileWithDate("$(HOME)/toto.txt")
757  //
758  //The file `toto.txt` will be renamed `toto.txt.2007-05-02_16:22:37`
759 
760  KVString fullpath = path;
761  gSystem->ExpandPathName(fullpath);
762  if (!gSystem->AccessPathName(fullpath.Data())) {//does the file exist ?
763  //backup file
764  TDatime now;
765  KVString date(now.AsSQLString());
766  date.ReplaceAll(' ', '_');
767  TString backup = fullpath + "." + date;
768  //lock both files
769  KVLockfile lf1(fullpath.Data()), lf2(backup.Data());
770  if (lf1.Lock() && lf2.Lock()) {
771  gSystem->Rename(fullpath.Data(), backup.Data());
772  printf("Info in <KVBase::BackupFileWithDate(const Char_t *)> : Existing file %s renamed %s\n",
773  fullpath.Data(), backup.Data());
774  }
775  }
776 }
777 
778 
779 
780 
787 
789 {
790  //Load plugin library in order to extend capabilities of base class "base", depending on
791  //the given uri (these arguments are used to call TPluginManager::FindHandler).
792  //Returns pointer to TPluginHandler.
793  //Returns 0 in case of problems.
794 
795  //does plugin exist for given name ?
796  TPluginHandler* ph =
797  (TPluginHandler*) gROOT->GetPluginManager()->FindHandler(base,
798  uri);
799  if (!ph)
800  return 0;
801 
802  //check plugin library/macro is available
803  if (ph->CheckPlugin() != 0)
804  return 0;
805 
806  //load plugin module
807  if (ph->LoadPlugin() != 0)
808  return 0;
809 
810  return ph;
811 }
812 
813 
814 
815 
821 
822 void KVBase::OpenTempFile(TString& base, ofstream& fp)
823 {
824  //Opens a uniquely-named file in system temp directory (gSystem->TempDirectory)
825  //Name of file is "basexxxxxxxxxx" where "xxxxxxxxx" is current time as returned
826  //by gSystem->Now().
827  //After opening file, 'base' contains full path to file.
828 
829  GetTempFileName(base);
830  fp.open(base.Data());
831 }
832 
833 
834 
835 
842 
844 {
845  //When called with base="toto.dat", the returned value of 'base' is
846  //"/full/path/to/temp/dir/toto.dat15930693"
847  //i.e. the full path to a file in the system temp directory (gSystem->TempDirectory)
848  //appended with the current time as returned by gSystem->Now() in order to make
849  //its name unique
850 
851  TString tmp1;
852  AssignAndDelete(tmp1,
854  base.Data()));
855  long lnow = (long) gSystem->Now();
856  base = tmp1 + lnow;
857  //make sure no existing file with same name
858  while (!gSystem->AccessPathName(base)) {
859  base = tmp1 + (++lnow);
860  }
861 }
862 
863 
864 
865 
868 
870 {
871  //Returns KaliVeda version string
872  return kaliveda::build_infos::KV_VERSION.c_str();
873 }
874 
875 
876 
877 
880 
882 {
883  // Returns username of person who performed build
885 }
886 
887 
888 
889 
892 
894 {
895  //Returns KaliVeda build date
897 }
898 
899 
900 
903 
905 {
906  //Returns KaliVeda build time
908 }
909 
910 
911 
912 
915 
917 {
918  //Returns KaliVeda build type (cmake build: Release, Debug, RelWithDebInfo, ...)
920 }
921 
922 
923 
924 
927 
929 {
930  //Returns top-level directory of source tree used for build
932 }
933 
934 
935 
936 
939 
941 {
942  //Returns top-level directory used for build
944 }
945 
946 
947 #ifdef WITH_GIT_INFOS
948 
951 
953 {
954  // Returns git branch of sources
955  return kaliveda::git_infos::KV_GIT_BRANCH.c_str();
956 }
957 
958 
959 
962 
964 {
965  // Returns last git commit of sources
966  return kaliveda::git_infos::KV_GIT_COMMIT.c_str();
967 }
968 
969 #endif
970 
971 
986 
988 {
989  //By default, `FindExecutable(exec)` will look for the executable named by `exec`
990  //in the directories contained in the environment variable `PATH`. You can override
991  //this by giving your own search `path` as second argument (remember to write
992  //environment variables as <code>\$(PATH)</code>, for cross-platform compatibility).
993  //
994  //If `exec` is not found, and if it does not end with `.exe`, we look for `exec.exe`
995  //This is for compatibility with Windows/cygwin environments.
996  //
997  //If the executable is found, returns `kTRUE` and `exec` then holds full path to executable.
998  //Returns `kFALSE` if `exec` not found in paths.
999  //
1000  //If `exec` is an absolute pathname, we return `kTRUE` if the file exists
1001  //(we do not use `path`).
1002 
1003  TString spath(path), backup(exec), backup2(exec), expandexec(exec);
1004  gSystem->ExpandPathName(expandexec);
1005  if (gSystem->IsAbsoluteFileName(expandexec.Data())) {
1006  //executable given as absolute path
1007  //we check if it exists
1008  if (!gSystem->AccessPathName(expandexec)) {
1009  exec = expandexec;
1010  return kTRUE;
1011  }
1012  else {
1013  //try with ".exe" in case of Windows system
1014  if (!expandexec.EndsWith(".exe")) {
1015  expandexec += ".exe";
1016  if (!gSystem->AccessPathName(expandexec)) {
1017  exec = expandexec;
1018  return kTRUE;
1019  }
1020  }
1021  }
1022  exec = backup;
1023  return kFALSE;
1024  }
1025  gSystem->ExpandPathName(spath);
1026  if (KVBase::FindFile(spath.Data(), exec))
1027  return kTRUE;
1028  if (!backup.EndsWith(".exe")) {
1029  backup += ".exe";
1030  if (KVBase::FindFile(spath.Data(), backup)) {
1031  exec = backup;
1032  return kTRUE;
1033  }
1034  }
1035  exec = backup2;
1036  return kFALSE;
1037 }
1038 
1039 
1040 
1041 
1045 
1046 const Char_t* KVBase::FindFile(const Char_t* search, TString& wfil)
1047 {
1048  //Backwards compatible fix for `TSystem::FindFile` which only exists from ROOT version 5.12/00 onwards.
1049  //Use this method as a replacement for `gSystem->FindFile` (same arguments)
1050 #ifdef __WITHOUT_TSYSTEM_FINDFILE
1051  Char_t* result = gSystem->Which(search, wfil.Data());
1052  if (result) {
1053  wfil = result;
1054  delete[]result;
1055  }
1056  else {
1057  wfil = "";
1058  }
1059  return wfil.Data();
1060 #else
1061  return gSystem->FindFile(search, wfil);
1062 #endif
1063 }
1064 
1065 
1066 
1067 
1087 
1088 Bool_t KVBase::FindClassSourceFiles(const KVString& class_name, KVString& imp_file, KVString& dec_file, const KVString& dir_name)
1089 {
1090  //Look for the source files corresponding to `class_name`
1091  //i.e. taking class_name as a base, we look for one of
1092  //
1093  //~~~~~~~
1094  //class_name.C,class_name.cpp,class_name.cxx
1095  //~~~~~~~
1096  //
1097  //and one of
1098  //
1099  //~~~~~~~
1100  //class_name.h,class_name.hh,class_name.H
1101  //~~~~~~~
1102  //
1103  //By default we look in the current working directory, unless argument `dir_name`
1104  //is given
1105  //
1106  //If found, the names of the two files are written in `imp_file` and
1107  //`dec_file`
1108 
1109  KVNameValueList impl_alt;
1110  int i = 0;
1111  impl_alt.SetValue("%s.C", i);
1112  impl_alt.SetValue("%s.cpp", i);
1113  impl_alt.SetValue("%s.cxx", i);
1114  KVNameValueList decl_alt;
1115  decl_alt.SetValue("%s.h", i);
1116  decl_alt.SetValue("%s.hh", i);
1117  decl_alt.SetValue("%s.H", i);
1118 
1119  TString _dir_name = dir_name;
1120  KVSystemDirectory dir("LocDir", _dir_name);
1121  TList* lf = dir.GetListOfFiles();
1122  Bool_t ok_imp, ok_dec;
1123  ok_imp = ok_dec = kFALSE;
1124 
1125  //look for implementation file
1126  for (i = 0; i < impl_alt.GetNpar(); i++) {
1127  if (lf->FindObject(Form(impl_alt.GetParameter(i)->GetName(), class_name.Data()))) {
1128  imp_file = Form(impl_alt.GetParameter(i)->GetName(), class_name.Data());
1129  ok_imp = kTRUE;
1130  }
1131  }
1132  //look for header file
1133  for (i = 0; i < decl_alt.GetNpar(); i++) {
1134  if (lf->FindObject(Form(decl_alt.GetParameter(i)->GetName(), class_name.Data()))) {
1135  dec_file = Form(decl_alt.GetParameter(i)->GetName(), class_name.Data());
1136  ok_dec = kTRUE;
1137  }
1138  }
1139  return (ok_imp && ok_dec);
1140 }
1141 
1142 
1143 
1144 
1160 
1161 const Char_t* KVBase::GetPluginURI(const Char_t* base, const Char_t* derived)
1162 {
1163  //Inverse of `gPluginMgr->FindHandler(const Char_t* base, const Char_t* uri)`
1164  //
1165  //Given a base class `base` and a derived class `derived`, we search `gEnv` to find the
1166  //URI corresponding to this plugin.
1167  //
1168  //Example: given a plugin such as
1169  //
1170  //~~~~~~~~
1171  //Plugin.KVIDTelescope: ^PHOS$ KVIDPhoswich KVIndra "KVIDPhoswich()"
1172  //~~~~~~~~
1173  //
1174  //then calling `KVBase::GetPluginURI("KVIDTelescope", "KVIDPhoswich")` will return `"PHOS"`.
1175  //
1176  //Most of the code is copied from `TPluginManager::LoadHandlersFromEnv`
1177 
1178  TIter next(gEnv->GetTable());
1179  TEnvRec* er;
1180  static TString tmp;
1181 
1182  while ((er = (TEnvRec*) next())) {
1183  const char* s;
1184  if ((s = strstr(er->GetName(), "Plugin."))) {
1185  // use s, i.e. skip possible OS and application prefix to Plugin.
1186  // so that GetValue() takes properly care of returning the value
1187  // for the specified OS and/or application
1188  const char* val = gEnv->GetValue(s, (const char*)0);
1189  if (val) {
1190  Int_t cnt = 0;
1191  s += 7;
1192  //is it the right base class ?
1193  if (strcmp(s, base)) continue; //skip to next env var if not right base
1194 
1195  char* v = StrDup(val);
1196  while (1) {
1197  TString regexp = strtok(!cnt ? v : 0, "; ");
1198  if (regexp.IsNull()) break;
1199  TString clss = strtok(0, "; ");
1200  if (clss.IsNull()) break;
1201  TString plugin = strtok(0, "; ");
1202  if (plugin.IsNull()) break;
1203  TString ctor = strtok(0, ";\"");
1204  if (!ctor.Contains("("))
1205  ctor = strtok(0, ";\"");
1206  if (clss == derived) {
1207  //found the required plugin
1208  //we remove the 'regexp' operator '^' from the beginning
1209  //and '$' from the end of the URI, if necessary
1210  if (regexp.MaybeRegexp()) {
1211  regexp.Remove(TString::kBoth, '^');
1212  regexp.Remove(TString::kBoth, '$');
1213  }
1214  tmp = regexp;
1215  delete [] v;
1216  return tmp.Data();
1217  }
1218  cnt++;
1219  }
1220  delete [] v;
1221  }
1222  }
1223  }
1224  tmp = "";
1225  return tmp;
1226 }
1227 
1228 
1229 
1230 
1243 
1245 {
1246  // Return whitespace-separated list of all plugin classes defined for
1247  // the given base class.
1248  //
1249  // E.g. if plugins exist for BaseClass:
1250  //
1251  // Plugin.BaseClass: URI PluginClass PluginLibrary "PluginClassConstructor(arguments)"
1252  // +Plugin.BaseClass: URI2 PluginClass2 PluginLibrary2 "PluginClass2Constructor(arguments)"
1253  //
1254  // then KVBase::GetListOfPlugins("BaseClass") will return "PluginClass PluginClass2"
1255  //
1256  // Most of the code is copied from `TPluginManager::LoadHandlersFromEnv`
1257 
1258  TIter next(gEnv->GetTable());
1259  TEnvRec* er;
1260  static TString tmp;
1261  tmp = "";
1262  while ((er = (TEnvRec*) next())) {
1263  const char* s;
1264  if ((s = strstr(er->GetName(), "Plugin."))) {
1265  // use s, i.e. skip possible OS and application prefix to Plugin.
1266  // so that GetValue() takes properly care of returning the value
1267  // for the specified OS and/or application
1268  const char* val = gEnv->GetValue(s, (const char*)0);
1269  if (val) {
1270  Int_t cnt = 0;
1271  s += 7;
1272  //is it the right base class ?
1273  if (strcmp(s, base)) continue; //skip to next env var if not right base
1274 
1275  char* v = StrDup(val);
1276  while (1) {
1277  TString regexp = strtok(!cnt ? v : 0, "; ");
1278  if (regexp.IsNull()) break;
1279  TString clss = strtok(0, "; ");
1280  if (clss.IsNull()) break;
1281  TString plugin = strtok(0, "; ");
1282  if (plugin.IsNull()) break;
1283  TString ctor = strtok(0, ";\"");
1284  if (!ctor.Contains("("))
1285  ctor = strtok(0, ";\"");
1286  tmp += clss;
1287  tmp += " ";
1288  cnt++;
1289  }
1290  delete [] v;
1291  }
1292  }
1293  }
1294  //remove final trailing whitespace
1295  tmp.Remove(TString::kTrailing, ' ');
1296  return tmp;
1297 }
1298 
1299 
1300 
1310 
1312 {
1313  // For a given base class, return a whitespace-separated list of plugin identifiers
1314  // which are known/defined.
1315  // E.g. if plugins exist for BaseClass:
1316  //
1317  // Plugin.BaseClass: URI PluginClass PluginLibrary "PluginClassConstructor(arguments)"
1318  // +Plugin.BaseClass: URI2 PluginClass2 PluginLibrary2 "PluginClass2Constructor(arguments)"
1319  //
1320  // then KVBase::GetListOfPluginURIs("BaseClass") will return "URI URI2"
1321 
1322  static TString tmp;
1323  KVString plugs = KVBase::GetListOfPlugins(base);
1324  plugs.Begin(" ");
1325  tmp = "";
1326  while (!plugs.End()) {
1327  if (tmp != "") tmp += " ";
1328  tmp += KVBase::GetPluginURI(base, plugs.Next());
1329  }
1330  return tmp;
1331 }
1332 
1333 
1334 
1340 
1342 {
1343  // Returns kTRUE if 'uri' is the name of a defined plugin, in which case 'base'
1344  // is the name of the base class extended by this plugin.
1345  //
1346  // Most of the code is copied from `TPluginManager::LoadHandlersFromEnv`
1347 
1348  TIter next(gEnv->GetTable());
1349  TEnvRec* er;
1350  while ((er = (TEnvRec*) next())) {
1351  KVString ername = er->GetName();
1352  if (ername.BeginsWith("Plugin.")) {
1353  base = ername;
1354  base.Remove(0, 7);
1355  KVString erval = gEnv->GetValue(ername, "");
1356  erval.Begin(" ");
1357  while (!erval.End()) {
1358  if (erval.Next() == uri) return kTRUE;
1359  }
1360  }
1361  }
1362  return kFALSE;
1363 }
1364 
1365 
1366 
1367 
1380 
1382 {
1383  // Add to standard ROOT mime types some new ones defined in `.kvrootrc`
1384  // for icons associated with graphs, runs, etc. by lines such as:
1385  //
1386  //~~~~~~~~~
1387  // KaliVeda.GUI.MimeTypes : KVIDMap
1388  // KaliVeda.GUI.MimeTypes.KVIDMap.Icon : rootdb_t.xpm
1389  // +KaliVeda.GUI.MimeTypes : KVIDZAGrid
1390  // KaliVeda.GUI.MimeTypes.KVIDZAGrid.Icon : draw_t.xpm
1391  //~~~~~~~~~
1392  //
1393  // etc.
1394 
1395  KVString mimetypes = gEnv->GetValue("KaliVeda.GUI.MimeTypes", "");
1396  if (mimetypes != "") {
1397 
1398  mimetypes.Begin(" ");
1399  while (!mimetypes.End()) {
1400 
1401  KVString classname = mimetypes.Next(kTRUE);
1402  KVString icon = gEnv->GetValue(Form("KaliVeda.GUI.MimeTypes.%s.Icon", classname.Data()), "draw_t.xpm");
1403  KVString type = classname;
1404  type.ToLower();
1405 
1406  if (gClient) gClient->GetMimeTypeList()->AddType(Form("[kaliveda/%s]", type.Data()),
1407  classname.Data(), icon.Data(), icon.Data(), "");
1408 
1409  }
1410  }
1411 }
1412 
1413 
1414 
1425 
1427 {
1428  // \brief Comparison between two 64-bit floating-point values
1429  //
1430  // Returns `kTRUE` if the integer representations of the two values are within
1431  // `maxdif` of each other. By default `maxdif=1`, which means that we consider that `x==y` if the
1432  // difference between them is no greater than the precision of `Double_t`
1433  // variables, i.e. `4.94065645841246544e-324`
1434  //
1435  // Based on the function `AlmostEqual2sComplement(float, float, int)`
1436  // by Bruce Dawson http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm
1437 
1438  union converter {
1439  Double_t f;
1440  Long64_t i;
1441  } zero, val1, val2;
1442 
1443  assert(maxdif > 0);
1444 
1445  if (A == B) return true;
1446 
1447  /* rustine to obtain the (64-bit) constant value 0x8000000000000000
1448  even on 32-bit machines (there is probably an easier way!) */
1449  zero.i = 1;
1450  zero.f = -zero.f;
1451  zero.i -= 1;
1452 
1453  val1.f = A;
1454  val2.f = B;
1455  Long64_t Aint, Bint;
1456  Aint = val1.i;
1457  Bint = val2.i;
1458  if (Aint < 0) Aint = zero.i - Aint;
1459  if (Bint < 0) Bint = zero.i - Bint;
1460 
1461  Long64_t intDiff = abs(val1.i - val2.i);
1462 
1463  if (intDiff <= maxdif) return true;
1464 
1465  return false;
1466 }
1467 
1468 
1469 
1478 
1479 Bool_t KVBase::OpenContextMenu(const char* method, TObject* obj, const char* alt_method_name)
1480 {
1481  // Open context menu for given method of object *obj.
1482  // By default title of menu is 'obj->ClassName()::method'
1483  // You can give an alternative method name in 'alt_method_name'
1484  // Returns kFALSE if the given method is not defined for the class of object in question.
1485  //
1486  // WARNING: even if this method returns kTRUE, this is no guarantee that the method
1487  // has indeed been executed. The user may have pressed the 'Cancel' button...
1488 
1489  TMethod* m = obj->IsA()->GetMethodAllAny(method);
1490  if (!m) {
1491  obj->Warning("OpenContextMenu", "%s is not a method of %s", method, obj->ClassName());
1492  return kFALSE;
1493  }
1494  TString Method = alt_method_name;
1495  if (Method == "") Method = method;
1496  TContextMenu* cm = new TContextMenu(Method, Form("%s::%s", obj->ClassName(), Method.Data()));
1497  cm->Action(obj, m);
1498  delete cm;
1499  return kTRUE;
1500 }
1501 
1502 
1503 
1510 
1511 void KVBase::CombineFiles(const Char_t* file1, const Char_t* file2, const Char_t* newfilename, Bool_t keep)
1512 {
1513  // STATIC method which allows to combine the contents of two ROOT files
1514  // (file1 and file2) into a new ROOT file (newfilename).
1515  // All objects from the two files will be written in the new file.
1516  //
1517  // if keep=kFALSE, the two files will be deleted after the operation
1518 
1519  ::Info("KVBase::CombineFiles", "Copying all objects from %s and %s ===> into new file %s", file1, file2, newfilename);
1520 
1521  TFileMerger file_merge;
1522  file_merge.AddFile(file1, kFALSE);
1523  file_merge.AddFile(file2, kFALSE);
1524  file_merge.OutputFile(newfilename);
1525  file_merge.Merge();
1526 
1527  // remove physical files from disk if required
1528  if (!keep) {
1529  gSystem->Unlink(file1);
1530  gSystem->Unlink(file2);
1531  }
1532 }
1533 
1534 
1535 
1543 
1545 {
1546  // Dummy method (returns NULL).
1547  // This method may be used in 'container' classes used with KVListView.
1548  // In order to open the context menu of the 'contained' object,
1549  // GetLabel() should return the real class of the object,
1550  // and this method should return its address.
1551  // Then call KVListView::SetUseObjLabelAsRealClass(kTRUE).
1552  return nullptr;
1553 }
1554 
1555 
1556 
1557 
1560 
1561 const Char_t* KVBase::GetExampleFilePath(const Char_t* library, const Char_t* namefile)
1562 {
1563  // Return full path to example file for given library (="KVMultiDet", "BackTrack", etc.)
1564  static TString path;
1565  path = KVBase::GetDATADIRFilePath("examples/");
1566  path += library;
1567  path += "/";
1568  path += namefile;
1569  return path.Data();
1570 }
1571 
1572 
1573 
1576 
1578 {
1579  // Prints welcome message and infos on version etc.
1580 
1581  cout << "/----------------------------------------------------------------------\\" << endl;
1582  cout << "| Welcome to KaliVeda v" << GetKVVersion() << " gitlab.in2p3.fr/kaliveda-dev/kaliveda |" << endl;
1583  cout << "| (c) 2002-2024, The KaliVeda development team |" << endl;
1584  cout << "| |" << endl;
1585  cout << "| Built with ROOT " << kaliveda::build_infos::KV_ROOT_VERSION << " on " << KVBase::GetKVBuildDate() << ", " << KVBase::GetKVBuildTime() << " |" << endl;
1586 #ifdef WITH_GIT_INFOS
1587  TString gitinfo;
1588  gitinfo.Form("%s@%s", gitBranch(), gitCommit());
1589  printf("| From %-63s |\n", gitinfo.Data());
1590 #endif
1591  cout << "| See https://kaliveda.in2p3.fr for help |" << endl;
1592  cout << "\\----------------------------------------------------------------------/" << endl << endl;
1593 }
1594 
1595 
1596 
1597 
1613 
1614 Double_t KVBase::ProtectedGetX(const TF1* func, Double_t val, int& status, Double_t xmin, Double_t xmax) const
1615 {
1616  // Since ROOT6, the TF1::GetX() method can no longer be used without precaution.
1617  //
1618  // In ROOT5, if the value val was larger or smaller than the maximum or minimum value of
1619  // the function (within its defined range) then TF1::GetX() would return X of the
1620  // maximum or minimum, respectively.
1621  //
1622  // In ROOT6, TF1::GetX() has been reimplemented so that, in the above case, it
1623  // prints out 3 warning messages and returns a TMath::QuietNaN()! Therefore we provide this
1624  // function in order to replicate the previous behaviour.
1625  //
1626  // The status = 0 if the value is within the limits of the function.
1627  // status = +1 if value is above the maximum, or status = -1 if value is below the minimum
1628  //
1629  // When compiled with ROOT5, this method just calls TF1::GetX() (and status = 0 always).
1630 
1631 #ifdef USING_ROOT6
1632  status = 0;
1633  if (val > func->GetMaximum(xmin, xmax)) {
1634  status = 1;
1635  return func->GetMaximumX(xmin, xmax);
1636  }
1637  else if (val < func->GetMinimum(xmin, xmax)) {
1638  status = -1;
1639  return func->GetMinimumX(xmin, xmax);
1640  }
1641  else
1642  return func->GetX(val, xmin, xmax);
1643 #else
1644  status = 0;
1645  return func->GetX(val, xmin, xmax);
1646 #endif
1647 }
1648 
1649 
1650 
1652 
1653 void KVBase::Warning(const char* location, const char* va_(fmt), ...) const
1654 {
1655  va_list ap;
1656  va_start(ap, va_(fmt));
1657  fprintf(stderr, "%s", "\033[1;38;5;202m");
1658  DoError(kWarning, location, va_(fmt), ap);
1659  fprintf(stderr, "%s", "\033[0m");
1660  va_end(ap);
1661 }
1662 
1663 
1665 
1666 void KVBase::Error(const char* location, const char* va_(fmt), ...) const
1667 {
1668  va_list ap;
1669  va_start(ap, va_(fmt));
1670  fprintf(stderr, "%s", "\033[1;38;5;196m");
1671  DoError(kError, location, va_(fmt), ap);
1672  fprintf(stderr, "%s", "\033[0m");
1673  va_end(ap);
1674 }
1675 
1676 
1677 
1683 
1684 void KVBase::Deprecated(const char* where, const char* advice)
1685 {
1686  // Print a message to indicate when the called method is deprecated and give advice how to do better
1687  //
1688  // Don't call directly: use the macro Deprecate(advice) which will automatically fill in the method name
1689  // (see KVMacros.h)
1690 
1691  printf("Warning in <%s>: Method is deprecated in v%s and will be removed in future.\n%s\n",
1692  where, KVBase::GetKVVersion(), advice);
1693 }
1694 
1695 
1696 
int Int_t
unsigned int UInt_t
#define f(i)
bool Bool_t
short Version_t
char Char_t
constexpr Bool_t kFALSE
double Double_t
constexpr Bool_t kTRUE
const char Option_t
R__EXTERN TEnv * gEnv
kEnvChange
#define gClient
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
char name[80]
float xmin
float xmax
#define gInterpreter
#define gROOT
R__EXTERN TRandom * gRandom
char * Form(const char *fmt,...)
char * StrDup(const char *str)
void AssignAndDelete(TString &target, char *tobedeleted)
R__EXTERN TSystem * gSystem
#define va_(arg)
Base class for KaliVeda framework.
Definition: KVBase.h:139
static TString fWorkingDirectory
user working directory for e.g. database files
Definition: KVBase.h:148
void Clear(Option_t *opt="") override
Clear object properties : name, type/title, number, label.
Definition: KVBase.cpp:375
UInt_t fNumber
for numbering objects
Definition: KVBase.h:142
virtual const Char_t * GetType() const
Definition: KVBase.h:176
static const Char_t * GetBINDIRFilePath(const Char_t *namefile="")
Definition: KVBase.cpp:112
static void OpenTempFile(TString &base, std::ofstream &fp)
Definition: KVBase.cpp:822
static const Char_t * GetDATADIRFilePath(const Char_t *namefile="")
Definition: KVBase.cpp:68
static const Char_t * GetDATABASEFilePath()
Definition: KVBase.cpp:86
static const Char_t * GetKVBuildDate()
Returns KaliVeda build date.
Definition: KVBase.cpp:893
static const Char_t * FindFile(const Char_t *search, TString &wfil)
Definition: KVBase.cpp:1046
static const Char_t * GetINCDIRFilePath(const Char_t *namefile="")
Definition: KVBase.cpp:103
void Error(const char *method, const char *msgfmt,...) const override
Definition: KVBase.cpp:1666
static const Char_t * gitCommit()
Returns last git commit of sources.
Definition: KVBase.cpp:963
static const Char_t * GetWORKDIRFilePath(const Char_t *namefile="")
Definition: KVBase.cpp:121
void init()
Default initialisation.
Definition: KVBase.cpp:147
static Bool_t FindExecutable(TString &exec, const Char_t *path="$(PATH)")
Definition: KVBase.cpp:987
static const Char_t * GetKVBuildUser()
Returns username of person who performed build.
Definition: KVBase.cpp:881
static void BackupFileWithDate(const Char_t *path)
Definition: KVBase.cpp:748
static void ReadConfigFiles()
Definition: KVBase.cpp:274
static const Char_t * gitBranch()
Returns git branch of sources.
Definition: KVBase.cpp:952
static const Char_t * GetListOfPluginURIs(const Char_t *base)
Definition: KVBase.cpp:1311
TString fLabel
label for the object
Definition: KVBase.h:144
KVBase()
Default constructor.
Definition: KVBase.cpp:321
static int GetKVMajorVersion()
Definition: KVBase.cpp:130
static const Char_t * GetListOfPlugins(const Char_t *base)
Definition: KVBase.cpp:1244
static Bool_t fEnvIsInit
set when environment is initialised
Definition: KVBase.h:147
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:1426
KVBase & operator=(const KVBase &)
copy assignment operator
Definition: KVBase.cpp:359
static void CombineFiles(const Char_t *file1, const Char_t *file2, const Char_t *newfilename, Bool_t keep=kTRUE)
Definition: KVBase.cpp:1511
const Char_t * GetLabel() const
Definition: KVBase.h:198
static Bool_t FindClassSourceFiles(const KVString &class_name, KVString &imp_file, KVString &dec_file, const KVString &dir_name=".")
Definition: KVBase.cpp:1088
static const Char_t * GetTEMPLATEDIRFilePath(const Char_t *namefile="")
Definition: KVBase.cpp:77
static const Char_t * GetKVSourceDir()
Returns top-level directory of source tree used for build.
Definition: KVBase.cpp:928
void Copy(TObject &) const override
Make a copy of this object.
Definition: KVBase.cpp:389
static void InitEnvironment()
Definition: KVBase.cpp:189
void Print(Option_t *option="") const override
Definition: KVBase.cpp:405
static const Char_t * GetKVBuildTime()
Returns KaliVeda build time.
Definition: KVBase.cpp:904
static int GetKVMinorVersion()
Definition: KVBase.cpp:138
static void PrintSplashScreen()
Prints welcome message and infos on version etc.
Definition: KVBase.cpp:1577
static const Char_t * GetLIBDIRFilePath(const Char_t *namefile="")
Definition: KVBase.cpp:94
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:1561
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:1614
static const Char_t * GetKVBuildDir()
Returns top-level directory used for build.
Definition: KVBase.cpp:940
static void ReadGUIMimeTypes()
Definition: KVBase.cpp:1381
static Bool_t IsThisAPlugin(const TString &uri, TString &base)
Definition: KVBase.cpp:1341
@ kIsKaliVedaObject
Definition: KVBase.h:159
virtual TObject * GetObject() const
Definition: KVBase.cpp:1544
static void GetTempFileName(TString &base)
Definition: KVBase.cpp:843
static Bool_t SearchKVFile(const Char_t *name, TString &fullpath, const Char_t *kvsubdir="")
Definition: KVBase.cpp:533
static const Char_t * GetKVBuildType()
Returns KaliVeda build type (cmake build: Release, Debug, RelWithDebInfo, ...)
Definition: KVBase.cpp:916
static const Char_t * GetPluginURI(const Char_t *base, const Char_t *plugin)
Definition: KVBase.cpp:1161
static const Char_t * GetETCDIRFilePath(const Char_t *namefile="")
Definition: KVBase.cpp:59
static Bool_t OpenContextMenu(const char *method, TObject *obj, const char *alt_method_name="")
Definition: KVBase.cpp:1479
static Bool_t SearchAndOpenKVFile(const Char_t *name, KVSQLite::database &dbfile, const Char_t *kvsubdir="")
Definition: KVBase.cpp:644
static TPluginHandler * LoadPlugin(const Char_t *base, const Char_t *uri="0")
Definition: KVBase.cpp:788
static const Char_t * GetKVVersion()
Returns KaliVeda version string.
Definition: KVBase.cpp:869
void Warning(const char *method, const char *msgfmt,...) const override
Definition: KVBase.cpp:1653
static void Deprecated(const char *method, const char *advice)
Definition: KVBase.cpp:1684
UInt_t GetNumber() const
Definition: KVBase.h:219
Interface to (Linux) system lockfile command.
Definition: KVLockfile.h:70
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
Interface to ROOT SQLite database backend.
Definition: SQLiteDB.h:473
bool good() const
Definition: SQLiteDB.h:540
void open(const TString &dbfile)
Definition: SQLiteDB.cpp:125
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
Definition: KVString.h:73
void Begin(TString delim) const
Definition: KVString.cpp:565
Bool_t End() const
Definition: KVString.cpp:634
KVString Next(Bool_t strip_whitespace=kFALSE) const
Definition: KVString.cpp:695
Extension of ROOT TSystemDirectory class, handling browsing directories on disk.
TList * GetListOfFiles() const override
virtual Version_t ReadVersion(UInt_t *start=nullptr, UInt_t *bcnt=nullptr, const TClass *cl=nullptr)=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
Int_t ReadBuffer(TBuffer &b, void *pointer)
TMethod * GetMethodAllAny(const char *method)
Int_t WriteBuffer(TBuffer &b, void *pointer, const char *info="")
const char * AsSQLString() const
const char * GetName() const override
THashList * GetTable() 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
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)
TObject * FindObject(const char *name) const override
void Copy(TObject &named) const override
const char * GetName() const override
void Streamer(TBuffer &) override
void Clear(Option_t *option="") override
static TClass * Class()
TClass * IsA() const override
void SetBit(UInt_t f)
virtual void DoError(int level, const char *location, const char *fmt, va_list va) const
virtual const char * ClassName() const
virtual void Warning(const char *method, const char *msgfmt,...) const
virtual TClass * IsA() 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
const char * Data() const
Bool_t MaybeRegexp() const
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) 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)
const char * pwd()
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)
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)
RVec< PromoteType< T > > abs(const RVec< T > &v)
const int kWarning
const int kError
void EnableThreadSafety()
void init()
const char * cnt
v
TMarker m
ClassImp(TPyArg)