ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Reconstruction
Jet
JetUncertainties
testingMacros
InputScripts
Final2012
Final2012/ParseFlavourInput.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
17
SystematicNameDictionary = {
18
'LQ'
:
'flavorCompLight'
,
19
'Gluon'
:
'flavorCompGlu'
,
20
'HerwigVsPythia_Gluon'
:
'FlavorResponse'
21
}
22
23
jetDefDict = {
24
'4EM'
:
'AntiKt4Topo_EMJES'
,
25
'6EM'
:
'AntiKt6Topo_EMJES'
,
26
'4LC'
:
'AntiKt4Topo_LCJES'
,
27
'6LC'
:
'AntiKt6Topo_LCJES'
28
}
29
30
def
ReadFlavourHistograms
(dirName):
31
if
not
dirName.endswith(
"/"
):
32
dirName = dirName +
"/"
33
34
# Run over each file (one per jet definition for LQ/Gluon and one per jet definition for HvP)
35
histos = {}
36
files = sorted(glob.glob(dirName+
"*.root"
))
37
for
aFileName
in
files:
38
# Determine the jet definition
39
jetDef =
""
40
for
aFileDef,aJetDef
in
jetDefDict.iteritems():
41
if
aFileDef
in
aFileName:
42
jetDef = aJetDef
43
break
44
if
jetDef ==
""
:
45
print
"Failed to determine jet definition for file:"
,aFileName
46
return
None
47
if
jetDef
not
in
histos:
48
histos[jetDef] = {}
49
50
# Read in the histograms from the file
51
# Note that we want all the histograms, but with this scheme not everything in the dict is in each file
52
# So instead loop over all histos in the file
53
inFile = TFile(aFileName,
"READ"
)
54
for
histName
in
inFile.GetKeyNames():
55
systematicName = SystematicNameDictionary[histName]+
"_"
+jetDef
56
histo = inFile.Get(histName)
57
if
histo
is
None
:
58
print
"Failed to get histogram:"
,systematicName
59
return
None
60
61
histoSym =
ProviderHistoHelpers.SymmetrizeHistoInEta
(histo,systematicName)
62
histoSym.SetDirectory(0)
63
histos[jetDef][SystematicNameDictionary[histName]] = histoSym
64
# Done reading, close the file
65
inFile.Close()
66
67
return
histos
68
69
70
ParseFlavourInput.GetKeyNames
GetKeyNames
Definition
Final2012/ParseFlavourInput.py:14
ParseFlavourInput.ReadFlavourHistograms
ReadFlavourHistograms(dirName)
Definition
Final2012/ParseFlavourInput.py:30
ProviderHistoHelpers.SymmetrizeHistoInEta
SymmetrizeHistoInEta(histo, histoName)
Definition
Final2012/ProviderHistoHelpers.py:127
Generated on
for ATLAS Offline Software by
1.17.0