ATLAS Offline Software
Loading...
Searching...
No Matches
CaloMonTransforms Namespace Reference

Functions

 cloneHistFloat (toClone)
 divideHistCaloMon (inputs, doPercentage=False)
 divideByOccupancy (inputs, titleToReplace="", replaceTitWith="")
 divideByAcceptedEvts (inputs)
 simpleDivideByAcceptedEvts (inputs, titleToReplace="", replaceTitWith="")

Function Documentation

◆ cloneHistFloat()

CaloMonTransforms.cloneHistFloat ( toClone)
If we want to clone the bins from an integer-type histogram, but then wish to fill it with floats (for efficiencies) 

Definition at line 16 of file CaloMonTransforms.py.

16def cloneHistFloat(toClone):
17 """ If we want to clone the bins from an integer-type histogram, but then wish to fill it with floats (for efficiencies) """
18 histype = str(type(toClone))
19 newhist = None
20 if "TH1I" in histype:
21 newhist = R.TH1F()
22 toClone.Copy(newhist)
23 elif "TH2I" in histype:
24 newhist = R.TH2F()
25 toClone.Copy(newhist)
26 else:
27 newhist = toClone.Clone()
28 return newhist
29
30

◆ divideByAcceptedEvts()

CaloMonTransforms.divideByAcceptedEvts ( inputs)
This function divides the input histogram by the number of events that passed a given selection

Definition at line 104 of file CaloMonTransforms.py.

104def divideByAcceptedEvts(inputs):
105 """ This function divides the input histogram by the number of events that passed a given selection"""
106 assert len(inputs) == 1
107 assert len(inputs[0][1]) == 2
108
109 cl = inputs[0][1][0].Clone()
110
111 label = inputs[0][0]['thr']
112
113 hnorm = inputs[0][1][1].Clone()
114 n0 = hnorm.GetNbinsX()
115 fbin = hnorm.GetXaxis().FindBin(label)
116
117 if fbin>=n0 or fbin<=0: #threshold not found
118 return [cl]
119
120 thenorm = hnorm.GetBinContent(fbin)
121
122 if thenorm==0:
123 return [cl]
124 cl.Scale(100.0/thenorm)
125
126 return [cl]
127
128

◆ divideByOccupancy()

CaloMonTransforms.divideByOccupancy ( inputs,
titleToReplace = "",
replaceTitWith = "" )
This function returns the ratio of two ROOT histograms 

Definition at line 73 of file CaloMonTransforms.py.

73def divideByOccupancy(inputs,titleToReplace="",replaceTitWith=""):
74 """ This function returns the ratio of two ROOT histograms """
75 assert len(inputs) == 1
76 assert len(inputs[0][1]) == 2
77
78 cl = cloneHistFloat(inputs[0][1][0])
79 cl.Reset()
80
81 if titleToReplace!="":
82 tit = cl.GetTitle()
83 tit = tit.replace(titleToReplace,replaceTitWith)
84 cl.SetTitle(tit)
85
86 nCells = cl.GetNcells()
87 assert(nCells==inputs[0][1][1].GetNcells())
88
89 cppyy.gbl.binbybinDiv(nCells,cl,inputs[0][1][0],inputs[0][1][1])
90 # for i in range(nCells):
91 # t = inputs[0][1][0].GetBinContent(i);
92 # o = inputs[0][1][1].GetBinContent(i);
93 # if o>0:
94 # cl.SetBinContent(i,t/o);
95 # cl.SetBinError(i,TMath.Sqrt(1./o));
96 # pass
97 #pass
98
99 cl.SetEntries(inputs[0][1][0].GetEntries())
100
101 return [cl]
102
103
TGraphErrors * GetEntries(TH2F *histo)

◆ divideHistCaloMon()

CaloMonTransforms.divideHistCaloMon ( inputs,
doPercentage = False )
This function returns the ratio of two ROOT histograms 

Definition at line 31 of file CaloMonTransforms.py.

31def divideHistCaloMon(inputs,doPercentage=False):
32 """ This function returns the ratio of two ROOT histograms """
33 assert len(inputs) == 1
34 assert len(inputs[0][1]) == 3
35
36 cl = cloneHistFloat(inputs[0][1][0])
37 cl.Divide(inputs[0][1][1])
38
39 label = inputs[0][0]['thr']
40
41 hnorm = inputs[0][1][2].Clone()
42 n0 = hnorm.GetNbinsX()
43 fbin = hnorm.GetXaxis().FindBin(label)
44
45 if fbin>=n0 or fbin<=0:
46 return [cl]
47
48 thenorm = hnorm.GetBinContent(fbin)
49 cl.SetEntries(thenorm)
50
51 if not doPercentage or thenorm==0:
52 return [cl]
53
54 cl.Scale(100.0/thenorm)
55
56 return [cl]
57
58

◆ simpleDivideByAcceptedEvts()

CaloMonTransforms.simpleDivideByAcceptedEvts ( inputs,
titleToReplace = "",
replaceTitWith = "" )
This function divides the input histogram by the number of accepted events

Definition at line 129 of file CaloMonTransforms.py.

129def simpleDivideByAcceptedEvts(inputs,titleToReplace="",replaceTitWith=""):
130 """ This function divides the input histogram by the number of accepted events"""
131 assert len(inputs) == 1 #Expect only one match
132 assert len(inputs[0][1]) == 2 # pair of (regex-match,list-of-hists)
133
134 cl = cloneHistFloat(inputs[0][1][0]) # First histogram of the list of histgrams in the pair
135
136 hnorm = inputs[0][1][1] #Second histogram in the list of histograms is the number of events
137 theNorm=hnorm.GetBinContent(1)
138 if theNorm>1:
139 cl.Scale(100.0/theNorm)
140
141 if titleToReplace!="":
142 tit = cl.GetTitle()
143 tit = tit.replace(titleToReplace,replaceTitWith)
144 cl.SetTitle(tit)
145
146 return [cl]