ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Reconstruction
Jet
JetUncertainties
testingMacros
InputScripts
Moriond2016
Moriond2016/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
print
"\n\n\ndoobledoobledooble"
22
23
# Run over each file (one per jet definition)
24
# Skip files that don't start with bJES and contain GSC
25
histos = {}
26
files = sorted(glob.glob(dirName+
"bJES*GSC.root"
))
27
28
if
len(files) > 1 :
29
print
"Not what I expected!"
30
return
None
31
aFileName = files[0]
32
33
print
"#######################"
34
print
"Beginning bJES fetcher on file"
,aFileName
35
36
# Read in the histograms of interest from the file
37
inFile = TFile(aFileName,
"READ"
)
38
for
inFileDef
in
jetDefDict.keys() :
39
jetDef = jetDefDict[inFileDef]
40
if
jetDef
not
in
histos.keys() :
41
histos[jetDef] = {}
42
fetchName =
"bJES_"
+ inFileDef
43
systematicName =
"bJES_"
+ jetDef
44
histo = inFile.Get(fetchName)
45
if
histo
is
None
:
46
print
"Failed to get histogram:"
,systematicName
47
return
None
48
histo.SetDirectory(0)
49
nbinsx = histo.GetNbinsX()
50
binsx = histo.GetXaxis().GetXbins()
51
newhisto = TH2D(
"bJES_extendedEta_{0}"
.format(jetDef),
"bJES_extendedEta_{0}"
.format(jetDef),nbinsx,binsx.GetArray(),2,-4.4,4.4)
52
newhisto.SetDirectory(0)
53
54
# This input is symmetric in eta but doesn't extend far enough.
55
# Should be symmetric in eta: find max value in each row and set everywhere.
56
# eta bins are y bins:
57
for
ptbin
in
range(1,histo.GetNbinsX()+1) :
58
59
# Get max val
60
maxVal = 0.0
61
for
etabin
in
range(1,histo.GetNbinsY()) :
62
thisVal = histo.GetBinContent(ptbin,etabin)
63
if
thisVal > maxVal : maxVal = thisVal
64
for
etabin
in
range(1,newhisto.GetNbinsY()+1) :
65
newhisto.SetBinContent(ptbin,etabin,maxVal)
66
67
histos[jetDef][
'bJES'
] = newhisto
68
69
# Done reading, close the file
70
inFile.Close()
71
72
print
"#######################"
73
print
"bJES fetcher returning:"
74
print
histos
75
76
return
histos
77
Generated on
for ATLAS Offline Software by
1.17.0