ATLAS Offline Software
Loading...
Searching...
No Matches
January2018_specialStatTerms/ParseCurrentFile.py
Go to the documentation of this file.
1from ROOT import *
2from array import array
3import glob
4import re
5import math
6import ProviderHistoHelpers
7
8def GetKeyNames(self,dir=""):
9 self.cd(dir)
10 return [key.GetName() for key in gDirectory.GetListOfKeys()]
11TFile.GetKeyNames = GetKeyNames
12
13def 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