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 
145 
147 {
149 }
150 
151 
154 
156 {
157  //Default initialisation
158 
159  InitEnvironment();
160  fNumber = 0;
161  fLabel = "";
162  SetBit(kIsKaliVedaObject);
163 }
164 
165 
166 
196 
198 {
199  // STATIC method to Initialise KaliVeda environment
200  // Reads config files in <code>\$(pkgdatadir)/etc</code> and sets up environment
201  // (data repositories, datasets, etc. etc.).
202  // Adds directory where kaliveda shared libs are installed to the dynamic
203  // path - for finding and loading plugins.
204  // Resets the `gRandom` random number sequence using a clock-based seed
205  // (i.e. random sequences do not repeat).
206  //
207  // Normally, the first object created which inherits from KVBase will
208  // perform this initialisation; if you need to set up the environment before
209  // creating a KVBase object, or if you just want to be absolutely sure that
210  // the environment has been initialised, you can call this method.
211  //
212  // #### Note for GNU-style installations
213  // If KaliVeda is built with the cmake option `-Dgnuinstall=yes` then each
214  // user will have a working directory which will be used to store any files
215  // generated by KaliVeda at runtime.
216  //
217  // By default the location of user's working directory is set to
218  //~~~~~~~~~
219  // $(HOME)/.kaliveda
220  //~~~~~~~~~
221  // but can be changed with variable
222  //~~~~~~~~~
223  // KaliVeda.WorkingDirectory: [directory]
224  //~~~~~~~~~
225  // in configuration file `.kvrootrc`.
226  //`[directory]` must be an absolute pathname, but can use shell variables like <code>\$(HOME)</code>.
227 
228  std::lock_guard<std::mutex> lk(_kvbase_mutex); // prevent multiple initialisation in different threads
229 
230  if (!fEnvIsInit) {//test if environment already initialised
231 
232  // enable ROOT thread safety
234 
235  // Add path to kaliveda libraries to dynamic loader path
236  // This is needed to find plugins
237  // and also to be able to compile with kaliveda in the interpreter
238  TString libdir = GetLIBDIRFilePath();
239  gSystem->AddDynamicPath(libdir);
240  // force re-reading of rootmap files in new dynamic path
241  gInterpreter->LoadLibraryMap();
242  // Add path to kaliveda header files
243  // This is needed to be able to compile with kaliveda in the interpreter
244  TString incdir = GetINCDIRFilePath();
245  incdir.Prepend("-I");
246  gSystem->AddIncludePath(incdir);
247 
248  //set up environment using kvrootrc file
249  if (!gEnv->Defined("DataSet.DatabaseFile")) {
250  ReadConfigFiles();
251  }
252 #ifdef WITH_GNU_INSTALL
253  // set working directory & create if needed
254  fWorkingDirectory = gEnv->GetValue("KaliVeda.WorkingDirectory", "$(HOME)/.kaliveda");
255  gSystem->ExpandPathName(fWorkingDirectory);
256  gSystem->mkdir(fWorkingDirectory, kTRUE);
257 #else
258  // set environment variable used in database makefiles
259  fWorkingDirectory = KV_ROOT;
260 #endif
261  // set environment variable used in database makefiles
262  gSystem->Setenv("KV_WORK_DIR", fWorkingDirectory);
263 
264  //generate new seed from system clock
265  gRandom->SetSeed(0);
266 
267  // initialisation has been performed
268  fEnvIsInit = kTRUE;
269  }
270 }
271 
272 
273 
281 
283 {
284  // Read all configuration files
285  // System config files are read first in the order they appear in file
286  // ${ETCDIR}/config.files
287  // Then we read any of the following files if they exist:
288  // ${HOME}/.kvrootrc
289  // ${PWD}/.kvrootrc (if PWD!=HOME)
290 
291  TString tmp = GetETCDIRFilePath("config.files");
292  ifstream conflist;
293  conflist.open(tmp.Data());
294  if (!conflist.good()) {
295  ::Fatal("KVBase::ReadConfigFiles", "Cannot open %s", tmp.Data());
296  return;
297  }
298  KVString file;
299  file.ReadLine(conflist);
300  conflist.close();
301  file.Begin(";");
302  while (!file.End()) {
303  tmp = GetETCDIRFilePath(file.Next().Data());
304  //skip over any missing files - this is needed when installing from
305  //e.g. ubuntu packages if not all packages are installed
306  if (!gSystem->AccessPathName(tmp.Data())) gEnv->ReadFile(tmp.Data(), kEnvChange);
307  }
308 
309  AssignAndDelete(tmp, gSystem->ConcatFileName(gSystem->Getenv("HOME"), ".kvrootrc"));
310  gEnv->ReadFile(tmp.Data(), kEnvChange);
311 
312  if (TString(gSystem->pwd()) != gSystem->HomeDirectory()) {
313  tmp = "./.kvrootrc";
314  gEnv->ReadFile(tmp.Data(), kEnvChange);
315  }
316 
317  // load plugin handlers
318  gROOT->GetPluginManager()->LoadHandlersFromEnv(gEnv);
319 
320  // load mime types/icon definitions when not in batch (i.e. GUI-less) mode
321  if (!gROOT->IsBatch()) ReadGUIMimeTypes();
322 }
323 
324 
325 
328 
330 {
331  //Default constructor.
332  init();
333 }
334 
335 
336 
339 
340 KVBase::KVBase(const Char_t* name, const Char_t* type): TNamed(name, type)
341 {
342  //Ctor for object with given name and type.
343  init();
344 }
345 
346 
347 
350 
351 KVBase::KVBase(const KVBase& obj) : TNamed()
352 {
353  //copy ctor
354  init();
355 #if ROOT_VERSION_CODE >= ROOT_VERSION(3,4,0)
356  obj.Copy(*this);
357 #else
358  ((KVBase&) obj).Copy(*this);
359 #endif
360 }
361 
362 
363 
366 
368 {
369  // copy assignment operator
370 
371  if (&other != this) {
372  other.Copy(*this);
373  }
374  return (*this);
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 
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 #ifdef WITH_RSQLITE
639 
651 
652 Bool_t KVBase::SearchAndOpenKVFile(const Char_t* name, KVSQLite::database& dbfile, const Char_t* kvsubdir)
653 {
654  //Search and open for reading/writing a sqlite database file:
655  //
656  //search for file (and open it, if found) in the following order:
657  // if 'name' = absolute path the function returns kTRUE if the file exists
658  // if name != absolute path:
659  // 1. a. if 'kvsubdir'="" (default) look for file in $(pkdatadir) directory
660  // 1. b. if 'kvsubdir'!="" look for file in $(pkdatadir)/'kvsubdir'
661  // 2. look for file with this name in user's home directory
662  // 3. look for file with this name in working directory
663  //if the file is not found, kFALSE is returned.
664 
665  TString fullpath;
666  if (SearchKVFile(name, fullpath, kvsubdir)) {
667  dbfile.open(fullpath);
668  if (dbfile.good()) {
669  //cout << "Opened file : " << fullpath.Data() << endl;
670  return kTRUE;
671  }
672  }
673  return kFALSE;
674 }
675 
676 #endif
677 
678 
697 
698 Bool_t KVBase::SearchAndOpenKVFile(const Char_t* name, ofstream& file, const Char_t* kvsubdir, KVLockfile* locks)
699 {
700  //Search and CREATE i.e. open for WRITING a file:
701  //
702  //open for writing an ascii file in the location determined in the following way:
703  // if 'name' = absolute path we use the full path
704  // if name != absolute path:
705  // 1. a. if 'kvsubdir'="" (default) file will be in $(pkdatadir) directory
706  // 1. b. if 'kvsubdir'!="":
707  // if 'kvsubdir' is an absolute pathname, file in 'kvsubdir'
708  // if 'kvsubdir' is not an absolute pathname,
709  // file will be in '$(pkdatadir)/kvsubdir'
710  //if an existing file is found, a warning is printed and the existing file 'toto' is renamed
711  //"toto.date". where 'date' is created with TDatime::AsSQLDate
712  // file' is then an ofstream connected to the opened file
713  //
714  //LOCKFILE:
715  //If a KVLockfile pointer is given, we use it to get a lock on the file before opening it.
716  //If this lock is not successful, the file is not opened and we return an error message.
717 
718  KVString fullpath;
719  if (gSystem->IsAbsoluteFileName(name)) {
720  fullpath = name;
721  }
722  else if (gSystem->IsAbsoluteFileName(kvsubdir)) {
723  AssignAndDelete(fullpath,
724  gSystem->ConcatFileName(kvsubdir, name));
725  }
726  else if (strcmp(kvsubdir, "")) {
727  KVString path = GetDATADIRFilePath(kvsubdir);
728  AssignAndDelete(fullpath,
729  gSystem->ConcatFileName(path.Data(), name));
730  }
731  else {
732  fullpath = GetDATADIRFilePath(name);
733  }
734  //Backup file if necessary
735  BackupFileWithDate(fullpath.Data());
736  //put lock on file if required
737  if (locks && !locks->Lock(fullpath.Data())) return kFALSE;
738  file.open(fullpath.Data());
739  return kTRUE;
740 }
741 
742 
743 
744 
755 
757 {
758  //`path` gives the full path (can include environment variables, special symbols)
759  //to a file which will be renamed with an extension containing the current date and time
760  //(in SQL format).
761  //
762  //Example:
763  //
764  // KVBase::BackupFileWithDate("$(HOME)/toto.txt")
765  //
766  //The file `toto.txt` will be renamed `toto.txt.2007-05-02_16:22:37`
767 
768  KVString fullpath = path;
769  gSystem->ExpandPathName(fullpath);
770  if (!gSystem->AccessPathName(fullpath.Data())) {//does the file exist ?
771  //backup file
772  TDatime now;
773  KVString date(now.AsSQLString());
774  date.ReplaceAll(' ', '_');
775  TString backup = fullpath + "." + date;
776  //lock both files
777  KVLockfile lf1(fullpath.Data()), lf2(backup.Data());
778  if (lf1.Lock() && lf2.Lock()) {
779  gSystem->Rename(fullpath.Data(), backup.Data());
780  printf("Info in <KVBase::BackupFileWithDate(const Char_t *)> : Existing file %s renamed %s\n",
781  fullpath.Data(), backup.Data());
782  }
783  }
784 }
785 
786 
787 
788 
795 
797 {
798  //Load plugin library in order to extend capabilities of base class "base", depending on
799  //the given uri (these arguments are used to call TPluginManager::FindHandler).
800  //Returns pointer to TPluginHandler.
801  //Returns 0 in case of problems.
802 
803  //does plugin exist for given name ?
804  TPluginHandler* ph =
805  (TPluginHandler*) gROOT->GetPluginManager()->FindHandler(base,
806  uri);
807  if (!ph)
808  return 0;
809 
810  //check plugin library/macro is available
811  if (ph->CheckPlugin() != 0)
812  return 0;
813 
814  //load plugin module
815  if (ph->LoadPlugin() != 0)
816  return 0;
817 
818  return ph;
819 }
820 
821 
822 
823 
829 
830 void KVBase::OpenTempFile(TString& base, ofstream& fp)
831 {
832  //Opens a uniquely-named file in system temp directory (gSystem->TempDirectory)
833  //Name of file is "basexxxxxxxxxx" where "xxxxxxxxx" is current time as returned
834  //by gSystem->Now().
835  //After opening file, 'base' contains full path to file.
836 
837  GetTempFileName(base);
838  fp.open(base.Data());
839 }
840 
841 
842 
843 
850 
852 {
853  //When called with base="toto.dat", the returned value of 'base' is
854  //"/full/path/to/temp/dir/toto.dat15930693"
855  //i.e. the full path to a file in the system temp directory (gSystem->TempDirectory)
856  //appended with the current time as returned by gSystem->Now() in order to make
857  //its name unique
858 
859  TString tmp1;
860  AssignAndDelete(tmp1,
862  base.Data()));
863  long lnow = (long) gSystem->Now();
864  base = tmp1 + lnow;
865  //make sure no existing file with same name
866  while (!gSystem->AccessPathName(base)) {
867  base = tmp1 + (++lnow);
868  }
869 }
870 
871 
872 
873 
876 
878 {
879  //Returns KaliVeda version string
880  return kaliveda::build_infos::KV_VERSION.c_str();
881 }
882 
883 
884 
885 
888 
890 {
891  // Returns username of person who performed build
893 }
894 
895 
896 
897 
900 
902 {
903  //Returns KaliVeda build date
905 }
906 
907 
908 
911 
913 {
914  //Returns KaliVeda build time
916 }
917 
918 
919 
920 
923 
925 {
926  //Returns KaliVeda build type (cmake build: Release, Debug, RelWithDebInfo, ...)
928 }
929 
930 
931 
932 
935 
937 {
938  //Returns top-level directory of source tree used for build
940 }
941 
942 
943 
944 
947 
949 {
950  //Returns top-level directory used for build
952 }
953 
954 
955 #ifdef WITH_GIT_INFOS
956 
959 
961 {
962  // Returns git branch of sources
963  return kaliveda::git_infos::KV_GIT_BRANCH.c_str();
964 }
965 
966 
967 
970 
972 {
973  // Returns last git commit of sources
974  return kaliveda::git_infos::KV_GIT_COMMIT.c_str();
975 }
976 
977 #endif
978 
979 
994 
996 {
997  //By default, `FindExecutable(exec)` will look for the executable named by `exec`
998  //in the directories contained in the environment variable `PATH`. You can override
999  //this by giving your own search `path` as second argument (remember to write
1000  //environment variables as <code>\$(PATH)</code>, for cross-platform compatibility).
1001  //
1002  //If `exec` is not found, and if it does not end with `.exe`, we look for `exec.exe`
1003  //This is for compatibility with Windows/cygwin environments.
1004  //
1005  //If the executable is found, returns `kTRUE` and `exec` then holds full path to executable.
1006  //Returns `kFALSE` if `exec` not found in paths.
1007  //
1008  //If `exec` is an absolute pathname, we return `kTRUE` if the file exists
1009  //(we do not use `path`).
1010 
1011  TString spath(path), backup(exec), backup2(exec), expandexec(exec);
1012  gSystem->ExpandPathName(expandexec);
1013  if (gSystem->IsAbsoluteFileName(expandexec.Data())) {
1014  //executable given as absolute path
1015  //we check if it exists
1016  if (!gSystem->AccessPathName(expandexec)) {
1017  exec = expandexec;
1018  return kTRUE;
1019  }
1020  else {
1021  //try with ".exe" in case of Windows system
1022  if (!expandexec.EndsWith(".exe")) {
1023  expandexec += ".exe";
1024  if (!gSystem->AccessPathName(expandexec)) {
1025  exec = expandexec;
1026  return kTRUE;
1027  }
1028  }
1029  }
1030  exec = backup;
1031  return kFALSE;
1032  }
1033  gSystem->ExpandPathName(spath);
1034  if (KVBase::FindFile(spath.Data(), exec))
1035  return kTRUE;
1036  if (!backup.EndsWith(".exe")) {
1037  backup += ".exe";
1038  if (KVBase::FindFile(spath.Data(), backup)) {
1039  exec = backup;
1040  return kTRUE;
1041  }
1042  }
1043  exec = backup2;
1044  return kFALSE;
1045 }
1046 
1047 
1048 
1049 
1053 
1054 const Char_t* KVBase::FindFile(const Char_t* search, TString& wfil)
1055 {
1056  //Backwards compatible fix for `TSystem::FindFile` which only exists from ROOT version 5.12/00 onwards.
1057  //Use this method as a replacement for `gSystem->FindFile` (same arguments)
1058 #ifdef __WITHOUT_TSYSTEM_FINDFILE
1059  Char_t* result = gSystem->Which(search, wfil.Data());
1060  if (result) {
1061  wfil = result;
1062  delete[]result;
1063  }
1064  else {
1065  wfil = "";
1066  }
1067  return wfil.Data();
1068 #else
1069  return gSystem->FindFile(search, wfil);
1070 #endif
1071 }
1072 
1073 
1074 
1075 
1095 
1096 Bool_t KVBase::FindClassSourceFiles(const KVString& class_name, KVString& imp_file, KVString& dec_file, const KVString& dir_name)
1097 {
1098  //Look for the source files corresponding to `class_name`
1099  //i.e. taking class_name as a base, we look for one of
1100  //
1101  //~~~~~~~
1102  //class_name.C,class_name.cpp,class_name.cxx
1103  //~~~~~~~
1104  //
1105  //and one of
1106  //
1107  //~~~~~~~
1108  //class_name.h,class_name.hh,class_name.H
1109  //~~~~~~~
1110  //
1111  //By default we look in the current working directory, unless argument `dir_name`
1112  //is given
1113  //
1114  //If found, the names of the two files are written in `imp_file` and
1115  //`dec_file`
1116 
1117  KVNameValueList impl_alt;
1118  int i = 0;
1119  impl_alt.SetValue("%s.C", i);
1120  impl_alt.SetValue("%s.cpp", i);
1121  impl_alt.SetValue("%s.cxx", i);
1122  KVNameValueList decl_alt;
1123  decl_alt.SetValue("%s.h", i);
1124  decl_alt.SetValue("%s.hh", i);
1125  decl_alt.SetValue("%s.H", i);
1126 
1127  TString _dir_name = dir_name;
1128  KVSystemDirectory dir("LocDir", _dir_name);
1129  TList* lf = dir.GetListOfFiles();
1130  Bool_t ok_imp, ok_dec;
1131  ok_imp = ok_dec = kFALSE;
1132 
1133  //look for implementation file
1134  for (i = 0; i < impl_alt.GetNpar(); i++) {
1135  if (lf->FindObject(Form(impl_alt.GetParameter(i)->GetName(), class_name.Data()))) {
1136  imp_file = Form(impl_alt.GetParameter(i)->GetName(), class_name.Data());
1137  ok_imp = kTRUE;
1138  }
1139  }
1140  //look for header file
1141  for (i = 0; i < decl_alt.GetNpar(); i++) {
1142  if (lf->FindObject(Form(decl_alt.GetParameter(i)->GetName(), class_name.Data()))) {
1143  dec_file = Form(decl_alt.GetParameter(i)->GetName(), class_name.Data());
1144  ok_dec = kTRUE;
1145  }
1146  }
1147  return (ok_imp && ok_dec);
1148 }
1149 
1150 
1151 
1152 
1168 
1169 const Char_t* KVBase::GetPluginURI(const Char_t* base, const Char_t* derived)
1170 {
1171  //Inverse of `gPluginMgr->FindHandler(const Char_t* base, const Char_t* uri)`
1172  //
1173  //Given a base class `base` and a derived class `derived`, we search `gEnv` to find the
1174  //URI corresponding to this plugin.
1175  //
1176  //Example: given a plugin such as
1177  //
1178  //~~~~~~~~
1179  //Plugin.KVIDTelescope: ^PHOS$ KVIDPhoswich KVIndra "KVIDPhoswich()"
1180  //~~~~~~~~
1181  //
1182  //then calling `KVBase::GetPluginURI("KVIDTelescope", "KVIDPhoswich")` will return `"PHOS"`.
1183  //
1184  //Most of the code is copied from `TPluginManager::LoadHandlersFromEnv`
1185 
1186  TIter next(gEnv->GetTable());
1187  TEnvRec* er;
1188  static TString tmp;
1189 
1190  while ((er = (TEnvRec*) next())) {
1191  const char* s;
1192  if ((s = strstr(er->GetName(), "Plugin."))) {
1193  // use s, i.e. skip possible OS and application prefix to Plugin.
1194  // so that GetValue() takes properly care of returning the value
1195  // for the specified OS and/or application
1196  const char* val = gEnv->GetValue(s, (const char*)0);
1197  if (val) {
1198  Int_t cnt = 0;
1199  s += 7;
1200  //is it the right base class ?
1201  if (strcmp(s, base)) continue; //skip to next env var if not right base
1202 
1203  char* v = StrDup(val);
1204  while (1) {
1205  TString regexp = strtok(!cnt ? v : 0, "; ");
1206  if (regexp.IsNull()) break;
1207  TString clss = strtok(0, "; ");
1208  if (clss.IsNull()) break;
1209  TString plugin = strtok(0, "; ");
1210  if (plugin.IsNull()) break;
1211  TString ctor = strtok(0, ";\"");
1212  if (!ctor.Contains("("))
1213  ctor = strtok(0, ";\"");
1214  if (clss == derived) {
1215  //found the required plugin
1216  //we remove the 'regexp' operator '^' from the beginning
1217  //and '$' from the end of the URI, if necessary
1218  if (regexp.MaybeRegexp()) {
1219  regexp.Remove(TString::kBoth, '^');
1220  regexp.Remove(TString::kBoth, '$');
1221  }
1222  tmp = regexp;
1223  delete [] v;
1224  return tmp.Data();
1225  }
1226  cnt++;
1227  }
1228  delete [] v;
1229  }
1230  }
1231  }
1232  tmp = "";
1233  return tmp;
1234 }
1235 
1236 
1237 
1238 
1251 
1253 {
1254  // Return whitespace-separated list of all plugin classes defined for
1255  // the given base class.
1256  //
1257  // E.g. if plugins exist for BaseClass:
1258  //
1259  // Plugin.BaseClass: URI PluginClass PluginLibrary "PluginClassConstructor(arguments)"
1260  // +Plugin.BaseClass: URI2 PluginClass2 PluginLibrary2 "PluginClass2Constructor(arguments)"
1261  //
1262  // then KVBase::GetListOfPlugins("BaseClass") will return "PluginClass PluginClass2"
1263  //
1264  // Most of the code is copied from `TPluginManager::LoadHandlersFromEnv`
1265 
1266  TIter next(gEnv->GetTable());
1267  TEnvRec* er;
1268  static TString tmp;
1269  tmp = "";
1270  while ((er = (TEnvRec*) next())) {
1271  const char* s;
1272  if ((s = strstr(er->GetName(), "Plugin."))) {
1273  // use s, i.e. skip possible OS and application prefix to Plugin.
1274  // so that GetValue() takes properly care of returning the value
1275  // for the specified OS and/or application
1276  const char* val = gEnv->GetValue(s, (const char*)0);
1277  if (val) {
1278  Int_t cnt = 0;
1279  s += 7;
1280  //is it the right base class ?
1281  if (strcmp(s, base)) continue; //skip to next env var if not right base
1282 
1283  char* v = StrDup(val);
1284  while (1) {
1285  TString regexp = strtok(!cnt ? v : 0, "; ");
1286  if (regexp.IsNull()) break;
1287  TString clss = strtok(0, "; ");
1288  if (clss.IsNull()) break;
1289  TString plugin = strtok(0, "; ");
1290  if (plugin.IsNull()) break;
1291  TString ctor = strtok(0, ";\"");
1292  if (!ctor.Contains("("))
1293  ctor = strtok(0, ";\"");
1294  tmp += clss;
1295  tmp += " ";
1296  cnt++;
1297  }
1298  delete [] v;
1299  }
1300  }
1301  }
1302  //remove final trailing whitespace
1303  tmp.Remove(TString::kTrailing, ' ');
1304  return tmp;
1305 }
1306 
1307 
1308 
1318 
1320 {
1321  // For a given base class, return a whitespace-separated list of plugin identifiers
1322  // which are known/defined.
1323  // E.g. if plugins exist for BaseClass:
1324  //
1325  // Plugin.BaseClass: URI PluginClass PluginLibrary "PluginClassConstructor(arguments)"
1326  // +Plugin.BaseClass: URI2 PluginClass2 PluginLibrary2 "PluginClass2Constructor(arguments)"
1327  //
1328  // then KVBase::GetListOfPluginURIs("BaseClass") will return "URI URI2"
1329 
1330  static TString tmp;
1331  KVString plugs = KVBase::GetListOfPlugins(base);
1332  plugs.Begin(" ");
1333  tmp = "";
1334  while (!plugs.End()) {
1335  if (tmp != "") tmp += " ";
1336  tmp += KVBase::GetPluginURI(base, plugs.Next());
1337  }
1338  return tmp;
1339 }
1340 
1341 
1342 
1348 
1350 {
1351  // Returns kTRUE if 'uri' is the name of a defined plugin, in which case 'base'
1352  // is the name of the base class extended by this plugin.
1353  //
1354  // Most of the code is copied from `TPluginManager::LoadHandlersFromEnv`
1355 
1356  TIter next(gEnv->GetTable());
1357  TEnvRec* er;
1358  while ((er = (TEnvRec*) next())) {
1359  KVString ername = er->GetName();
1360  if (ername.BeginsWith("Plugin.")) {
1361  base = ername;
1362  base.Remove(0, 7);
1363  KVString erval = gEnv->GetValue(ername, "");
1364  erval.Begin(" ");
1365  while (!erval.End()) {
1366  if (erval.Next() == uri) return kTRUE;
1367  }
1368  }
1369  }
1370  return kFALSE;
1371 }
1372 
1373 
1374 
1375 
1388 
1390 {
1391  // Add to standard ROOT mime types some new ones defined in `.kvrootrc`
1392  // for icons associated with graphs, runs, etc. by lines such as:
1393  //
1394  //~~~~~~~~~
1395  // KaliVeda.GUI.MimeTypes : KVIDMap
1396  // KaliVeda.GUI.MimeTypes.KVIDMap.Icon : rootdb_t.xpm
1397  // +KaliVeda.GUI.MimeTypes : KVIDZAGrid
1398  // KaliVeda.GUI.MimeTypes.KVIDZAGrid.Icon : draw_t.xpm
1399  //~~~~~~~~~
1400  //
1401  // etc.
1402 
1403  KVString mimetypes = gEnv->GetValue("KaliVeda.GUI.MimeTypes", "");
1404  if (mimetypes != "") {
1405 
1406  mimetypes.Begin(" ");
1407  while (!mimetypes.End()) {
1408 
1409  KVString classname = mimetypes.Next(kTRUE);
1410  KVString icon = gEnv->GetValue(Form("KaliVeda.GUI.MimeTypes.%s.Icon", classname.Data()), "draw_t.xpm");
1411  KVString type = classname;
1412  type.ToLower();
1413 
1414  if (gClient) gClient->GetMimeTypeList()->AddType(Form("[kaliveda/%s]", type.Data()),
1415  classname.Data(), icon.Data(), icon.Data(), "");
1416 
1417  }
1418  }
1419 }
1420 
1421 
1422 
1433 
1435 {
1436  // \brief Comparison between two 64-bit floating-point values
1437  //
1438  // Returns `kTRUE` if the integer representations of the two values are within
1439  // `maxdif` of each other. By default `maxdif=1`, which means that we consider that `x==y` if the
1440  // difference between them is no greater than the precision of `Double_t`
1441  // variables, i.e. `4.94065645841246544e-324`
1442  //
1443  // Based on the function `AlmostEqual2sComplement(float, float, int)`
1444  // by Bruce Dawson http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm
1445 
1446  union converter {
1447  Double_t f;
1448  Long64_t i;
1449  } zero, val1, val2;
1450 
1451  assert(maxdif > 0);
1452 
1453  if (A == B) return true;
1454 
1455  /* rustine to obtain the (64-bit) constant value 0x8000000000000000
1456  even on 32-bit machines (there is probably an easier way!) */
1457  zero.i = 1;
1458  zero.f = -zero.f;
1459  zero.i -= 1;
1460 
1461  val1.f = A;
1462  val2.f = B;
1463  Long64_t Aint, Bint;
1464  Aint = val1.i;
1465  Bint = val2.i;
1466  if (Aint < 0) Aint = zero.i - Aint;
1467  if (Bint < 0) Bint = zero.i - Bint;
1468 
1469  Long64_t intDiff = abs(val1.i - val2.i);
1470 
1471  if (intDiff <= maxdif) return true;
1472 
1473  return false;
1474 }
1475 
1476 
1477 
1486 
1487 Bool_t KVBase::OpenContextMenu(const char* method, TObject* obj, const char* alt_method_name)
1488 {
1489  // Open context menu for given method of object *obj.
1490  // By default title of menu is 'obj->ClassName()::method'
1491  // You can give an alternative method name in 'alt_method_name'
1492  // Returns kFALSE if the given method is not defined for the class of object in question.
1493  //
1494  // WARNING: even if this method returns kTRUE, this is no guarantee that the method
1495  // has indeed been executed. The user may have pressed the 'Cancel' button...
1496 
1497  TMethod* m = obj->IsA()->GetMethodAllAny(method);
1498  if (!m) {
1499  obj->Warning("OpenContextMenu", "%s is not a method of %s", method, obj->ClassName());
1500  return kFALSE;
1501  }
1502  TString Method = alt_method_name;
1503  if (Method == "") Method = method;
1504  TContextMenu* cm = new TContextMenu(Method, Form("%s::%s", obj->ClassName(), Method.Data()));
1505  cm->Action(obj, m);
1506  delete cm;
1507  return kTRUE;
1508 }
1509 
1510 
1511 
1518 
1519 void KVBase::CombineFiles(const Char_t* file1, const Char_t* file2, const Char_t* newfilename, Bool_t keep)
1520 {
1521  // STATIC method which allows to combine the contents of two ROOT files
1522  // (file1 and file2) into a new ROOT file (newfilename).
1523  // All objects from the two files will be written in the new file.
1524  //
1525  // if keep=kFALSE, the two files will be deleted after the operation
1526 
1527  ::Info("KVBase::CombineFiles", "Copying all objects from %s and %s ===> into new file %s", file1, file2, newfilename);
1528 
1529  TFileMerger file_merge;
1530  file_merge.AddFile(file1, kFALSE);
1531  file_merge.AddFile(file2, kFALSE);
1532  file_merge.OutputFile(newfilename);
1533  file_merge.Merge();
1534 
1535  // remove physical files from disk if required
1536  if (!keep) {
1537  gSystem->Unlink(file1);
1538  gSystem->Unlink(file2);
1539  }
1540 }
1541 
1542 
1543 
1551 
1553 {
1554  // Dummy method (returns NULL).
1555  // This method may be used in 'container' classes used with KVListView.
1556  // In order to open the context menu of the 'contained' object,
1557  // GetLabel() should return the real class of the object,
1558  // and this method should return its address.
1559  // Then call KVListView::SetUseObjLabelAsRealClass(kTRUE).
1560  return nullptr;
1561 }
1562 
1563 
1564 
1565 
1568 
1569 const Char_t* KVBase::GetExampleFilePath(const Char_t* library, const Char_t* namefile)
1570 {
1571  // Return full path to example file for given library (="KVMultiDet", "BackTrack", etc.)
1572  static TString path;
1573  path = KVBase::GetDATADIRFilePath("examples/");
1574  path += library;
1575  path += "/";
1576  path += namefile;
1577  return path.Data();
1578 }
1579 
1580 
1581 
1584 
1586 {
1587  // Prints welcome message and infos on version etc.
1588 
1589  cout << "/----------------------------------------------------------------------\\" << endl;
1590  cout << "| Welcome to KaliVeda v" << GetKVVersion() << " gitlab.in2p3.fr/kaliveda-dev/kaliveda |" << endl;
1591  cout << "| (c) 2002-2024, The KaliVeda development team |" << endl;
1592  cout << "| |" << endl;
1593  cout << "| Built with ROOT " << kaliveda::build_infos::KV_ROOT_VERSION << " on " << KVBase::GetKVBuildDate() << ", " << KVBase::GetKVBuildTime() << " |" << endl;
1594 #ifdef WITH_GIT_INFOS
1595  TString gitinfo;
1596  gitinfo.Form("%s@%s", gitBranch(), gitCommit());
1597  printf("| From %-63s |\n", gitinfo.Data());
1598 #endif
1599  cout << "| See https://kaliveda.in2p3.fr for help |" << endl;
1600  cout << "\\----------------------------------------------------------------------/" << endl << endl;
1601 }
1602 
1603 
1604 
1605 
1621 
1622 Double_t KVBase::ProtectedGetX(const TF1* func, Double_t val, int& status, Double_t xmin, Double_t xmax)
1623 {
1624  // Since ROOT6, the TF1::GetX() method can no longer be used without precaution.
1625  //
1626  // In ROOT5, if the value val was larger or smaller than the maximum or minimum value of
1627  // the function (within its defined range) then TF1::GetX() would return X of the
1628  // maximum or minimum, respectively.
1629  //
1630  // In ROOT6, TF1::GetX() has been reimplemented so that, in the above case, it
1631  // prints out 3 warning messages and returns a TMath::QuietNaN()! Therefore we provide this
1632  // function in order to replicate the previous behaviour.
1633  //
1634  // The status = 0 if the value is within the limits of the function.
1635  // status = +1 if value is above the maximum, or status = -1 if value is below the minimum
1636  //
1637  // When compiled with ROOT5, this method just calls TF1::GetX() (and status = 0 always).
1638 
1639 #ifdef USING_ROOT6
1640  status = 0;
1641  if (val > func->GetMaximum(xmin, xmax)) {
1642  status = 1;
1643  return func->GetMaximumX(xmin, xmax);
1644  }
1645  else if (val < func->GetMinimum(xmin, xmax)) {
1646  status = -1;
1647  return func->GetMinimumX(xmin, xmax);
1648  }
1649  else
1650  return func->GetX(val, xmin, xmax);
1651 #else
1652  status = 0;
1653  return func->GetX(val, xmin, xmax);
1654 #endif
1655 }
1656 
1657 
1658 
1660 
1661 Double_t KVBase::ProtectedGetX(const TF1& func, Double_t val, int& status, Double_t xmin, Double_t xmax)
1662 {
1663  return ProtectedGetX(&func,val,status,xmin,xmax);
1664 }
1665 
1666 
1667 
1669 
1670 void KVBase::Warning(const char* location, const char* va_(fmt), ...) const
1671 {
1672  va_list ap;
1673  va_start(ap, va_(fmt));
1674  fprintf(stderr, "%s", "\033[1;38;5;202m");
1675  DoError(kWarning, location, va_(fmt), ap);
1676  fprintf(stderr, "%s", "\033[0m");
1677  va_end(ap);
1678 }
1679 
1680 
1682 
1683 void KVBase::Error(const char* location, const char* va_(fmt), ...) const
1684 {
1685  va_list ap;
1686  va_start(ap, va_(fmt));
1687  fprintf(stderr, "%s", "\033[1;38;5;196m");
1688  DoError(kError, location, va_(fmt), ap);
1689  fprintf(stderr, "%s", "\033[0m");
1690  va_end(ap);
1691 }
1692 
1693 
1694 
1700 
1701 void KVBase::Deprecated(const char* where, const char* advice)
1702 {
1703  // Print a message to indicate when the called method is deprecated and give advice how to do better
1704  //
1705  // Don't call directly: use the macro Deprecate(advice) which will automatically fill in the method name
1706  // (see KVMacros.h)
1707 
1708  printf("Warning in <%s>: Method is deprecated in v%s and will be removed in future.\n%s\n",
1709  where, KVBase::GetKVVersion(), advice);
1710 }
1711 
1712 
1713 
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:383
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:830
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:901
static const Char_t * FindFile(const Char_t *search, TString &wfil)
Definition: KVBase.cpp:1054
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:1683
static const Char_t * gitCommit()
Returns last git commit of sources.
Definition: KVBase.cpp:971
static const Char_t * GetWORKDIRFilePath(const Char_t *namefile="")
Definition: KVBase.cpp:121
void init()
Default initialisation.
Definition: KVBase.cpp:155
static Bool_t FindExecutable(TString &exec, const Char_t *path="$(PATH)")
Definition: KVBase.cpp:995
static const Char_t * GetKVBuildUser()
Returns username of person who performed build.
Definition: KVBase.cpp:889
static void BackupFileWithDate(const Char_t *path)
Definition: KVBase.cpp:756
static void ReadConfigFiles()
Definition: KVBase.cpp:282
static const Char_t * gitBranch()
Returns git branch of sources.
Definition: KVBase.cpp:960
static const Char_t * GetListOfPluginURIs(const Char_t *base)
Definition: KVBase.cpp:1319
TString fLabel
label for the object
Definition: KVBase.h:144
KVBase()
Default constructor.
Definition: KVBase.cpp:329
static int GetKVMajorVersion()
Definition: KVBase.cpp:130
static const Char_t * GetListOfPlugins(const Char_t *base)
Definition: KVBase.cpp:1252
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:1434
KVBase & operator=(const KVBase &)
copy assignment operator
Definition: KVBase.cpp:367
static void CombineFiles(const Char_t *file1, const Char_t *file2, const Char_t *newfilename, Bool_t keep=kTRUE)
Definition: KVBase.cpp:1519
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:1096
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:936
void Copy(TObject &) const override
Make a copy of this object.
Definition: KVBase.cpp:397
static void InitEnvironment()
Definition: KVBase.cpp:197
static Double_t ProtectedGetX(const TF1 *func, Double_t val, int &status, Double_t xmin=0.0, Double_t xmax=0.0)
Definition: KVBase.cpp:1622
void Print(Option_t *option="") const override
Definition: KVBase.cpp:413
static const Char_t * GetKVBuildTime()
Returns KaliVeda build time.
Definition: KVBase.cpp:912
static int GetKVMinorVersion()
Definition: KVBase.cpp:138
static void PrintSplashScreen()
Prints welcome message and infos on version etc.
Definition: KVBase.cpp:1585
static const Char_t * GetLIBDIRFilePath(const Char_t *namefile="")
Definition: KVBase.cpp:94
static int GetKVPatchVersion()
Definition: KVBase.cpp:146
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:1569
static const Char_t * GetKVBuildDir()
Returns top-level directory used for build.
Definition: KVBase.cpp:948
static void ReadGUIMimeTypes()
Definition: KVBase.cpp:1389
static Bool_t IsThisAPlugin(const TString &uri, TString &base)
Definition: KVBase.cpp:1349
@ kIsKaliVedaObject
Definition: KVBase.h:159
virtual TObject * GetObject() const
Definition: KVBase.cpp:1552
static void GetTempFileName(TString &base)
Definition: KVBase.cpp:851
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:924
static const Char_t * GetPluginURI(const Char_t *base, const Char_t *plugin)
Definition: KVBase.cpp:1169
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:1487
static Bool_t SearchAndOpenKVFile(const Char_t *name, KVSQLite::database &dbfile, const Char_t *kvsubdir="")
Definition: KVBase.cpp:652
static TPluginHandler * LoadPlugin(const Char_t *base, const Char_t *uri="0")
Definition: KVBase.cpp:796
static const Char_t * GetKVVersion()
Returns KaliVeda version string.
Definition: KVBase.cpp:877
void Warning(const char *method, const char *msgfmt,...) const override
Definition: KVBase.cpp:1670
static void Deprecated(const char *method, const char *advice)
Definition: KVBase.cpp:1701
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)