16 for aBin
in range(1,self.GetNbinsX()+2):
17 xBins.append(self.GetXaxis().GetBinLowEdge(aBin))
20 if self.GetDimension() > 1:
21 for aBin
in range(1,self.GetNbinsY()+2):
22 yBins.append(self.GetYaxis().GetBinLowEdge(aBin))
25 if self.GetDimension() > 2:
26 for aBin
in range(1,self.GetNbinsZ()+2):
27 zBins.append(self.GetZaxis().GetBinLowEdge(aBin))
30 xBins = [aVal*factor
for aVal
in xBins]
32 yBins = [aVal*factor
for aVal
in yBins]
34 zBins = [aVal*factor
for aVal
in zBins]
37 if self.GetDimension() == 1:
38 if isinstance(self,TH1C):
39 histo = TH1C(self.GetName()+
"_scaled",self.GetTitle(),len(xBins)-1,array.array(
'd',xBins))
40 elif isinstance(self,TH1S):
41 histo = TH1S(self.GetName()+
"_scaled",self.GetTitle(),len(xBins)-1,array.array(
'd',xBins))
42 elif isinstance(self,TH1I):
43 histo = TH1I(self.GetName()+
"_scaled",self.GetTitle(),len(xBins)-1,array.array(
'd',xBins))
44 elif isinstance(self,TH1F):
45 histo =
TH1F(self.GetName()+
"_scaled",self.GetTitle(),len(xBins)-1,array.array(
'd',xBins))
46 elif isinstance(self,TH1D):
47 histo = TH1D(self.GetName()+
"_scaled",self.GetTitle(),len(xBins)-1,array.array(
'd',xBins))
48 for xBin
in range(1,self.GetNbinsX()+1):
49 histo.SetBinContent(xBin,self.GetBinContent(xBin))
50 elif self.GetDimension() == 2:
51 if isinstance(self,TH2C):
52 histo = TH2C(self.GetName()+
"_scaled",self.GetTitle(),len(xBins)-1,array.array(
'd',xBins),len(yBins)-1,array.array(
'd',yBins))
53 elif isinstance(self,TH2S):
54 histo = TH2S(self.GetName()+
"_scaled",self.GetTitle(),len(xBins)-1,array.array(
'd',xBins),len(yBins)-1,array.array(
'd',yBins))
55 elif isinstance(self,TH2I):
56 histo = TH2I(self.GetName()+
"_scaled",self.GetTitle(),len(xBins)-1,array.array(
'd',xBins),len(yBins)-1,array.array(
'd',yBins))
57 elif isinstance(self,TH2F):
58 histo =
TH2F(self.GetName()+
"_scaled",self.GetTitle(),len(xBins)-1,array.array(
'd',xBins),len(yBins)-1,array.array(
'd',yBins))
59 elif isinstance(self,TH2D):
60 histo = TH2D(self.GetName()+
"_scaled",self.GetTitle(),len(xBins)-1,array.array(
'd',xBins),len(yBins)-1,array.array(
'd',yBins))
61 for xBin
in range(1,self.GetNbinsX()+1):
62 for yBin
in range(1,self.GetNbinsY()+1):
63 histo.SetBinContent(xBin,yBin,self.GetBinContent(xBin,yBin))
64 elif self.GetDimension() == 3:
65 if isinstance(self,TH3C):
66 histo = TH3C(self.GetName()+
"_scaled",self.GetTitle(),len(xBins)-1,array.array(
'd',xBins),len(yBins)-1,array.array(
'd',yBins),len(zBins)-1,array.array(
'd',zBins))
67 elif isinstance(self,TH3S):
68 histo = TH3S(self.GetName()+
"_scaled",self.GetTitle(),len(xBins)-1,array.array(
'd',xBins),len(yBins)-1,array.array(
'd',yBins),len(zBins)-1,array.array(
'd',zBins))
69 elif isinstance(self,TH3I):
70 histo = TH3I(self.GetName()+
"_scaled",self.GetTitle(),len(xBins)-1,array.array(
'd',xBins),len(yBins)-1,array.array(
'd',yBins),len(zBins)-1,array.array(
'd',zBins))
71 elif isinstance(self,TH3F):
72 histo = TH3F(self.GetName()+
"_scaled",self.GetTitle(),len(xBins)-1,array.array(
'd',xBins),len(yBins)-1,array.array(
'd',yBins),len(zBins)-1,array.array(
'd',zBins))
73 elif isinstance(self,TH3D):
74 histo = TH3D(self.GetName()+
"_scaled",self.GetTitle(),len(xBins)-1,array.array(
'd',xBins),len(yBins)-1,array.array(
'd',yBins),len(zBins)-1,array.array(
'd',zBins))
75 for xBin
in range(1,self.GetNbinsX()+1):
76 for yBin
in range(1,self.GetNbinsY()+1):
77 for zBin
in range(1,self.GetNbinsZ()+1):
78 histo.SetBinContent(xBin,yBin,zBin,self.GetBinContent(xBin,yBin,zBin))
81 TH1.ScaleBins = ScaleBins