ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Reconstruction
Jet
JetUncertainties
testingMacros
InputScripts
January2018_specialStatTerms
January2018_specialStatTerms/ParseNonClosureInput.py
Go to the documentation of this file.
1
from
ROOT
import
*
2
from
array
import
array
3
import
glob
4
import
re
5
import
math
6
import
ProviderHistoHelpers
7
8
9
SystematicNameDictionary = {
10
'RelativeNonClosure_AFII_AntiKt4EMTopo'
:
'RelativeNonClosure_AFII'
,
11
'RelativeNonClosure_AFII_AntiKt4EMPFlow'
:
'RelativeNonClosure_AFII'
12
}
13
14
jetDefDict = {
15
'EMTopo'
:
'AntiKt4Topo_EMJES'
,
16
'EMPFlow'
:
'AntiKt4PFlow_EMJES'
,
17
}
18
19
def
ReadNonClosureHistograms(dirName,freezepT=False):
20
if
dirName.endswith(
".root"
) :
21
files = [dirName]
22
23
elif
not
dirName.endswith(
"/"
) :
24
dirName = dirName +
"/"
25
print
"Looking in dirName"
,dirName
26
import
os
27
os.listdir(dirName)
28
files = sorted(glob.glob(dirName+
"*.root"
))
29
30
# Run over each file (one per jet definition)
31
histos = {}
32
for
aFileName
in
files:
33
# Determine the jet definition
34
jetDef =
""
35
for
aFileDef,aJetDef
in
jetDefDict.iteritems():
36
if
aFileDef
in
aFileName:
37
jetDef = aJetDef
38
break
39
if
jetDef ==
""
:
40
print
"Failed to determine jet definition for file:"
,aFileName
41
return
None
42
histos[jetDef] = {}
43
44
# Read in the histogram from the file
45
inFile = TFile(aFileName,
"READ"
)
46
for
aName,aSystName
in
SystematicNameDictionary.iteritems():
47
print
aName,aFileDef,aSystName
48
if
not
aFileDef
in
aName :
continue
49
systematicName = aSystName +
"_"
+ jetDef
50
print
systematicName
51
histo = inFile.Get(aName)
52
if
histo
is
None
:
53
print
"Failed to get histogram:"
,systematicName
54
return
None
55
56
if
freezepT :
57
# Loop over eta bins.
58
for
ybin
in
range(histo.GetNbinsY()+2) :
59
# Loop out in pT.
60
freezeval = 0
61
for
xbin
in
range(histo.GetNbinsX()+2) :
62
inbin = histo.GetBinContent(xbin,ybin)
63
#print "Bin at pT ",histo.GetXaxis().GetBinCenter(xbin)," and [ylow,y,yhigh] = ", binYLow, histo.GetYaxis().GetBinCenter(ybin), binYHigh
64
# Store bin contents as we go out: last one is one we want as frozen value.
65
if
inbin > -0.5 :
66
freezeval = inbin
67
else
:
68
histo.SetBinContent(xbin,ybin,freezeval)
69
70
71
histoSym =
ProviderHistoHelpers.SymmetrizeHistoInEta
(histo,systematicName)
72
histoSym.SetDirectory(0)
73
histos[jetDef][aSystName] = histoSym
74
print
"Added hist with name"
,aSystName,
"for jetDef"
,jetDef
75
76
# Also add a blank nonclosure histo for Pythia8
77
# Also add a blank Closeby histo for both AFII and Pythia8
78
etaBins = [
min
(
ProviderHistoHelpers.GetDefaultEtaBins
()),0,
max
(
ProviderHistoHelpers.GetDefaultEtaBins
())]
79
histos[jetDef][
"RelativeNonClosure_MC16"
] =
ProviderHistoHelpers.MakeProviderHisto
(
"RelativeNonClosure_MC16"
,ptBins=[15,1000,2500],etaBins=etaBins)
80
histos[jetDef][
"RelativeNonClosure_MC16"
].SetDirectory(0)
81
histos[jetDef][
"CloseBy_Pythia8"
] =
ProviderHistoHelpers.MakeProviderHisto
(
"CloseBy_MC16"
,ptBins=[15,1000,2500],etaBins=etaBins)
82
histos[jetDef][
"CloseBy_Pythia8"
].SetDirectory(0)
83
histos[jetDef][
"CloseBy_AFII"
] =
ProviderHistoHelpers.MakeProviderHisto
(
"CloseBy_AFII"
,ptBins=[15,1000,2500],etaBins=etaBins)
84
histos[jetDef][
"CloseBy_AFII"
].SetDirectory(0)
85
86
# Done reading, close the file
87
inFile.Close()
88
89
return
histos
min
#define min(a, b)
Definition
cfImp.cxx:40
max
#define max(a, b)
Definition
cfImp.cxx:41
ProviderHistoHelpers.GetDefaultEtaBins
GetDefaultEtaBins()
Definition
Final2012/ProviderHistoHelpers.py:18
ProviderHistoHelpers.SymmetrizeHistoInEta
SymmetrizeHistoInEta(histo, histoName)
Definition
Final2012/ProviderHistoHelpers.py:127
ProviderHistoHelpers.MakeProviderHisto
MakeProviderHisto(histoName, ptBins=GetDefaultPtBins(), etaBins=GetDefaultEtaBins())
Definition
Final2012/ProviderHistoHelpers.py:40
Generated on
for ATLAS Offline Software by
1.17.0