ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Reconstruction
Jet
JetUncertainties
testingMacros
InputScripts
ICHEP2016
ICHEP2016/ParseInsituInput_MJB.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
# Dictionary to translate from Bogan's names to provider names
11
SystematicNameDictionary = {
12
'gammajetdphi'
:
'Gjet_dPhi'
,
13
'gammajetgenerator'
:
'Gjet_Generator'
,
14
'gammajetjvt'
:
'Gjet_Jvt'
,
15
'gammajetoutofcone'
:
'Gjet_OOC'
,
16
# 'gammajetphscalemat' : 'Gjet_GamESmaterial',
17
# 'gammajetphscaleps' : 'Gjet_GamESpresampler',
18
'gammajetphscalez'
:
'Gjet_GamESZee'
,
19
'gammajetphsmear'
:
'Gjet_GamEsmear'
,
20
'gammajetpurity'
:
'Gjet_Purity'
,
21
'gammajetstat1'
:
'Gjet_Stat1'
,
22
'gammajetstat2'
:
'Gjet_Stat2'
,
23
'gammajetstat3'
:
'Gjet_Stat3'
,
24
'gammajetstat4'
:
'Gjet_Stat4'
,
25
'gammajetstat5'
:
'Gjet_Stat5'
,
26
'gammajetstat6'
:
'Gjet_Stat6'
,
27
'gammajetstat7'
:
'Gjet_Stat7'
,
28
'gammajetstat8'
:
'Gjet_Stat8'
,
29
'gammajetstat9'
:
'Gjet_Stat9'
,
30
'gammajetstat10'
:
'Gjet_Stat10'
,
31
'gammajetstat11'
:
'Gjet_Stat11'
,
32
'gammajetstat12'
:
'Gjet_Stat12'
,
33
'gammajetstat13'
:
'Gjet_Stat13'
,
34
'gammajetstat14'
:
'Gjet_Stat14'
,
35
'gammajetstat15'
:
'Gjet_Stat15'
,
36
'gammajetsubleadingjet'
:
'Gjet_Veto'
,
37
'zjetdphi'
:
'Zjet_dPhi'
,
38
# 'zjetescalemat' : 'Zjet_ElecESmaterial',
39
# 'zjetescaleps' : 'Zjet_ElecESpresampler',
40
'zjetescalez'
:
'Zjet_ElecESZee'
,
41
'zjetesmear'
:
'Zjet_ElecEsmear'
,
42
'zjetgenerator'
:
'Zjet_MC'
,
43
'zjetjvt'
:
'Zjet_Jvt'
,
44
'zjetmuscale'
:
'Zjet_MuScale'
,
45
'zjetmusmearid'
:
'Zjet_MuSmearID'
,
46
'zjetmusmearms'
:
'Zjet_MuSmearMS'
,
47
'zjetoutofcone'
:
'Zjet_KTerm'
,
48
'zjetstat1'
:
'Zjet_Stat1'
,
49
'zjetstat2'
:
'Zjet_Stat2'
,
50
'zjetstat3'
:
'Zjet_Stat3'
,
51
'zjetstat4'
:
'Zjet_Stat4'
,
52
'zjetstat5'
:
'Zjet_Stat5'
,
53
'zjetstat6'
:
'Zjet_Stat6'
,
54
'zjetstat7'
:
'Zjet_Stat7'
,
55
'zjetstat8'
:
'Zjet_Stat8'
,
56
'zjetstat9'
:
'Zjet_Stat9'
,
57
'zjetstat10'
:
'Zjet_Stat10'
,
58
'zjetstat11'
:
'Zjet_Stat11'
,
59
'zjetstat12'
:
'Zjet_Stat12'
,
60
'zjetstat13'
:
'Zjet_Stat13'
,
61
'zjetsubleadingjet'
:
'Zjet_Veto'
,
62
}
63
64
jetDefDict = {
65
'EMJES_R4'
:
'AntiKt4Topo_EMJES'
,
66
'EMJES_R6'
:
'AntiKt6Topo_EMJES'
,
67
'LCJES_R4'
:
'AntiKt4Topo_LCJES'
,
68
'LCJES_R6'
:
'AntiKt6Topo_LCJES'
69
}
70
71
def
ReadInSituHistograms
(dirName):
72
if
not
dirName.endswith(
"/"
):
73
dirName = dirName +
"/"
74
75
# Run over each subdirectory (one per jet definition)
76
histos = {}
77
subDirs = sorted(glob.glob(dirName+
"*"
))
78
for
aSubDirName
in
subDirs:
79
# Determine the jet definition
80
jetDef =
""
81
for
aDirDef,aJetDef
in
jetDefDict.iteritems():
82
if
aDirDef
in
aSubDirName:
83
jetDef = aJetDef
84
break
85
if
jetDef ==
""
:
86
print
"Failed to determine jet definition for directory:"
,aSubDirName
87
continue
88
else
:
89
print
"Jet definition is"
,jetDef
90
histos[jetDef] = {}
91
92
# Loop over the systematic files in the subdirectory
93
systFiles = sorted(glob.glob(aSubDirName+
"/SystError_*.txt"
))
94
for
aSystFile
in
systFiles:
95
# Figure out which component this is
96
systematicNameHandle = re.sub(aSubDirName+
"/SystError_"
,
""
,aSystFile)
97
systematicNameHandle = re.sub(
".txt"
,
""
,systematicNameHandle)
98
systematicName = SystematicNameDictionary[systematicNameHandle]
99
print
"Making histogram %s --> %s"
%(systematicNameHandle,systematicName)
100
101
# Open the file
102
systematicFile = open(aSystFile,
"r"
)
103
104
# Read the lines of the file into arrays
105
lowBinEdges = []
106
systValues = []
107
for
line
in
systematicFile.readlines():
108
line = line.strip(
"\r\n"
)
109
lowEdge = float(line.split()[0])
110
systVal = float(line.split()[2].
strip
())
111
112
lowBinEdges.append(lowEdge)
113
systValues.append(systVal)
114
115
# Done reading, close the file
116
systematicFile.close()
117
118
# Make the last bin go up to 2500
119
lowBinEdges.append(2500.)
120
systValues.append(systValues[-1])
121
122
# Turn the lists into arrays and build the 1D histogram
123
lowBinEdgesArray =
array
(
'd'
,lowBinEdges)
124
systValuesArray =
array
(
'd'
,systValues)
125
histoName = systematicName+
"_"
+jetDef
126
histo1D = TH1D(histoName+
"_1D"
,histoName+
"_1D"
,len(lowBinEdges)-1,lowBinEdgesArray)
127
128
# Fill it from the file values
129
for
iBin
in
xrange
(1,histo1D.GetNbinsX()+1):
130
histo1D.SetBinContent(iBin,systValues[iBin-1])
131
132
# Convert to a 2D provider-stlye histo -- WHY WOULD WE DO THAT
133
# STOP DOING THAT IT BREAKS THINGS
134
# histo = ProviderHistoHelpers.ConvertPtHistoToProviderHisto(histo1D,histoName)
135
# histo.SetDirectory(0)
136
# print "Histo is type",type(histo),"whereas input was",histo1D
137
# histos[jetDef][systematicName] = histo
138
histos[jetDef][systematicName] = histo1D
139
140
# EM has 10 stat parameters, LC has 11
141
# So for EM algorithms, make an empty histo for stat 11
142
# if "EM" in jetDef:
143
# systematicName = SystematicNameDictionary['mjbstat11']
144
# histos[jetDef][systematicName] = ProviderHistoHelpers.MakeProviderHisto(systematicName+"_"+jetDef)
145
# histos[jetDef][systematicName].SetDirectory(0)
146
147
148
# Done, return dictionary of histos
149
return
histos
150
151
152
153
SiliconTech::strip
@ strip
Definition
FPGATrackSimTypes.h:25
array
STL class.
xrange
void xrange(TH1 *h, bool symmetric)
Definition
computils.cxx:518
ParseInsituInput_MJB.ReadInSituHistograms
ReadInSituHistograms(dirName)
Definition
ICHEP2016/ParseInsituInput_MJB.py:71
Generated on
for ATLAS Offline Software by
1.17.0