17 """ If we want to clone the bins from an integer-type histogram, but then wish to fill it with floats (for efficiencies) """
23 elif "TH2I" in histype:
27 newhist = toClone.Clone()
32 """ This function returns the ratio of two ROOT histograms """
33 assert len(inputs) == 1
34 assert len(inputs[0][1]) == 3
37 cl.Divide(inputs[0][1][1])
39 label = inputs[0][0][
'thr']
41 hnorm = inputs[0][1][2].Clone()
42 n0 = hnorm.GetNbinsX()
43 fbin = hnorm.GetXaxis().
FindBin(label)
45 if fbin>=n0
or fbin<=0:
48 thenorm = hnorm.GetBinContent(fbin)
49 cl.SetEntries(thenorm)
51 if not doPercentage
or thenorm==0:
54 cl.Scale(100.0/thenorm)
60 void binbybinDiv(size_t nCells,TH2* fraction, const TH2* total, const TH2* occupancy) {
61 for (size_t i=0;i<nCells;++i) {
62 const double t = total->GetBinContent(i);
63 const double o = occupancy->GetBinContent(i);
65 fraction->SetBinContent(i,t/o);
66 fraction->SetBinError(i,std::sqrt(1./o));
74 """ This function returns the ratio of two ROOT histograms """
75 assert len(inputs) == 1
76 assert len(inputs[0][1]) == 2
81 if titleToReplace!=
"":
83 tit = tit.replace(titleToReplace,replaceTitWith)
86 nCells = cl.GetNcells()
87 assert(nCells==inputs[0][1][1].GetNcells())
89 cppyy.gbl.binbybinDiv(nCells,cl,inputs[0][1][0],inputs[0][1][1])
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
109 cl = inputs[0][1][0].Clone()
111 label = inputs[0][0][
'thr']
113 hnorm = inputs[0][1][1].Clone()
114 n0 = hnorm.GetNbinsX()
115 fbin = hnorm.GetXaxis().
FindBin(label)
117 if fbin>=n0
or fbin<=0:
120 thenorm = hnorm.GetBinContent(fbin)
124 cl.Scale(100.0/thenorm)
130 """ This function divides the input histogram by the number of accepted events"""
131 assert len(inputs) == 1
132 assert len(inputs[0][1]) == 2
136 hnorm = inputs[0][1][1]
137 theNorm=hnorm.GetBinContent(1)
139 cl.Scale(100.0/theNorm)
141 if titleToReplace!=
"":
143 tit = tit.replace(titleToReplace,replaceTitWith)