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);
80  return kaliveda::build_infos::TEMPLATEDIR.c_str();
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 int KVBase::GetKVMajorVersion() { return kaliveda::build_infos::KV_MAJOR_VERSION; }
128 int KVBase::GetKVMinorVersion() { return kaliveda::build_infos::KV_MINOR_VERSION; }
129 
132 
134 {
135  //Default initialisation
136 
137  InitEnvironment();
138  fNumber = 0;
139  fLabel = "";
140  SetBit(kIsKaliVedaObject);
141 }
142 
143 
144 
174 
176 {
177  // STATIC method to Initialise KaliVeda environment
178  // Reads config files in <code>\$(pkgdatadir)/etc</code> and sets up environment
179  // (data repositories, datasets, etc. etc.).
180  // Adds directory where kaliveda shared libs are installed to the dynamic
181  // path - for finding and loading plugins.
182  // Resets the `gRandom` random number sequence using a clock-based seed
183  // (i.e. random sequences do not repeat).
184  //
185  // Normally, the first object created which inherits from KVBase will
186  // perform this initialisation; if you need to set up the environment before
187  // creating a KVBase object, or if you just want to be absolutely sure that
188  // the environment has been initialised, you can call this method.
189  //
190  // #### Note for GNU-style installations
191  // If KaliVeda is built with the cmake option `-Dgnuinstall=yes` then each
192  // user will have a working directory which will be used to store any files
193  // generated by KaliVeda at runtime.
194  //
195  // By default the location of user's working directory is set to
196  //~~~~~~~~~
197  // $(HOME)/.kaliveda
198  //~~~~~~~~~
199  // but can be changed with variable
200  //~~~~~~~~~
201  // KaliVeda.WorkingDirectory: [directory]
202  //~~~~~~~~~
203  // in configuration file `.kvrootrc`.
204  //`[directory]` must be an absolute pathname, but can use shell variables like <code>\$(HOME)</code>.
205 
206  std::lock_guard<std::mutex> lk(_kvbase_mutex); // prevent multiple initialisation in different threads
207 
208  if (!fEnvIsInit) {//test if environment already initialised
209 
210  // enable ROOT thread safety
212 
213  // Add path to kaliveda libraries to dynamic loader path
214  // This is needed to find plugins
215  // and also to be able to compile with kaliveda in the interpreter
216  TString libdir = GetLIBDIRFilePath();
217  gSystem->AddDynamicPath(libdir);
218  // force re-reading of rootmap files in new dynamic path
219  gInterpreter->LoadLibraryMap();
220  // Add path to kaliveda header files
221  // This is needed to be able to compile with kaliveda in the interpreter
222  TString incdir = GetINCDIRFilePath();
223  incdir.Prepend("-I");
224  gSystem->AddIncludePath(incdir);
225 
226  //set up environment using kvrootrc file
227  if (!gEnv->Defined("DataSet.DatabaseFile")) {
228  ReadConfigFiles();
229  }
230 #ifdef WITH_GNU_INSTALL
231  // set working directory & create if needed
232  fWorkingDirectory = gEnv->GetValue("KaliVeda.WorkingDirectory", "$(HOME)/.kaliveda");
233  gSystem->ExpandPathName(fWorkingDirectory);
234  gSystem->mkdir(fWorkingDirectory, kTRUE);
235 #else
236  // set environment variable used in database makefiles
237  fWorkingDirectory = KV_ROOT;
238 #endif
239  // set environment variable used in database makefiles
240  gSystem->Setenv("KV_WORK_DIR", fWorkingDirectory);
241 
242  //generate new seed from system clock
243  gRandom->SetSeed(0);
244 
245  // initialisation has been performed
246  fEnvIsInit = kTRUE;
247  }
248 }
249 
250 
251 
259 
261 {
262  // Read all configuration files
263  // System config files are read first in the order they appear in file
264  // ${ETCDIR}/config.files
265  // Then we read any of the following files if they exist:
266  // ${HOME}/.kvrootrc
267  // ${PWD}/.kvrootrc
268 
269  TString tmp = GetETCDIRFilePath("config.files");
270  ifstream conflist;
271  conflist.open(tmp.Data());
272  if (!conflist.good()) {
273  ::Fatal("KVBase::ReadConfigFiles", "Cannot open %s", tmp.Data());
274  return;
275  }
276  KVString file;
277  file.ReadLine(conflist);
278  conflist.close();
279  file.Begin(";");
280  while (!file.End()) {
281  tmp = GetETCDIRFilePath(file.Next().Data());
282  //skip over any missing files - this is needed when installing from
283  //e.g. ubuntu packages if not all packages are installed
284  if (!gSystem->AccessPathName(tmp.Data())) gEnv->ReadFile(tmp.Data(), kEnvChange);
285  }
286 
287  AssignAndDelete(tmp, gSystem->ConcatFileName(gSystem->Getenv("HOME"), ".kvrootrc"));
288  gEnv->ReadFile(tmp.Data(), kEnvChange);
289 
290  tmp = "./.kvrootrc";
291  gEnv->ReadFile(tmp.Data(), kEnvChange);
292 
293  // load plugin handlers
294  gROOT->GetPluginManager()->LoadHandlersFromEnv(gEnv);
295 
296  // load mime types/icon definitions when not in batch (i.e. GUI-less) mode
297  if (!gROOT->IsBatch()) ReadGUIMimeTypes();
298 }
299 
300 
301 
304 
306 {
307  //Default constructor.
308  init();
309 }
310 
311 
312 
315 
316 KVBase::KVBase(const Char_t* name, const Char_t* type): TNamed(name, type)
317 {
318  //Ctor for object with given name and type.
319  init();
320 }
321 
322 
323 
326 
327 KVBase::KVBase(const KVBase& obj) : TNamed()
328 {
329  //copy ctor
330  init();
331 #if ROOT_VERSION_CODE >= ROOT_VERSION(3,4,0)
332  obj.Copy(*this);
333 #else
334  ((KVBase&) obj).Copy(*this);
335 #endif
336 }
337 
338 
339 
342 
344 {
345  // copy assignment operator
346 
347  if (&other != this) {
348  other.Copy(*this);
349  }
350  return (*this);
351 }
352 
353 
354 
355 
358 
360 {
361  //Clear object properties : name, type/title, number, label
362  TNamed::Clear(opt);
363  fNumber = 0;
364  fLabel = "";
365 }
366 
367 
368 #if ROOT_VERSION_CODE >= ROOT_VERSION(3,4,0)
369 
372 
373 void KVBase::Copy(TObject& obj) const
374 #else
375 void KVBase::Copy(TObject& obj)
376 #endif
377 {
378  //Make a copy of this object
379 
380  TNamed::Copy(obj);
381  ((KVBase&) obj).SetNumber(fNumber);
382  ((KVBase&) obj).SetLabel(fLabel);
383 }
384 
385 
386 
388 
390 {
391  cout << "KVBase object: Name=" << GetName() << " Type=" << GetType();
392  if (fLabel != "")
393  cout << " Label=" << GetLabel();
394  if (fNumber != 0)
395  cout << " Number=" << GetNumber();
396  cout << endl;
397 }
398 
399 
400 
406 
407 void KVBase::Streamer(TBuffer& R__b)
408 {
409  //Backwards compatible streamer for KVBase objects
410  //Needed to handle 'fLabel' char array in class version 1
411  //Objects written with version < 3 did not have kIsKaliVedaObject bit set,
412  //we set it here when reading object.
413 
414  if (R__b.IsReading()) {
415  UInt_t R__s, R__c;
416  Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
417  if (R__v > 1) {
418  if (R__v < 4) {
419  TNamed::Streamer(R__b);
420  R__b >> fNumber;
421  R__b >> fLabel;
422  if (R__v < 3) SetBit(kIsKaliVedaObject);
423  R__b.CheckByteCount(R__s, R__c, KVBase::IsA());
424  }
425  else {
426  //AUTOMATIC STREAMER EVOLUTION FOR CLASS VERSION > 3
427  KVBase::Class()->ReadBuffer(R__b, this, R__v, R__s, R__c);
428  }
429  return;
430  }
431  //OLD STREAMER FOR CLASS VERSION 1
432  TNamed::Streamer(R__b);
433  R__b >> fNumber;
434  UInt_t LabelLength;
435  R__b >> LabelLength;
436  if (LabelLength) {
437  Char_t* Label = new Char_t[LabelLength];
438  R__b.ReadFastArray(Label, LabelLength);
439  fLabel = Label;
440  delete[]Label;
441  }
443  R__b.CheckByteCount(R__s, R__c, KVBase::IsA());
444  }
445  else {
446  KVBase::Class()->WriteBuffer(R__b, this);
447  }
448 }
449 
450 
451 
452 
464 
465 Bool_t SearchFile(const Char_t* name, TString& fullpath, int ndirs, ...)
466 {
467  //Search for file in an arbitrary number of locations, return kTRUE if file found and put full path to file in 'fullpath"
468  //
469  //'name' is a filename (not an absolute pathname) i.e. "toto.dat"
470  //'fullpath" will contain the full path to the file if it is found (if file not found, fullpath="")
471  //'ndirs" is the number of directories to search in
472  //the remaining arguments are the names of 'ndirs' paths to search in, i.e.
473  //
474  // SearchFile("toto.dat", fullpath, 2, gSystem->pwd(), gSystem->HomeDirectory());
475  //
476  //means: search for a file 'toto.dat' in current working directory, then user's home directory.
477 
478  if (ndirs <= 0)
479  return kFALSE;
480 
481  va_list args;
482  va_start(args, ndirs);
483 
484  for (; ndirs; ndirs--) { //loop over directories
485 
486  AssignAndDelete(fullpath,
487  gSystem->ConcatFileName(va_arg(args, const char*),
488  name));
489  if (!gSystem->AccessPathName(fullpath.Data())) {
490  va_end(args);
491  return kTRUE;
492  }
493 
494  }
495 
496  va_end(args);
497  fullpath = ""; //clear fullpath string to avoid using it by mistake
498  return kFALSE;
499 }
500 
501 
502 
516 
517 Bool_t KVBase::SearchKVFile(const Char_t* name, TString& fullpath,
518  const Char_t* kvsubdir)
519 {
520  //search for files in the following order:
521  // if 'name' = absolute path the function returns kTRUE if the file exists
522  // if name != absolute path:
523  // 1. a. if 'kvsubdir'="" (default) look for file in $(pkgdatadir) directory
524  // 1. b. if 'kvsubdir'!="":
525  // if 'kvsubdir' is an absolute pathname, look in 'kvsubdir'
526  // if 'kvsubdir' is not an absolute pathname,
527  // look in '$(pkdatadir)/kvsubdir'
528  // 2. look for file with this name in user's home directory
529  // 3. look for file with this name in working directory
530  //in all cases the function returns kTRUE if the file was found.
531  //'fullpath' then contains the absolute path to the file
532 
534  // absolute path
535  fullpath = name;
536  return !gSystem->AccessPathName(name);
537  }
538 
539  TString kvfile_dir;
540  if (strcmp(kvsubdir, "")) {
541  // subdirectory hint given
542  if (!gSystem->IsAbsoluteFileName(kvsubdir))
543  kvfile_dir = GetDATADIRFilePath(kvsubdir); // relative path - assume in $(pkgdatadir)
544  else
545  kvfile_dir = kvsubdir; // absolute path - use as is
546  }
547  else // no subdirectory hint given
548  kvfile_dir = GetDATADIRFilePath();
549 
550  return SearchFile(name, fullpath, 3, kvfile_dir.Data(),
552 }
553 
554 
555 
556 
576 
577 Bool_t KVBase::SearchAndOpenKVFile(const Char_t* name, ifstream& file, const Char_t* kvsubdir, KVLockfile* locks)
578 {
579  //Search and open for READING a file:
580  //
581  //search for ascii file (and open it, if found) in the following order:
582  // if 'name' = absolute path the function returns kTRUE if the file exists
583  // if name != absolute path:
584  // 1. a. if 'kvsubdir'="" (default) look for file in $(pkdatadir) directory
585  // 1. b. if 'kvsubdir'!="" look for file in $(pkdatadir)/'kvsubdir'
586  // if 'kvsubdir' is an absolute pathname, look in 'kvsubdir'
587  // if 'kvsubdir' is not an absolute pathname,
588  // look in '$(pkdatadir)/kvsubdir'
589  // 2. look for file with this name in user's home directory
590  // 3. look for file with this name in working directory
591  //if the file is not found, kFALSE is returned.
592  //if file is found and can be opened, 'file' is then an ifstream connected to the open (ascii) file
593  //
594  //LOCKFILE:
595  //If a KVLockfile pointer is given, we use it to get a lock on the file before opening it.
596  //If this lock is not successful, the file is not opened and we return an error message.
597 
598  TString fullpath;
599  if (SearchKVFile(name, fullpath, kvsubdir)) {
600  //put lock on file if required
601  if (locks && !locks->Lock(fullpath.Data())) return kFALSE;
602  file.open(fullpath.Data());
603  if (file.good()) {
604  //cout << "Opened file : " << fullpath.Data() << endl;
605  return kTRUE;
606  }
607  //unlock file if not opened successfully
608  if (locks) locks->Release();
609  }
610  return kFALSE;
611 }
612 
613 
614 #ifdef WITH_RSQLITE
615 
627 
628 Bool_t KVBase::SearchAndOpenKVFile(const Char_t* name, KVSQLite::database& dbfile, const Char_t* kvsubdir)
629 {
630  //Search and open for reading/writing a sqlite database file:
631  //
632  //search for file (and open it, if found) in the following order:
633  // if 'name' = absolute path the function returns kTRUE if the file exists
634  // if name != absolute path:
635  // 1. a. if 'kvsubdir'="" (default) look for file in $(pkdatadir) directory
636  // 1. b. if 'kvsubdir'!="" look for file in $(pkdatadir)/'kvsubdir'
637  // 2. look for file with this name in user's home directory
638  // 3. look for file with this name in working directory
639  //if the file is not found, kFALSE is returned.
640 
641  TString fullpath;
642  if (SearchKVFile(name, fullpath, kvsubdir)) {
643  dbfile.open(fullpath);
644  if (dbfile.good()) {
645  //cout << "Opened file : " << fullpath.Data() << endl;
646  return kTRUE;
647  }
648  }
649  return kFALSE;
650 }
651 
652 #endif
653 
654 
673 
674 Bool_t KVBase::SearchAndOpenKVFile(const Char_t* name, ofstream& file, const Char_t* kvsubdir, KVLockfile* locks)
675 {
676  //Search and CREATE i.e. open for WRITING a file:
677  //
678  //open for writing an ascii file in the location determined in the following way:
679  // if 'name' = absolute path we use the full path
680  // if name != absolute path:
681  // 1. a. if 'kvsubdir'="" (default) file will be in $(pkdatadir) directory
682  // 1. b. if 'kvsubdir'!="":
683  // if 'kvsubdir' is an absolute pathname, file in 'kvsubdir'
684  // if 'kvsubdir' is not an absolute pathname,
685  // file will be in '$(pkdatadir)/kvsubdir'
686  //if an existing file is found, a warning is printed and the existing file 'toto' is renamed
687  //"toto.date". where 'date' is created with TDatime::AsSQLDate
688  // file' is then an ofstream connected to the opened file
689  //
690  //LOCKFILE:
691  //If a KVLockfile pointer is given, we use it to get a lock on the file before opening it.
692  //If this lock is not successful, the file is not opened and we return an error message.
693 
694  KVString fullpath;
695  if (gSystem->IsAbsoluteFileName(name)) {
696  fullpath = name;
697  }
698  else if (gSystem->IsAbsoluteFileName(kvsubdir)) {
699  AssignAndDelete(fullpath,
700  gSystem->ConcatFileName(kvsubdir, name));
701  }
702  else if (strcmp(kvsubdir, "")) {
703  KVString path = GetDATADIRFilePath(kvsubdir);
704  AssignAndDelete(fullpath,
705  gSystem->ConcatFileName(path.Data(), name));
706  }
707  else {
708  fullpath = GetDATADIRFilePath(name);
709  }
710  //Backup file if necessary
711  BackupFileWithDate(fullpath.Data());
712  //put lock on file if required
713  if (locks && !locks->Lock(fullpath.Data())) return kFALSE;
714  file.open(fullpath.Data());
715  return kTRUE;
716 }
717 
718 
719 
720 
731 
733 {
734  //`path` gives the full path (can include environment variables, special symbols)
735  //to a file which will be renamed with an extension containing the current date and time
736  //(in SQL format).
737  //
738  //Example:
739  //
740  // KVBase::BackupFileWithDate("$(HOME)/toto.txt")
741  //
742  //The file `toto.txt` will be renamed `toto.txt.2007-05-02_16:22:37`
743 
744  KVString fullpath = path;
745  gSystem->ExpandPathName(fullpath);
746  if (!gSystem->AccessPathName(fullpath.Data())) {//does the file exist ?
747  //backup file
748  TDatime now;
749  KVString date(now.AsSQLString());
750  date.ReplaceAll(' ', '_');
751  TString backup = fullpath + "." + date;
752  //lock both files
753  KVLockfile lf1(fullpath.Data()), lf2(backup.Data());
754  if (lf1.Lock() && lf2.Lock()) {
755  gSystem->Rename(fullpath.Data(), backup.Data());
756  printf("Info in <KVBase::BackupFileWithDate(const Char_t *)> : Existing file %s renamed %s\n",
757  fullpath.Data(), backup.Data());
758  }
759  }
760 }
761 
762 
763 
764 
771 
773 {
774  //Load plugin library in order to extend capabilities of base class "base", depending on
775  //the given uri (these arguments are used to call TPluginManager::FindHandler).
776  //Returns pointer to TPluginHandler.
777  //Returns 0 in case of problems.
778 
779  //does plugin exist for given name ?
780  TPluginHandler* ph =
781  (TPluginHandler*) gROOT->GetPluginManager()->FindHandler(base,
782  uri);
783  if (!ph)
784  return 0;
785 
786  //check plugin library/macro is available
787  if (ph->CheckPlugin() != 0)
788  return 0;
789 
790  //load plugin module
791  if (ph->LoadPlugin() != 0)
792  return 0;
793 
794  return ph;
795 }
796 
797 
798 
799 
805 
806 void KVBase::OpenTempFile(TString& base, ofstream& fp)
807 {
808  //Opens a uniquely-named file in system temp directory (gSystem->TempDirectory)
809  //Name of file is "basexxxxxxxxxx" where "xxxxxxxxx" is current time as returned
810  //by gSystem->Now().
811  //After opening file, 'base' contains full path to file.
812 
813  GetTempFileName(base);
814  fp.open(base.Data());
815 }
816 
817 
818 
819 
826 
828 {
829  //When called with base="toto.dat", the returned value of 'base' is
830  //"/full/path/to/temp/dir/toto.dat15930693"
831  //i.e. the full path to a file in the system temp directory (gSystem->TempDirectory)
832  //appended with the current time as returned by gSystem->Now() in order to make
833  //its name unique
834 
835  TString tmp1;
836  AssignAndDelete(tmp1,
838  base.Data()));
839  long lnow = (long) gSystem->Now();
840  base = tmp1 + lnow;
841  //make sure no existing file with same name
842  while (!gSystem->AccessPathName(base)) {
843  base = tmp1 + (++lnow);
844  }
845 }
846 
847 
848 
849 
852 
854 {
855  //Returns KaliVeda version string
856  return kaliveda::build_infos::KV_VERSION.c_str();
857 }
858 
859 
860 
861 
864 
866 {
867  // Returns username of person who performed build
868  return kaliveda::build_infos::KV_BUILD_USER.c_str();
869 }
870 
871 
872 
873 
876 
878 {
879  //Returns KaliVeda build date
880  return kaliveda::build_infos::KV_BUILD_DATE.c_str();
881 }
882 
883 
884 
887 
889 {
890  //Returns KaliVeda build time
891  return kaliveda::build_infos::KV_BUILD_TIME.c_str();
892 }
893 
894 
895 
896 
899 
901 {
902  //Returns KaliVeda build type (cmake build: Release, Debug, RelWithDebInfo, ...)
903  return kaliveda::build_infos::KV_BUILD_TYPE.c_str();
904 }
905 
906 
907 
908 
911 
913 {
914  //Returns top-level directory of source tree used for build
915  return kaliveda::build_infos::KV_SOURCE_DIR.c_str();
916 }
917 
918 
919 
920 
923 
925 {
926  //Returns top-level directory used for build
927  return kaliveda::build_infos::KV_BUILD_DIR.c_str();
928 }
929 
930 
931 #ifdef WITH_GIT_INFOS
932 
935 
937 {
938  // Returns git branch of sources
939  return kaliveda::git_infos::KV_GIT_BRANCH.c_str();
940 }
941 
942 
943 
946 
948 {
949  // Returns last git commit of sources
950  return kaliveda::git_infos::KV_GIT_COMMIT.c_str();
951 }
952 
953 #endif
954 
955 
970 
972 {
973  //By default, `FindExecutable(exec)` will look for the executable named by `exec`
974  //in the directories contained in the environment variable `PATH`. You can override
975  //this by giving your own search `path` as second argument (remember to write
976  //environment variables as <code>\$(PATH)</code>, for cross-platform compatibility).
977  //
978  //If `exec` is not found, and if it does not end with `.exe`, we look for `exec.exe`
979  //This is for compatibility with Windows/cygwin environments.
980  //
981  //If the executable is found, returns `kTRUE` and `exec` then holds full path to executable.
982  //Returns `kFALSE` if `exec` not found in paths.
983  //
984  //If `exec` is an absolute pathname, we return `kTRUE` if the file exists
985  //(we do not use `path`).
986 
987  TString spath(path), backup(exec), backup2(exec), expandexec(exec);
988  gSystem->ExpandPathName(expandexec);
989  if (gSystem->IsAbsoluteFileName(expandexec.Data())) {
990  //executable given as absolute path
991  //we check if it exists
992  if (!gSystem->AccessPathName(expandexec)) {
993  exec = expandexec;
994  return kTRUE;
995  }
996  else {
997  //try with ".exe" in case of Windows system
998  if (!expandexec.EndsWith(".exe")) {
999  expandexec += ".exe";
1000  if (!gSystem->AccessPathName(expandexec)) {
1001  exec = expandexec;
1002  return kTRUE;
1003  }
1004  }
1005  }
1006  exec = backup;
1007  return kFALSE;
1008  }
1009  gSystem->ExpandPathName(spath);
1010  if (KVBase::FindFile(spath.Data(), exec))
1011  return kTRUE;
1012  if (!backup.EndsWith(".exe")) {
1013  backup += ".exe";
1014  if (KVBase::FindFile(spath.Data(), backup)) {
1015  exec = backup;
1016  return kTRUE;
1017  }
1018  }
1019  exec = backup2;
1020  return kFALSE;
1021 }
1022 
1023 
1024 
1025 
1029 
1030 const Char_t* KVBase::FindFile(const Char_t* search, TString& wfil)
1031 {
1032  //Backwards compatible fix for `TSystem::FindFile` which only exists from ROOT version 5.12/00 onwards.
1033  //Use this method as a replacement for `gSystem->FindFile` (same arguments)
1034 #ifdef __WITHOUT_TSYSTEM_FINDFILE
1035  Char_t* result = gSystem->Which(search, wfil.Data());
1036  if (result) {
1037  wfil = result;
1038  delete[]result;
1039  }
1040  else {
1041  wfil = "";
1042  }
1043  return wfil.Data();
1044 #else
1045  return gSystem->FindFile(search, wfil);
1046 #endif
1047 }
1048 
1049 
1050 
1051 
1071 
1072 Bool_t KVBase::FindClassSourceFiles(const KVString& class_name, KVString& imp_file, KVString& dec_file, const KVString& dir_name)
1073 {
1074  //Look for the source files corresponding to `class_name`
1075  //i.e. taking class_name as a base, we look for one of
1076  //
1077  //~~~~~~~
1078  //class_name.C,class_name.cpp,class_name.cxx
1079  //~~~~~~~
1080  //
1081  //and one of
1082  //
1083  //~~~~~~~
1084  //class_name.h,class_name.hh,class_name.H
1085  //~~~~~~~
1086  //
1087  //By default we look in the current working directory, unless argument `dir_name`
1088  //is given
1089  //
1090  //If found, the names of the two files are written in `imp_file` and
1091  //`dec_file`
1092 
1093  KVNameValueList impl_alt;
1094  int i = 0;
1095  impl_alt.SetValue("%s.C", i);
1096  impl_alt.SetValue("%s.cpp", i);
1097  impl_alt.SetValue("%s.cxx", i);
1098  KVNameValueList decl_alt;
1099  decl_alt.SetValue("%s.h", i);
1100  decl_alt.SetValue("%s.hh", i);
1101  decl_alt.SetValue("%s.H", i);
1102 
1103  TString _dir_name = dir_name;
1104  KVSystemDirectory dir("LocDir", _dir_name);
1105  TList* lf = dir.GetListOfFiles();
1106  Bool_t ok_imp, ok_dec;
1107  ok_imp = ok_dec = kFALSE;
1108 
1109  //look for implementation file
1110  for (i = 0; i < impl_alt.GetNpar(); i++) {
1111  if (lf->FindObject(Form(impl_alt.GetParameter(i)->GetName(), class_name.Data()))) {
1112  imp_file = Form(impl_alt.GetParameter(i)->GetName(), class_name.Data());
1113  ok_imp = kTRUE;
1114  }
1115  }
1116  //look for header file
1117  for (i = 0; i < decl_alt.GetNpar(); i++) {
1118  if (lf->FindObject(Form(decl_alt.GetParameter(i)->GetName(), class_name.Data()))) {
1119  dec_file = Form(decl_alt.GetParameter(i)->GetName(), class_name.Data());
1120  ok_dec = kTRUE;
1121  }
1122  }
1123  return (ok_imp && ok_dec);
1124 }
1125 
1126 
1127 
1128 
1144 
1145 const Char_t* KVBase::GetPluginURI(const Char_t* base, const Char_t* derived)
1146 {
1147  //Inverse of `gPluginMgr->FindHandler(const Char_t* base, const Char_t* uri)`
1148  //
1149  //Given a base class `base` and a derived class `derived`, we search `gEnv` to find the
1150  //URI corresponding to this plugin.
1151  //
1152  //Example: given a plugin such as
1153  //
1154  //~~~~~~~~
1155  //Plugin.KVIDTelescope: ^PHOS$ KVIDPhoswich KVIndra "KVIDPhoswich()"
1156  //~~~~~~~~
1157  //
1158  //then calling `KVBase::GetPluginURI("KVIDTelescope", "KVIDPhoswich")` will return `"PHOS"`.
1159  //
1160  //Most of the code is copied from `TPluginManager::LoadHandlersFromEnv`
1161 
1162  TIter next(gEnv->GetTable());
1163  TEnvRec* er;
1164  static TString tmp;
1165 
1166  while ((er = (TEnvRec*) next())) {
1167  const char* s;
1168  if ((s = strstr(er->GetName(), "Plugin."))) {
1169  // use s, i.e. skip possible OS and application prefix to Plugin.
1170  // so that GetValue() takes properly care of returning the value
1171  // for the specified OS and/or application
1172  const char* val = gEnv->GetValue(s, (const char*)0);
1173  if (val) {
1174  Int_t cnt = 0;
1175  s += 7;
1176  //is it the right base class ?
1177  if (strcmp(s, base)) continue; //skip to next env var if not right base
1178 
1179  char* v = StrDup(val);
1180  while (1) {
1181  TString regexp = strtok(!cnt ? v : 0, "; ");
1182  if (regexp.IsNull()) break;
1183  TString clss = strtok(0, "; ");
1184  if (clss.IsNull()) break;
1185  TString plugin = strtok(0, "; ");
1186  if (plugin.IsNull()) break;
1187  TString ctor = strtok(0, ";\"");
1188  if (!ctor.Contains("("))
1189  ctor = strtok(0, ";\"");
1190  if (clss == derived) {
1191  //found the required plugin
1192  //we remove the 'regexp' operator '^' from the beginning
1193  //and '$' from the end of the URI, if necessary
1194  if (regexp.MaybeRegexp()) {
1195  regexp.Remove(TString::kBoth, '^');
1196  regexp.Remove(TString::kBoth, '$');
1197  }
1198  tmp = regexp;
1199  delete [] v;
1200  return tmp.Data();
1201  }
1202  cnt++;
1203  }
1204  delete [] v;
1205  }
1206  }
1207  }
1208  tmp = "";
1209  return tmp;
1210 }
1211 
1212 
1213 
1214 
1227 
1229 {
1230  // Return whitespace-separated list of all plugin classes defined for
1231  // the given base class.
1232  //
1233  // E.g. if plugins exist for BaseClass:
1234  //
1235  // Plugin.BaseClass: URI PluginClass PluginLibrary "PluginClassConstructor(arguments)"
1236  // +Plugin.BaseClass: URI2 PluginClass2 PluginLibrary2 "PluginClass2Constructor(arguments)"
1237  //
1238  // then KVBase::GetListOfPlugins("BaseClass") will return "PluginClass PluginClass2"
1239  //
1240  // Most of the code is copied from `TPluginManager::LoadHandlersFromEnv`
1241 
1242  TIter next(gEnv->GetTable());
1243  TEnvRec* er;
1244  static TString tmp;
1245  tmp = "";
1246  while ((er = (TEnvRec*) next())) {
1247  const char* s;
1248  if ((s = strstr(er->GetName(), "Plugin."))) {
1249  // use s, i.e. skip possible OS and application prefix to Plugin.
1250  // so that GetValue() takes properly care of returning the value
1251  // for the specified OS and/or application
1252  const char* val = gEnv->GetValue(s, (const char*)0);
1253  if (val) {
1254  Int_t cnt = 0;
1255  s += 7;
1256  //is it the right base class ?
1257  if (strcmp(s, base)) continue; //skip to next env var if not right base
1258 
1259  char* v = StrDup(val);
1260  while (1) {
1261  TString regexp = strtok(!cnt ? v : 0, "; ");
1262  if (regexp.IsNull()) break;
1263  TString clss = strtok(0, "; ");
1264  if (clss.IsNull()) break;
1265  TString plugin = strtok(0, "; ");
1266  if (plugin.IsNull()) break;
1267  TString ctor = strtok(0, ";\"");
1268  if (!ctor.Contains("("))
1269  ctor = strtok(0, ";\"");
1270  tmp += clss;
1271  tmp += " ";
1272  cnt++;
1273  }
1274  delete [] v;
1275  }
1276  }
1277  }
1278  //remove final trailing whitespace
1279  tmp.Remove(TString::kTrailing, ' ');
1280  return tmp;
1281 }
1282 
1283 
1284 
1294 
1296 {
1297  // For a given base class, return a whitespace-separated list of plugin identifiers
1298  // which are known/defined.
1299  // E.g. if plugins exist for BaseClass:
1300  //
1301  // Plugin.BaseClass: URI PluginClass PluginLibrary "PluginClassConstructor(arguments)"
1302  // +Plugin.BaseClass: URI2 PluginClass2 PluginLibrary2 "PluginClass2Constructor(arguments)"
1303  //
1304  // then KVBase::GetListOfPluginURIs("BaseClass") will return "URI URI2"
1305 
1306  static TString tmp;
1307  KVString plugs = KVBase::GetListOfPlugins(base);
1308  plugs.Begin(" ");
1309  tmp = "";
1310  while (!plugs.End()) {
1311  if (tmp != "") tmp += " ";
1312  tmp += KVBase::GetPluginURI(base, plugs.Next());
1313  }
1314  return tmp;
1315 }
1316 
1317 
1318 
1324 
1326 {
1327  // Returns kTRUE if 'uri' is the name of a defined plugin, in which case 'base'
1328  // is the name of the base class extended by this plugin.
1329  //
1330  // Most of the code is copied from `TPluginManager::LoadHandlersFromEnv`
1331 
1332  TIter next(gEnv->GetTable());
1333  TEnvRec* er;
1334  while ((er = (TEnvRec*) next())) {
1335  KVString ername = er->GetName();
1336  if (ername.BeginsWith("Plugin.")) {
1337  base = ername;
1338  base.Remove(0, 7);
1339  KVString erval = gEnv->GetValue(ername, "");
1340  erval.Begin(" ");
1341  while (!erval.End()) {
1342  if (erval.Next() == uri) return kTRUE;
1343  }
1344  }
1345  }
1346  return kFALSE;
1347 }
1348 
1349 
1350 
1351 
1364 
1366 {
1367  // Add to standard ROOT mime types some new ones defined in `.kvrootrc`
1368  // for icons associated with graphs, runs, etc. by lines such as:
1369  //
1370  //~~~~~~~~~
1371  // KaliVeda.GUI.MimeTypes : KVIDMap
1372  // KaliVeda.GUI.MimeTypes.KVIDMap.Icon : rootdb_t.xpm
1373  // +KaliVeda.GUI.MimeTypes : KVIDZAGrid
1374  // KaliVeda.GUI.MimeTypes.KVIDZAGrid.Icon : draw_t.xpm
1375  //~~~~~~~~~
1376  //
1377  // etc.
1378 
1379  KVString mimetypes = gEnv->GetValue("KaliVeda.GUI.MimeTypes", "");
1380  if (mimetypes != "") {
1381 
1382  mimetypes.Begin(" ");
1383  while (!mimetypes.End()) {
1384 
1385  KVString classname = mimetypes.Next(kTRUE);
1386  KVString icon = gEnv->GetValue(Form("KaliVeda.GUI.MimeTypes.%s.Icon", classname.Data()), "draw_t.xpm");
1387  KVString type = classname;
1388  type.ToLower();
1389 
1390  if (gClient) gClient->GetMimeTypeList()->AddType(Form("[kaliveda/%s]", type.Data()),
1391  classname.Data(), icon.Data(), icon.Data(), "");
1392 
1393  }
1394  }
1395 }
1396 
1397 
1398 
1409 
1411 {
1412  // \brief Comparison between two 64-bit floating-point values
1413  //
1414  // Returns `kTRUE` if the integer representations of the two values are within
1415  // `maxdif` of each other. By default `maxdif=1`, which means that we consider that `x==y` if the
1416  // difference between them is no greater than the precision of `Double_t`
1417  // variables, i.e. `4.94065645841246544e-324`
1418  //
1419  // Based on the function `AlmostEqual2sComplement(float, float, int)`
1420  // by Bruce Dawson http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm
1421 
1422  union converter {
1423  Double_t f;
1424  Long64_t i;
1425  } zero, val1, val2;
1426 
1427  assert(maxdif > 0);
1428 
1429  if (A == B) return true;
1430 
1431  /* rustine to obtain the (64-bit) constant value 0x8000000000000000
1432  even on 32-bit machines (there is probably an easier way!) */
1433  zero.i = 1;
1434  zero.f = -zero.f;
1435  zero.i -= 1;
1436 
1437  val1.f = A;
1438  val2.f = B;
1439  Long64_t Aint, Bint;
1440  Aint = val1.i;
1441  Bint = val2.i;
1442  if (Aint < 0) Aint = zero.i - Aint;
1443  if (Bint < 0) Bint = zero.i - Bint;
1444 
1445  Long64_t intDiff = abs(val1.i - val2.i);
1446 
1447  if (intDiff <= maxdif) return true;
1448 
1449  return false;
1450 }
1451 
1452 
1453 
1462 
1463 Bool_t KVBase::OpenContextMenu(const char* method, TObject* obj, const char* alt_method_name)
1464 {
1465  // Open context menu for given method of object *obj.
1466  // By default title of menu is 'obj->ClassName()::method'
1467  // You can give an alternative method name in 'alt_method_name'
1468  // Returns kFALSE if the given method is not defined for the class of object in question.
1469  //
1470  // WARNING: even if this method returns kTRUE, this is no guarantee that the method
1471  // has indeed been executed. The user may have pressed the 'Cancel' button...
1472 
1473  TMethod* m = obj->IsA()->GetMethodAllAny(method);
1474  if (!m) {
1475  obj->Warning("OpenContextMenu", "%s is not a method of %s", method, obj->ClassName());
1476  return kFALSE;
1477  }
1478  TString Method = alt_method_name;
1479  if (Method == "") Method = method;
1480  TContextMenu* cm = new TContextMenu(Method, Form("%s::%s", obj->ClassName(), Method.Data()));
1481  cm->Action(obj, m);
1482  delete cm;
1483  return kTRUE;
1484 }
1485 
1486 
1487 
1494 
1495 void KVBase::CombineFiles(const Char_t* file1, const Char_t* file2, const Char_t* newfilename, Bool_t keep)
1496 {
1497  // STATIC method which allows to combine the contents of two ROOT files
1498  // (file1 and file2) into a new ROOT file (newfilename).
1499  // All objects from the two files will be written in the new file.
1500  //
1501  // if keep=kFALSE, the two files will be deleted after the operation
1502 
1503  ::Info("KVBase::CombineFiles", "Copying all objects from %s and %s ===> into new file %s", file1, file2, newfilename);
1504 
1505  TFileMerger file_merge;
1506  file_merge.AddFile(file1, kFALSE);
1507  file_merge.AddFile(file2, kFALSE);
1508  file_merge.OutputFile(newfilename);
1509  file_merge.Merge();
1510 
1511  // remove physical files from disk if required
1512  if (!keep) {
1513  gSystem->Unlink(file1);
1514  gSystem->Unlink(file2);
1515  }
1516 }
1517 
1518 
1519 
1527 
1529 {
1530  // Dummy method (returns NULL).
1531  // This method may be used in 'container' classes used with KVListView.
1532  // In order to open the context menu of the 'contained' object,
1533  // GetLabel() should return the real class of the object,
1534  // and this method should return its address.
1535  // Then call KVListView::SetUseObjLabelAsRealClass(kTRUE).
1536  return nullptr;
1537 }
1538 
1539 
1540 
1541 
1544 
1545 const Char_t* KVBase::GetExampleFilePath(const Char_t* library, const Char_t* namefile)
1546 {
1547  // Return full path to example file for given library (="KVMultiDet", "BackTrack", etc.)
1548  static TString path;
1549  path = KVBase::GetDATADIRFilePath("examples/");
1550  path += library;
1551  path += "/";
1552  path += namefile;
1553  return path.Data();
1554 }
1555 
1556 
1557 
1560 
1562 {
1563  // Prints welcome message and infos on version etc.
1564 
1565  cout << "/----------------------------------------------------------------------\\" << endl;
1566  cout << "| Welcome to KaliVeda v" << GetKVVersion() << " gitlab.in2p3.fr/kaliveda-dev/kaliveda |" << endl;
1567  cout << "| (c) 2002-2024, The KaliVeda development team |" << endl;
1568  cout << "| |" << endl;
1569  cout << "| Built with ROOT " << kaliveda::build_infos::KV_ROOT_VERSION << " on " << KVBase::GetKVBuildDate() << ", " << KVBase::GetKVBuildTime() << " |" << endl;
1570 #ifdef WITH_GIT_INFOS
1571  TString gitinfo;
1572  gitinfo.Form("%s@%s", gitBranch(), gitCommit());
1573  printf("| From %-63s |\n", gitinfo.Data());
1574 #endif
1575  cout << "| See https://kaliveda.in2p3.fr for help |" << endl;
1576  cout << "\\----------------------------------------------------------------------/" << endl << endl;
1577 }
1578 
1579 
1580 
1581 
1597 
1598 Double_t KVBase::ProtectedGetX(const TF1* func, Double_t val, int& status, Double_t xmin, Double_t xmax) const
1599 {
1600  // Since ROOT6, the TF1::GetX() method can no longer be used without precaution.
1601  //
1602  // In ROOT5, if the value val was larger or smaller than the maximum or minimum value of
1603  // the function (within its defined range) then TF1::GetX() would return X of the
1604  // maximum or minimum, respectively.
1605  //
1606  // In ROOT6, TF1::GetX() has been reimplemented so that, in the above case, it
1607  // prints out 3 warning messages and returns a TMath::QuietNaN()! Therefore we provide this
1608  // function in order to replicate the previous behaviour.
1609  //
1610  // The status = 0 if the value is within the limits of the function.
1611  // status = +1 if value is above the maximum, or status = -1 if value is below the minimum
1612  //
1613  // When compiled with ROOT5, this method just calls TF1::GetX() (and status = 0 always).
1614 
1615 #ifdef USING_ROOT6
1616  status = 0;
1617  if (val > func->GetMaximum(xmin, xmax)) {
1618  status = 1;
1619  return func->GetMaximumX(xmin, xmax);
1620  }
1621  else if (val < func->GetMinimum(xmin, xmax)) {
1622  status = -1;
1623  return func->GetMinimumX(xmin, xmax);
1624  }
1625  else
1626  return func->GetX(val, xmin, xmax);
1627 #else
1628  status = 0;
1629  return func->GetX(val, xmin, xmax);
1630 #endif
1631 }
1632 
1633 
1634 
1640 
1641 void KVBase::Deprecated(const char* where, const char* advice)
1642 {
1643  // Print a message to indicate when the called method is deprecated and give advice how to do better
1644  //
1645  // Don't call directly: use the macro Deprecate(advice) which will automatically fill in the method name
1646  // (see KVMacros.h)
1647 
1648  printf("Warning in <%s>: Method is deprecated in v%s and will be removed in future.\n%s\n",
1649  where, KVBase::GetKVVersion(), advice);
1650 }
1651 
1652 
1653 
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
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:359
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:806
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:877
static const Char_t * FindFile(const Char_t *search, TString &wfil)
Definition: KVBase.cpp:1030
static const Char_t * GetINCDIRFilePath(const Char_t *namefile="")
Definition: KVBase.cpp:103
static const Char_t * gitCommit()
Returns last git commit of sources.
Definition: KVBase.cpp:947
static const Char_t * GetWORKDIRFilePath(const Char_t *namefile="")
Definition: KVBase.cpp:121
void init()
Default initialisation.
Definition: KVBase.cpp:133
static Bool_t FindExecutable(TString &exec, const Char_t *path="$(PATH)")
Definition: KVBase.cpp:971
static const Char_t * GetKVBuildUser()
Returns username of person who performed build.
Definition: KVBase.cpp:865
static void BackupFileWithDate(const Char_t *path)
Definition: KVBase.cpp:732
static void ReadConfigFiles()
Definition: KVBase.cpp:260
static const Char_t * gitBranch()
Returns git branch of sources.
Definition: KVBase.cpp:936
static const Char_t * GetListOfPluginURIs(const Char_t *base)
Definition: KVBase.cpp:1295
TString fLabel
label for the object
Definition: KVBase.h:144
KVBase()
Default constructor.
Definition: KVBase.cpp:305
static int GetKVMajorVersion()
Definition: KVBase.cpp:127
static const Char_t * GetListOfPlugins(const Char_t *base)
Definition: KVBase.cpp:1228
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:1410
KVBase & operator=(const KVBase &)
copy assignment operator
Definition: KVBase.cpp:343
static void CombineFiles(const Char_t *file1, const Char_t *file2, const Char_t *newfilename, Bool_t keep=kTRUE)
Definition: KVBase.cpp:1495
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:1072
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:912
void Copy(TObject &) const override
Make a copy of this object.
Definition: KVBase.cpp:373
static void InitEnvironment()
Definition: KVBase.cpp:175
void Print(Option_t *option="") const override
Definition: KVBase.cpp:389
static const Char_t * GetKVBuildTime()
Returns KaliVeda build time.
Definition: KVBase.cpp:888
static int GetKVMinorVersion()
Definition: KVBase.cpp:128
static void PrintSplashScreen()
Prints welcome message and infos on version etc.
Definition: KVBase.cpp:1561
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:1545
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:1598
static const Char_t * GetKVBuildDir()
Returns top-level directory used for build.
Definition: KVBase.cpp:924
static void ReadGUIMimeTypes()
Definition: KVBase.cpp:1365
static Bool_t IsThisAPlugin(const TString &uri, TString &base)
Definition: KVBase.cpp:1325
@ kIsKaliVedaObject
Definition: KVBase.h:159
virtual TObject * GetObject() const
Definition: KVBase.cpp:1528
static void GetTempFileName(TString &base)
Definition: KVBase.cpp:827
static Bool_t SearchKVFile(const Char_t *name, TString &fullpath, const Char_t *kvsubdir="")
Definition: KVBase.cpp:517
static const Char_t * GetKVBuildType()
Returns KaliVeda build type (cmake build: Release, Debug, RelWithDebInfo, ...)
Definition: KVBase.cpp:900
static const Char_t * GetPluginURI(const Char_t *base, const Char_t *plugin)
Definition: KVBase.cpp:1145
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:1463
static Bool_t SearchAndOpenKVFile(const Char_t *name, KVSQLite::database &dbfile, const Char_t *kvsubdir="")
Definition: KVBase.cpp:628
static TPluginHandler * LoadPlugin(const Char_t *base, const Char_t *uri="0")
Definition: KVBase.cpp:772
static const Char_t * GetKVVersion()
Returns KaliVeda version string.
Definition: KVBase.cpp:853
static void Deprecated(const char *method, const char *advice)
Definition: KVBase.cpp:1641
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:477
bool good() const
Definition: SQLiteDB.h:544
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 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)
void EnableThreadSafety()
void init()
const char * cnt
v
TMarker m
ClassImp(TPyArg)