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