ATLAS Offline Software
January2018_specialStatTerms/ParseCurrentFile.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 def GetKeyNames(self,dir=""):
9  self.cd(dir)
10  return [key.GetName() for key in gDirectory.GetListOfKeys()]
11 TFile.GetKeyNames = GetKeyNames
12 
13 def ReadCurrentHistograms(aSystFile,newjetsdict=[]):
14 
15  useJetCollections = {"AntiKt4EMTopo" : "AntiKt4Topo_EMJES",
16  "AntiKt4EMPFlow": "AntiKt4PFlow_EMJES"}
17 
18  # Just one file here with everything in it.
19  systematicFile = TFile(aSystFile,"READ")
20 
21  if newjetsdict!=[] :
22  useJetCollections = newjetsdict
23 
24  histos = {}
25  for key in systematicFile.GetKeyNames() :
26 
27  # Only keep things of the jet collections we are using.
28  foundJetType = False
29  for type in useJetCollections :
30  if key.endswith(type) :
31  jettype = type
32  foundJetType = True
33  if not foundJetType :
34  print "No jet type matches"
35  continue
36  jetkey = useJetCollections[jettype]
37  if jetkey not in histos :
38  print "Adding extra dict..."
39  histos[jetkey] = {}
40 
41  systname = key.replace("_"+jettype,"")
42 
43  histo = systematicFile.Get(key)
44  histo.SetDirectory(0)
45  histos[jetkey][systname] = histo
46 
47  # Done, return dictionary of histos
48  return histos
49 
ParseCurrentFile.ReadCurrentHistograms
def ReadCurrentHistograms(aSystFile, newjetsdict=[])
Definition: ICHEP2016/ParseCurrentFile.py:15
ParseCurrentFile.GetKeyNames
def GetKeyNames(self, dir="")
Definition: ICHEP2016/ParseCurrentFile.py:10