ATLAS Offline Software
Functions | Variables
Parse2012Input Namespace Reference

Functions

def GetKeyNames (self, dir="")
 
def Read2012Histograms (dirName, scaleEtaInter3Regions=False, scaleEtaInter2Regions=False)
 

Variables

dictionary useJetCollections = {"AntiKt4EMTopo": "AntiKt4Topo_EMJES", "AntiKt4LCTopo": "AntiKt4Topo_LCJES"}
 
list haveUpdatedVersions
 

Function Documentation

◆ GetKeyNames()

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

Definition at line 27 of file ICHEP2016/Parse2012Input.py.

27 def GetKeyNames(self,dir=""):
28  self.cd(dir)
29  return [key.GetName() for key in gDirectory.GetListOfKeys()]
30 TFile.GetKeyNames = GetKeyNames
31 

◆ Read2012Histograms()

def Parse2012Input.Read2012Histograms (   dirName,
  scaleEtaInter3Regions = False,
  scaleEtaInter2Regions = False 
)

Definition at line 32 of file ICHEP2016/Parse2012Input.py.

32 def Read2012Histograms(dirName,scaleEtaInter3Regions=False,scaleEtaInter2Regions=False):
33  removeInSitu = False
34  if not dirName.endswith("/"):
35  dirName = dirName + "/"
36 
37  # Just one file here with everything in it.
38  aSystFile = dirName + "JESUncertainty_2012.root"
39  systematicFile = TFile(aSystFile,"READ")
40 
41  histos = {}
42  for key in systematicFile.GetKeyNames() :
43 
44  # Formatting is all already correct.
45 
46  # Only keep things of the jet collections we are using.
47  jettype = key.split("_")[-1]
48  if jettype not in useJetCollections.keys() :
49  continue
50  elif useJetCollections[jettype] not in histos :
51  print "Adding extra dict..."
52  histos[useJetCollections[jettype]] = {}
53 
54  # Only keep things for which we do not have a more current version.
55  systname = key.replace("_"+jettype,"")
56  if systname in haveUpdatedVersions :
57  continue
58 
59  histo = systematicFile.Get(key)
60  histo.SetDirectory(0)
61 
62  if key.find("EtaIntercalibration_Modelling")!=-1 and (scaleEtaInter3Regions or scaleEtaInter2Regions) :
63 
64  print "OH NO!!!"
65  return
66 
67  # Loop over pT bins.
68  for xbin in range(histo.GetNbinsX()+2) :
69  # Loop out in eta.
70  for ybin in range(histo.GetNbinsY()+2) :
71  run1val = histo.GetBinContent(xbin,ybin)
72  #print "Bin at pT ",histo.GetXaxis().GetBinCenter(xbin)," and [ylow,y,yhigh] = ", binYLow, histo.GetYaxis().GetBinCenter(ybin), binYHigh
73  # Store bin contents as we go out: last one is one we want as frozen value.
74  if abs(histo.GetYaxis().GetBinCenter(ybin)) < 0.8 :
75  continue
76  elif 0.8 < abs(histo.GetYaxis().GetBinCenter(ybin)) < 2.5 :
77  if scaleEtaInter3Regions :
78  histo.SetBinContent(xbin,ybin,2.0*run1val)
79  else :
80  continue
81  else :
82  histo.SetBinContent(xbin,ybin,3.0*run1val)
83 
84  if (key.find("LAr_")!=-1 or key.find("Zjet_")!=-1 or key.find("Gjet")!=-1) and removeInSitu :
85 
86  # Loop over all bins. If outside eta range, set to "no uncertainty" = 0
87  for xbin in range(histo.GetNbinsX()+2) :
88  for ybin in range(histo.GetNbinsY()+2) :
89  # Set to zero if outside of eta range.
90  #print 'Eta is', abs(histo.GetYaxis().GetBinCenter(ybin))
91  if abs(histo.GetYaxis().GetBinCenter(ybin)) > 0.8 :
92  histo.SetBinContent(xbin,ybin,0.0)
93  else :
94  continue
95  #print "Leaving bin content."
96 
97  if key.find("PunchThrough")!=-1 :
98 
99  # Find maximum value on old histogram: we will use this everywhere
100  maxVal = histo.GetMaximum()
101  print "For punchthrough, using max val",maxVal
102 
103  # Loop over all bins in x, y, z.
104  for xbin in range(histo.GetNbinsX()+2) :
105  for ybin in range(histo.GetNbinsY()+2) :
106  for zbin in range(histo.GetNbinsZ()+2) :
107  # Permitted regions are only:
108  # - pT > 50 GeV
109  # - eta < 2.7
110  # - NSegments > 20
111 
112  # x axis is pT.
113  # y axis is nSegments
114  # z axis is eta
115  if histo.GetXaxis().GetBinCenter(xbin) < 50 or \
116  histo.GetYaxis().GetBinCenter(ybin) < 20 or \
117  histo.GetZaxis().GetBinCenter(zbin) > 2.7 :
118  histo.SetBinContent(xbin,ybin,zbin,0.0)
119 
120  else :
121  # Set to maximum value
122  histo.SetBinContent(xbin,ybin,zbin,maxVal)
123 
124  if key.find("MC12") :
125  # New histo
126  newhist = histo.Clone()
127  oldname = histo.GetName()
128  newname = oldname.replace("MC12","MC15")
129  newhist.SetName(newname)
130  newkey = systname.replace("MC12","MC15")
131  newhist.SetDirectory(0)
132  histos[useJetCollections[jettype]][newkey] = newhist
133  continue
134 
135  histos[useJetCollections[jettype]][systname] = histo
136 
137  # Done, return dictionary of histos
138  return histos
139 
140 
141 
142 

Variable Documentation

◆ haveUpdatedVersions

list Parse2012Input.haveUpdatedVersions
Initial value:
1 = ["FlavorResponse",
2  "flavorCompGlu",
3  "flavorCompLight",
4  "Pileup_OffsetMu",
5  "Pileup_OffsetNPV",
6  "Pileup_PtTerm_Mu",
7  "Pileup_PtTerm_NPV",
8 # "PunchThrough_AFII",
9 # "PunchThrough_MC12",
10  "RelativeNonClosure_AFII",
11  "RelativeNonClosure_MC12",
12  "EtaIntercalibration_Modelling",
13  "EtaIntercalibration_TotalStat",]

Definition at line 13 of file ICHEP2016/Parse2012Input.py.

◆ useJetCollections

dictionary Parse2012Input.useJetCollections = {"AntiKt4EMTopo": "AntiKt4Topo_EMJES", "AntiKt4LCTopo": "AntiKt4Topo_LCJES"}

Definition at line 11 of file ICHEP2016/Parse2012Input.py.

Parse2012Input.GetKeyNames
def GetKeyNames(self, dir="")
Definition: ICHEP2016/Parse2012Input.py:27
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
Parse2012Input.Read2012Histograms
def Read2012Histograms(dirName, scaleEtaInter3Regions=False, scaleEtaInter2Regions=False)
Definition: ICHEP2016/Parse2012Input.py:32