ATLAS Offline Software
Functions | Variables
ConvertOldUJHistosToNewHistos Namespace Reference

Functions

def GetKeyNames (self, dir="")
 
def ScaleBins (self, factor, axis="x")
 

Variables

 outFileName = sys.argv[1]
 
 inFileName = sys.argv[2]
 
 outFile = TFile.Open(outFileName,"RECREATE")
 
 inFile = TFile.Open(inFileName,"READ")
 
 validHist = inFile.Get("Valid_area")
 
 hist = inFile.Get(histName)
 
 histNameConverted = None
 
string jetType = "AntiKt10LCTopoTrimmedPtFrac5SmallR30"
 
 converted = hist
 
list bins = []
 
 binArray = array.array('d',bins)
 
list etaBins = [-4.5,4.5]
 
 etaBinArray = array.array('d',etaBins)
 

Function Documentation

◆ GetKeyNames()

def ConvertOldUJHistosToNewHistos.GetKeyNames (   self,
  dir = "" 
)

Definition at line 8 of file ConvertOldUJHistosToNewHistos.py.

8 def GetKeyNames(self,dir=""):
9  self.cd(dir)
10  return [key.GetName() for key in gDirectory.GetListOfKeys()]
11 TFile.GetKeyNames = GetKeyNames
12 
13 

◆ ScaleBins()

def ConvertOldUJHistosToNewHistos.ScaleBins (   self,
  factor,
  axis = "x" 
)

Definition at line 14 of file ConvertOldUJHistosToNewHistos.py.

14 def ScaleBins(self,factor,axis="x"):
15  xBins = []
16  for aBin in range(1,self.GetNbinsX()+2):
17  xBins.append(self.GetXaxis().GetBinLowEdge(aBin))
18 
19  yBins = []
20  if self.GetDimension() > 1:
21  for aBin in range(1,self.GetNbinsY()+2):
22  yBins.append(self.GetYaxis().GetBinLowEdge(aBin))
23 
24  zBins = []
25  if self.GetDimension() > 2:
26  for aBin in range(1,self.GetNbinsZ()+2):
27  zBins.append(self.GetZaxis().GetBinLowEdge(aBin))
28 
29  if "x" in axis:
30  xBins = [aVal*factor for aVal in xBins]
31  if "y" in axis:
32  yBins = [aVal*factor for aVal in yBins]
33  if "z" in axis:
34  zBins = [aVal*factor for aVal in zBins]
35 
36  histo = None
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))
79  return histo
80 
81 TH1.ScaleBins = ScaleBins
82 
83 
84 

Variable Documentation

◆ binArray

ConvertOldUJHistosToNewHistos.binArray = array.array('d',bins)

Definition at line 143 of file ConvertOldUJHistosToNewHistos.py.

◆ bins

list ConvertOldUJHistosToNewHistos.bins = []

Definition at line 140 of file ConvertOldUJHistosToNewHistos.py.

◆ converted

ConvertOldUJHistosToNewHistos.converted = hist

Definition at line 137 of file ConvertOldUJHistosToNewHistos.py.

◆ etaBinArray

ConvertOldUJHistosToNewHistos.etaBinArray = array.array('d',etaBins)

Definition at line 146 of file ConvertOldUJHistosToNewHistos.py.

◆ etaBins

list ConvertOldUJHistosToNewHistos.etaBins = [-4.5,4.5]

Definition at line 145 of file ConvertOldUJHistosToNewHistos.py.

◆ hist

ConvertOldUJHistosToNewHistos.hist = inFile.Get(histName)

Definition at line 118 of file ConvertOldUJHistosToNewHistos.py.

◆ histNameConverted

ConvertOldUJHistosToNewHistos.histNameConverted = None

Definition at line 120 of file ConvertOldUJHistosToNewHistos.py.

◆ inFile

ConvertOldUJHistosToNewHistos.inFile = TFile.Open(inFileName,"READ")

Definition at line 106 of file ConvertOldUJHistosToNewHistos.py.

◆ inFileName

ConvertOldUJHistosToNewHistos.inFileName = sys.argv[2]

Definition at line 92 of file ConvertOldUJHistosToNewHistos.py.

◆ jetType

string ConvertOldUJHistosToNewHistos.jetType = "AntiKt10LCTopoTrimmedPtFrac5SmallR30"

Definition at line 121 of file ConvertOldUJHistosToNewHistos.py.

◆ outFile

ConvertOldUJHistosToNewHistos.outFile = TFile.Open(outFileName,"RECREATE")

Definition at line 105 of file ConvertOldUJHistosToNewHistos.py.

◆ outFileName

ConvertOldUJHistosToNewHistos.outFileName = sys.argv[1]

Definition at line 91 of file ConvertOldUJHistosToNewHistos.py.

◆ validHist

ConvertOldUJHistosToNewHistos.validHist = inFile.Get("Valid_area")

Definition at line 110 of file ConvertOldUJHistosToNewHistos.py.

ConvertOldUJHistosToNewHistos.ScaleBins
def ScaleBins(self, factor, axis="x")
Definition: ConvertOldUJHistosToNewHistos.py:14
python.TrigEgammaMonitorHelper.TH2F
def TH2F(name, title, nxbins, bins_par2, bins_par3, bins_par4, bins_par5=None, bins_par6=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:45
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
ConvertOldUJHistosToNewHistos.GetKeyNames
def GetKeyNames(self, dir="")
Definition: ConvertOldUJHistosToNewHistos.py:8
python.TrigEgammaMonitorHelper.TH1F
def TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:24