ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Reconstruction
Jet
JetUncertainties
testingMacros
InputScripts
Moriond2016
Moriond2016/ParseHighPtInput.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
11
def
GetKeyNames(self,dir=""):
12
self.cd(dir)
13
return
[key.GetName()
for
key
in
gDirectory.GetListOfKeys()]
14
TFile.GetKeyNames = GetKeyNames
15
16
jetDefList = [
'AntiKt4Topo_EMJES'
]
#,"AntiKt4Topo_LCJES"]#,'AntiKt6Topo_EMJES','AntiKt4Topo_LCJES','AntiKt6Topo_LCJES']
17
18
def
ReadHighPtHistogramsFromOldFile(fileName) :
19
20
histos = {}
21
for
jetDef
in
jetDefList :
22
histos[jetDef] = {}
23
inFile = TFile(fileName,
"READ"
)
24
uncNames = [
"SingleParticle_HighPt"
]
25
jetCollections = {
"AntiKt4EMTopo"
:
"AntiKt4Topo_EMJES"
}
#, "AntiKt4LCTopo" : "AntiKt4Topo_LCJES"}
26
for
name
in
uncNames :
27
for
jetCollection
in
jetCollections.keys() :
28
getJetType = jetCollections[jetCollection]
29
fetchName = name+
"_"
+getJetType
30
hist = inFile.Get(fetchName)
31
hist.SetDirectory(0)
32
histos[jetCollections[jetCollection]][name] = hist
33
34
return
histos
35
36
def
ReadHighPtHistograms(dirName):
37
if
not
dirName.endswith(
"/"
):
38
dirName = dirName +
"/"
39
40
# Run over the two files
41
emFileList = sorted(glob.glob(dirName+
"EM*/*.root"
))
42
lcFileList = sorted(glob.glob(dirName+
"LC*/*.root"
))
43
if
len(emFileList) != 1:
44
print
"Found a number of EM root files not equal to 1 in dir:"
,dirName
45
return
None
46
if
len(lcFileList) != 1:
47
print
"Found a number of LC root files not equal to 1 in dir:"
,dirName
48
return
None
49
emFile = TFile(emFileList[0],
"READ"
)
50
lcFile = TFile(lcFileList[0],
"READ"
)
51
52
histos = {}
53
for
aJetDef
in
jetDefList:
54
histos[aJetDef] = {}
55
56
rootFile =
None
57
if
"EMJES"
in
aJetDef:
58
rootFile = emFile
59
elif
"LCJES"
in
aJetDef:
60
rootFile = lcFile
61
else
:
62
print
"Unexpected jet def:"
,aJetDef
63
return
None
64
65
for
histName
in
rootFile.GetKeyNames():
66
if
aJetDef
not
in
histName:
continue
67
histo = rootFile.Get(histName)
68
if
histo
is
None
:
69
print
"Failed to get histogram:"
,histName
70
return
None
71
histo.SetName(histName+
"_1D"
)
72
73
histos[aJetDef][re.sub(
"_%s"
%(aJetDef),
""
,histName)] =
ProviderHistoHelpers.ConvertPtHistoToProviderHisto
(histo,histName)
74
histos[aJetDef][re.sub(
"_%s"
%(aJetDef),
""
,histName)].SetDirectory(0)
75
76
lcFile.Close()
77
emFile.Close()
78
79
return
histos
80
ProviderHistoHelpers.ConvertPtHistoToProviderHisto
ConvertPtHistoToProviderHisto(histo1D, histoName)
Definition
Final2012/ProviderHistoHelpers.py:44
Generated on
for ATLAS Offline Software by
1.17.0