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

Functions

 JsonHist_builder (monTool, mypath, filename)

Function Documentation

◆ JsonHist_builder()

JsonHist_builder ( monTool,
mypath,
filename )

Definition at line 12 of file JsonConfig.py.

12def JsonHist_builder( monTool, mypath, filename ) :
13
14 mpath = mypath + "/Json"
15
16 # from HistUtils import ptbins_default
17 # ptbins = ptbins_default
18
19 # from HistUtils import d0bins_default
20 # d0bins = d0bins_default
21
22 # get histograms from json and create them properly ...
23 # NB: need to sort out what to do with these variable ?
24
25 with open( filename , "r") as file:
26 data = json.load(file)
27
28 # for shte, dck in data.items():
29
30 # print( f"{shte} :" )
31
32 # for cnt, sck in dck.items():
33 # print( f" {cnt} {sck}" )
34
35 for name, hist in data.items():
36
37 htype = hist.get("type", "")
38
39 xaxis = hist.get("xAxis", {})
40 yaxis = hist.get("yAxis", {})
41
42 xbins = int(xaxis.get("nBins", 0))
43 xmin = float(xaxis.get("low", 0))
44 xmax = float(xaxis.get("high", 0))
45
46 xtitle = xaxis.get("title", "")
47 ytitle = yaxis.get("title", "")
48
49 ybins = -1
50
51 if htype == "TH2F" :
52 ybins = int(yaxis.get("nBins", 0))
53 ymin = float(yaxis.get("low", 0))
54 ymax = float(yaxis.get("high", 0))
55 if ymin >= ymax : print( f"y axis range error {name}")
56
57 print(f" name : {name} type: {htype} xbins: {xbins} lo: {xmin} hi: {xmax}")
58 defineHisto( monTool, name, path=mpath, type=htype, title=f"{name};{xtitle};{ytitle}", xbins=xbins, xmin=xmin, xmax=xmax, ybins=ybins, ymin=ymin, ymax=ymax )
59 else:
60 if xmin >= xmax : print( f"x axis range error {name}")
61 print(f" name : {name} type: {htype} xbins: {xbins} lo: {xmin} hi: {xmax}")
62 defineHisto( monTool, name, path=mpath, type=htype, title=f"{name};{xtitle};{ytitle}", xbins=xbins, xmin=xmin, xmax=xmax )
63
void print(char *figname, TCanvas *c1)