ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Reconstruction
Jet
JetUncertainties
testingMacros
InputScripts
ICHEP2016
ICHEP2016/ParsebJESInput.py
Go to the documentation of this file.
1
# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
2
3
from
ROOT
import
*
4
from
array
import
array
5
import
glob
6
import
re
7
import
math
8
import
ProviderHistoHelpers
9
10
jetDefDict = {
11
'AntiKt4EMTopo'
:
'AntiKt4Topo_EMJES'
,
12
# 'AntiKt6EMTopo' : 'AntiKt6Topo_EMJES',
13
'AntiKt4LCTopo'
:
'AntiKt4Topo_LCJES'
,
14
# 'AntiKt6LCTopo' : 'AntiKt6Topo_LCJES'
15
}
16
17
def
ReadBJESHistograms(dirName):
18
if
not
dirName.endswith(
"/"
):
19
dirName = dirName +
"/"
20
21
# Run over each file (one per jet definition)
22
# Skip files that don't start with bJES and contain GSC
23
histos = {}
24
files = sorted(glob.glob(dirName+
"bJES*GSC.root"
))
25
26
if
len(files) > 1 :
27
print
"Not what I expected!"
28
return
None
29
aFileName = files[0]
30
31
# Read in the histograms of interest from the file
32
inFile = TFile(aFileName,
"READ"
)
33
for
inFileDef
in
jetDefDict.keys() :
34
jetDef = jetDefDict[inFileDef]
35
if
jetDef
not
in
histos.keys() :
36
histos[jetDef] = {}
37
fetchName =
"bJES_"
+ inFileDef
38
systematicName =
"bJES_"
+ jetDef
39
histo = inFile.Get(fetchName)
40
if
histo
is
None
:
41
print
"Failed to get histogram:"
,systematicName
42
return
None
43
histo.SetDirectory(0)
44
nbinsx = histo.GetNbinsX()
45
binsx = histo.GetXaxis().GetXbins()
46
newhisto = TH2D(
"bJES_extendedEta_{0}"
.format(jetDef),
"bJES_extendedEta_{0}"
.format(jetDef),nbinsx,binsx.GetArray(),2,-4.4,4.4)
47
newhisto.SetDirectory(0)
48
49
# This input is symmetric in eta but doesn't extend far enough.
50
# Should be symmetric in eta: find max value in each row and set everywhere.
51
# eta bins are y bins:
52
for
ptbin
in
range(1,histo.GetNbinsX()+1) :
53
54
# Get max val
55
maxVal = 0.0
56
for
etabin
in
range(1,histo.GetNbinsY()) :
57
thisVal = histo.GetBinContent(ptbin,etabin)
58
if
thisVal > maxVal : maxVal = thisVal
59
for
etabin
in
range(1,newhisto.GetNbinsY()+1) :
60
newhisto.SetBinContent(ptbin,etabin,maxVal)
61
62
histos[jetDef][
'bJES'
] = newhisto
63
64
# Done reading, close the file
65
inFile.Close()
66
67
return
histos
68
Generated on
for ATLAS Offline Software by
1.17.0