mist-hep
0.1.0
ROOT-backed analysis helpers built on mist
Loading...
Searching...
No Matches
globals.h
Go to the documentation of this file.
1
// SPDX-License-Identifier: MIT
2
//
3
// mist/hep/globals.h — Meyers-singleton accessors for the kinds of
4
// long-lived ROOT helpers that AAU originally held as header-globals.
5
//
6
// Why singletons instead of `inline` namespace objects?
7
// - TRandom / TBenchmark / TLatex are stateful and not cheap to construct.
8
// - Lazy first-use construction defers ROOT initialisation until actually
9
// needed (matters when consumers include mist/hep/globals.h transitively
10
// but never touch the accessors).
11
// - One instance per process, zero ODR risk across translation units.
12
//
13
#pragma once
14
15
#include <TBenchmark.h>
16
#include <TLatex.h>
17
#include <TRandom3.h>
18
19
namespace
mist::hep
{
20
21
// Process-wide RNG. TRandom3 (Mersenne Twister) is the modern default —
22
// AAU's plain TRandom was the LCG; we upgrade transparently.
23
inline
TRandom3&
rng
() {
24
static
TRandom3 instance;
25
return
instance;
26
}
27
28
inline
TBenchmark&
benchmark
() {
29
static
TBenchmark instance;
30
return
instance;
31
}
32
33
inline
TLatex&
latex
() {
34
static
TLatex instance;
35
return
instance;
36
}
37
38
}
// namespace mist::hep
mist::hep
Definition
functions.h:20
mist::hep::benchmark
TBenchmark & benchmark()
Definition
globals.h:28
mist::hep::latex
TLatex & latex()
Definition
globals.h:33
mist::hep::rng
TRandom3 & rng()
Definition
globals.h:23
include
mist
hep
globals.h
Generated by
1.9.8