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