ATLAS Offline Software
Loading...
Searching...
No Matches
python.HistUtils Namespace Reference

Functions

 _th1 (m, n)
 _tprof (m, n)
 _txy (m, n)
 _tyx (m, n)
 defineHisto (montool, name, namespace="", **args)
 resplot (montool, namespace, path, label, xbins=0, xmin=None, xmax=None, ybins=0, ymin=None, ymax=None)
 _getbins (name, xbins, xmin=None, xmax=None)
 monGroup (analysis_chain)

Variables

dict _FORMATTERS
list ptbins_mb
list ptbins_default
list vnbins_full
list vnbins_short
list d0bins_default
list d0bins_lrt

Function Documentation

◆ _getbins()

_getbins ( name,
xbins,
xmin = None,
xmax = None )
protected

Definition at line 78 of file HistUtils.py.

78def _getbins( name, xbins, xmin=None, xmax=None ):
79
80 if isinstance(xbins,list): return xbins
81 else:
82 if xmin >= xmax : print( name, "BINS OUT OF RANGE !", xbins, xmin, xmax )
83 width = (xmax - xmin) / xbins
84 limits = []
85 for i in range(xbins):
86 limits.append( xmin + i*width )
87
88 # return [xmin + i * width for i in range(bins + 1)]
89
90 return limits
91
92
93
94
95
96# generate the mongroup hist path from the analysis string
97
void print(char *figname, TCanvas *c1)

◆ _th1()

_th1 ( m,
n )
protected

Definition at line 16 of file HistUtils.py.

16def _th1(m,n): return f"{m};{n}"

◆ _tprof()

_tprof ( m,
n )
protected

Definition at line 17 of file HistUtils.py.

17def _tprof(m,n): return f"{m},{m}_weight;{n}"

◆ _txy()

_txy ( m,
n )
protected

Definition at line 18 of file HistUtils.py.

18def _txy(m,n): return f"{m}__x,{m}__y;{n}"

◆ _tyx()

_tyx ( m,
n )
protected

Definition at line 19 of file HistUtils.py.

19def _tyx(m,n): return f"{m}__y,{m}__x;{n}"
20

◆ defineHisto()

defineHisto ( montool,
name,
namespace = "",
** args )

Definition at line 33 of file HistUtils.py.

33def defineHisto( montool, name, namespace="", **args ) :
34
35 # here we auto-generate the x and y variable names, so that we can
36 # also auto-generated them for a fill without needing to parse
37 # anything
38
39 mname = name
40 if namespace : mname = f"{namespace}_{name}"
41
42 htype = str(args.get("type", "")).strip()
43
44 # NB, we swap the default x and y variables for a TEfficiency,
45 # in order to avoid the egregious bool-before-float root
46 # TEfficiency::Fill() convention
47
48 formatter = _FORMATTERS.get(htype, _th1)
49 pname = formatter(mname, name)
50
51 # make sure that the histogram is created, even if it is never filled
52 args["opt"] = "kAlwaysCreate"
53
54 montool.defineHistogram(pname, **args)
55
56
57
58 # create the required histograms for the differential resolutions
59# NB: should probably also include the chi2 and the uncertainty histograms,
60# and maybe the slices, although they can be left up to the c++ code
61

◆ monGroup()

monGroup ( analysis_chain)

Definition at line 98 of file HistUtils.py.

98def monGroup( analysis_chain ) :
99
100 from TrigInDetAnalysisExample.chainString import chainString
101
102 chain = chainString( analysis_chain )
103
104 mg = ""
105
106 if chain.head == "" : mg = "/Fullscan"
107 else : mg = "/"+chain.head
108
109 mg += "/"+chain.tail
110
111 if chain.roi : mg += "_"+chain.roi
112 if chain.vtx : mg += "_"+chain.vtx
113 if chain.element : mg += "_" + chain.element
114 if chain.extra : mg += "_" + chain.extra
115 if chain.passed : mg += "/DTE"
116
117 return mg
118
119
120
121# superior binning for numerous histograms ...
122# NB: these should probably go into their own file, rather than
123# hijack the HistUtils, but they are useful everywhere so
124# leave them here for the time being
125
126

◆ resplot()

resplot ( montool,
namespace,
path,
label,
xbins = 0,
xmin = None,
xmax = None,
ybins = 0,
ymin = None,
ymax = None )

Definition at line 62 of file HistUtils.py.

62def resplot( montool, namespace, path, label, xbins=0, xmin=None, xmax=None, ybins=0, ymin=None, ymax=None):
63
64 vxbins = _getbins( namespace, xbins, xmin, xmax )
65 vybins = _getbins( namespace, ybins, ymin, ymax )
66
67 subpath = f"{path}/{namespace}"
68
69 defineHisto( montool, "2D", namespace=namespace, path=subpath, type="TH2F", title=f"2D ({label})", xbins=vxbins, ybins=vybins )
70
71 defineHisto( montool, "1D", path=subpath, type="TH1F", title=f"1D ({label})", xbins=vybins )
72 defineHisto( montool, "mean", path=subpath, type="TH1F", title=f"mean {label}", xbins=vxbins )
73 defineHisto( montool, "sigma", path=subpath, type="TH1F", title=f"sigma {label}", xbins=vxbins )
74
75
76
77

Variable Documentation

◆ _FORMATTERS

dict python.HistUtils._FORMATTERS
protected
Initial value:
= {
"TH1F": _th1,
"TProfile": _tprof,
"TH2F": _txy,
"TEfficiency": _tyx
}

Definition at line 21 of file HistUtils.py.

◆ d0bins_default

list python.HistUtils.d0bins_default
Initial value:
= [ -5.0, -4.0, -3.0, -2.5,
-2.0, -1.8, -1.6, -1.4, -1.2,
-1.05, -0.95, -0.85, -0.75, -0.65, -0.55, -0.45, -0.35, -0.25, -0.15, -0.05,
0.05, 0.15, 0.25, 0.35, 0.45, 0.55, 0.65, 0.75, 0.85, 0.95, 1.05,
1.2, 1.4, 1.6, 1.8, 2.0,
2.5, 3.0, 4.0, 5.0 ]

Definition at line 174 of file HistUtils.py.

◆ d0bins_lrt

list python.HistUtils.d0bins_lrt
Initial value:
= [ -100.5, -97.5, -93.5, -90.5,
-86.5, -83.5, -80.5,
-77.5, -74.5, -71.5,
-69.5, -66.5, -63.5, -61.5,
-59.5, -57.5, -54.5, -52.5, -50.5,
-49.5, -47.5, -45.5, -43.5, -42.5, -40.5,
-39.5, -37.5, -36.5, -34.5, -33.5, -32.5, -31.5,
-29.5, -28.5, -27.5, -26.5, -25.5, -24.5, -23.5, -22.5, -21.5, -20.5,
-19.5, -18.5, -17.5, -16.5, -15.5, -14.5, -13.5, -12.5, -11.5, -10.5,
-9.5, -8.5, -7.5, -6.5, -5.5, -4.5, -3.5, -2.5, -1.5, -0.5,
0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5,
10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5,
20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 29.5,
31.5, 32.5, 33.5, 34.5, 36.5, 37.5, 39.5,
40.5, 42.5, 43.5, 45.5, 47.5, 49.5,
50.5, 52.5, 54.5, 57.5, 59.5,
61.5, 63.5, 66.5, 69.5,
71.5, 74.5, 77.5,
80.5, 83.5, 86.5,
90.5, 93.5, 97.5,
100.5 ]

Definition at line 181 of file HistUtils.py.

◆ ptbins_default

list python.HistUtils.ptbins_default
Initial value:
= [ 1, 1.20226, 1.44544, 1.7378, 2.0893, 2.51189, 3.01995, 3.63078, 4.36516, 5.24807, 6.30957,
7.58578, 9.12011, 10.9648, 13.1826, 15.8489, 19.0546, 22.9087, 27.5423, 33.1131, 39.8107,
47.863, 57.544, 69.1831, 83.1764, 100 ]

Definition at line 132 of file HistUtils.py.

◆ ptbins_mb

list python.HistUtils.ptbins_mb
Initial value:
= [ 0.2, 0.4, 0.6, 0.8,
1, 1.20226, 1.44544, 1.7378, 2.0893, 2.51189, 3.01995, 3.63078, 4.36516, 5.24807, 6.30957,
7.58578, 9.12011, 10.9648, 13.1826, 15.8489, 19.0546, 22.9087, 27.5423, 33.1131, 39.8107,
47.863, 57.544, 69.1831, 83.1764, 100 ]

Definition at line 127 of file HistUtils.py.

◆ vnbins_full

list python.HistUtils.vnbins_full
Initial value:
= [ -0.5,
0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5,
13.5, 14.5, 15.5, 17.5, 18.5, 19.5, 21.5, 23.5, 24.5, 26.5, 28.5, 30.5, 32.5,
35.5, 37.5, 40.5, 43.5, 46.5, 50.5, 53.5, 57.5, 61.5, 66.5, 71.5, 76.5, 81.5,
87.5, 93.5, 100.5, 107.5, 114.5, 123.5, 131.5, 141.5, 150.5, 161.5, 172.5, 185.5, 198.5,
211.5, 226.5, 242.5, 259.5, 277.5, 297.5,
317.5, 340.5, 363.5, 389.5, 416.5, 445.5, 476.5, 509.5,
544.5, 582.5, 623.5, 666.5, 713.5, 762.5, 815.5, 872.5, 933.5, 998.5, 1067.5,
1141.5, 1221.5, 1305.5, 1396.5, 1493.5, 1597.5,
1708.5, 1827.5, 1953.5, 2089.5 ]

Definition at line 137 of file HistUtils.py.

◆ vnbins_short

list python.HistUtils.vnbins_short
Initial value:
= [
-0.5,
0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5,
10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 17.5, 18.5, 19.5,
21.5, 23.5, 24.5, 26.5, 28.5,
30.5, 32.5, 35.5, 37.5,
40.5, 43.5, 46.5,
50.5, 53.5, 57.5,
61.5, 66.5,
71.5, 76.5,
81.5, 87.5,
93.5,
100.5, 107.5, 114.5, 123.5, 131.5, 141.5, 150.5, 161.5, 172.5, 185.5, 198.5,
211.5, 226.5, 242.5, 259.5, 277.5, 297.5,
317.5, 340.5, 363.5, 389.5,
416.5, 445.5, 476.5,
509.5, 544.5, 582.5,
623.5, 666.5,
713.5, 762.5,
815.5, 872.5,
933.5, 998.5,
1067.5
]

Definition at line 149 of file HistUtils.py.