KaliVeda
Toolkit for HIC analysis
Loading...
Searching...
No Matches
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 "Riostream.h"
20#include "TMath.h"
21#include "TFile.h"
22#include "KVBase.h"
23#include "TClass.h"
24#include "KVString.h"
25#include "TSystem.h"
26#include "TInterpreter.h"
27#include "TEnv.h"
28#include "TPluginManager.h"
29#include "KVNameValueList.h"
30#include "TSystemDirectory.h"
31#include "KVVersion.h"
32#ifdef WITH_GIT_INFOS
33#include "KVGitInfo.h"
34#endif
35#ifdef WITH_RSQLITE
36#include "SQLiteDB.h"
37#endif
38#include "TROOT.h"
39#include "TDatime.h"
40#include "THashList.h"
41#include "TError.h"
42#include "TGMimeTypes.h"
43#include "TGClient.h"
44#include "TContextMenu.h"
45#include <TFileMerger.h>
46#include <TH1.h>
47#include <TKey.h>
48#include "TTree.h"
49
50using namespace std;
51
53
54
55
56#define xstr(s) str(s)
57#define str(s) #s
59TString KVBase::fWorkingDirectory = "$(HOME)/.kaliveda";
61
62
64
66{
67 if (strcmp(namefile, "")) return Form("%s/%s", xstr(ETCDIR), namefile);
68 return Form("%s", xstr(ETCDIR));
69}
70
71
73
75{
76 if (strcmp(namefile, "")) return Form("%s/%s", xstr(DATADIR), namefile);
77 return Form("%s", xstr(DATADIR));
78}
79
80
82
84{
85 if (strcmp(namefile, "")) return Form("%s/%s", xstr(TEMPLATEDIR), namefile);
86 return Form("%s", xstr(TEMPLATEDIR));
87}
88
89
91
93{
94 return Form("%s/db", fWorkingDirectory.Data());
95}
96
97
99
101{
102 if (strcmp(namefile, "")) return Form("%s/%s", xstr(LIBDIR), namefile);
103 return Form("%s", xstr(LIBDIR));
104}
105
106
108
110{
111 if (strcmp(namefile, "")) return Form("%s/%s", xstr(INCDIR), namefile);
112 return Form("%s", xstr(INCDIR));
113}
114
115
117
119{
120 if (strcmp(namefile, "")) return Form("%s/%s", xstr(BINDIR), namefile);
121 return Form("%s", xstr(BINDIR));
122}
123
124
126
128{
129 if (strcmp(namefile, "")) return Form("%s/%s", fWorkingDirectory.Data(), namefile);
130 return fWorkingDirectory;
131}
132
133
134
137
139{
140 //Default initialisation
141
143 fNumber = 0;
144 fNbObj++;
145 fLabel = "";
147}
148
149
150
180
182{
183 // STATIC method to Initialise KaliVeda environment
184 // Reads config files in <code>\$(pkgdatadir)/etc</code> and sets up environment
185 // (data repositories, datasets, etc. etc.).
186 // Adds directory where kaliveda shared libs are installed to the dynamic
187 // path - for finding and loading plugins.
188 // Resets the `gRandom` random number sequence using a clock-based seed
189 // (i.e. random sequences do not repeat).
190 //
191 // Normally, the first object created which inherits from KVBase will
192 // perform this initialisation; if you need to set up the environment before
193 // creating a KVBase object, or if you just want to be absolutely sure that
194 // the environment has been initialised, you can call this method.
195 //
196 // #### Note for GNU-style installations
197 // If KaliVeda is built with the cmake option `-Dgnuinstall=yes` then each
198 // user will have a working directory which will be used to store any files
199 // generated by KaliVeda at runtime.
200 //
201 // By default the location of user's working directory is set to
202 //~~~~~~~~~
203 // $(HOME)/.kaliveda
204 //~~~~~~~~~
205 // but can be changed with variable
206 //~~~~~~~~~
207 // KaliVeda.WorkingDirectory: [directory]
208 //~~~~~~~~~
209 // in configuration file `.kvrootrc`.
210 //`[directory]` must be an absolute pathname, but can use shell variables like <code>\$(HOME)</code>.
211
212 if (!fEnvIsInit) {//test if environment already initialised
213
214 // enable ROOT thread safety
216
217 // Add path to kaliveda libraries to dynamic loader path
218 // This is needed to find plugins
219 // and also to be able to compile with kaliveda in the interpreter
220 TString libdir = GetLIBDIRFilePath();
221 gSystem->AddDynamicPath(libdir);
222#ifdef ADD_DYN_PATH
223 // add paths to utility libraries to dynamic path to avoid bug with on-demand class loading for ROOT5/CINT
224 KVString add_dyn_path(ADD_DYN_PATH);
225 add_dyn_path.Begin(";");
226 while (!add_dyn_path.End()) {
227 gSystem->AddDynamicPath(add_dyn_path.Next(kTRUE));
228 }
229#endif
230 // force re-reading of rootmap files in new dynamic path
231 gInterpreter->LoadLibraryMap();
232 // Add path to kaliveda header files
233 // This is needed to be able to compile with kaliveda in the interpreter
234 TString incdir = GetINCDIRFilePath();
235 incdir.Prepend("-I");
236 gSystem->AddIncludePath(incdir);
237
238 //set up environment using kvrootrc file
239 if (!gEnv->Defined("DataSet.DatabaseFile")) {
241 }
242#ifdef WITH_GNU_INSTALL
243 // set working directory & create if needed
244 fWorkingDirectory = gEnv->GetValue("KaliVeda.WorkingDirectory", "$(HOME)/.kaliveda");
247#else
248 // set environment variable used in database makefiles
249 fWorkingDirectory = KV_ROOT;
250#endif
251 // set environment variable used in database makefiles
252 gSystem->Setenv("KV_WORK_DIR", fWorkingDirectory);
253
254 //generate new seed from system clock
255 gRandom->SetSeed(0);
256
257 // initialisation has been performed
259 }
260}
261
262
263
271
273{
274 // Read all configuration files
275 // System config files are read first in the order they appear in file
276 // ${ETCDIR}/config.files
277 // Then we read any of the following files if they exist:
278 // ${HOME}/.kvrootrc
279 // ${PWD}/.kvrootrc
280
281 TString tmp = GetETCDIRFilePath("config.files");
282 ifstream conflist;
283 conflist.open(tmp.Data());
284 if (!conflist.good()) {
285 ::Fatal("KVBase::ReadConfigFiles", "Cannot open %s", tmp.Data());
286 return;
287 }
289 file.ReadLine(conflist);
290 conflist.close();
291 file.Begin(";");
292 while (!file.End()) {
293 tmp = GetETCDIRFilePath(file.Next().Data());
294 //skip over any missing files - this is needed when installing from
295 //e.g. ubuntu packages if not all packages are installed
296 if (!gSystem->AccessPathName(tmp.Data())) gEnv->ReadFile(tmp.Data(), kEnvChange);
297 }
298
299 AssignAndDelete(tmp, gSystem->ConcatFileName(gSystem->Getenv("HOME"), ".kvrootrc"));
300 gEnv->ReadFile(tmp.Data(), kEnvChange);
301
302 tmp = "./.kvrootrc";
303 gEnv->ReadFile(tmp.Data(), kEnvChange);
304
305 // load plugin handlers
306 gROOT->GetPluginManager()->LoadHandlersFromEnv(gEnv);
307
308 // load mime types/icon definitions when not in batch (i.e. GUI-less) mode
309 if (!gROOT->IsBatch()) ReadGUIMimeTypes();
310}
311
312
313
316
318{
319 //Default constructor.
320 init();
321}
322
323
324
327
328KVBase::KVBase(const Char_t* name, const Char_t* type): TNamed(name, type)
329{
330 //Ctor for object with given name and type.
331 init();
332}
333
334
335
338
340{
341 //copy ctor
342 init();
343#if ROOT_VERSION_CODE >= ROOT_VERSION(3,4,0)
344 obj.Copy(*this);
345#else
346 ((KVBase&) obj).Copy(*this);
347#endif
348}
349
350
351
354
356{
357 // copy assignment operator
358
359 if (&other != this) {
360 other.Copy(*this);
361 }
362 return (*this);
363}
364
365
366
368
370{
371 fNbObj--;
372}
373
374
375
376
379
381{
382 //Clear object properties : name, type/title, number, label
383 TNamed::Clear(opt);
384 fNumber = 0;
385 fLabel = "";
386}
387
388
389#if ROOT_VERSION_CODE >= ROOT_VERSION(3,4,0)
390
393
394void KVBase::Copy(TObject& obj) const
395#else
396void KVBase::Copy(TObject& obj)
397#endif
398{
399 //Make a copy of this object
400
401 TNamed::Copy(obj);
402 ((KVBase&) obj).SetNumber(fNumber);
403 ((KVBase&) obj).SetLabel(fLabel);
404}
405
406
407
409
411{
412 cout << "KVBase object: Name=" << GetName() << " Type=" << GetType();
413 if (fLabel != "")
414 cout << " Label=" << GetLabel();
415 if (fNumber != 0)
416 cout << " Number=" << GetNumber();
417 cout << endl;
418}
419
420
421
427
428void KVBase::Streamer(TBuffer& R__b)
429{
430 //Backwards compatible streamer for KVBase objects
431 //Needed to handle 'fLabel' char array in class version 1
432 //Objects written with version < 3 did not have kIsKaliVedaObject bit set,
433 //we set it here when reading object.
434
435 if (R__b.IsReading()) {
436 UInt_t R__s, R__c;
437 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
438 if (R__v > 1) {
439 if (R__v < 4) {
440 TNamed::Streamer(R__b);
441 R__b >> fNumber;
442 R__b >> fLabel;
443 if (R__v < 3) SetBit(kIsKaliVedaObject);
444 R__b.CheckByteCount(R__s, R__c, KVBase::IsA());
445 }
446 else {
447 //AUTOMATIC STREAMER EVOLUTION FOR CLASS VERSION > 3
448 KVBase::Class()->ReadBuffer(R__b, this, R__v, R__s, R__c);
449 }
450 return;
451 }
452 //OLD STREAMER FOR CLASS VERSION 1
453 TNamed::Streamer(R__b);
454 R__b >> fNumber;
455 UInt_t LabelLength;
456 R__b >> LabelLength;
457 if (LabelLength) {
458 Char_t* Label = new Char_t[LabelLength];
459 R__b.ReadFastArray(Label, LabelLength);
460 fLabel = Label;
461 delete[]Label;
462 }
464 R__b.CheckByteCount(R__s, R__c, KVBase::IsA());
465 }
466 else {
467 KVBase::Class()->WriteBuffer(R__b, this);
468 }
469}
470
471
472
473
485
486Bool_t SearchFile(const Char_t* name, TString& fullpath, int ndirs, ...)
487{
488 //Search for file in an arbitrary number of locations, return kTRUE if file found and put full path to file in 'fullpath"
489 //
490 //'name' is a filename (not an absolute pathname) i.e. "toto.dat"
491 //'fullpath" will contain the full path to the file if it is found (if file not found, fullpath="")
492 //'ndirs" is the number of directories to search in
493 //the remaining arguments are the names of 'ndirs' paths to search in, i.e.
494 //
495 // SearchFile("toto.dat", fullpath, 2, gSystem->pwd(), gSystem->HomeDirectory());
496 //
497 //means: search for a file 'toto.dat' in current working directory, then user's home directory.
498
499 if (ndirs <= 0)
500 return kFALSE;
501
502 va_list args;
503 va_start(args, ndirs);
504
505 for (; ndirs; ndirs--) { //loop over directories
506
507 AssignAndDelete(fullpath,
508 gSystem->ConcatFileName(va_arg(args, const char*),
509 name));
510 if (!gSystem->AccessPathName(fullpath.Data())) {
511 va_end(args);
512 return kTRUE;
513 }
514
515 }
516
517 va_end(args);
518 fullpath = ""; //clear fullpath string to avoid using it by mistake
519 return kFALSE;
520}
521
522
523
537
539 const Char_t* kvsubdir)
540{
541 //search for files in the following order:
542 // if 'name' = absolute path the function returns kTRUE if the file exists
543 // if name != absolute path:
544 // 1. a. if 'kvsubdir'="" (default) look for file in $(pkgdatadir) directory
545 // 1. b. if 'kvsubdir'!="":
546 // if 'kvsubdir' is an absolute pathname, look in 'kvsubdir'
547 // if 'kvsubdir' is not an absolute pathname,
548 // look in '$(pkdatadir)/kvsubdir'
549 // 2. look for file with this name in user's home directory
550 // 3. look for file with this name in working directory
551 //in all cases the function returns kTRUE if the file was found.
552 //'fullpath' then contains the absolute path to the file
553
555 // absolute path
556 fullpath = name;
557 return !gSystem->AccessPathName(name);
558 }
559
560 TString kvfile_dir;
561 if (strcmp(kvsubdir, "")) {
562 // subdirectory hint given
563 if (!gSystem->IsAbsoluteFileName(kvsubdir))
564 kvfile_dir = GetDATADIRFilePath(kvsubdir); // relative path - assume in $(pkgdatadir)
565 else
566 kvfile_dir = kvsubdir; // absolute path - use as is
567 }
568 else // no subdirectory hint given
569 kvfile_dir = GetDATADIRFilePath();
570
571 return SearchFile(name, fullpath, 3, kvfile_dir.Data(),
573}
574
575
576
577
597
598Bool_t KVBase::SearchAndOpenKVFile(const Char_t* name, ifstream& file, const Char_t* kvsubdir, KVLockfile* locks)
599{
600 //Search and open for READING a file:
601 //
602 //search for ascii file (and open it, if found) in the following order:
603 // if 'name' = absolute path the function returns kTRUE if the file exists
604 // if name != absolute path:
605 // 1. a. if 'kvsubdir'="" (default) look for file in $(pkdatadir) directory
606 // 1. b. if 'kvsubdir'!="" look for file in $(pkdatadir)/'kvsubdir'
607 // if 'kvsubdir' is an absolute pathname, look in 'kvsubdir'
608 // if 'kvsubdir' is not an absolute pathname,
609 // look in '$(pkdatadir)/kvsubdir'
610 // 2. look for file with this name in user's home directory
611 // 3. look for file with this name in working directory
612 //if the file is not found, kFALSE is returned.
613 //if file is found and can be opened, 'file' is then an ifstream connected to the open (ascii) file
614 //
615 //LOCKFILE:
616 //If a KVLockfile pointer is given, we use it to get a lock on the file before opening it.
617 //If this lock is not successful, the file is not opened and we return an error message.
618
619 TString fullpath;
620 if (SearchKVFile(name, fullpath, kvsubdir)) {
621 //put lock on file if required
622 if (locks && !locks->Lock(fullpath.Data())) return kFALSE;
623 file.open(fullpath.Data());
624 if (file.good()) {
625 //cout << "Opened file : " << fullpath.Data() << endl;
626 return kTRUE;
627 }
628 //unlock file if not opened successfully
629 if (locks) locks->Release();
630 }
631 return kFALSE;
632}
633
634
635#ifdef WITH_RSQLITE
636
648
650{
651 //Search and open for reading/writing a sqlite database file:
652 //
653 //search for file (and open it, if found) in the following order:
654 // if 'name' = absolute path the function returns kTRUE if the file exists
655 // if name != absolute path:
656 // 1. a. if 'kvsubdir'="" (default) look for file in $(pkdatadir) directory
657 // 1. b. if 'kvsubdir'!="" look for file in $(pkdatadir)/'kvsubdir'
658 // 2. look for file with this name in user's home directory
659 // 3. look for file with this name in working directory
660 //if the file is not found, kFALSE is returned.
661
662 TString fullpath;
663 if (SearchKVFile(name, fullpath, kvsubdir)) {
664 dbfile.open(fullpath);
665 if (dbfile.good()) {
666 //cout << "Opened file : " << fullpath.Data() << endl;
667 return kTRUE;
668 }
669 }
670 return kFALSE;
671}
672
673#endif
674
675
694
695Bool_t KVBase::SearchAndOpenKVFile(const Char_t* name, ofstream& file, const Char_t* kvsubdir, KVLockfile* locks)
696{
697 //Search and CREATE i.e. open for WRITING a file:
698 //
699 //open for writing an ascii file in the location determined in the following way:
700 // if 'name' = absolute path we use the full path
701 // if name != absolute path:
702 // 1. a. if 'kvsubdir'="" (default) file will be in $(pkdatadir) directory
703 // 1. b. if 'kvsubdir'!="":
704 // if 'kvsubdir' is an absolute pathname, file in 'kvsubdir'
705 // if 'kvsubdir' is not an absolute pathname,
706 // file will be in '$(pkdatadir)/kvsubdir'
707 //if an existing file is found, a warning is printed and the existing file 'toto' is renamed
708 //"toto.date". where 'date' is created with TDatime::AsSQLDate
709 // file' is then an ofstream connected to the opened file
710 //
711 //LOCKFILE:
712 //If a KVLockfile pointer is given, we use it to get a lock on the file before opening it.
713 //If this lock is not successful, the file is not opened and we return an error message.
714
715 KVString fullpath;
716 if (gSystem->IsAbsoluteFileName(name)) {
717 fullpath = name;
718 }
719 else if (gSystem->IsAbsoluteFileName(kvsubdir)) {
720 AssignAndDelete(fullpath,
721 gSystem->ConcatFileName(kvsubdir, name));
722 }
723 else if (strcmp(kvsubdir, "")) {
724 KVString path = GetDATADIRFilePath(kvsubdir);
725 AssignAndDelete(fullpath,
726 gSystem->ConcatFileName(path.Data(), name));
727 }
728 else {
729 fullpath = GetDATADIRFilePath(name);
730 }
731 //Backup file if necessary
732 BackupFileWithDate(fullpath.Data());
733 //put lock on file if required
734 if (locks && !locks->Lock(fullpath.Data())) return kFALSE;
735 file.open(fullpath.Data());
736 return kTRUE;
737}
738
739
740
741
752
754{
755 //`path` gives the full path (can include environment variables, special symbols)
756 //to a file which will be renamed with an extension containing the current date and time
757 //(in SQL format).
758 //
759 //Example:
760 //
761 // KVBase::BackupFileWithDate("$(HOME)/toto.txt")
762 //
763 //The file `toto.txt` will be renamed `toto.txt.2007-05-02_16:22:37`
764
765 KVString fullpath = path;
766 gSystem->ExpandPathName(fullpath);
767 if (!gSystem->AccessPathName(fullpath.Data())) {//does the file exist ?
768 //backup file
769 TDatime now;
770 KVString date(now.AsSQLString());
771 date.ReplaceAll(' ', '_');
772 TString backup = fullpath + "." + date;
773 //lock both files
774 KVLockfile lf1(fullpath.Data()), lf2(backup.Data());
775 if (lf1.Lock() && lf2.Lock()) {
776 gSystem->Rename(fullpath.Data(), backup.Data());
777 printf("Info in <KVBase::BackupFileWithDate(const Char_t *)> : Existing file %s renamed %s\n",
778 fullpath.Data(), backup.Data());
779 }
780 }
781}
782
783
784
785
792
794{
795 //Load plugin library in order to extend capabilities of base class "base", depending on
796 //the given uri (these arguments are used to call TPluginManager::FindHandler).
797 //Returns pointer to TPluginHandler.
798 //Returns 0 in case of problems.
799
800 //does plugin exist for given name ?
801 TPluginHandler* ph =
802 (TPluginHandler*) gROOT->GetPluginManager()->FindHandler(base,
803 uri);
804 if (!ph)
805 return 0;
806
807 //check plugin library/macro is available
808 if (ph->CheckPlugin() != 0)
809 return 0;
810
811 //load plugin module
812 if (ph->LoadPlugin() != 0)
813 return 0;
814
815 return ph;
816}
817
818
819
820
826
827void KVBase::OpenTempFile(TString& base, ofstream& fp)
828{
829 //Opens a uniquely-named file in system temp directory (gSystem->TempDirectory)
830 //Name of file is "basexxxxxxxxxx" where "xxxxxxxxx" is current time as returned
831 //by gSystem->Now().
832 //After opening file, 'base' contains full path to file.
833
834 GetTempFileName(base);
835 fp.open(base.Data());
836}
837
838
839
840
847
849{
850 //When called with base="toto.dat", the returned value of 'base' is
851 //"/full/path/to/temp/dir/toto.dat15930693"
852 //i.e. the full path to a file in the system temp directory (gSystem->TempDirectory)
853 //appended with the current time as returned by gSystem->Now() in order to make
854 //its name unique
855
856 TString tmp1;
857 AssignAndDelete(tmp1,
859 base.Data()));
860 long lnow = (long) gSystem->Now();
861 base = tmp1 + lnow;
862 //make sure no existing file with same name
863 while (!gSystem->AccessPathName(base)) {
864 base = tmp1 + (++lnow);
865 }
866}
867
868
869
870
873
875{
876 //Returns KaliVeda version string
877 static TString tmp(KV_VERSION);
878 return tmp.Data();
879}
880
881
882
883
886
888{
889 // Returns username of person who performed build
890 static TString tmp(KV_BUILD_USER);
891 return tmp.Data();
892}
893
894
895
896
899
901{
902 //Returns KaliVeda build date
903 static TString tmp(KV_BUILD_DATE);
904 return tmp.Data();
905}
906
907
908
911
913{
914 //Returns KaliVeda build time
915 static TString tmp(KV_BUILD_TIME);
916 return tmp.Data();
917}
918
919
920
921
924
926{
927 //Returns KaliVeda build type (cmake build: Release, Debug, RelWithDebInfo, ...)
928 static TString tmp(KV_BUILD_TYPE);
929 return tmp.Data();
930}
931
932
933
934
937
939{
940 //Returns top-level directory of source tree used for build
941 static TString tmp(KV_SOURCE_DIR);
942 return tmp.Data();
943}
944
945
946
947
950
952{
953 //Returns top-level directory used for build
954 static TString tmp(KV_BUILD_DIR);
955 return tmp.Data();
956}
957
958
959#ifdef WITH_GIT_INFOS
960
963
965{
966 // Returns git branch of sources
967 static TString tmp(KV_GIT_BRANCH);
968 return tmp.Data();
969}
970
971
972
975
977{
978 // Returns last git commit of sources
979 static TString tmp(KV_GIT_COMMIT);
980 return tmp.Data();
981}
982
983#endif
984
985
1000
1002{
1003 //By default, `FindExecutable(exec)` will look for the executable named by `exec`
1004 //in the directories contained in the environment variable `PATH`. You can override
1005 //this by giving your own search `path` as second argument (remember to write
1006 //environment variables as <code>\$(PATH)</code>, for cross-platform compatibility).
1007 //
1008 //If `exec` is not found, and if it does not end with `.exe`, we look for `exec.exe`
1009 //This is for compatibility with Windows/cygwin environments.
1010 //
1011 //If the executable is found, returns `kTRUE` and `exec` then holds full path to executable.
1012 //Returns `kFALSE` if `exec` not found in paths.
1013 //
1014 //If `exec` is an absolute pathname, we return `kTRUE` if the file exists
1015 //(we do not use `path`).
1016
1017 TString spath(path), backup(exec), backup2(exec), expandexec(exec);
1018 gSystem->ExpandPathName(expandexec);
1019 if (gSystem->IsAbsoluteFileName(expandexec.Data())) {
1020 //executable given as absolute path
1021 //we check if it exists
1022 if (!gSystem->AccessPathName(expandexec)) {
1023 exec = expandexec;
1024 return kTRUE;
1025 }
1026 else {
1027 //try with ".exe" in case of Windows system
1028 if (!expandexec.EndsWith(".exe")) {
1029 expandexec += ".exe";
1030 if (!gSystem->AccessPathName(expandexec)) {
1031 exec = expandexec;
1032 return kTRUE;
1033 }
1034 }
1035 }
1036 exec = backup;
1037 return kFALSE;
1038 }
1039 gSystem->ExpandPathName(spath);
1040 if (KVBase::FindFile(spath.Data(), exec))
1041 return kTRUE;
1042 if (!backup.EndsWith(".exe")) {
1043 backup += ".exe";
1044 if (KVBase::FindFile(spath.Data(), backup)) {
1045 exec = backup;
1046 return kTRUE;
1047 }
1048 }
1049 exec = backup2;
1050 return kFALSE;
1051}
1052
1053
1054
1055
1059
1060const Char_t* KVBase::FindFile(const Char_t* search, TString& wfil)
1061{
1062 //Backwards compatible fix for `TSystem::FindFile` which only exists from ROOT version 5.12/00 onwards.
1063 //Use this method as a replacement for `gSystem->FindFile` (same arguments)
1064#ifdef __WITHOUT_TSYSTEM_FINDFILE
1065 Char_t* result = gSystem->Which(search, wfil.Data());
1066 if (result) {
1067 wfil = result;
1068 delete[]result;
1069 }
1070 else {
1071 wfil = "";
1072 }
1073 return wfil.Data();
1074#else
1075 return gSystem->FindFile(search, wfil);
1076#endif
1077}
1078
1079
1080
1081
1101
1102Bool_t KVBase::FindClassSourceFiles(const Char_t* class_name, KVString& imp_file, KVString& dec_file, const Char_t* dir_name)
1103{
1104 //Look for the source files corresponding to `class_name`
1105 //i.e. taking class_name as a base, we look for one of
1106 //
1107 //~~~~~~~
1108 //class_name.C,class_name.cpp,class_name.cxx
1109 //~~~~~~~
1110 //
1111 //and one of
1112 //
1113 //~~~~~~~
1114 //class_name.h,class_name.hh,class_name.H
1115 //~~~~~~~
1116 //
1117 //By default we look in the current working directory, unless argument `dir_name`
1118 //is given
1119 //
1120 //If found, the names of the two files are written in `imp_file` and
1121 //`dec_file`
1122
1123 KVNameValueList impl_alt;
1124 int i = 0;
1125 impl_alt.SetValue("%s.C", i);
1126 impl_alt.SetValue("%s.cpp", i);
1127 impl_alt.SetValue("%s.cxx", i);
1128 KVNameValueList decl_alt;
1129 decl_alt.SetValue("%s.h", i);
1130 decl_alt.SetValue("%s.hh", i);
1131 decl_alt.SetValue("%s.H", i);
1132
1133 TString _dir_name = dir_name;
1134 gSystem->ExpandPathName(_dir_name);
1135 TSystemDirectory dir("LocDir", _dir_name.Data());
1136 TList* lf = dir.GetListOfFiles();
1137 Bool_t ok_imp, ok_dec;
1138 ok_imp = ok_dec = kFALSE;
1139
1140 //look for implementation file
1141 for (i = 0; i < impl_alt.GetNpar(); i++) {
1142 if (lf->FindObject(Form(impl_alt.GetParameter(i)->GetName(), class_name))) {
1143 imp_file = Form(impl_alt.GetParameter(i)->GetName(), class_name);
1144 ok_imp = kTRUE;
1145 }
1146 }
1147 //look for header file
1148 for (i = 0; i < decl_alt.GetNpar(); i++) {
1149 if (lf->FindObject(Form(decl_alt.GetParameter(i)->GetName(), class_name))) {
1150 dec_file = Form(decl_alt.GetParameter(i)->GetName(), class_name);
1151 ok_dec = kTRUE;
1152 }
1153 }
1154 delete lf;
1155 return (ok_imp && ok_dec);
1156}
1157
1158
1159
1160
1176
1177const Char_t* KVBase::GetPluginURI(const Char_t* base, const Char_t* derived)
1178{
1179 //Inverse of `gPluginMgr->FindHandler(const Char_t* base, const Char_t* uri)`
1180 //
1181 //Given a base class `base` and a derived class `derived`, we search `gEnv` to find the
1182 //URI corresponding to this plugin.
1183 //
1184 //Example: given a plugin such as
1185 //
1186 //~~~~~~~~
1187 //Plugin.KVIDTelescope: ^PHOS$ KVIDPhoswich KVIndra "KVIDPhoswich()"
1188 //~~~~~~~~
1189 //
1190 //then calling `KVBase::GetPluginURI("KVIDTelescope", "KVIDPhoswich")` will return `"PHOS"`.
1191 //
1192 //Most of the code is copied from `TPluginManager::LoadHandlersFromEnv`
1193
1194 TIter next(gEnv->GetTable());
1195 TEnvRec* er;
1196 static TString tmp;
1197
1198 while ((er = (TEnvRec*) next())) {
1199 const char* s;
1200 if ((s = strstr(er->GetName(), "Plugin."))) {
1201 // use s, i.e. skip possible OS and application prefix to Plugin.
1202 // so that GetValue() takes properly care of returning the value
1203 // for the specified OS and/or application
1204 const char* val = gEnv->GetValue(s, (const char*)0);
1205 if (val) {
1206 Int_t cnt = 0;
1207 s += 7;
1208 //is it the right base class ?
1209 if (strcmp(s, base)) continue; //skip to next env var if not right base
1210
1211 char* v = StrDup(val);
1212 while (1) {
1213 TString regexp = strtok(!cnt ? v : 0, "; ");
1214 if (regexp.IsNull()) break;
1215 TString clss = strtok(0, "; ");
1216 if (clss.IsNull()) break;
1217 TString plugin = strtok(0, "; ");
1218 if (plugin.IsNull()) break;
1219 TString ctor = strtok(0, ";\"");
1220 if (!ctor.Contains("("))
1221 ctor = strtok(0, ";\"");
1222 if (clss == derived) {
1223 //found the required plugin
1224 //we remove the 'regexp' operator '^' from the beginning
1225 //and '$' from the end of the URI, if necessary
1226 if (regexp.MaybeRegexp()) {
1227 regexp.Remove(TString::kBoth, '^');
1228 regexp.Remove(TString::kBoth, '$');
1229 }
1230 tmp = regexp;
1231 delete [] v;
1232 return tmp.Data();
1233 }
1234 cnt++;
1235 }
1236 delete [] v;
1237 }
1238 }
1239 }
1240 tmp = "";
1241 return tmp;
1242}
1243
1244
1245
1246
1259
1261{
1262 // Return whitespace-separated list of all plugin classes defined for
1263 // the given base class.
1264 //
1265 // E.g. if plugins exist for BaseClass:
1266 //
1267 // Plugin.BaseClass: URI PluginClass PluginLibrary "PluginClassConstructor(arguments)"
1268 // +Plugin.BaseClass: URI2 PluginClass2 PluginLibrary2 "PluginClass2Constructor(arguments)"
1269 //
1270 // then KVBase::GetListOfPlugins("BaseClass") will return "PluginClass PluginClass2"
1271 //
1272 // Most of the code is copied from `TPluginManager::LoadHandlersFromEnv`
1273
1274 TIter next(gEnv->GetTable());
1275 TEnvRec* er;
1276 static TString tmp;
1277 tmp = "";
1278 while ((er = (TEnvRec*) next())) {
1279 const char* s;
1280 if ((s = strstr(er->GetName(), "Plugin."))) {
1281 // use s, i.e. skip possible OS and application prefix to Plugin.
1282 // so that GetValue() takes properly care of returning the value
1283 // for the specified OS and/or application
1284 const char* val = gEnv->GetValue(s, (const char*)0);
1285 if (val) {
1286 Int_t cnt = 0;
1287 s += 7;
1288 //is it the right base class ?
1289 if (strcmp(s, base)) continue; //skip to next env var if not right base
1290
1291 char* v = StrDup(val);
1292 while (1) {
1293 TString regexp = strtok(!cnt ? v : 0, "; ");
1294 if (regexp.IsNull()) break;
1295 TString clss = strtok(0, "; ");
1296 if (clss.IsNull()) break;
1297 TString plugin = strtok(0, "; ");
1298 if (plugin.IsNull()) break;
1299 TString ctor = strtok(0, ";\"");
1300 if (!ctor.Contains("("))
1301 ctor = strtok(0, ";\"");
1302 tmp += clss;
1303 tmp += " ";
1304 cnt++;
1305 }
1306 delete [] v;
1307 }
1308 }
1309 }
1310 //remove final trailing whitespace
1311 tmp.Remove(TString::kTrailing, ' ');
1312 return tmp;
1313}
1314
1315
1316
1326
1328{
1329 // For a given base class, return a whitespace-separated list of plugin identifiers
1330 // which are known/defined.
1331 // E.g. if plugins exist for BaseClass:
1332 //
1333 // Plugin.BaseClass: URI PluginClass PluginLibrary "PluginClassConstructor(arguments)"
1334 // +Plugin.BaseClass: URI2 PluginClass2 PluginLibrary2 "PluginClass2Constructor(arguments)"
1335 //
1336 // then KVBase::GetListOfPluginURIs("BaseClass") will return "URI URI2"
1337
1338 static TString tmp;
1339 KVString plugs = KVBase::GetListOfPlugins(base);
1340 plugs.Begin(" ");
1341 tmp = "";
1342 while (!plugs.End()) {
1343 if (tmp != "") tmp += " ";
1344 tmp += KVBase::GetPluginURI(base, plugs.Next());
1345 }
1346 return tmp;
1347}
1348
1349
1350
1356
1358{
1359 // Returns kTRUE if 'uri' is the name of a defined plugin, in which case 'base'
1360 // is the name of the base class extended by this plugin.
1361 //
1362 // Most of the code is copied from `TPluginManager::LoadHandlersFromEnv`
1363
1364 TIter next(gEnv->GetTable());
1365 TEnvRec* er;
1366 while ((er = (TEnvRec*) next())) {
1367 KVString ername = er->GetName();
1368 if (ername.BeginsWith("Plugin.")) {
1369 base = ername;
1370 base.Remove(0, 7);
1371 KVString erval = gEnv->GetValue(ername, "");
1372 erval.Begin(" ");
1373 while (!erval.End()) {
1374 if (erval.Next() == uri) return kTRUE;
1375 }
1376 }
1377 }
1378 return kFALSE;
1379}
1380
1381
1382
1383
1396
1398{
1399 // Add to standard ROOT mime types some new ones defined in `.kvrootrc`
1400 // for icons associated with graphs, runs, etc. by lines such as:
1401 //
1402 //~~~~~~~~~
1403 // KaliVeda.GUI.MimeTypes : KVIDMap
1404 // KaliVeda.GUI.MimeTypes.KVIDMap.Icon : rootdb_t.xpm
1405 // +KaliVeda.GUI.MimeTypes : KVIDZAGrid
1406 // KaliVeda.GUI.MimeTypes.KVIDZAGrid.Icon : draw_t.xpm
1407 //~~~~~~~~~
1408 //
1409 // etc.
1410
1411 KVString mimetypes = gEnv->GetValue("KaliVeda.GUI.MimeTypes", "");
1412 if (mimetypes != "") {
1413
1414 mimetypes.Begin(" ");
1415 while (!mimetypes.End()) {
1416
1417 KVString classname = mimetypes.Next(kTRUE);
1418 KVString icon = gEnv->GetValue(Form("KaliVeda.GUI.MimeTypes.%s.Icon", classname.Data()), "draw_t.xpm");
1419 KVString type = classname;
1420 type.ToLower();
1421
1422 if (gClient) gClient->GetMimeTypeList()->AddType(Form("[kaliveda/%s]", type.Data()),
1423 classname.Data(), icon.Data(), icon.Data(), "");
1424
1425 }
1426 }
1427}
1428
1429
1430
1441
1443{
1444 // \brief Comparison between two 64-bit floating-point values
1445 //
1446 // Returns `kTRUE` if the integer representations of the two values are within
1447 // `maxdif` of each other. By default `maxdif=1`, which means that we consider that `x==y` if the
1448 // difference between them is no greater than the precision of `Double_t`
1449 // variables, i.e. `4.94065645841246544e-324`
1450 //
1451 // Based on the function `AlmostEqual2sComplement(float, float, int)`
1452 // by Bruce Dawson http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm
1453
1454 union converter {
1455 Double_t f;
1456 Long64_t i;
1457 } zero, val1, val2;
1458
1459 assert(maxdif > 0);
1460
1461 if (A == B) return true;
1462
1463 /* rustine to obtain the (64-bit) constant value 0x8000000000000000
1464 even on 32-bit machines (there is probably an easier way!) */
1465 zero.i = 1;
1466 zero.f = -zero.f;
1467 zero.i -= 1;
1468
1469 val1.f = A;
1470 val2.f = B;
1471 Long64_t Aint, Bint;
1472 Aint = val1.i;
1473 Bint = val2.i;
1474 if (Aint < 0) Aint = zero.i - Aint;
1475 if (Bint < 0) Bint = zero.i - Bint;
1476
1477 Long64_t intDiff = abs(val1.i - val2.i);
1478
1479 if (intDiff <= maxdif) return true;
1480
1481 return false;
1482}
1483
1484
1485
1494
1495Bool_t KVBase::OpenContextMenu(const char* method, TObject* obj, const char* alt_method_name)
1496{
1497 // Open context menu for given method of object *obj.
1498 // By default title of menu is 'obj->ClassName()::method'
1499 // You can give an alternative method name in 'alt_method_name'
1500 // Returns kFALSE if the given method is not defined for the class of object in question.
1501 //
1502 // WARNING: even if this method returns kTRUE, this is no guarantee that the method
1503 // has indeed been executed. The user may have pressed the 'Cancel' button...
1504
1505 TMethod* m = obj->IsA()->GetMethodAllAny(method);
1506 if (!m) {
1507 obj->Warning("OpenContextMenu", "%s is not a method of %s", method, obj->ClassName());
1508 return kFALSE;
1509 }
1510 TString Method = alt_method_name;
1511 if (Method == "") Method = method;
1512 TContextMenu* cm = new TContextMenu(Method, Form("%s::%s", obj->ClassName(), Method.Data()));
1513 cm->Action(obj, m);
1514 delete cm;
1515 return kTRUE;
1516}
1517
1518
1519
1526
1527void KVBase::CombineFiles(const Char_t* file1, const Char_t* file2, const Char_t* newfilename, Bool_t keep)
1528{
1529 // STATIC method which allows to combine the contents of two ROOT files
1530 // (file1 and file2) into a new ROOT file (newfilename).
1531 // All objects from the two files will be written in the new file.
1532 //
1533 // if keep=kFALSE, the two files will be deleted after the operation
1534
1535 ::Info("KVBase::CombineFiles", "Copying all objects from %s and %s ===> into new file %s", file1, file2, newfilename);
1536
1537 TFileMerger file_merge;
1538 file_merge.AddFile(file1, kFALSE);
1539 file_merge.AddFile(file2, kFALSE);
1540 file_merge.OutputFile(newfilename);
1541 file_merge.Merge();
1542
1543 // remove physical files from disk if required
1544 if (!keep) {
1545 gSystem->Unlink(file1);
1546 gSystem->Unlink(file2);
1547 }
1548}
1549
1550
1551
1559
1561{
1562 // Dummy method (returns NULL).
1563 // This method may be used in 'container' classes used with KVListView.
1564 // In order to open the context menu of the 'contained' object,
1565 // GetLabel() should return the real class of the object,
1566 // and this method should return its address.
1567 // Then call KVListView::SetUseObjLabelAsRealClass(kTRUE).
1568 return nullptr;
1569}
1570
1571
1572
1573
1576
1577const Char_t* KVBase::GetExampleFilePath(const Char_t* library, const Char_t* namefile)
1578{
1579 // Return full path to example file for given library (="KVMultiDet", "BackTrack", etc.)
1580 static TString path;
1581 path = KVBase::GetDATADIRFilePath("examples/");
1582 path += library;
1583 path += "/";
1584 path += namefile;
1585 return path.Data();
1586}
1587
1588
1589
1592
1594{
1595 // Prints welcome message and infos on version etc.
1596
1597 cout << "/----------------------------------------------------------------------\\" << endl;
1598 cout << "| Welcome to KaliVeda v" << GetKVVersion() << " gitlab.in2p3.fr/kaliveda-dev/kaliveda |" << endl;
1599 cout << "| (c) 2002-2023, The KaliVeda development team |" << endl;
1600 cout << "| |" << endl;
1601 cout << "| Built with ROOT " << KV_ROOT_VERSION << " on " << KVBase::GetKVBuildDate() << ", " << KVBase::GetKVBuildTime() << " |" << endl;
1602#ifdef WITH_GIT_INFOS
1603 TString gitinfo;
1604 gitinfo.Form("%s@%s", gitBranch(), gitCommit());
1605 printf("| From %-63s |\n", gitinfo.Data());
1606#endif
1607 cout << "| See https://kaliveda.in2p3.fr for help |" << endl;
1608 cout << "\\----------------------------------------------------------------------/" << endl << endl;
1609}
1610
1611
1612
1618
1619const Char_t* KVBase::GetDataSetEnv(const Char_t* dataset, const Char_t* type, const Char_t* defval)
1620{
1621 // Static method to interrogate dataset-specific variables in configuration
1622 // Will look for gEnv->GetValue "dataset.type"
1623 // then simply "type" if no dataset-specific value is found.
1624 // If neither resource is defined, return the "defval" default value (="" by default)
1625 TString temp;
1626 temp.Form("%s.%s", dataset, type);
1627 if (gEnv->Defined(temp.Data())) return gEnv->GetValue(temp.Data(), "");
1628 return gEnv->GetValue(type, defval);
1629}
1630
1631
1632
1638
1639Double_t KVBase::GetDataSetEnv(const Char_t* dataset, const Char_t* type, Double_t defval)
1640{
1641 // Static method to interrogate dataset-specific variables in configuration
1642 // Will look for gEnv->GetValue "dataset.type"
1643 // then simply "type" if no dataset-specific value is found.
1644 // If neither resource is defined, return the "defval" default value
1645
1646 TString temp;
1647 temp.Form("%s.%s", dataset, type);
1648 if (gEnv->Defined(temp.Data())) return gEnv->GetValue(temp.Data(), 0.0);
1649 return gEnv->GetValue(type, defval);
1650}
1651
1652
1653
1659
1660Bool_t KVBase::GetDataSetEnv(const Char_t* dataset, const Char_t* type, Bool_t defval)
1661{
1662 // Static method to interrogate dataset-specific variables in configuration
1663 //Will look for gEnv->GetValue "dataset.type"
1664 //then simply "type" if no dataset-specific value is found.
1665 //If neither resource is defined, return the "defval" default value
1666
1667 TString temp;
1668 temp.Form("%s.%s", dataset, type);
1669 if (gEnv->Defined(temp.Data())) return gEnv->GetValue(temp.Data(), kFALSE);
1670 return gEnv->GetValue(type, defval);
1671}
1672
1673
1674
1690
1691Double_t KVBase::ProtectedGetX(const TF1* func, Double_t val, int& status, Double_t xmin, Double_t xmax) const
1692{
1693 // Since ROOT6, the TF1::GetX() method can no longer be used without precaution.
1694 //
1695 // In ROOT5, if the value val was larger or smaller than the maximum or minimum value of
1696 // the function (within its defined range) then TF1::GetX() would return X of the
1697 // maximum or minimum, respectively.
1698 //
1699 // In ROOT6, TF1::GetX() has been reimplemented so that, in the above case, it
1700 // prints out 3 warning messages and returns a TMath::QuietNaN()! Therefore we provide this
1701 // function in order to replicate the previous behaviour.
1702 //
1703 // The status = 0 if the value is within the limits of the function.
1704 // status = +1 if value is above the maximum, or status = -1 if value is below the minimum
1705 //
1706 // When compiled with ROOT5, this method just calls TF1::GetX() (and status = 0 always).
1707
1708#ifdef USING_ROOT6
1709 status = 0;
1710 if (val > func->GetMaximum(xmin, xmax)) {
1711 status = 1;
1712 return func->GetMaximumX(xmin, xmax);
1713 }
1714 else if (val < func->GetMinimum(xmin, xmax)) {
1715 status = -1;
1716 return func->GetMinimumX(xmin, xmax);
1717 }
1718 else
1719 return func->GetX(val, xmin, xmax);
1720#else
1721 status = 0;
1722 return func->GetX(val, xmin, xmax);
1723#endif
1724}
1725
1726
1727
1733
1734void KVBase::Deprecated(const char* where, const char* advice)
1735{
1736 // Print a message to indicate when the called method is deprecated and give advice how to do better
1737 //
1738 // Don't call directly: use the macro Deprecate(advice) which will automatically fill in the method name
1739 // (see KVMacros.h)
1740
1741 printf("Warning in <%s>: Method is deprecated in v%s and will be removed in future.\n%s\n",
1742 where, KVBase::GetKVVersion(), advice);
1743}
1744
1745
1746
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:142
static TString fWorkingDirectory
user working directory for e.g. database files
Definition KVBase.h:152
static UInt_t fNbObj
Total number of KaliVeda objects (actually counts number of calls to default ctor)
Definition KVBase.h:145
UInt_t fNumber
for numbering objects
Definition KVBase.h:146
static Bool_t FindClassSourceFiles(const Char_t *class_name, KVString &imp_file, KVString &dec_file, const Char_t *dir_name=".")
Definition KVBase.cpp:1102
static const Char_t * GetBINDIRFilePath(const Char_t *namefile="")
Definition KVBase.cpp:118
virtual ~KVBase()
Definition KVBase.cpp:369
static void OpenTempFile(TString &base, std::ofstream &fp)
Definition KVBase.cpp:827
static const Char_t * GetDATADIRFilePath(const Char_t *namefile="")
Definition KVBase.cpp:74
static const Char_t * GetDATABASEFilePath()
Definition KVBase.cpp:92
static const Char_t * GetKVBuildDate()
Returns KaliVeda build date.
Definition KVBase.cpp:900
static const Char_t * FindFile(const Char_t *search, TString &wfil)
Definition KVBase.cpp:1060
static const Char_t * GetINCDIRFilePath(const Char_t *namefile="")
Definition KVBase.cpp:109
static const Char_t * gitCommit()
Returns last git commit of sources.
Definition KVBase.cpp:976
static const Char_t * GetWORKDIRFilePath(const Char_t *namefile="")
Definition KVBase.cpp:127
void init()
Default initialisation.
Definition KVBase.cpp:138
static Bool_t FindExecutable(TString &exec, const Char_t *path="$(PATH)")
Definition KVBase.cpp:1001
static const Char_t * GetKVBuildUser()
Returns username of person who performed build.
Definition KVBase.cpp:887
static void BackupFileWithDate(const Char_t *path)
Definition KVBase.cpp:753
static void ReadConfigFiles()
Definition KVBase.cpp:272
static const Char_t * gitBranch()
Returns git branch of sources.
Definition KVBase.cpp:964
static const Char_t * GetListOfPluginURIs(const Char_t *base)
Definition KVBase.cpp:1327
TString fLabel
label for the object
Definition KVBase.h:148
virtual void Clear(Option_t *opt="")
Clear object properties : name, type/title, number, label.
Definition KVBase.cpp:380
KVBase()
Default constructor.
Definition KVBase.cpp:317
static const Char_t * GetListOfPlugins(const Char_t *base)
Definition KVBase.cpp:1260
static Bool_t fEnvIsInit
set when environment is initialised
Definition KVBase.h:151
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:1442
KVBase & operator=(const KVBase &)
copy assignment operator
Definition KVBase.cpp:355
static void CombineFiles(const Char_t *file1, const Char_t *file2, const Char_t *newfilename, Bool_t keep=kTRUE)
Definition KVBase.cpp:1527
static const Char_t * GetTEMPLATEDIRFilePath(const Char_t *namefile="")
Definition KVBase.cpp:83
static const Char_t * GetKVSourceDir()
Returns top-level directory of source tree used for build.
Definition KVBase.cpp:938
static void InitEnvironment()
Definition KVBase.cpp:181
virtual void Print(Option_t *option="") const
Definition KVBase.cpp:410
static const Char_t * GetDataSetEnv(const Char_t *dataset, const Char_t *type, const Char_t *defval)
Definition KVBase.cpp:1619
static const Char_t * GetKVBuildTime()
Returns KaliVeda build time.
Definition KVBase.cpp:912
static void PrintSplashScreen()
Prints welcome message and infos on version etc.
Definition KVBase.cpp:1593
static const Char_t * GetLIBDIRFilePath(const Char_t *namefile="")
Definition KVBase.cpp:100
static const Char_t * GetExampleFilePath(const Char_t *library, const Char_t *namefile)
Return full path to example file for given library (="KVMultiDet", "BackTrack", etc....
Definition KVBase.cpp:1577
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:1691
static const Char_t * GetKVBuildDir()
Returns top-level directory used for build.
Definition KVBase.cpp:951
static void ReadGUIMimeTypes()
Definition KVBase.cpp:1397
static Bool_t IsThisAPlugin(const TString &uri, TString &base)
Definition KVBase.cpp:1357
@ kIsKaliVedaObject
Definition KVBase.h:163
virtual TObject * GetObject() const
Definition KVBase.cpp:1560
static void GetTempFileName(TString &base)
Definition KVBase.cpp:848
static Bool_t SearchKVFile(const Char_t *name, TString &fullpath, const Char_t *kvsubdir="")
Definition KVBase.cpp:538
static const Char_t * GetKVBuildType()
Returns KaliVeda build type (cmake build: Release, Debug, RelWithDebInfo, ...)
Definition KVBase.cpp:925
static const Char_t * GetPluginURI(const Char_t *base, const Char_t *plugin)
Definition KVBase.cpp:1177
static const Char_t * GetETCDIRFilePath(const Char_t *namefile="")
Definition KVBase.cpp:65
static Bool_t OpenContextMenu(const char *method, TObject *obj, const char *alt_method_name="")
Definition KVBase.cpp:1495
const Char_t * GetLabel() const
Definition KVBase.h:199
static Bool_t SearchAndOpenKVFile(const Char_t *name, KVSQLite::database &dbfile, const Char_t *kvsubdir="")
Definition KVBase.cpp:649
virtual void Copy(TObject &) const
Make a copy of this object.
Definition KVBase.cpp:394
virtual const Char_t * GetType() const
Definition KVBase.h:177
static TPluginHandler * LoadPlugin(const Char_t *base, const Char_t *uri="0")
Definition KVBase.cpp:793
static const Char_t * GetKVVersion()
Returns KaliVeda version string.
Definition KVBase.cpp:874
static void Deprecated(const char *method, const char *advice)
Definition KVBase.cpp:1734
UInt_t GetNumber() const
Definition KVBase.h:220
Interface to (Linux) system lockfile command.
Definition KVLockfile.h:70
Bool_t Release()
Bool_t Lock(const Char_t *filename="")
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:401
bool good() const
Definition SQLiteDB.h:464
void open(const TString &dbfile)
Definition SQLiteDB.cpp:110
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
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 void Fatal(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)
virtual TList * GetListOfFiles() const
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
RVec< PromoteType< T > > abs(const RVec< T > &v)
const Rcpp::internal::NamedPlaceHolder & Label
void EnableThreadSafety()
const char * cnt
v
TMarker m
ClassImp(TPyArg)