Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TROOT.cxx
Go to the documentation of this file.
1// @(#)root/base:$Id$
2// Author: Rene Brun 08/12/94
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12/** \class TROOT
13\ingroup Base
14
15ROOT top level object description.
16
17The TROOT object is the entry point to the ROOT system.
18The single instance of TROOT is accessible via the global gROOT.
19Using the gROOT pointer one has access to basically every object
20created in a ROOT based program. The TROOT object is essentially a
21container of several lists pointing to the main ROOT objects.
22
23The following lists are accessible from gROOT object:
24
25~~~ {.cpp}
26 gROOT->GetListOfClasses
27 gROOT->GetListOfColors
28 gROOT->GetListOfTypes
29 gROOT->GetListOfGlobals
30 gROOT->GetListOfGlobalFunctions
31 gROOT->GetListOfFiles
32 gROOT->GetListOfMappedFiles
33 gROOT->GetListOfSockets
34 gROOT->GetListOfSecContexts
35 gROOT->GetListOfCanvases
36 gROOT->GetListOfStyles
37 gROOT->GetListOfFunctions
38 gROOT->GetListOfSpecials (for example graphical cuts)
39 gROOT->GetListOfGeometries
40 gROOT->GetListOfBrowsers
41 gROOT->GetListOfCleanups
42 gROOT->GetListOfMessageHandlers
43~~~
44
45The TROOT class provides also many useful services:
46 - Get pointer to an object in any of the lists above
47 - Time utilities TROOT::Time
48
49The ROOT object must be created as a static object. An example
50of a main program creating an interactive version is shown below:
51
52### Example of a main program
53
54~~~ {.cpp}
55 #include "TRint.h"
56
57 int main(int argc, char **argv)
58 {
59 TRint *theApp = new TRint("ROOT example", &argc, argv);
60
61 // Init Intrinsics, build all windows, and enter event loop
62 theApp->Run();
63
64 return(0);
65 }
66~~~
67*/
68
69#include <ROOT/RConfig.hxx>
71#include <ROOT/RVersion.hxx>
72#include "RConfigure.h"
73#include "RConfigOptions.h"
74#include <atomic>
75#include <filesystem>
76#include <string>
77#include <map>
78#include <sstream>
79#include <set>
80#include <cstdlib>
81#ifdef WIN32
82#include <io.h>
83#include "Windows4Root.h"
84#include <Psapi.h>
85#define RTLD_DEFAULT ((void *)::GetModuleHandle(NULL))
86//#define dlsym(library, function_name) ::GetProcAddress((HMODULE)library, function_name)
87#define dlopen(library_name, flags) ::LoadLibrary(library_name)
88#define dlclose(library) ::FreeLibrary((HMODULE)library)
89char *dlerror() {
90 static char Msg[1000];
93 sizeof(Msg), NULL);
94 return Msg;
95}
96FARPROC dlsym(void *library, const char *function_name)
97{
98 HMODULE hMods[1024];
99 DWORD cbNeeded;
100 FARPROC address = NULL;
101 unsigned int i;
102 if (library == RTLD_DEFAULT) {
104 for (i = 0; i < (cbNeeded / sizeof(HMODULE)); i++) {
106 if (address)
107 return address;
108 }
109 }
110 return address;
111 } else {
112 return ::GetProcAddress((HMODULE)library, function_name);
113 }
114}
115#elif defined(__APPLE__)
116#include <dlfcn.h>
117#include <mach-o/dyld.h>
118#else
119#include <dlfcn.h>
120#include <link.h>
121#endif
122
123#include <iostream>
125#include "TROOT.h"
126#include "TClass.h"
127#include "TClassEdit.h"
128#include "TClassGenerator.h"
129#include "TDataType.h"
130#include "TStyle.h"
131#include "TObjectTable.h"
132#include "TClassTable.h"
133#include "TSystem.h"
134#include "THashList.h"
135#include "TObjArray.h"
136#include "TEnv.h"
137#include "TError.h"
138#include "TColor.h"
139#include "TGlobal.h"
140#include "TFunction.h"
141#include "TVirtualPad.h"
142#include "TBrowser.h"
143#include "TSystemDirectory.h"
144#include "TApplication.h"
145#include "TInterpreter.h"
146#include "TGuiFactory.h"
147#include "TMessageHandler.h"
148#include "TFolder.h"
149#include "TQObject.h"
150#include "TProcessUUID.h"
151#include "TPluginManager.h"
152#include "TVirtualMutex.h"
153#include "TListOfTypes.h"
154#include "TListOfDataMembers.h"
155#include "TListOfEnumsWithLock.h"
156#include "TListOfFunctions.h"
158#include "TFunctionTemplate.h"
159#include "ThreadLocalStorage.h"
160#include "TVirtualMapFile.h"
161#include "TVirtualRWMutex.h"
162#include "TVirtualX.h"
163
164#if defined(R__UNIX)
165#if defined(R__HAS_COCOA)
166#include "TMacOSXSystem.h"
167#include "TUrl.h"
168#else
169#include "TUnixSystem.h"
170#endif
171#elif defined(R__WIN32)
172#include "TWinNTSystem.h"
173#endif
174
176{
177 return r.fSecContexts;
178}
179
180extern "C" void R__SetZipMode(int);
181
183static void *gInterpreterLib = nullptr;
184
185// Mutex for protection of concurrent gROOT access
188
189// For accessing TThread::Tsd indirectly.
190void **(*gThreadTsd)(void*,Int_t) = nullptr;
191
192//-------- Names of next three routines are a small homage to CMZ --------------
193////////////////////////////////////////////////////////////////////////////////
194/// Return version id as an integer, i.e. "2.22/04" -> 22204.
195
196static Int_t IVERSQ()
197{
198 Int_t maj, min, cycle;
199 sscanf(ROOT_RELEASE, "%d.%d.%d", &maj, &min, &cycle);
200 return 10000*maj + 100*min + cycle;
201}
202
203////////////////////////////////////////////////////////////////////////////////
204/// Return built date as integer, i.e. "Apr 28 2000" -> 20000428.
205
206static Int_t IDATQQ(const char *date)
207{
208 if (!date) {
209 Error("TSystem::IDATQQ", "nullptr date string, expected e.g. 'Dec 21 2022'");
210 return -1;
211 }
212
213 static const char *months[] = {"Jan","Feb","Mar","Apr","May",
214 "Jun","Jul","Aug","Sep","Oct",
215 "Nov","Dec"};
216 char sm[12];
217 Int_t yy, mm=0, dd;
218 if (sscanf(date, "%s %d %d", sm, &dd, &yy) != 3) {
219 Error("TSystem::IDATQQ", "Cannot parse date string '%s', expected e.g. 'Dec 21 2022'", date);
220 return -1;
221 }
222 for (int i = 0; i < 12; i++)
223 if (!strncmp(sm, months[i], 3)) {
224 mm = i+1;
225 break;
226 }
227 return 10000*yy + 100*mm + dd;
228}
229
230////////////////////////////////////////////////////////////////////////////////
231/// Return built time as integer (with min precision), i.e.
232/// "17:32:37" -> 1732.
233
234static Int_t ITIMQQ(const char *time)
235{
236 Int_t hh, mm, ss;
237 sscanf(time, "%d:%d:%d", &hh, &mm, &ss);
238 return 100*hh + mm;
239}
240
241////////////////////////////////////////////////////////////////////////////////
242/// Clean up at program termination before global objects go out of scope.
243
244static void CleanUpROOTAtExit()
245{
246 if (gROOT) {
248
249 if (gROOT->GetListOfFiles())
250 gROOT->GetListOfFiles()->Delete("slow");
251 if (gROOT->GetListOfSockets())
252 gROOT->GetListOfSockets()->Delete();
253 if (gROOT->GetListOfMappedFiles())
254 gROOT->GetListOfMappedFiles()->Delete("slow");
255 if (gROOT->GetListOfClosedObjects())
256 gROOT->GetListOfClosedObjects()->Delete("slow");
257 }
258}
259
260////////////////////////////////////////////////////////////////////////////////
261/// A module and its headers. Intentionally not a copy:
262/// If these strings end up in this struct they are
263/// long lived by definition because they get passed in
264/// before initialization of TCling.
265
266namespace {
267 struct ModuleHeaderInfo_t {
268 ModuleHeaderInfo_t(const char* moduleName,
269 const char** headers,
270 const char** includePaths,
271 const char* payloadCode,
272 const char* fwdDeclCode,
273 void (*triggerFunc)(),
275 const char **classesHeaders,
276 bool hasCxxModule):
277 fModuleName(moduleName),
278 fHeaders(headers),
279 fPayloadCode(payloadCode),
280 fFwdDeclCode(fwdDeclCode),
281 fIncludePaths(includePaths),
282 fTriggerFunc(triggerFunc),
283 fClassesHeaders(classesHeaders),
284 fFwdNargsToKeepColl(fwdDeclsArgToSkip),
285 fHasCxxModule(hasCxxModule) {}
286
287 const char* fModuleName; // module name
288 const char** fHeaders; // 0-terminated array of header files
289 const char* fPayloadCode; // Additional code to be given to cling at library load
290 const char* fFwdDeclCode; // Additional code to let cling know about selected classes and functions
291 const char** fIncludePaths; // 0-terminated array of header files
292 void (*fTriggerFunc)(); // Pointer to the dict initialization used to find the library name
293 const char** fClassesHeaders; // 0-terminated list of classes and related header files
294 const TROOT::FwdDeclArgsToKeepCollection_t fFwdNargsToKeepColl; // Collection of
295 // pairs of template fwd decls and number of
296 bool fHasCxxModule; // Whether this module has a C++ module alongside it.
297 };
298
299 std::vector<ModuleHeaderInfo_t>& GetModuleHeaderInfoBuffer() {
300 static std::vector<ModuleHeaderInfo_t> moduleHeaderInfoBuffer;
302 }
303
304 enum class AutoReg : unsigned char {
305 kNotInitialised = 0,
306 kOn,
307 kOff,
308 };
309
310 ////////////////////////////////////////////////////////////////////////////////
311 /// \brief Test if various objects (such as TH1-derived classes) should automatically register
312 /// themselves (ROOT 6 mode) or not (ROOT 7 mode).
313 /// A default can be set in a .rootrc using e.g. "Root.ObjectAutoRegistration: 1" or setting
314 /// the environment variable "ROOT_OBJECT_AUTO_REGISTRATION=0".
316 {
317 static constexpr auto rcName = "Root.ObjectAutoRegistration"; // Update the docs if this is changed
318 static constexpr auto envName = "ROOT_OBJECT_AUTO_REGISTRATION"; // Update the docs if this is changed
319 thread_local static AutoReg tlsState = AutoReg::kNotInitialised;
320
321 static const AutoReg defaultState = []() {
322 AutoReg autoReg = AutoReg::kOn; // ROOT 6 default
323 std::stringstream infoMessage;
324
325 if (gEnv) {
326 const auto desiredValue = gEnv->GetValue(rcName, -1);
327 if (desiredValue == 0) {
328 autoReg = AutoReg::kOff;
329 infoMessage << "disabled in " << gEnv->GetRcName();
330 } else if (desiredValue == 1) {
331 autoReg = AutoReg::kOn;
332 infoMessage << "enabled in " << gEnv->GetRcName();
333 } else if (desiredValue != -1) {
334 Error("TROOT", "%s should be 0 or 1", rcName);
335 }
336 }
337
338 if (const auto env = gSystem->Getenv(envName); env) {
339 int desiredValue = -1;
340 try {
341 desiredValue = std::stoi(env);
342 } catch (std::invalid_argument &e) {
343 Error("TROOT", "%s should be 0 or 1", envName);
344 }
345 if (desiredValue == 0) {
346 autoReg = AutoReg::kOff;
347 infoMessage << (infoMessage.str().empty() ? "" : " and ") << "disabled using the environment variable "
348 << envName;
349 } else if (desiredValue == 1) {
350 autoReg = AutoReg::kOn;
351 infoMessage << (infoMessage.str().empty() ? "" : " and ") << "enabled using the environment variable "
352 << envName;
353 } else {
354 Error("TROOT", "%s should be 0 or 1", envName);
355 }
356 }
357
358 if (!infoMessage.str().empty()) {
359 Info("TROOT", "Object auto registration %s\n", infoMessage.str().c_str());
360 }
361
362 return autoReg;
363 }();
364
365 if (tlsState == AutoReg::kNotInitialised) {
366 assert(defaultState != AutoReg::kNotInitialised);
368 }
369
370 return tlsState;
371 }
372}
373
376
381
382// This local static object initializes the ROOT system
383namespace ROOT {
384namespace Internal {
386 // Simple wrapper to separate, time-wise, the call to the
387 // TROOT destructor and the actual free-ing of the memory.
388 //
389 // Since the interpreter implementation (currently TCling) is
390 // loaded via dlopen by libCore, the destruction of its global
391 // variable (i.e. in particular clang's) is scheduled before
392 // those in libCore so we need to schedule the call to the TROOT
393 // destructor before that *but* we want to make sure the memory
394 // stay around until libCore itself is unloaded so that code
395 // using gROOT can 'properly' check for validity.
396 //
397 // The order of loading for is:
398 // libCore.so
399 // libRint.so
400 // ... anything other library hard linked to the executable ...
401 // ... for example libEvent
402 // libCling.so
403 // ... other libraries like libTree for example ....
404 // and the destruction order is (of course) the reverse.
405 // By default the unloading of the dictionary, does use
406 // the service of the interpreter ... which of course
407 // fails if libCling is already unloaded by that information
408 // has not been registered per se.
409 //
410 // To solve this problem, we now schedule the destruction
411 // of the TROOT object to happen _just_ before the
412 // unloading/destruction of libCling so that we can
413 // maximize the amount of clean-up we can do correctly
414 // and we can still allocate the TROOT object's memory
415 // statically.
416 //
417 union {
419 char fHolder[sizeof(TROOT)];
420 };
421 public:
422 TROOTAllocator(): fObj("root", "The ROOT of EVERYTHING")
423 {}
424
426 if (gROOTLocal) {
428 }
429 }
430 };
431
432 // The global gROOT is defined to be a function (ROOT::GetROOT())
433 // which itself is dereferencing a function pointer.
434
435 // Initially this function pointer's value is & GetROOT1 whose role is to
436 // create and initialize the TROOT object itself.
437 // At the very end of the TROOT constructor the value of the function pointer
438 // is switch to & GetROOT2 whose role is to initialize the interpreter.
439
440 // This mechanism was primarily intended to fix the issues with order in which
441 // global TROOT and LLVM globals are initialized. TROOT was initializing
442 // Cling, but Cling could not be used yet due to LLVM globals not being
443 // Initialized yet. The solution is to delay initializing the interpreter in
444 // TROOT till after main() when all LLVM globals are initialized.
445
446 // Technically, the mechanism used actually delay the interpreter
447 // initialization until the first use of gROOT *after* the end of the
448 // TROOT constructor.
449
450 // So to delay until after the start of main, we also made sure that none
451 // of the ROOT code (mostly the dictionary code) used during library loading
452 // is using gROOT (directly or indirectly).
453
454 // In practice, the initialization of the interpreter is now delayed until
455 // the first use gROOT (or gInterpreter) after the start of main (but user
456 // could easily break this by using gROOT in their library initialization
457 // code).
458
459 extern TROOT *gROOTLocal;
460
462 if (gROOTLocal)
463 return gROOTLocal;
464 static TROOTAllocator alloc;
465 return gROOTLocal;
466 }
467
470 if (!initInterpreter) {
473 // Load and init threads library
475 }
476 return gROOTLocal;
477 }
478 typedef TROOT *(*GetROOTFun_t)();
479
481
482 static Func_t GetSymInLibImt(const char *funcname)
483 {
484 const static bool loadSuccess = dlsym(RTLD_DEFAULT, "usedToIdentifyRootClingByDlSym")? false : 0 <= gSystem->Load("libImt");
485 if (loadSuccess) {
486 if (auto sym = gSystem->DynFindSymbol(nullptr, funcname)) {
487 return sym;
488 } else {
489 Error("GetSymInLibImt", "Cannot get symbol %s.", funcname);
490 }
491 }
492 return nullptr;
493 }
494
495 //////////////////////////////////////////////////////////////////////////////
496 /// Globally enables the parallel branch processing, which is a case of
497 /// implicit multi-threading (IMT) in ROOT, activating the required locks.
498 /// This IMT use case, implemented in TTree::GetEntry, spawns a task for
499 /// each branch of the tree. Therefore, a task takes care of the reading,
500 /// decompression and deserialisation of a given branch.
502 {
503#ifdef R__USE_IMT
504 static void (*sym)() = (void(*)())Internal::GetSymInLibImt("ROOT_TImplicitMT_EnableParBranchProcessing");
505 if (sym)
506 sym();
507#else
508 ::Warning("EnableParBranchProcessing", "Cannot enable parallel branch processing, please build ROOT with -Dimt=ON");
509#endif
510 }
511
512 //////////////////////////////////////////////////////////////////////////////
513 /// Globally disables the IMT use case of parallel branch processing,
514 /// deactivating the corresponding locks.
516 {
517#ifdef R__USE_IMT
518 static void (*sym)() = (void(*)())Internal::GetSymInLibImt("ROOT_TImplicitMT_DisableParBranchProcessing");
519 if (sym)
520 sym();
521#else
522 ::Warning("DisableParBranchProcessing", "Cannot disable parallel branch processing, please build ROOT with -Dimt=ON");
523#endif
524 }
525
526 //////////////////////////////////////////////////////////////////////////////
527 /// Returns true if parallel branch processing is enabled.
529 {
530#ifdef R__USE_IMT
531 static Bool_t (*sym)() = (Bool_t(*)())Internal::GetSymInLibImt("ROOT_TImplicitMT_IsParBranchProcessingEnabled");
532 if (sym)
533 return sym();
534 else
535 return kFALSE;
536#else
537 return kFALSE;
538#endif
539 }
540
541 ////////////////////////////////////////////////////////////////////////////////
542 /// Keeps track of the status of ImplicitMT w/o resorting to the load of
543 /// libImt
549} // end of Internal sub namespace
550// back to ROOT namespace
551
553 return (*Internal::gGetROOT)();
554 }
555
557 static TString macroPath;
558 return macroPath;
559 }
560
561 // clang-format off
562 ////////////////////////////////////////////////////////////////////////////////
563 /// Enables the global mutex to make ROOT thread safe/aware.
564 ///
565 /// The following becomes safe:
566 /// - concurrent construction and destruction of TObjects, including the ones registered in ROOT's global lists (e.g. gROOT->GetListOfCleanups(), gROOT->GetListOfFiles())
567 /// - concurrent usage of _different_ ROOT objects from different threads, including ones with global state (e.g. TFile, TTree, TChain) with the exception of graphics classes (e.g. TCanvas)
568 /// - concurrent calls to ROOT's type system classes, e.g. TClass and TEnum
569 /// - concurrent calls to the interpreter through gInterpreter
570 /// - concurrent loading of ROOT plug-ins
571 ///
572 /// In addition, gDirectory, gFile and gPad become a thread-local variable.
573 /// In all threads, gDirectory defaults to gROOT, a singleton which supports thread-safe insertion and deletion of contents.
574 /// gFile and gPad default to nullptr, as it is for single-thread programs.
575 ///
576 /// The ROOT graphics subsystem is not made thread-safe by this method. In particular drawing or printing different
577 /// canvases from different threads (and analogous operations such as invoking `Draw` on a `TObject`) is not thread-safe.
578 ///
579 /// Note that there is no `DisableThreadSafety()`. ROOT's thread-safety features cannot be disabled once activated.
580 // clang-format on
582 {
583 static void (*sym)() = (void(*)())Internal::GetSymInLibImt("ROOT_TThread_Initialize");
584 if (sym)
585 sym();
586 }
587
588 ////////////////////////////////////////////////////////////////////////////////
589 /// @param[in] numthreads Number of threads to use. If not specified or
590 /// set to zero, the number of threads is automatically
591 /// decided by the implementation. Any other value is
592 /// used as a hint.
593 ///
594 /// ROOT must be built with the compilation flag `imt=ON` for this feature to be available.
595 /// The following objects and methods automatically take advantage of
596 /// multi-threading if a call to `EnableImplicitMT` has been made before usage:
597 ///
598 /// - RDataFrame internally runs the event-loop by parallelizing over clusters of entries
599 /// - TTree::GetEntry reads multiple branches in parallel
600 /// - TTree::FlushBaskets writes multiple baskets to disk in parallel
601 /// - TTreeCacheUnzip decompresses the baskets contained in a TTreeCache in parallel
602 /// - THx::Fit performs in parallel the evaluation of the objective function over the data
603 /// - TMVA::DNN trains the deep neural networks in parallel
604 /// - TMVA::BDT trains the classifier in parallel and multiclass BDTs are evaluated in parallel
605 ///
606 /// EnableImplicitMT calls in turn EnableThreadSafety.
607 /// The 'numthreads' parameter allows to control the number of threads to
608 /// be used by the implicit multi-threading. However, this parameter is just
609 /// a hint for ROOT: it will try to satisfy the request if the execution
610 /// scenario allows it. For example, if ROOT is configured to use an external
611 /// scheduler, setting a value for 'numthreads' might not have any effect.
612 /// The maximum number of threads can be influenced by the environment
613 /// variable `ROOT_MAX_THREADS`: `export ROOT_MAX_THREADS=2` will try to set
614 /// the maximum number of active threads to 2, if the scheduling library
615 /// (such as tbb) "permits".
616 ///
617 /// \note Use `DisableImplicitMT()` to disable multi-threading (some locks will remain in place as
618 /// described in EnableThreadSafety()). `EnableImplicitMT(1)` creates a thread-pool of size 1.
620 {
621#ifdef R__USE_IMT
623 return;
625 static void (*sym)(UInt_t) = (void(*)(UInt_t))Internal::GetSymInLibImt("ROOT_TImplicitMT_EnableImplicitMT");
626 if (sym)
627 sym(numthreads);
629#else
630 ::Warning("EnableImplicitMT", "Cannot enable implicit multi-threading with %d threads, please build ROOT with -Dimt=ON", numthreads);
631#endif
632 }
633
634 ////////////////////////////////////////////////////////////////////////////////
635 /// @param[in] config Configuration to use. The default is kWholeMachine, which
636 /// will create a thread pool that spans the whole machine.
637 ///
638 /// EnableImplicitMT calls in turn EnableThreadSafety.
639 /// If ImplicitMT is already enabled, this function does nothing.
640
642 {
643#ifdef R__USE_IMT
645 return;
647 static void (*sym)(ROOT::EIMTConfig) =
648 (void (*)(ROOT::EIMTConfig))Internal::GetSymInLibImt("ROOT_TImplicitMT_EnableImplicitMT_Config");
649 if (sym)
650 sym(config);
652#else
653 ::Warning("EnableImplicitMT",
654 "Cannot enable implicit multi-threading with config %d, please build ROOT with -Dimt=ON",
655 static_cast<int>(config));
656#endif
657 }
658
659 ////////////////////////////////////////////////////////////////////////////////
660 /// Disables the implicit multi-threading in ROOT (see EnableImplicitMT).
662 {
663#ifdef R__USE_IMT
664 static void (*sym)() = (void(*)())Internal::GetSymInLibImt("ROOT_TImplicitMT_DisableImplicitMT");
665 if (sym)
666 sym();
668#else
669 ::Warning("DisableImplicitMT", "Cannot disable implicit multi-threading, please build ROOT with -Dimt=ON");
670#endif
671 }
672
673 ////////////////////////////////////////////////////////////////////////////////
674 /// Returns true if the implicit multi-threading in ROOT is enabled.
679
680 ////////////////////////////////////////////////////////////////////////////////
681 /// Returns the size of ROOT's thread pool
683 {
684#ifdef R__USE_IMT
685 static UInt_t (*sym)() = (UInt_t(*)())Internal::GetSymInLibImt("ROOT_MT_GetThreadPoolSize");
686 if (sym)
687 return sym();
688 else
689 return 0;
690#else
691 return 0;
692#endif
693 }
694
695 /// Namespace for ROOT features in testing.
696 /// The API might change without notice until moved out of this namespace.
697 namespace Experimental {
698 ////////////////////////////////////////////////////////////////////////////////
699 /// \brief Enable automatic registration of objects for the current thread (ROOT 6 default).
700 ///
701 /// In ROOT 6 mode, ROOT will implicitly assign ownership of histograms or TTrees
702 /// to the current \ref gDirectory, for example to the last TFile that was opened.
703 /// \code{.cpp}
704 /// TFile file(...);
705 /// TTree* tree = new TTree(...);
706 /// TH1D* histo = new TH1D(...);
707 /// file.Write(); // Both tree and histogram are in the file now
708 /// \endcode
709 ///
710 /// On the path to ROOT 7, the auto registration of most objects will be phased out, so
711 /// they are fully owned by the user. To write these to files, the user needs to do
712 /// one of the following:
713 /// - Manage the object, and write it explicitly:
714 /// \code{.cpp}
715 /// TFile file(...);
716 /// std::unique_ptr<TH1D> histo{new TH1D(...)};
717 /// file.WriteObject(histo.get(), "HistogramName");
718 /// // histo remains valid even if the file is closed
719 /// \endcode
720 /// - Explicitly transfer ownership to the file using `SetDirectory()`:
721 /// \code{.cpp}
722 /// TFile file(...);
723 /// TH1x* histogram = new TH1x(...);
724 /// histogram->SetDirectory(&file);
725 /// \endcode
726 ///
727 /// ### Objects covered by this mode
728 ///
729 /// | | Honours `DisableObjectAutoRegistration()`? | Could this be disabled previously? |
730 /// | --------------------- | ------------------------------------------ | ---------------------------------- |
731 /// | TH1 and derived | Yes | TH1::AddDirectoryStatus() |
732 /// | TGraph2D | Yes | TH1::AddDirectoryStatus() |
733 /// | RooPlot | Yes | RooPlot::addDirectoryStatus() |
734 /// | TEfficiency | Yes | No |
735 /// | TProfile2D | Yes | TH1::AddDirectoryStatus() |
736 /// | TEntryList | No, but planned for 6.42 | No |
737 /// | TEventList | No, but planned for 6.42 | No |
738 /// | TFunction | No, but work in progress | No |
739 ///
740 /// ## Setting defaults
741 ///
742 /// A default can be set in a .rootrc using e.g. `Root.ObjectAutoRegistration: 1` or setting
743 /// the environment variable `ROOT_OBJECT_AUTO_REGISTRATION=0`. Note that this default affects
744 /// all the threads that get started.
745 /// When a default is set using one of these methods, ROOT will notify with an Info message.
746 ///
747 /// ## Difference to TH1::AddDirectoryStatus()
748 ///
749 /// For classes deriving from TH1, both ObjectAutoRegistrationEnabled() and TH1::AddDirectoryStatus()
750 /// need to be true for auto-registration to take effect. The former should be preferred over the latter, however,
751 /// because it is thread local and extends to more objects such as TGraph2D, TEfficiency, RooPlot.
753 {
754 ObjectAutoRegistrationEnabledImpl() = AutoReg::kOn;
755 }
756
757 ////////////////////////////////////////////////////////////////////////////////
758 /// \brief Disable automatic registration of objects for the current thread (ROOT 7 default).
759 /// \copydetails ROOT::Experimental::EnableObjectAutoRegistration()
761 {
762 ObjectAutoRegistrationEnabledImpl() = AutoReg::kOff;
763 }
764
765 ////////////////////////////////////////////////////////////////////////////////
766 /// Test whether objects in this thread auto-register themselves, e.g. to the current ROOT directory.
767 /// \copydetails ROOT::Experimental::EnableObjectAutoRegistration()
769 {
770 const auto state = ObjectAutoRegistrationEnabledImpl();
771 assert(state != AutoReg::kNotInitialised);
772 return state == AutoReg::kOn;
773 }
774 } // namespace Experimental
775} // end of ROOT namespace
776
778
779// Global debug flag (set to > 0 to get debug output).
780// Can be set either via the interpreter (gDebug is exported to CINT),
781// via the rootrc resource "Root.Debug", via the shell environment variable
782// ROOTDEBUG, or via the debugger.
784
785
786
787////////////////////////////////////////////////////////////////////////////////
788/// Default ctor.
789
791
792////////////////////////////////////////////////////////////////////////////////
793/// Initialize the ROOT system. The creation of the TROOT object initializes
794/// the ROOT system. It must be the first ROOT related action that is
795/// performed by a program. The TROOT object must be created on the stack
796/// (can not be called via new since "operator new" is protected). The
797/// TROOT object is either created as a global object (outside the main()
798/// program), or it is one of the first objects created in main().
799/// Make sure that the TROOT object stays in scope for as long as ROOT
800/// related actions are performed. TROOT is a so called singleton so
801/// only one instance of it can be created. The single TROOT object can
802/// always be accessed via the global pointer gROOT.
803/// The name and title arguments can be used to identify the running
804/// application. The initfunc argument can contain an array of
805/// function pointers (last element must be 0). These functions are
806/// executed at the end of the constructor. This way one can easily
807/// extend the ROOT system without adding permanent dependencies
808/// (e.g. the graphics system is initialized via such a function).
809
810TROOT::TROOT(const char *name, const char *title, VoidFuncPtr_t *initfunc) : TDirectory()
811{
813 //Warning("TROOT", "only one instance of TROOT allowed");
814 return;
815 }
816
818
820 gDirectory = nullptr;
821
822 SetName(name);
823 SetTitle(title);
824
825 // will be used by global "operator delete" so make sure it is set
826 // before anything is deleted
827 fMappedFiles = nullptr;
828
829 // create already here, but only initialize it after gEnv has been created
831
832 // Initialize Operating System interface
833 InitSystem();
834
835 // Initialize static directory functions
836 GetRootSys();
837 GetBinDir();
838 GetLibDir();
840 GetEtcDir();
841 GetDataDir();
842 GetDocDir();
843 GetMacroDir();
845 GetIconPath();
847
848 gRootDir = GetRootSys().Data();
849
850 TDirectory::BuildDirectory(nullptr, nullptr);
851
852 // Initialize interface to CINT C++ interpreter
853 fVersionInt = 0; // check in TROOT dtor in case TCling fails
854 fClasses = nullptr; // might be checked via TCling ctor
855 fEnums = nullptr;
856
866
867 ReadGitInfo();
868
869 fClasses = new THashTable(800,3); fClasses->UseRWLock();
870 //fIdMap = new IdMap_t;
873
874 // usedToIdentifyRootClingByDlSym is available when TROOT is part of
875 // rootcling.
876 if (!dlsym(RTLD_DEFAULT, "usedToIdentifyRootClingByDlSym")) {
877 // initialize plugin manager early
879 }
880
882
883 auto setNameLocked = [](TSeqCollection *l, const char *collection_name) {
884 l->SetName(collection_name);
885 l->UseRWLock();
886 return l;
887 };
888
889 fTimer = 0;
890 fApplication = nullptr;
891 fColors = setNameLocked(new TObjArray(1000), "ListOfColors");
892 fColors->SetOwner();
893 fTypes = nullptr;
894 fGlobals = nullptr;
895 fGlobalFunctions = nullptr;
896 // fList was created in TDirectory::Build but with different sizing.
897 delete fList;
898 fList = new THashList(1000,3); fList->UseRWLock();
899 fClosedObjects = setNameLocked(new TList, "ClosedFiles");
900 fFiles = setNameLocked(new TList, "Files");
901 fMappedFiles = setNameLocked(new TList, "MappedFiles");
902 fSockets = setNameLocked(new TList, "Sockets");
903 fCanvases = setNameLocked(new TList, "Canvases");
904 fStyles = setNameLocked(new TList, "Styles");
905 fFunctions = setNameLocked(new TList, "Functions");
906 fTasks = setNameLocked(new TList, "Tasks");
907 fGeometries = setNameLocked(new TList, "Geometries");
908 fBrowsers = setNameLocked(new TList, "Browsers");
909 fSpecials = setNameLocked(new TList, "Specials");
910 fBrowsables = (TList*)setNameLocked(new TList, "Browsables");
911 fCleanups = setNameLocked(new THashList, "Cleanups");
912 fMessageHandlers = setNameLocked(new TList, "MessageHandlers");
913 fSecContexts = setNameLocked(new TList, "SecContexts");
914 fClipboard = setNameLocked(new TList, "Clipboard");
915 fDataSets = setNameLocked(new TList, "DataSets");
917
919 fUUIDs = new TProcessUUID();
920
921 fRootFolder = new TFolder();
922 fRootFolder->SetName("root");
923 fRootFolder->SetTitle("root of all folders");
924 fRootFolder->AddFolder("Classes", "List of Active Classes",fClasses);
925 fRootFolder->AddFolder("Colors", "List of Active Colors",fColors);
926 fRootFolder->AddFolder("MapFiles", "List of MapFiles",fMappedFiles);
927 fRootFolder->AddFolder("Sockets", "List of Socket Connections",fSockets);
928 fRootFolder->AddFolder("Canvases", "List of Canvases",fCanvases);
929 fRootFolder->AddFolder("Styles", "List of Styles",fStyles);
930 fRootFolder->AddFolder("Functions", "List of Functions",fFunctions);
931 fRootFolder->AddFolder("Tasks", "List of Tasks",fTasks);
932 fRootFolder->AddFolder("Geometries","List of Geometries",fGeometries);
933 fRootFolder->AddFolder("Browsers", "List of Browsers",fBrowsers);
934 fRootFolder->AddFolder("Specials", "List of Special Objects",fSpecials);
935 fRootFolder->AddFolder("Handlers", "List of Message Handlers",fMessageHandlers);
936 fRootFolder->AddFolder("Cleanups", "List of RecursiveRemove Collections",fCleanups);
937 fRootFolder->AddFolder("StreamerInfo","List of Active StreamerInfo Classes",fStreamerInfo);
938 fRootFolder->AddFolder("SecContexts","List of Security Contexts",fSecContexts);
939 fRootFolder->AddFolder("ROOT Memory","List of Objects in the gROOT Directory",fList);
940 fRootFolder->AddFolder("ROOT Files","List of Connected ROOT Files",fFiles);
941
942 // by default, add the list of files, tasks, canvases and browsers in the Cleanups list
948 // And add TROOT's TDirectory personality
950
955 fEscape = kFALSE;
957 fPrimitive = nullptr;
958 fSelectPad = nullptr;
959 fEditorMode = 0;
960 fDefCanvasName = "c1";
962 fLineIsProcessing = 1; // This prevents WIN32 "Windows" thread to pick ROOT objects with mouse
963 gDirectory = this;
964 gPad = nullptr;
965
966 //set name of graphical cut class for the graphics editor
967 //cannot call SetCutClassName at this point because the TClass of TCutG
968 //is not yet build
969 fCutClassName = "TCutG";
970
971 // Create a default MessageHandler
972 new TMessageHandler((TClass*)nullptr);
973
974 // Create some styles
975 gStyle = nullptr;
977 SetStyle(gEnv->GetValue("Canvas.Style", "Modern"));
978
979 // Setup default (batch) graphics and GUI environment
982 gGXBatch = new TVirtualX("Batch", "ROOT Interface to batch graphics");
984
985 if (gSystem->Getenv("ROOT_BATCH"))
986 fBatch = kTRUE;
987 else {
988#if defined(R__WIN32) || defined(R__HAS_COCOA)
989 fBatch = kFALSE;
990#else
991 if (gSystem->Getenv("DISPLAY"))
992 fBatch = kFALSE;
993 else
994 fBatch = kTRUE;
995#endif
996 }
997
998 const char *webdisplay = gSystem->Getenv("ROOT_WEBDISPLAY");
999 if (!webdisplay || !*webdisplay)
1000 webdisplay = gEnv->GetValue("WebGui.Display", "");
1001 if (webdisplay && *webdisplay)
1002 SetWebDisplay(webdisplay);
1003
1004 int i = 0;
1005 while (initfunc && initfunc[i]) {
1006 (initfunc[i])();
1007 fBatch = kFALSE; // put system in graphics mode (backward compatible)
1008 i++;
1009 }
1010
1011 // Set initial/default list of browsable objects
1012 fBrowsables->Add(fRootFolder, "root");
1014 fBrowsables->Add(fFiles, "ROOT Files");
1015
1017
1019}
1020
1021////////////////////////////////////////////////////////////////////////////////
1022/// Clean up and free resources used by ROOT (files, network sockets,
1023/// shared memory segments, etc.).
1024
1026{
1027 using namespace ROOT::Internal;
1028
1029 if (gROOTLocal == this) {
1030
1031 // TMapFile must be closed before they are deleted, so run CloseFiles
1032 // (possibly a second time if the application has an explicit TApplication
1033 // object, but in that this is a no-op). TMapFile needs the slow close
1034 // so that the custome operator delete can properly find out whether the
1035 // memory being 'freed' is part of a memory mapped file or not.
1036 CloseFiles();
1037
1038 // If the interpreter has not yet been initialized, don't bother
1039 gGetROOT = &GetROOT1;
1040
1041 // Mark the object as invalid, so that we can veto some actions
1042 // (like autoloading) while we are in the destructor.
1044
1045 // Turn-off the global mutex to avoid recreating mutexes that have
1046 // already been deleted during the destruction phase
1047 if (gGlobalMutex) {
1049 gGlobalMutex = nullptr;
1050 delete m;
1051 }
1052
1053 // Return when error occurred in TCling, i.e. when setup file(s) are
1054 // out of date
1055 if (!fVersionInt) return;
1056
1057 // ATTENTION!!! Order is important!
1058
1060
1061 // FIXME: Causes rootcling to deadlock, debug and uncomment
1062 // SafeDelete(fRootFolder);
1063
1064#ifdef R__COMPLETE_MEM_TERMINATION
1065 fSpecials->Delete(); SafeDelete(fSpecials); // delete special objects : PostScript, Minuit, Html
1066#endif
1067
1068 fClosedObjects->Delete("slow"); // and closed files
1069 fFiles->Delete("slow"); // and files
1071 fSecContexts->Delete("slow"); SafeDelete(fSecContexts); // and security contexts
1072 fSockets->Delete(); SafeDelete(fSockets); // and sockets
1073 fMappedFiles->Delete("slow"); // and mapped files
1074 TSeqCollection *tl = fMappedFiles; fMappedFiles = nullptr; delete tl;
1075
1077
1078 delete fUUIDs;
1079 TProcessID::Cleanup(); // and list of ProcessIDs
1080
1081 fFunctions->Delete(); SafeDelete(fFunctions); // etc..
1087
1088#ifdef R__COMPLETE_MEM_TERMINATION
1093#endif
1094
1095 // Stop emitting signals
1097
1099
1100#ifdef R__COMPLETE_MEM_TERMINATION
1105
1106 fCleanups->Clear();
1108 delete gClassTable; gClassTable = 0;
1109 delete gEnv; gEnv = 0;
1110
1111 if (fTypes) fTypes->Delete();
1113 if (fGlobals) fGlobals->Delete();
1117 fEnums.load()->Delete();
1118
1119 fClasses->Delete(); SafeDelete(fClasses); // TClass'es must be deleted last
1120#endif
1121
1122 // Remove shared libraries produced by the TSystem::CompileMacro() call
1124
1125 // Cleanup system class
1129 delete gSystem;
1130
1131 // ROOT-6022:
1132 // if (gInterpreterLib) dlclose(gInterpreterLib);
1133#ifdef R__COMPLETE_MEM_TERMINATION
1134 // On some 'newer' platform (Fedora Core 17+, Ubuntu 12), the
1135 // initialization order is (by default?) is 'wrong' and so we can't
1136 // delete the interpreter now .. because any of the static in the
1137 // interpreter's library have already been deleted.
1138 // On the link line, we must list the most dependent .o file
1139 // and end with the least dependent (LLVM libraries), unfortunately,
1140 // Fedora Core 17+ or Ubuntu 12 will also execute the initialization
1141 // in the same order (hence doing libCore's before LLVM's and
1142 // vice et versa for both the destructor. We worked around the
1143 // initialization order by delay the TROOT creation until first use.
1144 // We can not do the same for destruction as we have no way of knowing
1145 // the last access ...
1146 // So for now, let's avoid delete TCling except in the special build
1147 // checking the completeness of the termination deletion.
1148
1149 // TODO: Should we do more cleanup here than just call delete?
1150 // Segfaults rootcling in some cases, debug and uncomment:
1151 //
1152 // delete fInterpreter;
1153
1154 // We cannot delete fCleanups because of the logic in atexit which needs it.
1156#endif
1157
1158#ifdef _MSC_VER
1159 // usedToIdentifyRootClingByDlSym is available when TROOT is part of rootcling.
1160 if (dlsym(RTLD_DEFAULT, "usedToIdentifyRootClingByDlSym")) {
1161 // deleting the interpreter makes things crash at exit in some cases
1162 delete fInterpreter;
1163 }
1164#else
1165 // deleting the interpreter makes things crash at exit in some cases
1166 delete fInterpreter;
1167#endif
1168
1169 // Prints memory stats
1171
1172 gROOTLocal = nullptr;
1174 }
1175}
1176
1177////////////////////////////////////////////////////////////////////////////////
1178/// Add a class to the list and map of classes.
1179/// This routine is deprecated, use TClass::AddClass directly.
1180
1182{
1183 TClass::AddClass(cl);
1184}
1185
1186////////////////////////////////////////////////////////////////////////////////
1187/// Add a class generator. This generator will be called by TClass::GetClass
1188/// in case its does not find a loaded rootcint dictionary to request the
1189/// creation of a TClass object.
1190
1196
1197////////////////////////////////////////////////////////////////////////////////
1198/// Append object to this directory.
1199///
1200/// If replace is true:
1201/// remove any existing objects with the same same (if the name is not "")
1202
1203void TROOT::Append(TObject *obj, Bool_t replace /* = kFALSE */)
1204{
1206 TDirectory::Append(obj,replace);
1207}
1208
1209////////////////////////////////////////////////////////////////////////////////
1210/// Add browsable objects to TBrowser.
1211
1213{
1214 TObject *obj;
1215 TIter next(fBrowsables);
1216
1217 while ((obj = (TObject *) next())) {
1218 const char *opt = next.GetOption();
1219 if (opt && strlen(opt))
1220 b->Add(obj, opt);
1221 else
1222 b->Add(obj, obj->GetName());
1223 }
1224}
1225
1226namespace {
1227 std::set<TClass *> &GetClassSavedSet()
1228 {
1229 static thread_local std::set<TClass*> gClassSaved;
1230 return gClassSaved;
1231 }
1232}
1233
1234////////////////////////////////////////////////////////////////////////////////
1235/// return class status 'ClassSaved' for class cl
1236/// This function is called by the SavePrimitive functions writing
1237/// the C++ code for an object.
1238
1240{
1241 if (cl == nullptr)
1242 return kFALSE;
1243
1244 auto result = GetClassSavedSet().insert(cl);
1245
1246 // Return false on the first insertion only.
1247 return !result.second;
1248}
1249
1250////////////////////////////////////////////////////////////////////////////////
1251/// Reset the ClassSaved status of all classes
1253{
1254 GetClassSavedSet().clear();
1255}
1256
1257namespace {
1258 template <typename Content>
1259 static void R__ListSlowClose(TList *files)
1260 {
1261 // Routine to close a list of files using the 'slow' techniques
1262 // that also for the deletion ot update the list itself.
1263
1264 static TObject harmless;
1265 TObjLink *cursor = files->FirstLink();
1266 while (cursor) {
1267 Content *dir = static_cast<Content*>( cursor->GetObject() );
1268 if (dir) {
1269 // In order for the iterator to stay valid, we must
1270 // prevent the removal of the object (dir) from the list
1271 // (which is done in TFile::Close). We can also can not
1272 // just move to the next iterator since the Close might
1273 // also (indirectly) remove that file.
1274 // So we SetObject to a harmless value, so that 'dir'
1275 // is not seen as part of the list.
1276 // We will later, remove all the object (see files->Clear()
1277 cursor->SetObject(&harmless); // this must not be zero otherwise things go wrong.
1278 // See related comment at the files->Clear("nodelete");
1279 dir->Close("nodelete");
1280 // Put it back
1281 cursor->SetObject(dir);
1282 }
1283 cursor = cursor->Next();
1284 };
1285 // Now were done, clear the list but do not delete the objects as
1286 // they have been moved to the list of closed objects and must be
1287 // deleted from there in order to avoid a double delete from a
1288 // use objects (on the interpreter stack).
1289 files->Clear("nodelete");
1290 }
1291
1293 {
1294 // Routine to delete the content of list of files using the 'slow' techniques
1295
1296 static TObject harmless;
1297 TObjLink *cursor = files->FirstLink();
1298 while (cursor) {
1299 TDirectory *dir = dynamic_cast<TDirectory*>( cursor->GetObject() );
1300 if (dir) {
1301 // In order for the iterator to stay valid, we must
1302 // prevent the removal of the object (dir) from the list
1303 // (which is done in TFile::Close). We can also can not
1304 // just move to the next iterator since the Close might
1305 // also (indirectly) remove that file.
1306 // So we SetObject to a harmless value, so that 'dir'
1307 // is not seen as part of the list.
1308 // We will later, remove all the object (see files->Clear()
1309 cursor->SetObject(&harmless); // this must not be zero otherwise things go wrong.
1310 // See related comment at the files->Clear("nodelete");
1311 dir->GetList()->Delete("slow");
1312 // Put it back
1313 cursor->SetObject(dir);
1314 }
1315 cursor = cursor->Next();
1316 };
1317 }
1318}
1319
1320////////////////////////////////////////////////////////////////////////////////
1321/// Close any files and sockets that gROOT knows about.
1322/// This can be used to insures that the files and sockets are closed before any library is unloaded!
1323
1325{
1326 // Close files without deleting the objects (`ResetGlobals` will be called
1327 // next; see `EndOfProcessCleanups()` below.)
1328 if (fFiles && fFiles->First()) {
1330 }
1331 // and Close TROOT itself.
1332 Close("nodelete");
1333 // Now sockets.
1334 if (fSockets && fSockets->First()) {
1335 if (nullptr==fCleanups->FindObject(fSockets) ) {
1338 }
1339 CallFunc_t *socketCloser = gInterpreter->CallFunc_Factory();
1340 Longptr_t offset = 0;
1341 TClass *socketClass = TClass::GetClass("TSocket");
1342 gInterpreter->CallFunc_SetFuncProto(socketCloser, socketClass->GetClassInfo(), "Close", "", &offset);
1343 if (gInterpreter->CallFunc_IsValid(socketCloser)) {
1344 static TObject harmless;
1345 TObjLink *cursor = static_cast<TList*>(fSockets)->FirstLink();
1347 while (cursor) {
1348 TObject *socket = cursor->GetObject();
1349 // In order for the iterator to stay valid, we must
1350 // prevent the removal of the object (dir) from the list
1351 // (which is done in TFile::Close). We can also can not
1352 // just move to the next iterator since the Close might
1353 // also (indirectly) remove that file.
1354 // So we SetObject to a harmless value, so that 'dir'
1355 // is not seen as part of the list.
1356 // We will later, remove all the object (see files->Clear()
1357 cursor->SetObject(&harmless); // this must not be zero otherwise things go wrong.
1358
1359 if (socket->IsA()->InheritsFrom(socketClass)) {
1360 gInterpreter->CallFunc_Exec(socketCloser, ((char*)socket)+offset);
1361 // Put the object in the closed list for later deletion.
1362 socket->SetBit(kMustCleanup);
1364 } else {
1365 // Crap ... this is not a socket, let's try to find a Close
1367 CallFunc_t *otherCloser = gInterpreter->CallFunc_Factory();
1368 gInterpreter->CallFunc_SetFuncProto(otherCloser, socket->IsA()->GetClassInfo(), "Close", "", &other_offset);
1369 if (gInterpreter->CallFunc_IsValid(otherCloser)) {
1370 gInterpreter->CallFunc_Exec(otherCloser, ((char*)socket)+other_offset);
1371 // Put the object in the closed list for later deletion.
1372 socket->SetBit(kMustCleanup);
1374 } else {
1375 notclosed.AddLast(socket);
1376 }
1377 gInterpreter->CallFunc_Delete(otherCloser);
1378 // Put it back
1379 cursor->SetObject(socket);
1380 }
1381 cursor = cursor->Next();
1382 }
1383 // Now were done, clear the list
1384 fSockets->Clear();
1385 // Read the one we did not close
1386 cursor = notclosed.FirstLink();
1387 while (cursor) {
1388 static_cast<TList*>(fSockets)->AddLast(cursor->GetObject());
1389 cursor = cursor->Next();
1390 }
1391 }
1392 gInterpreter->CallFunc_Delete(socketCloser);
1393 }
1394 if (fMappedFiles && fMappedFiles->First()) {
1396 }
1397
1398}
1399
1400////////////////////////////////////////////////////////////////////////////////
1401/// Execute the cleanups necessary at the end of the process, in particular
1402/// those that must be executed before the library start being unloaded.
1403
1405{
1406 // This will not delete the objects 'held' by the TFiles so that
1407 // they can still be 'reacheable' when ResetGlobals is run.
1408 CloseFiles();
1409
1410 if (gInterpreter) {
1411 // This might delete some of the objects 'held' by the TFiles (hence
1412 // `CloseFiles` must not delete them)
1413 gInterpreter->ResetGlobals();
1414 }
1415
1416 // Now delete the objects still 'held' by the TFiles so that it
1417 // is done before the tear down of the libraries.
1420 }
1421 fList->Delete("slow");
1422
1423 // Now a set of simpler things to delete. See the same ordering in
1424 // TROOT::~TROOT
1425 fFunctions->Delete();
1427 fBrowsers->Delete();
1428 fCanvases->Delete("slow");
1429 fColors->Delete();
1430 fStyles->Delete();
1431
1433
1434 if (gInterpreter) {
1435 gInterpreter->ShutDown();
1436 }
1437}
1438
1439
1440////////////////////////////////////////////////////////////////////////////////
1441/// Find an object in one Root folder
1442
1444{
1445 Error("FindObject","Not yet implemented");
1446 return nullptr;
1447}
1448
1449////////////////////////////////////////////////////////////////////////////////
1450/// Returns address of a ROOT object if it exists
1451///
1452/// If name contains at least one "/" the function calls FindObjectany
1453/// else
1454/// This function looks in the following order in the ROOT lists:
1455/// - List of files
1456/// - List of memory mapped files
1457/// - List of functions
1458/// - List of geometries
1459/// - List of canvases
1460/// - List of styles
1461/// - List of specials
1462/// - List of materials in current geometry
1463/// - List of shapes in current geometry
1464/// - List of matrices in current geometry
1465/// - List of Nodes in current geometry
1466/// - Current Directory in memory
1467/// - Current Directory on file
1468
1469TObject *TROOT::FindObject(const char *name) const
1470{
1471 if (name && strstr(name,"/")) return FindObjectAny(name);
1472
1473 TObject *temp = nullptr;
1474
1475 temp = fFiles->FindObject(name); if (temp) return temp;
1476 temp = fMappedFiles->FindObject(name); if (temp) return temp;
1477 {
1479 temp = fFunctions->FindObject(name);if (temp) return temp;
1480 }
1481 temp = fGeometries->FindObject(name); if (temp) return temp;
1482 temp = fCanvases->FindObject(name); if (temp) return temp;
1483 temp = fStyles->FindObject(name); if (temp) return temp;
1484 {
1486 temp = fSpecials->FindObject(name); if (temp) return temp;
1487 }
1488 TIter next(fGeometries);
1489 TObject *obj;
1490 while ((obj=next())) {
1491 temp = obj->FindObject(name); if (temp) return temp;
1492 }
1493 if (gDirectory) temp = gDirectory->Get(name);
1494 if (temp) return temp;
1495 if (gPad) {
1496 TVirtualPad *canvas = gPad->GetVirtCanvas();
1497 if (fCanvases->FindObject(canvas)) { //this check in case call from TCanvas ctor
1498 temp = canvas->FindObject(name);
1499 if (!temp && canvas != gPad) temp = gPad->FindObject(name);
1500 }
1501 }
1502 return temp;
1503}
1504
1505////////////////////////////////////////////////////////////////////////////////
1506/// Returns address and folder of a ROOT object if it exists
1507///
1508/// This function looks in the following order in the ROOT lists:
1509/// - List of files
1510/// - List of memory mapped files
1511/// - List of functions
1512/// - List of geometries
1513/// - List of canvases
1514/// - List of styles
1515/// - List of specials
1516/// - List of materials in current geometry
1517/// - List of shapes in current geometry
1518/// - List of matrices in current geometry
1519/// - List of Nodes in current geometry
1520/// - Current Directory in memory
1521/// - Current Directory on file
1522
1524{
1525 TObject *temp = nullptr;
1526 where = nullptr;
1527
1528 if (!temp) {
1529 temp = fFiles->FindObject(name);
1530 where = fFiles;
1531 }
1532 if (!temp) {
1533 temp = fMappedFiles->FindObject(name);
1535 }
1536 if (!temp) {
1538 temp = fFunctions->FindObject(name);
1539 where = fFunctions;
1540 }
1541 if (!temp) {
1542 temp = fCanvases->FindObject(name);
1543 where = fCanvases;
1544 }
1545 if (!temp) {
1546 temp = fStyles->FindObject(name);
1547 where = fStyles;
1548 }
1549 if (!temp) {
1550 temp = fSpecials->FindObject(name);
1551 where = fSpecials;
1552 }
1553 if (!temp) {
1555 if (glast) {where = glast; temp = glast->FindObject(name);}
1556 }
1557 if (!temp && gDirectory) {
1558 gDirectory->GetObject(name, temp);
1559 where = gDirectory;
1560 }
1561 if (!temp && gPad) {
1562 TVirtualPad *canvas = gPad->GetVirtCanvas();
1563 if (fCanvases->FindObject(canvas)) { //this check in case call from TCanvas ctor
1564 temp = canvas->FindObject(name);
1565 where = canvas;
1566 if (!temp && canvas != gPad) {
1567 temp = gPad->FindObject(name);
1568 where = gPad;
1569 }
1570 }
1571 }
1572 if (!temp) return nullptr;
1573 if (!ROOT::Detail::HasBeenDeleted(temp)) return temp;
1574 return nullptr;
1575}
1576
1577////////////////////////////////////////////////////////////////////////////////
1578/// Return a pointer to the first object with name starting at //root.
1579/// This function scans the list of all folders.
1580/// if no object found in folders, it scans the memory list of all files.
1581
1583{
1585 if (obj) return obj;
1586 return gDirectory->FindObjectAnyFile(name);
1587}
1588
1589////////////////////////////////////////////////////////////////////////////////
1590/// Scan the memory lists of all files for an object with name
1591
1593{
1595 TDirectory *d;
1596 TIter next(GetListOfFiles());
1597 while ((d = (TDirectory*)next())) {
1598 // Call explicitly TDirectory::FindObject to restrict the search to the
1599 // already in memory object.
1600 TObject *obj = d->TDirectory::FindObject(name);
1601 if (obj) return obj;
1602 }
1603 return nullptr;
1604}
1605
1606////////////////////////////////////////////////////////////////////////////////
1607/// Returns class name of a ROOT object including CINT globals.
1608
1609const char *TROOT::FindObjectClassName(const char *name) const
1610{
1611 // Search first in the list of "standard" objects
1612 TObject *obj = FindObject(name);
1613 if (obj) return obj->ClassName();
1614
1615 // Is it a global variable?
1616 TGlobal *g = GetGlobal(name);
1617 if (g) return g->GetTypeName();
1618
1619 return nullptr;
1620}
1621
1622////////////////////////////////////////////////////////////////////////////////
1623/// Return path name of obj somewhere in the //root/... path.
1624/// The function returns the first occurrence of the object in the list
1625/// of folders. The returned string points to a static char array in TROOT.
1626/// If this function is called in a loop or recursively, it is the
1627/// user's responsibility to copy this string in their area.
1628
1629const char *TROOT::FindObjectPathName(const TObject *) const
1630{
1631 Error("FindObjectPathName","Not yet implemented");
1632 return "??";
1633}
1634
1635////////////////////////////////////////////////////////////////////////////////
1636/// return a TClass object corresponding to 'name' assuming it is an STL container.
1637/// In particular we looking for possible alternative name (default template
1638/// parameter, typedefs template arguments, typedefed name).
1639
1641{
1642 // Example of inputs are
1643 // vector<int> (*)
1644 // vector<Int_t>
1645 // vector<long long>
1646 // vector<Long_64_t> (*)
1647 // vector<int, allocator<int> >
1648 // vector<Int_t, allocator<int> >
1649 //
1650 // One of the possibly expensive operation is the resolving of the typedef
1651 // which can provoke the parsing of the header files (and/or the loading
1652 // of clang pcms information).
1653
1655
1656 // Remove std::, allocator, typedef, add Long64_t, etc. in just one call.
1657 std::string normalized;
1659
1660 TClass *cl = nullptr;
1661 if (normalized != name) cl = TClass::GetClass(normalized.c_str(),load,silent);
1662
1663 if (load && cl==nullptr) {
1664 // Create an Emulated class for this container.
1665 cl = gInterpreter->GenerateTClass(normalized.c_str(), kTRUE, silent);
1666 }
1667
1668 return cl;
1669}
1670
1671////////////////////////////////////////////////////////////////////////////////
1672/// Return pointer to class with name. Obsolete, use TClass::GetClass directly
1673
1674TClass *TROOT::GetClass(const char *name, Bool_t load, Bool_t silent) const
1675{
1676 return TClass::GetClass(name,load,silent);
1677}
1678
1679
1680////////////////////////////////////////////////////////////////////////////////
1681/// Return pointer to class from its name. Obsolete, use TClass::GetClass directly
1682/// See TClass::GetClass
1683
1684TClass *TROOT::GetClass(const std::type_info& typeinfo, Bool_t load, Bool_t silent) const
1685{
1686 return TClass::GetClass(typeinfo,load,silent);
1687}
1688
1689////////////////////////////////////////////////////////////////////////////////
1690/// Return address of color with index color.
1691
1693{
1696 if (!lcolors) return nullptr;
1697 if (color < 0 || color >= lcolors->GetSize()) return nullptr;
1698 TColor *col = (TColor*)lcolors->At(color);
1699 if (col && col->GetNumber() == color) return col;
1700 TIter next(lcolors);
1701 while ((col = (TColor *) next()))
1702 if (col->GetNumber() == color) return col;
1703
1704 return nullptr;
1705}
1706
1707////////////////////////////////////////////////////////////////////////////////
1708/// Return a default canvas.
1709
1711{
1712 return (TCanvas*)gROOT->ProcessLine("TCanvas::MakeDefCanvas();");
1713}
1714
1715////////////////////////////////////////////////////////////////////////////////
1716/// Return pointer to type with name.
1717
1718TDataType *TROOT::GetType(const char *name, Bool_t /* load */) const
1719{
1720 return (TDataType*)gROOT->GetListOfTypes()->FindObject(name);
1721}
1722
1723////////////////////////////////////////////////////////////////////////////////
1724/// Return pointer to file with name.
1725
1726TFile *TROOT::GetFile(const char *name) const
1727{
1729 return (TFile*)GetListOfFiles()->FindObject(name);
1730}
1731
1732////////////////////////////////////////////////////////////////////////////////
1733/// Return pointer to style with name
1734
1735TStyle *TROOT::GetStyle(const char *name) const
1736{
1738}
1739
1740////////////////////////////////////////////////////////////////////////////////
1741/// Return pointer to function with name.
1742
1744{
1745 if (!name || !*name)
1746 return nullptr;
1747
1748 static std::atomic<bool> isInited = false;
1749
1750 // Capture the state before calling FindObject as it could change
1751 // between the end of FindObject and the if statement
1752 bool wasInited = isInited.load();
1753
1754 auto f1 = fFunctions->FindObject(name);
1755 if (f1 || wasInited)
1756 return f1;
1757
1758 // If 2 threads gets here at the same time, the static initialization "lock"
1759 // will stall one of them until ProcessLine is finished and both will return the
1760 // correct answer.
1761 // Note: if one (or more) thread(s) is suspended right after the 'isInited.load()`
1762 // and restart after this thread has finished the initialization (i.e. a rare case),
1763 // the only penalty we pay is a spurious 2nd lookup for an unknown function.
1764 [[maybe_unused]] static const auto _res = []() {
1765 gROOT->ProcessLine("TF1::InitStandardFunctions(); TF2::InitStandardFunctions(); TF3::InitStandardFunctions();");
1766 isInited = true;
1767 return true;
1768 }();
1769 return fFunctions->FindObject(name);
1770}
1771
1772////////////////////////////////////////////////////////////////////////////////
1773
1775{
1776 if (!gInterpreter) return nullptr;
1777
1779
1781}
1782
1783////////////////////////////////////////////////////////////////////////////////
1784/// Return pointer to global variable by name. If load is true force
1785/// reading of all currently defined globals from CINT (more expensive).
1786
1787TGlobal *TROOT::GetGlobal(const char *name, Bool_t load) const
1788{
1789 return (TGlobal *)gROOT->GetListOfGlobals(load)->FindObject(name);
1790}
1791
1792////////////////////////////////////////////////////////////////////////////////
1793/// Return pointer to global variable with address addr.
1794
1795TGlobal *TROOT::GetGlobal(const TObject *addr, Bool_t /* load */) const
1796{
1797 if (addr == nullptr || ((Longptr_t)addr) == -1) return nullptr;
1798
1799 TInterpreter::DeclId_t decl = gInterpreter->GetDataMemberAtAddr(addr);
1800 if (decl) {
1801 TListOfDataMembers *globals = ((TListOfDataMembers*)(gROOT->GetListOfGlobals(kFALSE)));
1802 return (TGlobal*)globals->Get(decl);
1803 }
1804 // If we are actually looking for a global that is held by a global
1805 // pointer (for example gRandom), we need to find a pointer with the
1806 // correct value.
1807 decl = gInterpreter->GetDataMemberWithValue(addr);
1808 if (decl) {
1809 TListOfDataMembers *globals = ((TListOfDataMembers*)(gROOT->GetListOfGlobals(kFALSE)));
1810 return (TGlobal*)globals->Get(decl);
1811 }
1812 return nullptr;
1813}
1814
1815////////////////////////////////////////////////////////////////////////////////
1816/// Internal routine returning, and creating if necessary, the list
1817/// of global function.
1818
1824
1825////////////////////////////////////////////////////////////////////////////////
1826/// Return the collection of functions named "name".
1827
1829{
1830 return ((TListOfFunctions*)fGlobalFunctions)->GetListForObject(name);
1831}
1832
1833////////////////////////////////////////////////////////////////////////////////
1834/// Return pointer to global function by name.
1835/// If params != 0 it will also resolve overloading other it returns the first
1836/// name match.
1837/// If params == 0 and load is true force reading of all currently defined
1838/// global functions from Cling.
1839/// The param string must be of the form: "3189,\"aap\",1.3".
1840
1841TFunction *TROOT::GetGlobalFunction(const char *function, const char *params,
1842 Bool_t load)
1843{
1844 if (!params) {
1846 return (TFunction *)GetListOfGlobalFunctions(load)->FindObject(function);
1847 } else {
1848 if (!fInterpreter)
1849 Fatal("GetGlobalFunction", "fInterpreter not initialized");
1850
1852 TInterpreter::DeclId_t decl = gInterpreter->GetFunctionWithValues(nullptr,
1853 function, params,
1854 false);
1855
1856 if (!decl) return nullptr;
1857
1859 if (f) return f;
1860
1861 Error("GetGlobalFunction",
1862 "\nDid not find matching TFunction <%s> with \"%s\".",
1863 function,params);
1864 return nullptr;
1865 }
1866}
1867
1868////////////////////////////////////////////////////////////////////////////////
1869/// Return pointer to global function by name. If proto != 0
1870/// it will also resolve overloading. If load is true force reading
1871/// of all currently defined global functions from CINT (more expensive).
1872/// The proto string must be of the form: "int, char*, float".
1873
1875 const char *proto, Bool_t load)
1876{
1877 if (!proto) {
1879 return (TFunction *)GetListOfGlobalFunctions(load)->FindObject(function);
1880 } else {
1881 if (!fInterpreter)
1882 Fatal("GetGlobalFunctionWithPrototype", "fInterpreter not initialized");
1883
1885 TInterpreter::DeclId_t decl = gInterpreter->GetFunctionWithPrototype(nullptr,
1886 function, proto);
1887
1888 if (!decl) return nullptr;
1889
1891 if (f) return f;
1892
1893 Error("GetGlobalFunctionWithPrototype",
1894 "\nDid not find matching TFunction <%s> with \"%s\".",
1895 function,proto);
1896 return nullptr;
1897 }
1898}
1899
1900////////////////////////////////////////////////////////////////////////////////
1901/// Return pointer to Geometry with name
1902
1904{
1906}
1907
1908////////////////////////////////////////////////////////////////////////////////
1909
1911{
1912 if(!fEnums.load()) {
1914 // Test again just in case, another thread did the work while we were
1915 // waiting.
1916 if (!fEnums.load()) fEnums = new TListOfEnumsWithLock(nullptr);
1917 }
1918 if (load) {
1920 (*fEnums).Load(); // Refresh the list of enums.
1921 }
1922 return fEnums.load();
1923}
1924
1925////////////////////////////////////////////////////////////////////////////////
1926
1935
1936////////////////////////////////////////////////////////////////////////////////
1937/// Return list containing the TGlobals currently defined.
1938/// Since globals are created and deleted during execution of the
1939/// program, we need to update the list of globals every time we
1940/// execute this method. However, when calling this function in
1941/// a (tight) loop where no interpreter symbols will be created
1942/// you can set load=kFALSE (default).
1943
1945{
1946 if (!fGlobals) {
1948 // We add to the list the "funcky-fake" globals.
1949
1950 // provide special functor for gROOT, while ROOT::GetROOT() does not return reference
1951 TGlobalMappedFunction::MakeFunctor("gROOT", "TROOT*", ROOT::GetROOT, [] {
1952 ROOT::GetROOT();
1953 return (void *)&ROOT::Internal::gROOTLocal;
1954 });
1955
1957 TGlobalMappedFunction::MakeFunctor("gVirtualX", "TVirtualX*", TVirtualX::Instance);
1959
1960 // Don't let TGlobalMappedFunction delete our globals, now that we take them.
1964 }
1965
1966 if (!fInterpreter)
1967 Fatal("GetListOfGlobals", "fInterpreter not initialized");
1968
1969 if (load) fGlobals->Load();
1970
1971 return fGlobals;
1972}
1973
1974////////////////////////////////////////////////////////////////////////////////
1975/// Return list containing the TFunctions currently defined.
1976/// Since functions are created and deleted during execution of the
1977/// program, we need to update the list of functions every time we
1978/// execute this method. However, when calling this function in
1979/// a (tight) loop where no interpreter symbols will be created
1980/// you can set load=kFALSE (default).
1981
1983{
1985
1986 if (!fGlobalFunctions) {
1987 fGlobalFunctions = new TListOfFunctions(nullptr);
1988 }
1989
1990 if (!fInterpreter)
1991 Fatal("GetListOfGlobalFunctions", "fInterpreter not initialized");
1992
1993 // A thread that calls with load==true and a thread that calls with load==false
1994 // will conflict here (the load==true will be updating the list while the
1995 // other is reading it). To solve the problem, we could use a read-write lock
1996 // inside the list itself.
1997 if (load) fGlobalFunctions->Load();
1998
1999 return fGlobalFunctions;
2000}
2001
2002////////////////////////////////////////////////////////////////////////////////
2003/// Return a dynamic list giving access to all TDataTypes (typedefs)
2004/// currently defined.
2005///
2006/// The list is populated on demand. Calling
2007/// ~~~ {.cpp}
2008/// gROOT->GetListOfTypes()->FindObject(nameoftype);
2009/// ~~~
2010/// will return the TDataType corresponding to 'nameoftype'. If the
2011/// TDataType is not already in the list itself and the type does exist,
2012/// a new TDataType will be created and added to the list.
2013///
2014/// Calling
2015/// ~~~ {.cpp}
2016/// gROOT->GetListOfTypes()->ls(); // or Print()
2017/// ~~~
2018/// list only the typedefs that have been previously accessed through the
2019/// list (plus the builtins types).
2020
2022{
2023 if (!fInterpreter)
2024 Fatal("GetListOfTypes", "fInterpreter not initialized");
2025
2026 return fTypes;
2027}
2028
2029////////////////////////////////////////////////////////////////////////////////
2030/// Get number of classes.
2031
2033{
2034 return fClasses->GetSize();
2035}
2036
2037////////////////////////////////////////////////////////////////////////////////
2038/// Get number of types.
2039
2041{
2042 return fTypes->GetSize();
2043}
2044
2045////////////////////////////////////////////////////////////////////////////////
2046/// Execute command when system has been idle for idleTimeInSec seconds.
2047
2049{
2050 if (!fApplication.load())
2052
2053 if (idleTimeInSec <= 0)
2054 (*fApplication).RemoveIdleTimer();
2055 else
2056 (*fApplication).SetIdleTimer(idleTimeInSec, command);
2057}
2058
2059////////////////////////////////////////////////////////////////////////////////
2060/// Check whether className is a known class, and only autoload
2061/// if we can. Helper function for TROOT::IgnoreInclude().
2062
2063static TClass* R__GetClassIfKnown(const char* className)
2064{
2065 // Check whether the class is available for auto-loading first:
2066 const char* libsToLoad = gInterpreter->GetClassSharedLibs(className);
2067 TClass* cla = nullptr;
2068 if (libsToLoad) {
2069 // trigger autoload, and only create TClass in this case.
2070 return TClass::GetClass(className);
2071 } else if (gROOT->GetListOfClasses()
2072 && (cla = (TClass*)gROOT->GetListOfClasses()->FindObject(className))) {
2073 // cla assigned in if statement
2074 } else if (gClassTable->FindObject(className)) {
2075 return TClass::GetClass(className);
2076 }
2077 return cla;
2078}
2079
2080////////////////////////////////////////////////////////////////////////////////
2081/// Return 1 if the name of the given include file corresponds to a class that
2082/// is known to ROOT, e.g. "TLorentzVector.h" versus TLorentzVector.
2083
2084Int_t TROOT::IgnoreInclude(const char *fname, const char * /*expandedfname*/)
2085{
2086 if (fname == nullptr) return 0;
2087
2089 // Remove extension if any, ignore files with extension not being .h*
2090 Int_t where = stem.Last('.');
2091 if (where != kNPOS) {
2092 if (stem.EndsWith(".so") || stem.EndsWith(".sl") ||
2093 stem.EndsWith(".dl") || stem.EndsWith(".a") ||
2094 stem.EndsWith(".dll", TString::kIgnoreCase))
2095 return 0;
2096 stem.Remove(where);
2097 }
2098
2099 TString className = gSystem->BaseName(stem);
2100 TClass* cla = R__GetClassIfKnown(className);
2101 if (!cla) {
2102 // Try again with modifications to the file name:
2103 className = stem;
2104 className.ReplaceAll("/", "::");
2105 className.ReplaceAll("\\", "::");
2106 if (className.Contains(":::")) {
2107 // "C:\dir" becomes "C:::dir".
2108 // fname corresponds to whatever is stated after #include and
2109 // a full path name usually means that it's not a regular #include
2110 // but e.g. a ".L", so we can assume that this is not a header of
2111 // a class in a namespace (a global-namespace class would have been
2112 // detected already before).
2113 return 0;
2114 }
2115 cla = R__GetClassIfKnown(className);
2116 }
2117
2118 if (!cla) {
2119 return 0;
2120 }
2121
2122 // cla is valid, check wether it's actually in the header of the same name:
2123 if (cla->GetDeclFileLine() <= 0) return 0; // to a void an error with VisualC++
2124 TString decfile = gSystem->BaseName(cla->GetDeclFileName());
2125 if (decfile != gSystem->BaseName(fname)) {
2126 return 0;
2127 }
2128 return 1;
2129}
2130
2131////////////////////////////////////////////////////////////////////////////////
2132/// Initialize operating system interface.
2133
2135{
2136 if (gSystem == nullptr) {
2137#if defined(R__UNIX)
2138#if defined(R__HAS_COCOA)
2139 gSystem = new TMacOSXSystem;
2140#else
2141 gSystem = new TUnixSystem;
2142#endif
2143#elif defined(R__WIN32)
2144 gSystem = new TWinNTSystem;
2145#else
2146 gSystem = new TSystem;
2147#endif
2148
2149 if (gSystem->Init())
2150 fprintf(stderr, "Fatal in <TROOT::InitSystem>: can't init operating system layer\n");
2151
2152 gSystem->SetIncludePath(("-I" + GetIncludeDir()).Data());
2153
2154 if (!gSystem->HomeDirectory()) {
2155 fprintf(stderr, "Fatal in <TROOT::InitSystem>: HOME directory not set\n");
2156 fprintf(stderr, "Fix this by defining the HOME shell variable\n");
2157 }
2158
2159 // read default files
2160 gEnv = new TEnv(".rootrc");
2161
2164
2165 gDebug = gEnv->GetValue("Root.Debug", 0);
2166
2167 if (!gEnv->GetValue("Root.ErrorHandlers", 1))
2169
2170 // The old "Root.ZipMode" had a discrepancy between documentation vs actual meaning.
2171 // Also, a value with the meaning "default" wasn't available. To solved this,
2172 // "Root.ZipMode" was replaced by "Root.CompressionAlgorithm". Warn about usage of
2173 // the old value, if it's set to 0, but silently translate the setting to
2174 // "Root.CompressionAlgorithm" for values > 1.
2175 Int_t oldzipmode = gEnv->GetValue("Root.ZipMode", -1);
2176 if (oldzipmode == 0) {
2177 fprintf(stderr, "Warning in <TROOT::InitSystem>: ignoring old rootrc entry \"Root.ZipMode = 0\"!\n");
2178 } else {
2179 if (oldzipmode == -1 || oldzipmode == 1) {
2180 // Not set or default value, use "default" for "Root.CompressionAlgorithm":
2181 oldzipmode = 0;
2182 }
2183 // else keep the old zipmode (e.g. "3") as "Root.CompressionAlgorithm"
2184 // if "Root.CompressionAlgorithm" isn't set; see below.
2185 }
2186
2187 Int_t zipmode = gEnv->GetValue("Root.CompressionAlgorithm", oldzipmode);
2188 if (zipmode != 0) R__SetZipMode(zipmode);
2189
2190 const char *sdeb;
2191 if ((sdeb = gSystem->Getenv("ROOTDEBUG")))
2192 gDebug = atoi(sdeb);
2193
2194 if (gDebug > 0 && isatty(2))
2195 fprintf(stderr, "Info in <TROOT::InitSystem>: running with gDebug = %d\n", gDebug);
2196
2197#if defined(R__HAS_COCOA)
2198 // create and delete a dummy TUrl so that TObjectStat table does not contain
2199 // objects that are deleted after recording is turned-off (in next line),
2200 // like the TUrl::fgSpecialProtocols list entries which are created in the
2201 // TMacOSXSystem ctor.
2202 { TUrl dummy("/dummy"); }
2203#endif
2204 TObject::SetObjectStat(gEnv->GetValue("Root.ObjectStat", 0));
2205 }
2206}
2207
2208////////////////////////////////////////////////////////////////////////////////
2209/// Load and initialize thread library.
2210
2212{
2213 if (gEnv->GetValue("Root.UseThreads", 0) || gEnv->GetValue("Root.EnableThreadSafety", 0)) {
2215 }
2216}
2217
2218////////////////////////////////////////////////////////////////////////////////
2219/// Initialize the interpreter. Should be called only after main(),
2220/// to make sure LLVM/Clang is fully initialized.
2221/// This function must be called in a single thread context (static initialization)
2222
2224{
2225 // usedToIdentifyRootClingByDlSym is available when TROOT is part of
2226 // rootcling.
2227 if (!dlsym(RTLD_DEFAULT, "usedToIdentifyRootClingByDlSym")
2228 && !dlsym(RTLD_DEFAULT, "usedToIdentifyStaticRoot")) {
2229 char *libRIO = gSystem->DynamicPathName("libRIO");
2231 delete [] libRIO;
2232 if (!libRIOHandle) {
2233 TString err = dlerror();
2234 fprintf(stderr, "Fatal in <TROOT::InitInterpreter>: cannot load library %s\n", err.Data());
2235 exit(1);
2236 }
2237
2238 char *libcling = gSystem->DynamicPathName("libCling");
2240 delete [] libcling;
2241
2242 if (!gInterpreterLib) {
2243 TString err = dlerror();
2244 fprintf(stderr, "Fatal in <TROOT::InitInterpreter>: cannot load library %s\n", err.Data());
2245 exit(1);
2246 }
2247 dlerror(); // reset error message
2248 } else {
2250 }
2252 if (!CreateInterpreter) {
2253 TString err = dlerror();
2254 fprintf(stderr, "Fatal in <TROOT::InitInterpreter>: cannot load symbol %s\n", err.Data());
2255 exit(1);
2256 }
2257 // Schedule the destruction of TROOT.
2259
2261 if (!gDestroyInterpreter) {
2262 TString err = dlerror();
2263 fprintf(stderr, "Fatal in <TROOT::InitInterpreter>: cannot load symbol %s\n", err.Data());
2264 exit(1);
2265 }
2266
2267 const char *interpArgs[] = {
2268#ifdef NDEBUG
2269 "-DNDEBUG",
2270#else
2271 "-UNDEBUG",
2272#endif
2273#ifdef DEBUG
2274 "-DDEBUG",
2275#else
2276 "-UDEBUG",
2277#endif
2278#ifdef _DEBUG
2279 "-D_DEBUG",
2280#else
2281 "-U_DEBUG",
2282#endif
2283 nullptr};
2284
2286
2289
2290 fgRootInit = kTRUE;
2291
2292 // initialize gClassTable is not already done
2293 if (!gClassTable)
2294 new TClassTable;
2295
2296 // Initialize all registered dictionaries.
2297 for (std::vector<ModuleHeaderInfo_t>::const_iterator
2298 li = GetModuleHeaderInfoBuffer().begin(),
2299 le = GetModuleHeaderInfoBuffer().end(); li != le; ++li) {
2300 // process buffered module registrations
2301 fInterpreter->RegisterModule(li->fModuleName,
2302 li->fHeaders,
2303 li->fIncludePaths,
2304 li->fPayloadCode,
2305 li->fFwdDeclCode,
2306 li->fTriggerFunc,
2307 li->fFwdNargsToKeepColl,
2308 li->fClassesHeaders,
2309 kTRUE /*lateRegistration*/,
2310 li->fHasCxxModule);
2311 }
2312 GetModuleHeaderInfoBuffer().clear();
2313
2315}
2316
2317////////////////////////////////////////////////////////////////////////////////
2318/// Helper function used by TClass::GetClass().
2319/// This function attempts to load the dictionary for 'classname'
2320/// either from the TClassTable or from the list of generator.
2321/// If silent is 'true', do not warn about missing dictionary for the class.
2322/// (typically used for class that are used only for transient members)
2323///
2324/// The 'requestedname' is expected to be already normalized.
2325
2330
2331////////////////////////////////////////////////////////////////////////////////
2332/// Check if class "classname" is known to the interpreter (in fact,
2333/// this check is not needed anymore, so classname is ignored). If
2334/// not it will load library "libname". If the library couldn't be found with original
2335/// libname and if the name was not prefixed with lib, try to prefix with "lib" and search again.
2336/// If DynamicPathName still couldn't find the library, return -1.
2337/// If check is true it will only check if libname exists and is
2338/// readable.
2339/// Returns 0 on successful loading, -1 in case libname does not
2340/// exist or in case of error and -2 in case of version mismatch.
2341
2342Int_t TROOT::LoadClass(const char * /*classname*/, const char *libname,
2343 Bool_t check)
2344{
2345 TString lib(libname);
2346
2347 // Check if libname exists in path or not
2348 if (char *path = gSystem->DynamicPathName(lib, kTRUE)) {
2349 // If check == true, only check if it exists and if it's readable
2350 if (check) {
2351 delete [] path;
2352 return 0;
2353 }
2354
2355 // If check == false, try to load the library
2356 else {
2357 int err = gSystem->Load(path, nullptr, kTRUE);
2358 delete [] path;
2359
2360 // TSystem::Load returns 1 when the library was already loaded, return success in this case.
2361 if (err == 1)
2362 err = 0;
2363 if (err == 0)
2364 // Register the Autoloading of the library
2366 return err;
2367 }
2368 } else {
2369 // This is the branch where libname didn't exist
2370 if (check) {
2371 FileStat_t stat;
2372 if (!gSystem->GetPathInfo(libname, stat) && (R_ISREG(stat.fMode) &&
2374 return 0;
2375 }
2376
2377 // Take care of user who didn't write the whole name
2378 if (!lib.BeginsWith("lib")) {
2379 lib = "lib" + lib;
2380 return LoadClass("", lib.Data(), check);
2381 }
2382 }
2383
2384 // Execution reaches here when library was prefixed with lib, check is false and couldn't find
2385 // the library name.
2386 return -1;
2387}
2388
2389////////////////////////////////////////////////////////////////////////////////
2390/// Return true if the file is local and is (likely) to be a ROOT file
2391
2393{
2396 if (mayberootfile) {
2397 char header[5];
2398 if (fgets(header,5,mayberootfile)) {
2399 result = strncmp(header,"root",4)==0;
2400 }
2402 }
2403 return result;
2404}
2405
2406////////////////////////////////////////////////////////////////////////////////
2407/// To list all objects of the application.
2408/// Loop on all objects created in the ROOT linked lists.
2409/// Objects may be files and windows or any other object directly
2410/// attached to the ROOT linked list.
2411
2413{
2414// TObject::SetDirLevel();
2415// GetList()->R__FOR_EACH(TObject,ls)(option);
2417}
2418
2419////////////////////////////////////////////////////////////////////////////////
2420/// Load a macro in the interpreter's memory. Equivalent to the command line
2421/// command ".L filename". If the filename has "+" or "++" appended
2422/// the macro will be compiled by ACLiC. The filename must have the format:
2423/// [path/]macro.C[+|++[g|O]].
2424/// The possible error codes are defined by TInterpreter::EErrorCode.
2425/// If check is true it will only check if filename exists and is
2426/// readable.
2427/// Returns 0 on successful loading and -1 in case filename does not
2428/// exist or in case of error.
2429
2430Int_t TROOT::LoadMacro(const char *filename, int *error, Bool_t check)
2431{
2432 Int_t err = -1;
2433 Int_t lerr, *terr;
2434 if (error)
2435 terr = error;
2436 else
2437 terr = &lerr;
2438
2439 if (fInterpreter) {
2441 TString arguments;
2442 TString io;
2444
2445 if (arguments.Length()) {
2446 Warning("LoadMacro", "argument(%s) ignored in %s", arguments.Data(), GetMacroPath());
2447 }
2449 if (!mac) {
2450 if (!check)
2451 Error("LoadMacro", "macro %s not found in path %s", fname.Data(), GetMacroPath());
2453 } else {
2454 err = 0;
2455 if (!check) {
2456 fname = mac;
2457 fname += aclicMode;
2458 fname += io;
2459 gInterpreter->LoadMacro(fname.Data(), (TInterpreter::EErrorCode*)terr);
2460 if (*terr)
2461 err = -1;
2462 }
2463 }
2464 delete [] mac;
2465 }
2466 return err;
2467}
2468
2469////////////////////////////////////////////////////////////////////////////////
2470/// Execute a macro in the interpreter. Equivalent to the command line
2471/// command ".x filename". If the filename has "+" or "++" appended
2472/// the macro will be compiled by ACLiC. The filename must have the format:
2473/// [path/]macro.C[+|++[g|O]][(args)].
2474/// The possible error codes are defined by TInterpreter::EErrorCode.
2475/// If padUpdate is true (default) update the current pad.
2476/// Returns the macro return value.
2477
2479{
2480 Longptr_t result = 0;
2481
2482 if (fInterpreter) {
2484 TString arguments;
2485 TString io;
2487
2489 if (!mac) {
2490 Error("Macro", "macro %s not found in path %s", fname.Data(), GetMacroPath());
2491 if (error)
2492 *error = TInterpreter::kFatal;
2493 } else {
2494 fname = mac;
2495 fname += aclicMode;
2496 fname += arguments;
2497 fname += io;
2498 result = gInterpreter->ExecuteMacro(fname, (TInterpreter::EErrorCode*)error);
2499 }
2500 delete [] mac;
2501
2502 if (padUpdate && gPad)
2503 gPad->Update();
2504 }
2505
2506 return result;
2507}
2508
2509////////////////////////////////////////////////////////////////////////////////
2510/// Process message id called by obj.
2511
2512void TROOT::Message(Int_t id, const TObject *obj)
2513{
2514 TIter next(fMessageHandlers);
2516 while ((mh = (TMessageHandler*)next())) {
2517 mh->HandleMessage(id,obj);
2518 }
2519}
2520
2521////////////////////////////////////////////////////////////////////////////////
2522/// Process interpreter command via TApplication::ProcessLine().
2523/// On Win32 the line will be processed asynchronously by sending
2524/// it to the CINT interpreter thread. For explicit synchronous processing
2525/// use ProcessLineSync(). On non-Win32 platforms there is no difference
2526/// between ProcessLine() and ProcessLineSync().
2527/// The possible error codes are defined by TInterpreter::EErrorCode. In
2528/// particular, error will equal to TInterpreter::kProcessing until the
2529/// CINT interpreted thread has finished executing the line.
2530/// Returns the result of the command, cast to a Longptr_t.
2531
2533{
2534 TString sline = line;
2535 sline = sline.Strip(TString::kBoth);
2536
2537 if (!fApplication.load())
2539
2540 return (*fApplication).ProcessLine(sline, kFALSE, error);
2541}
2542
2543////////////////////////////////////////////////////////////////////////////////
2544/// Process interpreter command via TApplication::ProcessLine().
2545/// On Win32 the line will be processed synchronously (i.e. it will
2546/// only return when the CINT interpreter thread has finished executing
2547/// the line). On non-Win32 platforms there is no difference between
2548/// ProcessLine() and ProcessLineSync().
2549/// The possible error codes are defined by TInterpreter::EErrorCode.
2550/// Returns the result of the command, cast to a Longptr_t.
2551
2553{
2554 TString sline = line;
2555 sline = sline.Strip(TString::kBoth);
2556
2557 if (!fApplication.load())
2559
2560 return (*fApplication).ProcessLine(sline, kTRUE, error);
2561}
2562
2563////////////////////////////////////////////////////////////////////////////////
2564/// Process interpreter command directly via CINT interpreter.
2565/// Only executable statements are allowed (no variable declarations),
2566/// In all other cases use TROOT::ProcessLine().
2567/// The possible error codes are defined by TInterpreter::EErrorCode.
2568
2570{
2571 TString sline = line;
2572 sline = sline.Strip(TString::kBoth);
2573
2574 if (!fApplication.load())
2576
2577 Longptr_t result = 0;
2578
2579 if (fInterpreter) {
2581 result = gInterpreter->Calc(sline, code);
2582 }
2583
2584 return result;
2585}
2586
2587////////////////////////////////////////////////////////////////////////////////
2588/// Read Git commit information and branch name from the
2589/// etc/gitinfo.txt file.
2590
2592{
2593 TString filename = "gitinfo.txt";
2595
2596 FILE *fp = fopen(filename, "r");
2597 if (fp) {
2598 TString s;
2599 // read branch name
2600 s.Gets(fp);
2601 fGitBranch = s;
2602 // read commit hash
2603 s.Gets(fp);
2604 fGitCommit = s;
2605 // read date/time make was run
2606 s.Gets(fp);
2607 fGitDate = s;
2608 fclose(fp);
2609 } else {
2610 Error("ReadGitInfo()", "Cannot determine git info: etc/gitinfo.txt not found!");
2611 }
2612}
2613
2618
2619////////////////////////////////////////////////////////////////////////////////
2620/// Deprecated (will be removed in next release).
2621
2623{
2624 return GetReadingObject();
2625}
2626
2631
2632
2633////////////////////////////////////////////////////////////////////////////////
2634/// Return date/time make was run.
2635
2637{
2638 if (fGitDate == "") {
2640 static const char *months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
2641 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
2642 Int_t idate = gROOT->GetBuiltDate();
2643 Int_t itime = gROOT->GetBuiltTime();
2644 iday = idate%100;
2645 imonth = (idate/100)%100;
2646 iyear = idate/10000;
2647 ihour = itime/100;
2648 imin = itime%100;
2649 fGitDate.Form("%s %02d %4d, %02d:%02d:00", months[imonth-1], iday, iyear, ihour, imin);
2650 }
2651 return fGitDate;
2652}
2653
2654////////////////////////////////////////////////////////////////////////////////
2655/// Recursively remove this object from the list of Cleanups.
2656/// Typically RecursiveRemove is implemented by classes that can contain
2657/// mulitple references to a same object or shared ownership of the object
2658/// with others.
2659
2666
2667////////////////////////////////////////////////////////////////////////////////
2668/// Refresh all browsers. Call this method when some command line
2669/// command or script has changed the browser contents. Not needed
2670/// for objects that have the kMustCleanup bit set. Most useful to
2671/// update browsers that show the file system or other objects external
2672/// to the running ROOT session.
2673
2675{
2676 TIter next(GetListOfBrowsers());
2677 TBrowser *b;
2678 while ((b = (TBrowser*) next()))
2680}
2681////////////////////////////////////////////////////////////////////////////////
2682/// Insure that the files, canvases and sockets are closed.
2683
2684static void CallCloseFiles()
2685{
2687 gROOT->CloseFiles();
2688 }
2689}
2690
2691////////////////////////////////////////////////////////////////////////////////
2692/// Called by static dictionary initialization to register clang modules
2693/// for headers. Calls TCling::RegisterModule() unless gCling
2694/// is NULL, i.e. during startup, where the information is buffered in
2695/// the static GetModuleHeaderInfoBuffer().
2696/// The caller of this function should be holding the ROOT Write lock or be
2697/// single threaded (dlopen)
2698
2700 const char** headers,
2701 const char** includePaths,
2702 const char* payloadCode,
2703 const char* fwdDeclCode,
2704 void (*triggerFunc)(),
2706 const char** classesHeaders,
2707 bool hasCxxModule)
2708{
2709
2710 // First a side track to insure proper end of process behavior.
2711
2712 // Register for each loaded dictionary (and thus for each library),
2713 // that we need to Close the ROOT files as soon as this library
2714 // might start being unloaded after main.
2715 //
2716 // By calling atexit here (rather than directly from within the
2717 // library) we make sure that this is not called if the library is
2718 // 'only' dlclosed.
2719
2720 // On Ubuntu the linker strips the unused libraries. Eventhough
2721 // stressHistogram is explicitly linked against libNet, it is not
2722 // retained and thus is loaded only as needed in the middle part of
2723 // the execution. Concretely this also means that it is loaded
2724 // *after* the construction of the TApplication object and thus
2725 // after the registration (atexit) of the EndOfProcessCleanups
2726 // routine. Consequently, after the end of main, libNet is
2727 // unloaded before EndOfProcessCleanups is called. When
2728 // EndOfProcessCleanups is executed it indirectly needs the TClass
2729 // for TSocket and its search will use resources that have already
2730 // been unloaded (technically the function static in TUnixSystem's
2731 // DynamicPath and the dictionary from libNet).
2732
2733 // Similarly, the ordering (before this commit) was broken in the
2734 // following case:
2735
2736 // TApplication creation (EndOfProcessCleanups registration)
2737 // load UserLibrary
2738 // create TFile
2739 // Append UserObject to TFile
2740
2741 // and after the end of main the order of execution was
2742
2743 // unload UserLibrary
2744 // call EndOfProcessCleanups
2745 // Write the TFile
2746 // attempt to write the user object.
2747 // ....
2748
2749 // where what we need is to have the files closen/written before
2750 // the unloading of the library.
2751
2752 // To solve the problem we now register an atexit function for
2753 // every dictionary thus making sure there is at least one executed
2754 // before the first library tear down after main.
2755
2756 // If atexit is called directly within a library's code, the
2757 // function will called *either* when the library is 'dlclose'd or
2758 // after then end of main (whichever comes first). We do *not*
2759 // want the files to be closed whenever a library is unloaded via
2760 // dlclose. To avoid this, we add the function (CallCloseFiles)
2761 // from the dictionary indirectly (via ROOT::RegisterModule). In
2762 // this case the function will only only be called either when
2763 // libCore is 'dlclose'd or right after the end of main.
2764
2766
2767 // Now register with TCling.
2768 if (TROOT::Initialized()) {
2771 } else {
2772 GetModuleHeaderInfoBuffer().push_back(ModuleHeaderInfo_t(modulename, headers, includePaths, payloadCode,
2775 }
2776}
2777
2778////////////////////////////////////////////////////////////////////////////////
2779/// Remove an object from the in-memory list.
2780/// Since TROOT is global resource, this is lock protected.
2781
2783{
2785 return TDirectory::Remove(obj);
2786}
2787
2788////////////////////////////////////////////////////////////////////////////////
2789/// Remove a class from the list and map of classes.
2790/// This routine is deprecated, use TClass::RemoveClass directly.
2791
2796
2797////////////////////////////////////////////////////////////////////////////////
2798/// Delete all global interpreter objects created since the last call to Reset
2799///
2800/// If option="a" is set reset to startup context (i.e. unload also
2801/// all loaded files, classes, structs, typedefs, etc.).
2802///
2803/// This function is typically used at the beginning (or end) of an unnamed macro
2804/// to clean the environment.
2805///
2806/// IMPORTANT WARNING:
2807/// Do not use this call from within any function (neither compiled nor
2808/// interpreted. This should only be used from a unnamed macro
2809/// (which starts with a { (curly braces) ). For example, using TROOT::Reset
2810/// from within an interpreted function will lead to the unloading of the
2811/// dictionary and source file, including the one defining the function being
2812/// executed.
2813///
2814
2816{
2817 if (IsExecutingMacro()) return; //True when TMacro::Exec runs
2818 if (fInterpreter) {
2819 if (!strncmp(option, "a", 1)) {
2822 } else
2823 gInterpreter->ResetGlobals();
2824
2825 if (fGlobals) fGlobals->Unload();
2827
2828 SaveContext();
2829 }
2830}
2831
2832////////////////////////////////////////////////////////////////////////////////
2833/// Save the current interpreter context.
2834
2836{
2837 if (fInterpreter)
2838 gInterpreter->SaveGlobalsContext();
2839}
2840
2841////////////////////////////////////////////////////////////////////////////////
2842/// Set the default graphical cut class name for the graphics editor
2843/// By default the graphics editor creates an instance of a class TCutG.
2844/// This function may be called to specify a different class that MUST
2845/// derive from TCutG
2846
2848{
2849 if (!name) {
2850 Error("SetCutClassName","Invalid class name");
2851 return;
2852 }
2854 if (!cl) {
2855 Error("SetCutClassName","Unknown class:%s",name);
2856 return;
2857 }
2858 if (!cl->InheritsFrom("TCutG")) {
2859 Error("SetCutClassName","Class:%s does not derive from TCutG",name);
2860 return;
2861 }
2863}
2864
2865////////////////////////////////////////////////////////////////////////////////
2866/// Set editor mode
2867
2869{
2870 fEditorMode = 0;
2871 if (!mode[0]) return;
2872 if (!strcmp(mode,"Arc")) {fEditorMode = kArc; return;}
2873 if (!strcmp(mode,"Line")) {fEditorMode = kLine; return;}
2874 if (!strcmp(mode,"Arrow")) {fEditorMode = kArrow; return;}
2875 if (!strcmp(mode,"Button")) {fEditorMode = kButton; return;}
2876 if (!strcmp(mode,"Diamond")) {fEditorMode = kDiamond; return;}
2877 if (!strcmp(mode,"Ellipse")) {fEditorMode = kEllipse; return;}
2878 if (!strcmp(mode,"Pad")) {fEditorMode = kPad; return;}
2879 if (!strcmp(mode,"Pave")) {fEditorMode = kPave; return;}
2880 if (!strcmp(mode,"PaveLabel")){fEditorMode = kPaveLabel; return;}
2881 if (!strcmp(mode,"PaveText")) {fEditorMode = kPaveText; return;}
2882 if (!strcmp(mode,"PavesText")){fEditorMode = kPavesText; return;}
2883 if (!strcmp(mode,"PolyLine")) {fEditorMode = kPolyLine; return;}
2884 if (!strcmp(mode,"CurlyLine")){fEditorMode = kCurlyLine; return;}
2885 if (!strcmp(mode,"CurlyArc")) {fEditorMode = kCurlyArc; return;}
2886 if (!strcmp(mode,"Text")) {fEditorMode = kText; return;}
2887 if (!strcmp(mode,"Marker")) {fEditorMode = kMarker; return;}
2888 if (!strcmp(mode,"CutG")) {fEditorMode = kCutG; return;}
2889}
2890
2891////////////////////////////////////////////////////////////////////////////////
2892/// Change current style to style with name stylename
2893
2895{
2897
2899 if (style) style->cd();
2900 else Error("SetStyle","Unknown style:%s",style_name.Data());
2901}
2902
2903
2904//-------- Static Member Functions ---------------------------------------------
2905
2906
2907////////////////////////////////////////////////////////////////////////////////
2908/// Decrease the indentation level for ls().
2909
2911{
2912 return --fgDirLevel;
2913}
2914
2915////////////////////////////////////////////////////////////////////////////////
2916///return directory level
2917
2919{
2920 return fgDirLevel;
2921}
2922
2923////////////////////////////////////////////////////////////////////////////////
2924/// Get macro search path. Static utility function.
2925
2927{
2929
2930 if (macroPath.Length() == 0) {
2931 macroPath = gEnv->GetValue("Root.MacroPath", (char*)nullptr);
2932#if defined(R__WIN32)
2933 macroPath.ReplaceAll("; ", ";");
2934#else
2935 macroPath.ReplaceAll(": ", ":");
2936#endif
2937 if (macroPath.Length() == 0)
2938#if !defined(R__WIN32)
2939 macroPath = ".:" + TROOT::GetMacroDir();
2940#else
2941 macroPath = ".;" + TROOT::GetMacroDir();
2942#endif
2943 }
2944
2945 return macroPath;
2946}
2947
2948////////////////////////////////////////////////////////////////////////////////
2949/// Set or extend the macro search path. Static utility function.
2950/// If newpath=0 or "" reset to value specified in the rootrc file.
2951
2953{
2955
2956 if (!newpath || !*newpath)
2957 macroPath = "";
2958 else
2960}
2961
2962////////////////////////////////////////////////////////////////////////////////
2963/// Set batch mode for ROOT
2964/// If the argument evaluates to `true`, the session does not use interactive graphics.
2965/// Batch mode can also be enabled by setting the ROOT_BATCH environment variable.
2966/// If web graphics runs in server mode, the web widgets are still available via URL.
2967
2974
2975////////////////////////////////////////////////////////////////////////////////
2976/// \brief Specify where web graphics shall be rendered
2977///
2978/// The input parameter `webdisplay` defines where web graphics is rendered.
2979/// `webdisplay` parameter may contain:
2980///
2981/// - "firefox": select Mozilla Firefox browser for interactive web display
2982/// - "chrome": select Google Chrome browser for interactive web display. Can also be set to "chromium"
2983/// - "edge": select Microsoft Edge browser for interactive web display
2984/// - "native": select one of the natively-supported web browsers firefox/chrome/edge for interactive web display
2985/// - "qt6": uses QWebEngine from Qt6, no real http server started (requires `qt6web` component build for ROOT)
2986/// - "cef": uses Chromium Embeded Framework, no real http server started (requires `cefweb` component build for ROOT)
2987/// - "local": select one of available local (without http server) engines like qt6/cef
2988/// - "default": system default web browser, invoked with `xdg-open` on Linux, `start` on Mac or `open` on Windows
2989/// - "on": try "local", then "native", then "default" option
2990/// - "off": turns off the web display and comes back to normal graphics in
2991/// interactive mode.
2992/// - "server:port": turns the web display into server mode with specified port. Web widgets will not be displayed,
2993/// only text message with window URL will be printed on standard output
2994///
2995/// \note See more details related to webdisplay on RWebWindowsManager::ShowWindow
2996
2997void TROOT::SetWebDisplay(const char *webdisplay)
2998{
2999 const char *wd = webdisplay ? webdisplay : "";
3000
3001 // store default values to set them back when needed
3002 static TString canName = gEnv->GetValue("Canvas.Name", "");
3003 static TString brName = gEnv->GetValue("Browser.Name", "");
3004 static TString trName = gEnv->GetValue("TreeViewer.Name", "");
3005 static TString geomName = gEnv->GetValue("GeomPainter.Name", "");
3006
3008
3009 if (!strcmp(wd, "off")) {
3011 fWebDisplay = "off";
3012 } else {
3014
3015 // handle server mode
3016 if (!strncmp(wd, "server", 6)) {
3017 fWebDisplay = "server";
3019 if (wd[6] == ':') {
3020 if ((wd[7] >= '0') && (wd[7] <= '9')) {
3021 auto port = TString(wd+7).Atoi();
3022 if (port > 0)
3023 gEnv->SetValue("WebGui.HttpPort", port);
3024 else
3025 Error("SetWebDisplay", "Wrong port parameter %s for server", wd+7);
3026 } else if (wd[7]) {
3027 gEnv->SetValue("WebGui.UnixSocket", wd+7);
3028 }
3029 }
3030 } else {
3031 fWebDisplay = wd;
3032 }
3033 }
3034
3035 if (fIsWebDisplay) {
3036 // restore canvas and browser classes configured at the moment when gROOT->SetWebDisplay() was called for the first time
3037 // This is necessary when SetWebDisplay() called several times and therefore current settings may differ
3038 gEnv->SetValue("Canvas.Name", canName);
3039 gEnv->SetValue("Browser.Name", brName);
3040 gEnv->SetValue("TreeViewer.Name", trName);
3041 gEnv->SetValue("GeomPainter.Name", geomName);
3042 } else {
3043 gEnv->SetValue("Canvas.Name", "TRootCanvas");
3044 gEnv->SetValue("Browser.Name", "TRootBrowser");
3045 gEnv->SetValue("TreeViewer.Name", "TTreeViewer");
3046 gEnv->SetValue("GeomPainter.Name", "root");
3047 }
3048}
3049
3050////////////////////////////////////////////////////////////////////////////////
3051/// Increase the indentation level for ls().
3052
3054{
3055 return ++fgDirLevel;
3056}
3057
3058////////////////////////////////////////////////////////////////////////////////
3059/// Functions used by ls() to indent an object hierarchy.
3060
3062{
3063 for (int i = 0; i < fgDirLevel; i++) std::cout.put(' ');
3064}
3065
3066////////////////////////////////////////////////////////////////////////////////
3067/// Initialize ROOT explicitly.
3068
3070 (void) gROOT;
3071}
3072
3073////////////////////////////////////////////////////////////////////////////////
3074/// Return kTRUE if the TROOT object has been initialized.
3075
3077{
3078 return fgRootInit;
3079}
3080
3081////////////////////////////////////////////////////////////////////////////////
3082/// Return Indentation level for ls().
3083
3085{
3086 fgDirLevel = level;
3087}
3088
3089////////////////////////////////////////////////////////////////////////////////
3090/// Convert version code to an integer, i.e. 331527 -> 51507.
3091
3093{
3094 return 10000*(code>>16) + 100*((code&65280)>>8) + (code&255);
3095}
3096
3097////////////////////////////////////////////////////////////////////////////////
3098/// Convert version as an integer to version code as used in RVersion.h.
3099
3101{
3102 int a = v/10000;
3103 int b = (v - a*10000)/100;
3104 int c = v - a*10000 - b*100;
3105 return (a << 16) + (b << 8) + c;
3106}
3107
3108////////////////////////////////////////////////////////////////////////////////
3109/// Return ROOT version code as defined in RVersion.h.
3110
3115////////////////////////////////////////////////////////////////////////////////
3116/// Provide command line arguments to the interpreter construction.
3117/// These arguments are added to the existing flags (e.g. `-DNDEBUG`).
3118/// They are evaluated once per process, at the time where TROOT (and thus
3119/// TInterpreter) is constructed.
3120/// Returns the new flags.
3121
3122const std::vector<std::string> &TROOT::AddExtraInterpreterArgs(const std::vector<std::string> &args) {
3123 static std::vector<std::string> sArgs = {};
3124 sArgs.insert(sArgs.begin(), args.begin(), args.end());
3125 return sArgs;
3126}
3127
3128////////////////////////////////////////////////////////////////////////////////
3129/// INTERNAL function!
3130/// Used by rootcling to inject interpreter arguments through a C-interface layer.
3131
3133 static const char** extraInterpArgs = nullptr;
3134 return extraInterpArgs;
3135}
3136
3137////////////////////////////////////////////////////////////////////////////////
3138
3139#ifdef ROOTPREFIX
3140static Bool_t IgnorePrefix() {
3141 static Bool_t ignorePrefix = gSystem->Getenv("ROOTIGNOREPREFIX");
3142 return ignorePrefix;
3143}
3144#endif
3145
3146////////////////////////////////////////////////////////////////////////////////
3147/// Get the rootsys directory in the installation. Static utility function.
3148
3150 // Avoid returning a reference to a temporary because of the conversion
3151 // between std::string and TString.
3153 return rootsys;
3154}
3155
3156////////////////////////////////////////////////////////////////////////////////
3157/// Get the binary directory in the installation. Static utility function.
3158
3160#ifdef ROOTBINDIR
3161 if (IgnorePrefix()) {
3162#endif
3163 static TString rootbindir;
3164 if (rootbindir.IsNull()) {
3165 rootbindir = "bin";
3167 }
3168 return rootbindir;
3169#ifdef ROOTBINDIR
3170 } else {
3171 const static TString rootbindir = ROOTBINDIR;
3172 return rootbindir;
3173 }
3174#endif
3175}
3176
3177////////////////////////////////////////////////////////////////////////////////
3178/// Get the library directory in the installation. Static utility function.
3179///
3180/// By default, this is just an alias for TROOT::GetSharedLibDir(), which
3181/// returns the directory containing the ROOT shared libraries.
3182///
3183/// On Windows, the behavior is different. In that case, this function doesn't
3184/// return the directory of the **shared libraries** (like `libCore.dll`), but
3185/// the **import libraries**, which are used at link time (like `libCore.lib`).
3186
3188{
3189#if defined(R__WIN32)
3190 static bool initialized = false;
3191 static TString rootlibdir;
3192 if (initialized)
3193 return rootlibdir;
3194
3195 initialized = true;
3196 rootlibdir = "lib";
3198 return rootlibdir;
3199#else
3200 return TROOT::GetSharedLibDir();
3201#endif
3202}
3203
3204////////////////////////////////////////////////////////////////////////////////
3205/// Get the shared libraries directory in the installation. Static utility function.
3206///
3207/// This function inspects the libraries currently loaded in the process to
3208/// locate the ROOT Core library. Once found, it extracts and returns the
3209/// directory containing that library. If the ROOT Core library was not found,
3210/// it will return an empty string.
3211///
3212/// The result is cached in a static variable so the lookup is only performed
3213/// once per process, and the implementation is platform-specific.
3214///
3215/// \return The directory path (as a `TString`) containing the ROOT shared libraries.
3216
3218{
3219 static bool haveLooked = false;
3220 static TString rootlibdir;
3221 if (haveLooked)
3222 return rootlibdir;
3223
3224 haveLooked = true;
3225
3226 namespace fs = std::filesystem;
3227
3228#if defined(__APPLE__)
3229
3230 uint32_t count = _dyld_image_count();
3231 for (uint32_t i = 0; i < count; i++) {
3232 const char *path = _dyld_get_image_name(i);
3233 if (!path)
3234 continue;
3235
3236 fs::path p(path);
3237 if (p.filename() == _R_QUOTEVAL_(LIB_CORE_NAME)) {
3238 rootlibdir = p.parent_path().c_str();
3239 break;
3240 }
3241 }
3242
3243#elif defined(_WIN32)
3244
3245 HMODULE modulesStack[1024];
3246 std::vector<HMODULE> modulesHeap;
3248 DWORD needed = 0;
3249
3250 HANDLE process = GetCurrentProcess();
3251
3252 bool success = EnumProcessModules(process, modulesStack, sizeof(modulesStack), &needed);
3253
3254 // It is recommended in the API documentation to check if the output array
3255 // was too small, and if yes, call EnumProcessModules again with an array of
3256 // the required size. To avoid heap allocations, we use a heap array only
3257 // when the number of modules was too large for the original stack array.
3258 // See: https://learn.microsoft.com/en-us/windows/win32/api/psapi/nf-psapi-enumprocessmodules#remarks
3259 if (needed > sizeof(modulesStack)) {
3260 modulesHeap.resize(needed / sizeof(HMODULE));
3261 success = EnumProcessModules(process, modulesHeap.data(), needed, &needed);
3262 modules = modulesHeap.data();
3263 }
3264
3265 if (success) {
3266 const unsigned int count = needed / sizeof(HMODULE);
3267
3268 for (unsigned int i = 0; i < count; ++i) {
3269 wchar_t wpath[MAX_PATH];
3271 if (!len)
3272 continue;
3273
3274 // According to the Windows API documentation, there are exceptions
3275 // where a path can be longer than MAX_PATH:
3276 // https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=registry
3277 // In case that happens here, we print an error message.
3278 if (len == MAX_PATH) {
3279 // Convert UTF-16 path to UTF-8 for the error message
3280 int utf8len = WideCharToMultiByte(CP_UTF8, 0, wpath, -1, nullptr, 0, nullptr, nullptr);
3281
3282 std::string utf8path(utf8len - 1, '\0');
3283 WideCharToMultiByte(CP_UTF8, 0, wpath, -1, utf8path.data(), utf8len, nullptr, nullptr);
3284
3285 utf8path += "... [TRUNCATED]";
3286
3287 ::Error("TROOT::GetSharedLibDir",
3288 "Module path \"%s\" exceeded maximum path length of %u characters! "
3289 "ROOT might not be able to resolve its resource directories.",
3290 utf8path.c_str(), MAX_PATH);
3291
3292 continue;
3293 }
3294
3295 fs::path p{wpath};
3296 if (p.filename() == _R_QUOTEVAL_(LIB_CORE_NAME)) {
3297
3298 // Convert UTF-16 to UTF-8 explicitly
3299 const std::wstring wdir = p.parent_path().wstring();
3300
3301 int utf8len = WideCharToMultiByte(CP_UTF8, 0, wdir.c_str(), -1, nullptr, 0, nullptr, nullptr);
3302
3303 std::string utf8dir(utf8len - 1, '\0');
3304 WideCharToMultiByte(CP_UTF8, 0, wdir.c_str(), -1, utf8dir.data(), utf8len, nullptr, nullptr);
3305
3306 rootlibdir = utf8dir.c_str();
3307 break;
3308 }
3309 }
3310 }
3311
3312#else
3313
3314 auto callback = +[](struct dl_phdr_info *info, size_t /*size*/, void *data) -> int {
3315 TString &libdir = *static_cast<TString *>(data);
3316 if (!info->dlpi_name)
3317 return 0;
3318
3319 fs::path p = info->dlpi_name;
3320 if (p.filename() == _R_QUOTEVAL_(LIB_CORE_NAME)) {
3321 std::error_code ec;
3322
3323 // Resolve symlinks: critical for environments like CMSSW, where the
3324 // ROOT libraries are loaded via symlinks that point to the actual
3325 // install directory
3326 fs::path resolved = fs::canonical(p, ec);
3327 if (ec) {
3328 ::Error("TROOT",
3329 "Failed to canonicalize detected ROOT shared library path:\n"
3330 "%s\n"
3331 "Error code: %d (%s)\n"
3332 "Error category: %s\n"
3333 "This is an unexpected internal error and ROOT might not work.\n"
3334 "Please report this issue on GitHub: https://github.com/root-project/root/issues",
3335 p.string().c_str(), ec.value(), ec.message().c_str(), ec.category().name());
3336 // Fall back to the loader path if canonicalization fails. The path
3337 // will likely be wrong, but at least not garbage
3338 resolved = p;
3339 }
3340 libdir = resolved.parent_path().c_str();
3341 return 1; // stop iteration
3342 }
3343 return 0; // continue
3344 };
3345
3346 dl_iterate_phdr(callback, &rootlibdir);
3347
3348#endif
3349
3350 return rootlibdir;
3351}
3352
3353////////////////////////////////////////////////////////////////////////////////
3354/// Get the include directory in the installation. Static utility function.
3355
3357{
3358 static TString rootincdir;
3359
3360 if (!rootincdir.IsNull())
3361 return rootincdir;
3362
3363 namespace fs = std::filesystem;
3364
3365 // The shared library directory can be found automatically, because the
3366 // libCore is loaded by definition when using TROOT. It's used as the anchor
3367 // to resolve the ROOT include directory, using the correct relative path
3368 // for either the build or install tree.
3369 fs::path libPath = GetSharedLibDir().Data();
3370
3371 // Check if we are in the build tree using the build tree marker file
3372 const bool isBuildTree = fs::exists(libPath / "root-build-tree-marker");
3373
3374 fs::path includePath = isBuildTree ? "../include" : INSTALL_LIB_TO_INCLUDE;
3375
3376 // The INSTALL_LIB_TO_INCLUDE might already be absolute
3377 if (!includePath.is_absolute()) {
3379 }
3380
3381 // Normalize to get rid of the "../" in relative paths
3382 rootincdir = includePath.lexically_normal().string();
3383
3384 return rootincdir;
3385}
3386
3387////////////////////////////////////////////////////////////////////////////////
3388/// Get the sysconfig directory in the installation. Static utility function.
3389
3391 // Avoid returning a reference to a temporary because of the conversion
3392 // between std::string and TString.
3394 return etcdir;
3395}
3396
3397////////////////////////////////////////////////////////////////////////////////
3398/// Get the data directory in the installation. Static utility function.
3399
3401#ifdef ROOTDATADIR
3402 if (IgnorePrefix()) {
3403#endif
3404 return GetRootSys();
3405#ifdef ROOTDATADIR
3406 } else {
3407 const static TString rootdatadir = ROOTDATADIR;
3408 return rootdatadir;
3409 }
3410#endif
3411}
3412
3413////////////////////////////////////////////////////////////////////////////////
3414/// Get the documentation directory in the installation. Static utility function.
3415
3417#ifdef ROOTDOCDIR
3418 if (IgnorePrefix()) {
3419#endif
3420 return GetRootSys();
3421#ifdef ROOTDOCDIR
3422 } else {
3423 const static TString rootdocdir = ROOTDOCDIR;
3424 return rootdocdir;
3425 }
3426#endif
3427}
3428
3429////////////////////////////////////////////////////////////////////////////////
3430/// Get the macro directory in the installation. Static utility function.
3431
3433#ifdef ROOTMACRODIR
3434 if (IgnorePrefix()) {
3435#endif
3436 static TString rootmacrodir;
3437 if (rootmacrodir.IsNull()) {
3438 rootmacrodir = "macros";
3440 }
3441 return rootmacrodir;
3442#ifdef ROOTMACRODIR
3443 } else {
3444 const static TString rootmacrodir = ROOTMACRODIR;
3445 return rootmacrodir;
3446 }
3447#endif
3448}
3449
3450////////////////////////////////////////////////////////////////////////////////
3451/// Get the tutorials directory in the installation. Static utility function.
3452
3454#ifdef ROOTTUTDIR
3455 if (IgnorePrefix()) {
3456#endif
3457 static TString roottutdir;
3458 if (roottutdir.IsNull()) {
3459 roottutdir = "tutorials";
3461 }
3462 return roottutdir;
3463#ifdef ROOTTUTDIR
3464 } else {
3465 const static TString roottutdir = ROOTTUTDIR;
3466 return roottutdir;
3467 }
3468#endif
3469}
3470
3471////////////////////////////////////////////////////////////////////////////////
3472/// Shut down ROOT.
3473
3475{
3476 if (gROOT)
3477 gROOT->EndOfProcessCleanups();
3478 else if (gInterpreter)
3479 gInterpreter->ShutDown();
3480}
3481
3482////////////////////////////////////////////////////////////////////////////////
3483/// Get the source directory in the installation. Static utility function.
3484
3486#ifdef ROOTSRCDIR
3487 if (IgnorePrefix()) {
3488#endif
3489 static TString rootsrcdir;
3490 if (rootsrcdir.IsNull()) {
3491 rootsrcdir = "src";
3493 }
3494 return rootsrcdir;
3495#ifdef ROOTSRCDIR
3496 } else {
3497 const static TString rootsrcdir = ROOTSRCDIR;
3498 return rootsrcdir;
3499 }
3500#endif
3501}
3502
3503////////////////////////////////////////////////////////////////////////////////
3504/// Get the icon path in the installation. Static utility function.
3505
3507#ifdef ROOTICONPATH
3508 if (IgnorePrefix()) {
3509#endif
3510 static TString rooticonpath;
3511 if (rooticonpath.IsNull()) {
3512 rooticonpath = "icons";
3514 }
3515 return rooticonpath;
3516#ifdef ROOTICONPATH
3517 } else {
3518 const static TString rooticonpath = ROOTICONPATH;
3519 return rooticonpath;
3520 }
3521#endif
3522}
3523
3524////////////////////////////////////////////////////////////////////////////////
3525/// Get the fonts directory in the installation. Static utility function.
3526
3528#ifdef TTFFONTDIR
3529 if (IgnorePrefix()) {
3530#endif
3531 static TString ttffontdir;
3532 if (ttffontdir.IsNull()) {
3533 ttffontdir = "fonts";
3535 }
3536 return ttffontdir;
3537#ifdef TTFFONTDIR
3538 } else {
3539 const static TString ttffontdir = TTFFONTDIR;
3540 return ttffontdir;
3541 }
3542#endif
3543}
3544
3545////////////////////////////////////////////////////////////////////////////////
3546/// Get the tutorials directory in the installation. Static utility function.
3547/// Backward compatibility function - do not use for new code
3548
3550 return GetTutorialDir();
3551}
@ kMarker
Definition Buttons.h:34
@ kCurlyArc
Definition Buttons.h:38
@ kPad
Definition Buttons.h:30
@ kPolyLine
Definition Buttons.h:28
@ kDiamond
Definition Buttons.h:37
@ kPave
Definition Buttons.h:31
@ kArrow
Definition Buttons.h:33
@ kPaveText
Definition Buttons.h:32
@ kCutG
Definition Buttons.h:38
@ kLine
Definition Buttons.h:33
@ kPavesText
Definition Buttons.h:32
@ kCurlyLine
Definition Buttons.h:38
@ kPaveLabel
Definition Buttons.h:31
@ kButton
Definition Buttons.h:37
@ kEllipse
Definition Buttons.h:32
@ kText
Definition Buttons.h:30
@ kArc
Definition Buttons.h:33
The file contains utilities which are foundational and could be used across the core component of ROO...
#define _R_QUOTEVAL_(string)
Definition RConfig.hxx:450
#define SafeDelete(p)
Definition RConfig.hxx:531
#define d(i)
Definition RSha256.hxx:102
#define b(i)
Definition RSha256.hxx:100
#define f(i)
Definition RSha256.hxx:104
#define c(i)
Definition RSha256.hxx:101
#define g(i)
Definition RSha256.hxx:105
#define a(i)
Definition RSha256.hxx:99
#define e(i)
Definition RSha256.hxx:103
#define ROOT_RELEASE_TIME
Definition RVersion.h:6
#define ROOT_RELEASE
Definition RVersion.hxx:44
#define ROOT_VERSION_CODE
Definition RVersion.hxx:24
#define ROOT_RELEASE_DATE
Definition RVersion.hxx:8
bool Bool_t
Boolean (0=false, 1=true) (bool)
Definition RtypesCore.h:77
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
long Longptr_t
Integer large enough to hold a pointer (platform-dependent)
Definition RtypesCore.h:89
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int)
Definition RtypesCore.h:60
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Ssiz_t kNPOS
The equivalent of std::string::npos for the ROOT class TString.
Definition RtypesCore.h:131
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
const char Option_t
Option string (const char)
Definition RtypesCore.h:80
void(* VoidFuncPtr_t)()
Definition Rtypes.h:85
R__EXTERN TClassTable * gClassTable
TInterpreter * CreateInterpreter(void *interpLibHandle, const char *argv[])
Definition TCling.cxx:625
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
#define gDirectory
Definition TDirectory.h:385
R__EXTERN TEnv * gEnv
Definition TEnv.h:170
void DefaultErrorHandler(Int_t level, Bool_t abort_bool, const char *location, const char *msg)
The default error handler function.
void Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
Definition TError.cxx:241
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Definition TError.cxx:208
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
Definition TError.cxx:252
ErrorHandlerFunc_t SetErrorHandler(ErrorHandlerFunc_t newhandler)
Set an errorhandler function. Returns the old handler.
Definition TError.cxx:92
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t cursor
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 filename
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 offset
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 r
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 UChar_t len
Option_t Option_t TPoint TPoint const char mode
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize fs
Option_t Option_t style
char name[80]
Definition TGX11.cxx:148
R__EXTERN TGuiFactory * gBatchGuiFactory
Definition TGuiFactory.h:67
R__EXTERN TGuiFactory * gGuiFactory
Definition TGuiFactory.h:66
R__EXTERN TVirtualMutex * gInterpreterMutex
TInterpreter * CreateInterpreter_t(void *shlibHandle, const char *argv[])
R__EXTERN TInterpreter * gCling
#define gInterpreter
void * DestroyInterpreter_t(TInterpreter *)
R__EXTERN TPluginManager * gPluginMgr
Bool_t & GetReadingObject()
Definition TROOT.cxx:2614
static Int_t IVERSQ()
Return version id as an integer, i.e. "2.22/04" -> 22204.
Definition TROOT.cxx:196
static Int_t IDATQQ(const char *date)
Return built date as integer, i.e. "Apr 28 2000" -> 20000428.
Definition TROOT.cxx:206
static TClass * R__GetClassIfKnown(const char *className)
Check whether className is a known class, and only autoload if we can.
Definition TROOT.cxx:2063
static DestroyInterpreter_t * gDestroyInterpreter
Definition TROOT.cxx:182
Int_t gDebug
Global variable setting the debug level. Set to 0 to disable, increase it in steps of 1 to increase t...
Definition TROOT.cxx:783
static void * gInterpreterLib
Definition TROOT.cxx:183
static Int_t ITIMQQ(const char *time)
Return built time as integer (with min precision), i.e.
Definition TROOT.cxx:234
static void at_exit_of_TROOT()
Definition TROOT.cxx:377
TVirtualMutex * gROOTMutex
Definition TROOT.cxx:186
static void CleanUpROOTAtExit()
Clean up at program termination before global objects go out of scope.
Definition TROOT.cxx:244
static void CallCloseFiles()
Insure that the files, canvases and sockets are closed.
Definition TROOT.cxx:2684
void R__SetZipMode(int)
R__EXTERN TVirtualMutex * gROOTMutex
Definition TROOT.h:63
#define gROOT
Definition TROOT.h:426
R__EXTERN TStyle * gStyle
Definition TStyle.h:442
void(* Func_t)()
Definition TSystem.h:249
R__EXTERN const char * gRootDir
Definition TSystem.h:251
@ kReadPermission
Definition TSystem.h:55
Bool_t R_ISREG(Int_t mode)
Definition TSystem.h:126
R__EXTERN TSystem * gSystem
Definition TSystem.h:582
R__EXTERN TVirtualMutex * gGlobalMutex
#define R__LOCKGUARD(mutex)
#define gPad
#define R__READ_LOCKGUARD(mutex)
#define gVirtualX
Definition TVirtualX.h:368
R__EXTERN TVirtualX * gGXBatch
Definition TVirtualX.h:370
const char * proto
Definition civetweb.c:18822
char fHolder[sizeof(TROOT)]
Definition TROOT.cxx:419
const_iterator begin() const
static void CreateApplication()
Static function used to create a default application environment.
Using a TBrowser one can browse all ROOT objects.
Definition TBrowser.h:37
void SetRefreshFlag(Bool_t flag)
Definition TBrowser.h:100
The Canvas class.
Definition TCanvas.h:23
Objects following this interface can be passed onto the TROOT object to implement a user customized w...
This class registers for all classes their name, id and dictionary function in a hash table.
Definition TClassTable.h:38
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:84
static void AddClass(TClass *cl)
static: Add a class to the list and map of classes.
Definition TClass.cxx:557
static TClass * LoadClass(const char *requestedname, Bool_t silent)
Helper function used by TClass::GetClass().
Definition TClass.cxx:5851
static void RemoveClass(TClass *cl)
static: Remove a class from the list and map of classes
Definition TClass.cxx:587
Bool_t InheritsFrom(const char *cl) const override
Return kTRUE if this class inherits from a class with name "classname".
Definition TClass.cxx:4932
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
Definition TClass.cxx:2994
Collection abstract base class.
Definition TCollection.h:65
void RecursiveRemove(TObject *obj) override
Remove object from this collection and recursively remove the object from all other objects (and coll...
virtual bool UseRWLock(Bool_t enable=true)
Set this collection to use a RW lock upon access, making it thread safe.
virtual void AddAll(const TCollection *col)
Add all objects from collection col to this collection.
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
virtual void Add(TObject *obj)=0
TObject * FindObject(const char *name) const override
Find an object in this collection using its name.
void Delete(Option_t *option="") override=0
Delete this object.
void Clear(Option_t *option="") override=0
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
The color creation and management class.
Definition TColor.h:22
static void InitializeColors()
Initialize colors used by the TCanvas based graphics (via TColor objects).
Definition TColor.cxx:1172
Int_t GetNumber() const
Definition TColor.h:59
Basic data type descriptor (datatype information is obtained from CINT).
Definition TDataType.h:44
Describe directory structure in memory.
Definition TDirectory.h:45
virtual void Close(Option_t *option="")
Delete all objects from memory and directory structure itself.
virtual TList * GetList() const
Definition TDirectory.h:223
void ls(Option_t *option="") const override
List Directory contents.
virtual void Append(TObject *obj, Bool_t replace=kFALSE)
Append object to this directory.
void SetName(const char *newname) override
Set the name for directory If the directory name is changed after the directory was written once,...
void BuildDirectory(TFile *motherFile, TDirectory *motherDir)
Initialise directory to defaults.
static std::atomic< TDirectory * > & CurrentDirectory()
Return the current directory for the current thread.
virtual TObject * Remove(TObject *)
Remove an object from the in-memory list.
TList * fList
List of objects in memory.
Definition TDirectory.h:142
The TEnv class reads config files, by default named .rootrc.
Definition TEnv.h:124
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition TEnv.cxx:503
virtual void SetValue(const char *name, const char *value, EEnvLevel level=kEnvChange, const char *type=nullptr)
Set the value of a resource or create a new resource.
Definition TEnv.cxx:744
virtual const char * GetRcName() const
Definition TEnv.h:144
A file, usually with extension .root, that stores data and code in the form of serialized objects in ...
Definition TFile.h:130
<div class="legacybox"><h2>Legacy Code</h2> TFolder is a legacy interface: there will be no bug fixes...
Definition TFolder.h:30
virtual TObject * FindObjectAny(const char *name) const
Return a pointer to the first object with name starting at this folder.
Definition TFolder.cxx:342
TFolder * AddFolder(const char *name, const char *title, TCollection *collection=nullptr)
Create a new folder and add it to the list of folders of this folder, return a pointer to the created...
Definition TFolder.cxx:181
Dictionary for function template This class describes one single function template.
Global functions class (global functions are obtained from CINT).
Definition TFunction.h:30
static void MakeFunctor(const char *name, const char *type, GlobFunc &func)
Definition TGlobal.h:73
static TList & GetEarlyRegisteredGlobals()
Returns list collected globals Used to storeTGlobalMappedFunctions from other libs,...
Definition TGlobal.cxx:188
Global variables class (global variables are obtained from CINT).
Definition TGlobal.h:28
This ABC is a factory for GUI components.
Definition TGuiFactory.h:42
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
Definition THashList.h:34
THashTable implements a hash table to store TObject's.
Definition THashTable.h:35
virtual void RegisterModule(const char *, const char **, const char **, const char *, const char *, void(*)(), const FwdDeclArgsToKeepCollection_t &fwdDeclArgsToKeep, const char **classesHeaders, Bool_t lateRegistration=false, Bool_t hasCxxModule=false)=0
virtual void RegisterAutoLoadedLibrary(const char *libname)=0
virtual void Reset()=0
virtual void Initialize()=0
std::vector< std::pair< std::string, int > > FwdDeclArgsToKeepCollection_t
virtual void SaveContext()=0
TDictionary::DeclId_t DeclId_t
Option_t * GetOption() const
A collection of TDataMember objects designed for fast access given a DeclId_t and for keep track of T...
void Delete(Option_t *option="") override
Delete all TDataMember object files.
void Unload()
Mark 'all func' as being unloaded.
void Load()
Load all the DataMembers known to the interpreter for the scope 'fClass' into this collection.
A collection of TEnum objects designed for fast access given a DeclId_t and for keep track of TEnum t...
A collection of TFunction objects designed for fast access given a DeclId_t and for keep track of TFu...
TObject * FindObject(const char *name) const override
Specialize FindObject to do search for the a function just by name or create it if its not already in...
A collection of TFunction objects designed for fast access given a DeclId_t and for keep track of TFu...
TFunction * Get(DeclId_t id)
Return (after creating it if necessary) the TMethod or TFunction describing the function correspondin...
void Delete(Option_t *option="") override
Delete all TFunction object files.
void Load()
Load all the functions known to the interpreter for the scope 'fClass' into this collection.
void Unload()
Mark 'all func' as being unloaded.
A collection of TDataType designed to hold the typedef information and numerical type information.
A doubly linked list.
Definition TList.h:38
void Add(TObject *obj) override
Definition TList.h:81
void Delete(Option_t *option="") override
Remove all objects from the list AND delete all heap based objects.
Definition TList.cxx:600
Handle messages that might be generated by the system.
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition TNamed.cxx:173
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition TNamed.cxx:149
An array of TObjects.
Definition TObjArray.h:31
Mother of all ROOT objects.
Definition TObject.h:42
static void SetObjectStat(Bool_t stat)
Turn on/off tracking of objects in the TObjectTable.
Definition TObject.cxx:1185
virtual const char * GetName() const
Returns name of object.
Definition TObject.cxx:459
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition TObject.cxx:224
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:1081
virtual TObject * FindObject(const char *name) const
Must be redefined in derived classes.
Definition TObject.cxx:422
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:885
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1095
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
Definition TObject.cxx:1123
@ kInvalidObject
if object ctor succeeded but object should not be used
Definition TObject.h:81
@ kMustCleanup
if object destructor must call RecursiveRemove()
Definition TObject.h:73
This class implements a plugin library manager.
void LoadHandlersFromEnv(TEnv *env)
Load plugin handlers specified in config file, like:
static void Cleanup()
static function (called by TROOT destructor) to delete all TProcessIDs
static TProcessID * AddProcessID()
Static function to add a new TProcessID to the list of PIDs.
This class is a specialized TProcessID managing the list of UUIDs.
static Bool_t BlockAllSignals(Bool_t b)
Block or unblock all signals. Returns the previous block status.
ROOT top level object description.
Definition TROOT.h:111
static Int_t IncreaseDirLevel()
Increase the indentation level for ls().
Definition TROOT.cxx:3053
Int_t IgnoreInclude(const char *fname, const char *expandedfname)
Return 1 if the name of the given include file corresponds to a class that is known to ROOT,...
Definition TROOT.cxx:2084
Int_t fVersionCode
ROOT version code as used in RVersion.h.
Definition TROOT.h:133
void Message(Int_t id, const TObject *obj)
Process message id called by obj.
Definition TROOT.cxx:2512
void RemoveClass(TClass *)
Remove a class from the list and map of classes.
Definition TROOT.cxx:2792
TCollection * fClassGenerators
List of user defined class generators;.
Definition TROOT.h:178
TROOT()
Only used by Dictionary.
Definition TROOT.cxx:790
void SetCutClassName(const char *name="TCutG")
Set the default graphical cut class name for the graphics editor By default the graphics editor creat...
Definition TROOT.cxx:2847
TSeqCollection * fCanvases
List of canvases.
Definition TROOT.h:167
TObject * FindObjectAnyFile(const char *name) const override
Scan the memory lists of all files for an object with name.
Definition TROOT.cxx:1592
const TObject * fPrimitive
Currently selected primitive.
Definition TROOT.h:156
void SetWebDisplay(const char *webdisplay="")
Specify where web graphics shall be rendered.
Definition TROOT.cxx:2997
Bool_t fIsWebDisplay
True if session uses web widgets.
Definition TROOT.h:146
TFolder * fRootFolder
top level folder //root
Definition TROOT.h:184
void AddClassGenerator(TClassGenerator *gen)
Add a class generator.
Definition TROOT.cxx:1191
TSeqCollection * fGeometries
List of geometries.
Definition TROOT.h:172
TString fCutClassName
Name of default CutG class in graphics editor.
Definition TROOT.h:187
TInterpreter * fInterpreter
Command interpreter.
Definition TROOT.h:143
std::vector< std::pair< std::string, int > > FwdDeclArgsToKeepCollection_t
Definition TROOT.h:204
Int_t fVersionTime
Time of ROOT version (ex 1152)
Definition TROOT.h:135
void EndOfProcessCleanups()
Execute the cleanups necessary at the end of the process, in particular those that must be executed b...
Definition TROOT.cxx:1404
Bool_t fBatch
True if session without graphics.
Definition TROOT.h:144
TSeqCollection * GetListOfFiles() const
Definition TROOT.h:254
Bool_t fEscape
True if ESC has been pressed.
Definition TROOT.h:153
static const TString & GetBinDir()
Get the binary directory in the installation. Static utility function.
Definition TROOT.cxx:3159
Int_t fVersionInt
ROOT version in integer format (501)
Definition TROOT.h:132
static const TString & GetIncludeDir()
Get the include directory in the installation. Static utility function.
Definition TROOT.cxx:3356
Bool_t fFromPopUp
True if command executed from a popup menu.
Definition TROOT.h:149
void Idle(UInt_t idleTimeInSec, const char *command=nullptr)
Execute command when system has been idle for idleTimeInSec seconds.
Definition TROOT.cxx:2048
TSeqCollection * fSockets
List of network sockets.
Definition TROOT.h:166
void ls(Option_t *option="") const override
To list all objects of the application.
Definition TROOT.cxx:2412
static const char * GetMacroPath()
Get macro search path. Static utility function.
Definition TROOT.cxx:2926
TCollection * fFunctions
List of analytic functions.
Definition TROOT.h:169
void SaveContext()
Save the current interpreter context.
Definition TROOT.cxx:2835
Bool_t IsExecutingMacro() const
Definition TROOT.h:298
TDataType * GetType(const char *name, Bool_t load=kFALSE) const
Return pointer to type with name.
Definition TROOT.cxx:1718
static void Initialize()
Initialize ROOT explicitly.
Definition TROOT.cxx:3069
static void ShutDown()
Shut down ROOT.
Definition TROOT.cxx:3474
TObject * GetFunction(const char *name) const
Return pointer to function with name.
Definition TROOT.cxx:1743
static Int_t ConvertVersionCode2Int(Int_t code)
Convert version code to an integer, i.e. 331527 -> 51507.
Definition TROOT.cxx:3092
TSeqCollection * fMessageHandlers
List of message handlers.
Definition TROOT.h:176
static const TString & GetSourceDir() R__DEPRECATED(6
Get the source directory in the installation. Static utility function.
Definition TROOT.cxx:3485
void SetStyle(const char *stylename="Default")
Change current style to style with name stylename.
Definition TROOT.cxx:2894
AListOfEnums_t fEnums
List of enum types.
Definition TROOT.h:182
void ReadGitInfo()
Read Git commit SHA1 and branch name.
Definition TROOT.cxx:2591
static Bool_t fgRootInit
Singleton initialization flag.
Definition TROOT.h:121
void RefreshBrowsers()
Refresh all browsers.
Definition TROOT.cxx:2674
void CloseFiles()
Close any files and sockets that gROOT knows about.
Definition TROOT.cxx:1324
std::atomic< TApplication * > fApplication
Pointer to current application.
Definition TROOT.h:142
const char * FindObjectPathName(const TObject *obj) const
Return path name of obj somewhere in the //root/... path.
Definition TROOT.cxx:1629
static Int_t ConvertVersionInt2Code(Int_t v)
Convert version as an integer to version code as used in RVersion.h.
Definition TROOT.cxx:3100
void ResetClassSaved()
Reset the ClassSaved status of all classes.
Definition TROOT.cxx:1252
static const TString & GetTTFFontDir()
Get the fonts directory in the installation. Static utility function.
Definition TROOT.cxx:3527
Bool_t fForceStyle
Force setting of current style when reading objects.
Definition TROOT.h:151
TCanvas * MakeDefCanvas() const
Return a default canvas.
Definition TROOT.cxx:1710
TCollection * fTypes
List of data types definition.
Definition TROOT.h:159
TColor * GetColor(Int_t color) const
Return address of color with index color.
Definition TROOT.cxx:1692
TGlobal * GetGlobal(const char *name, Bool_t load=kFALSE) const
Return pointer to global variable by name.
Definition TROOT.cxx:1787
TClass * FindSTLClass(const char *name, Bool_t load, Bool_t silent=kFALSE) const
return a TClass object corresponding to 'name' assuming it is an STL container.
Definition TROOT.cxx:1640
TSeqCollection * fStreamerInfo
List of active StreamerInfo classes.
Definition TROOT.h:177
void Append(TObject *obj, Bool_t replace=kFALSE) override
Append object to this directory.
Definition TROOT.cxx:1203
static const TString & GetIconPath()
Get the icon path in the installation. Static utility function.
Definition TROOT.cxx:3506
TCollection * GetListOfGlobalFunctions(Bool_t load=kFALSE)
Return list containing the TFunctions currently defined.
Definition TROOT.cxx:1982
TString fGitDate
Date and time when make was run.
Definition TROOT.h:140
TSeqCollection * fSpecials
List of special objects.
Definition TROOT.h:174
TCollection * GetListOfFunctionTemplates()
Definition TROOT.cxx:1927
static void RegisterModule(const char *modulename, const char **headers, const char **includePaths, const char *payLoadCode, const char *fwdDeclCode, void(*triggerFunc)(), const FwdDeclArgsToKeepCollection_t &fwdDeclsArgToSkip, const char **classesHeaders, bool hasCxxModule=false)
Called by static dictionary initialization to register clang modules for headers.
Definition TROOT.cxx:2699
TObject * FindObject(const char *name) const override
Returns address of a ROOT object if it exists.
Definition TROOT.cxx:1469
TCollection * fClasses
List of classes definition.
Definition TROOT.h:158
Bool_t fEditHistograms
True if histograms can be edited with the mouse.
Definition TROOT.h:148
TListOfDataMembers * fGlobals
List of global variables.
Definition TROOT.h:161
TListOfFunctionTemplates * fFuncTemplate
List of global function templates.
Definition TROOT.h:160
Int_t fTimer
Timer flag.
Definition TROOT.h:141
TSeqCollection * fDataSets
List of data sets (TDSet or TChain)
Definition TROOT.h:181
TString fConfigOptions
ROOT ./configure set build options.
Definition TROOT.h:129
TStyle * GetStyle(const char *name) const
Return pointer to style with name.
Definition TROOT.cxx:1735
TCollection * GetListOfEnums(Bool_t load=kFALSE)
Definition TROOT.cxx:1910
Longptr_t ProcessLineSync(const char *line, Int_t *error=nullptr)
Process interpreter command via TApplication::ProcessLine().
Definition TROOT.cxx:2552
void InitInterpreter()
Initialize interpreter (cling)
Definition TROOT.cxx:2223
TCollection * GetListOfGlobals(Bool_t load=kFALSE)
Return list containing the TGlobals currently defined.
Definition TROOT.cxx:1944
static void SetDirLevel(Int_t level=0)
Return Indentation level for ls().
Definition TROOT.cxx:3084
TSeqCollection * fSecContexts
List of security contexts (TSecContext)
Definition TROOT.h:179
TString fWebDisplay
If not empty it defines where web graphics should be rendered (cef, qt6, browser.....
Definition TROOT.h:145
static const char * GetTutorialsDir()
Get the tutorials directory in the installation.
Definition TROOT.cxx:3549
TCollection * GetListOfFunctionOverloads(const char *name) const
Return the collection of functions named "name".
Definition TROOT.cxx:1828
TSeqCollection * fCleanups
List of recursiveRemove collections.
Definition TROOT.h:175
static Bool_t Initialized()
Return kTRUE if the TROOT object has been initialized.
Definition TROOT.cxx:3076
void SetBatch(Bool_t batch=kTRUE)
Set batch mode for ROOT If the argument evaluates to true, the session does not use interactive graph...
Definition TROOT.cxx:2968
Int_t fLineIsProcessing
To synchronize multi-threads.
Definition TROOT.h:118
static const TString & GetMacroDir()
Get the macro directory in the installation. Static utility function.
Definition TROOT.cxx:3432
TString fGitCommit
Git commit SHA1 of built.
Definition TROOT.h:138
Longptr_t ProcessLine(const char *line, Int_t *error=nullptr)
Process interpreter command via TApplication::ProcessLine().
Definition TROOT.cxx:2532
TSeqCollection * fClosedObjects
List of closed objects from the list of files and sockets, so we can delete them if neededCl.
Definition TROOT.h:163
TSeqCollection * fTasks
List of tasks.
Definition TROOT.h:170
TSeqCollection * fClipboard
List of clipboard objects.
Definition TROOT.h:180
const char * GetGitDate()
Return date/time make was run.
Definition TROOT.cxx:2636
void SetEditorMode(const char *mode="")
Set editor mode.
Definition TROOT.cxx:2868
static const TString & GetTutorialDir()
Get the tutorials directory in the installation. Static utility function.
Definition TROOT.cxx:3453
virtual ~TROOT()
Clean up and free resources used by ROOT (files, network sockets, shared memory segments,...
Definition TROOT.cxx:1025
TSeqCollection * fColors
List of colors.
Definition TROOT.h:171
TFunction * GetGlobalFunctionWithPrototype(const char *name, const char *proto=nullptr, Bool_t load=kFALSE)
Return pointer to global function by name.
Definition TROOT.cxx:1874
TSeqCollection * GetListOfBrowsers() const
Definition TROOT.h:262
Bool_t ReadingObject() const
Deprecated (will be removed in next release).
Definition TROOT.cxx:2622
TSeqCollection * fStyles
List of styles.
Definition TROOT.h:168
Int_t fVersionDate
Date of ROOT version (ex 951226)
Definition TROOT.h:134
TSeqCollection * GetListOfColors() const
Definition TROOT.h:249
Longptr_t Macro(const char *filename, Int_t *error=nullptr, Bool_t padUpdate=kTRUE)
Execute a macro in the interpreter.
Definition TROOT.cxx:2478
Int_t fBuiltTime
Time of ROOT built.
Definition TROOT.h:137
static const std::vector< std::string > & AddExtraInterpreterArgs(const std::vector< std::string > &args)
Provide command line arguments to the interpreter construction.
Definition TROOT.cxx:3122
TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE) const
Return pointer to class with name. Obsolete, use TClass::GetClass directly.
Definition TROOT.cxx:1674
TVirtualPad * fSelectPad
Currently selected pad.
Definition TROOT.h:157
TSeqCollection * fFiles
List of files.
Definition TROOT.h:164
void Browse(TBrowser *b) override
Add browsable objects to TBrowser.
Definition TROOT.cxx:1212
static const TString & GetRootSys()
Get the rootsys directory in the installation. Static utility function.
Definition TROOT.cxx:3149
TListOfFunctions * GetGlobalFunctions()
Internal routine returning, and creating if necessary, the list of global function.
Definition TROOT.cxx:1819
Bool_t fInterrupt
True if macro should be interrupted.
Definition TROOT.h:152
Bool_t fMustClean
True if object destructor scans canvases.
Definition TROOT.h:150
Int_t LoadClass(const char *classname, const char *libname, Bool_t check=kFALSE)
Check if class "classname" is known to the interpreter (in fact, this check is not needed anymore,...
Definition TROOT.cxx:2342
TFunction * GetGlobalFunction(const char *name, const char *params=nullptr, Bool_t load=kFALSE)
Return pointer to global function by name.
Definition TROOT.cxx:1841
void AddClass(TClass *cl)
Add a class to the list and map of classes.
Definition TROOT.cxx:1181
static Int_t RootVersionCode()
Return ROOT version code as defined in RVersion.h.
Definition TROOT.cxx:3111
TObject * FindSpecialObject(const char *name, void *&where)
Returns address and folder of a ROOT object if it exists.
Definition TROOT.cxx:1523
TObject * Remove(TObject *) override
Remove an object from the in-memory list.
Definition TROOT.cxx:2782
void InitSystem()
Operating System interface.
Definition TROOT.cxx:2134
Longptr_t ProcessLineFast(const char *line, Int_t *error=nullptr)
Process interpreter command directly via CINT interpreter.
Definition TROOT.cxx:2569
Bool_t ClassSaved(TClass *cl)
return class status 'ClassSaved' for class cl This function is called by the SavePrimitive functions ...
Definition TROOT.cxx:1239
TString fGitBranch
Git branch.
Definition TROOT.h:139
TCollection * GetListOfTypes(Bool_t load=kFALSE)
Return a dynamic list giving access to all TDataTypes (typedefs) currently defined.
Definition TROOT.cxx:2021
static Int_t fgDirLevel
Indentation level for ls()
Definition TROOT.h:120
Bool_t IsRootFile(const char *filename) const
Return true if the file is local and is (likely) to be a ROOT file.
Definition TROOT.cxx:2392
static void IndentLevel()
Functions used by ls() to indent an object hierarchy.
Definition TROOT.cxx:3061
static const TString & GetDocDir()
Get the documentation directory in the installation. Static utility function.
Definition TROOT.cxx:3416
static const TString & GetEtcDir()
Get the sysconfig directory in the installation. Static utility function.
Definition TROOT.cxx:3390
Int_t GetNclasses() const
Get number of classes.
Definition TROOT.cxx:2032
static const char **& GetExtraInterpreterArgs()
INTERNAL function! Used by rootcling to inject interpreter arguments through a C-interface layer.
Definition TROOT.cxx:3132
static void SetMacroPath(const char *newpath)
Set or extend the macro search path.
Definition TROOT.cxx:2952
void InitThreads()
Initialize threads library.
Definition TROOT.cxx:2211
TProcessUUID * fUUIDs
Pointer to TProcessID managing TUUIDs.
Definition TROOT.h:183
TString fConfigFeatures
ROOT ./configure detected build features.
Definition TROOT.h:130
TFunctionTemplate * GetFunctionTemplate(const char *name)
Definition TROOT.cxx:1774
TPluginManager * fPluginManager
Keeps track of plugin library handlers.
Definition TROOT.h:186
TObject * GetGeometry(const char *name) const
Return pointer to Geometry with name.
Definition TROOT.cxx:1903
void RecursiveRemove(TObject *obj) override
Recursively remove this object from the list of Cleanups.
Definition TROOT.cxx:2660
Bool_t fExecutingMacro
True while executing a TMacro.
Definition TROOT.h:154
Int_t fBuiltDate
Date of ROOT built.
Definition TROOT.h:136
Bool_t fIsWebDisplayBatch
True if web widgets are not displayed.
Definition TROOT.h:147
static const TString & GetSharedLibDir()
Get the shared libraries directory in the installation.
Definition TROOT.cxx:3217
TSeqCollection * fMappedFiles
List of memory mapped files.
Definition TROOT.h:165
Int_t GetNtypes() const
Get number of types.
Definition TROOT.cxx:2040
Int_t LoadMacro(const char *filename, Int_t *error=nullptr, Bool_t check=kFALSE)
Load a macro in the interpreter's memory.
Definition TROOT.cxx:2430
TFile * GetFile() const override
Definition TROOT.h:278
static const TString & GetLibDir()
Get the library directory in the installation.
Definition TROOT.cxx:3187
TSeqCollection * fBrowsers
List of browsers.
Definition TROOT.h:173
TString fDefCanvasName
Name of default canvas.
Definition TROOT.h:188
TListOfFunctions * fGlobalFunctions
List of global functions.
Definition TROOT.h:162
TList * fBrowsables
List of browsables.
Definition TROOT.h:185
TObject * FindObjectAny(const char *name) const override
Return a pointer to the first object with name starting at //root.
Definition TROOT.cxx:1582
static Int_t DecreaseDirLevel()
Decrease the indentation level for ls().
Definition TROOT.cxx:2910
void Reset(Option_t *option="")
Delete all global interpreter objects created since the last call to Reset.
Definition TROOT.cxx:2815
Int_t fEditorMode
Current Editor mode.
Definition TROOT.h:155
const char * FindObjectClassName(const char *name) const
Returns class name of a ROOT object including CINT globals.
Definition TROOT.cxx:1609
static const TString & GetDataDir()
Get the data directory in the installation. Static utility function.
Definition TROOT.cxx:3400
TSeqCollection * GetListOfGeometries() const
Definition TROOT.h:261
TSeqCollection * GetListOfStyles() const
Definition TROOT.h:258
TString fVersion
ROOT version as TString, example: 0.05.01.
Definition TROOT.h:131
static Int_t GetDirLevel()
return directory level
Definition TROOT.cxx:2918
void SetReadingObject(Bool_t flag=kTRUE)
Definition TROOT.cxx:2627
Sequenceable collection abstract base class.
virtual void AddLast(TObject *obj)=0
virtual TObject * Last() const =0
virtual TObject * First() const =0
void Add(TObject *obj) override
static void PrintStatistics()
Print memory usage statistics.
Definition TStorage.cxx:365
Basic string class.
Definition TString.h:138
Ssiz_t Length() const
Definition TString.h:425
Int_t Atoi() const
Return integer value of string.
Definition TString.cxx:1994
Bool_t Gets(FILE *fp, Bool_t chop=kTRUE)
Read one line from the stream, including the \n, or until EOF.
Definition Stringio.cxx:204
const char * Data() const
Definition TString.h:384
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition TString.h:713
@ kBoth
Definition TString.h:284
@ kIgnoreCase
Definition TString.h:285
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
Definition TString.h:632
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition TString.cxx:2362
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:641
TStyle objects may be created to define special styles.
Definition TStyle.h:29
static void BuildStyles()
Create some standard styles.
Definition TStyle.cxx:524
Describes an Operating System directory for the browser.
Abstract base class defining a generic interface to the underlying Operating System.
Definition TSystem.h:276
virtual Func_t DynFindSymbol(const char *module, const char *entry)
Find specific entry point in specified library.
Definition TSystem.cxx:2055
virtual const char * Getenv(const char *env)
Get environment variable.
Definition TSystem.cxx:1676
virtual TString SplitAclicMode(const char *filename, TString &mode, TString &args, TString &io) const
This method split a filename of the form:
Definition TSystem.cxx:4317
virtual void CleanCompiledMacros()
Remove the shared libs produced by the CompileMacro() function, together with their rootmaps,...
Definition TSystem.cxx:4431
virtual void SetIncludePath(const char *includePath)
IncludePath should contain the list of compiler flags to indicate where to find user defined header f...
Definition TSystem.cxx:4253
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
Definition TSystem.cxx:1868
int GetPathInfo(const char *path, Long_t *id, Long_t *size, Long_t *flags, Long_t *modtime)
Get info about a file: id, size, flags, modification time.
Definition TSystem.cxx:1409
virtual const char * PrependPathName(const char *dir, TString &name)
Concatenate a directory and a file name.
Definition TSystem.cxx:1092
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
Definition TSystem.cxx:1307
virtual Bool_t Init()
Initialize the OS interface.
Definition TSystem.cxx:181
virtual const char * BaseName(const char *pathname)
Base name of a file name. Base name of /user/root is root.
Definition TSystem.cxx:944
virtual const char * WorkingDirectory()
Return working directory.
Definition TSystem.cxx:881
virtual char * Which(const char *search, const char *file, EAccessMode mode=kFileExists)
Find location of file in a search path.
Definition TSystem.cxx:1559
virtual const char * HomeDirectory(const char *userName=nullptr)
Return the user's home directory.
Definition TSystem.cxx:897
virtual const char * GetError()
Return system error string.
Definition TSystem.cxx:252
virtual void ResetSignals()
Reset signals handlers to previous behaviour.
Definition TSystem.cxx:582
char * DynamicPathName(const char *lib, Bool_t quiet=kFALSE)
Find a dynamic library called lib using the system search paths.
Definition TSystem.cxx:2031
This class represents a WWW compatible URL.
Definition TUrl.h:33
This class implements a mutex interface.
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition TVirtualPad.h:51
static TVirtualPad *& Pad()
Return the current pad for the current thread.
virtual TVirtualPad * GetVirtCanvas() const =0
Semi-Abstract base class defining a generic interface to the underlying, low level,...
Definition TVirtualX.h:46
static TVirtualX *& Instance()
Returns gVirtualX global.
Definition TVirtualX.cxx:57
Class providing an interface to the Windows NT Operating System.
TLine * line
TF1 * f1
Definition legend1.C:11
TSeqCollection * GetListOfSecContexts(const TROOT &)
Definition TROOT.cxx:175
R__ALWAYS_INLINE bool HasBeenDeleted(const TObject *obj)
Check if the TObject's memory has been deleted.
Definition TObject.h:409
void EnableObjectAutoRegistration()
Enable automatic registration of objects for the current thread (ROOT 6 default).
Definition TROOT.cxx:752
void DisableObjectAutoRegistration()
Disable automatic registration of objects for the current thread (ROOT 7 default).
Definition TROOT.cxx:760
bool ObjectAutoRegistrationEnabled()
Test whether objects in this thread auto-register themselves, e.g.
Definition TROOT.cxx:768
const std::string & GetRootSys()
const std::string & GetEtcDir()
static Func_t GetSymInLibImt(const char *funcname)
Definition TROOT.cxx:482
static GetROOTFun_t gGetROOT
Definition TROOT.cxx:480
R__EXTERN TROOT * gROOTLocal
Definition TROOT.h:399
void DisableParBranchProcessing()
Globally disables the IMT use case of parallel branch processing, deactivating the corresponding lock...
Definition TROOT.cxx:515
std::function< const char *()> ErrorSystemMsgHandlerFunc_t
Retrieves the error string associated with the last system error.
Definition TError.h:60
static Bool_t & IsImplicitMTEnabledImpl()
Keeps track of the status of ImplicitMT w/o resorting to the load of libImt.
Definition TROOT.cxx:544
void MinimalErrorHandler(int level, Bool_t abort, const char *location, const char *msg)
A very simple error handler that is usually replaced by the TROOT default error handler.
Definition TError.cxx:69
TROOT *(* GetROOTFun_t)()
Definition TROOT.cxx:478
ErrorSystemMsgHandlerFunc_t SetErrorSystemMsgHandler(ErrorSystemMsgHandlerFunc_t h)
Returns the previous system error message handler.
Definition TError.cxx:58
void EnableParBranchProcessing()
Globally enables the parallel branch processing, which is a case of implicit multi-threading (IMT) in...
Definition TROOT.cxx:501
Bool_t IsParBranchProcessingEnabled()
Returns true if parallel branch processing is enabled.
Definition TROOT.cxx:528
TROOT * GetROOT2()
Definition TROOT.cxx:468
TROOT * GetROOT1()
Definition TROOT.cxx:461
void ReleaseDefaultErrorHandler()
Destructs resources that are taken by using the default error handler.
TString & GetMacroPath()
Definition TROOT.cxx:556
void EnableImplicitMT(UInt_t numthreads=0)
Enable ROOT's implicit multi-threading for all objects and methods that provide an internal paralleli...
Definition TROOT.cxx:619
Bool_t IsImplicitMTEnabled()
Returns true if the implicit multi-threading in ROOT is enabled.
Definition TROOT.cxx:675
UInt_t GetThreadPoolSize()
Returns the size of ROOT's thread pool.
Definition TROOT.cxx:682
R__EXTERN TVirtualRWMutex * gCoreMutex
void EnableThreadSafety()
Enable support for multi-threading within the ROOT code in particular, enables the global mutex to ma...
Definition TROOT.cxx:581
EIMTConfig
Definition TROOT.h:83
TROOT * GetROOT()
Definition TROOT.cxx:552
void DisableImplicitMT()
Disables the implicit multi-threading in ROOT (see EnableImplicitMT).
Definition TROOT.cxx:661
void GetNormalizedName(std::string &norm_name, std::string_view name)
Return the normalized name.
Int_t fMode
Definition TSystem.h:135
TMarker m
Definition textangle.C:8
TLine l
Definition textangle.C:4