ATLAS Offline Software
Loading...
Searching...
No Matches
Prerec2012/ParsePunchthroughInput.py
Go to the documentation of this file.
1# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
2
3from ROOT import *
4from array import array
5import glob
6import re
7import math
8import ProviderHistoHelpers
9
10def GetKeyNames(self,dir=""):
11 self.cd(dir)
12 return [key.GetName() for key in gDirectory.GetListOfKeys()]
13TFile.GetKeyNames = GetKeyNames
14
15SystematicNameDictionary = {
16 'PunchThroughUncertainties_interpolation_resp_eta_0' : 'PunchThroughCentral',
17 'PunchThroughUncertainties_interpolation_resp_eta_1' : 'PunchThroughCrack',
18 'PunchThroughUncertainties_interpolation_resp_eta_2' : 'PunchThroughForward'
19 }
20
21jetDefDict = {
22 'AntiKt4TopoEM' : 'AntiKt4Topo_EMJES',
23 'AntiKt6TopoEM' : 'AntiKt6Topo_EMJES',
24 'AntiKt4LCTopo' : 'AntiKt4Topo_LCJES',
25 'AntiKt6LCTopo' : 'AntiKt6Topo_LCJES'
26 }
27
28#SystematicNameList = ['PunchThroughCentral','PunchThroughCrack','PunchThroughForward']
29#jetDefList = ['AntiKt4Topo_EMJES','AntiKt6Topo_EMJES','AntiKt4Topo_LCJES','AntiKt6Topo_LCJES']
30
31def ReadPunchthroughHistograms(dirName):
32 if not dirName.endswith("/"):
33 dirName = dirName + "/"
34
35 # Run over the one file
36 rootFileList = sorted(glob.glob(dirName+"*.root"))
37 if len(rootFileList) != 1:
38 print "Found a number of root files not equal to 1 in dir:",dirName
39 return None
40 rootFile = TFile(rootFileList[0],"READ")
41
42 histos = {}
43 for aJetDef,aJetDefProv in jetDefDict.iteritems():
44 histos[aJetDefProv] = {}
45
46 for histName in rootFile.GetKeyNames():
47 if aJetDef not in histName: continue
48 for aKey,aVal in SystematicNameDictionary.iteritems():
49 histName = aJetDef+"_"+aKey
50 histo = rootFile.Get(histName)
51 if histo is None:
52 print "Failed to get histogram:",histName
53 return None
54 histo.SetName(aVal+"_"+aJetDefProv)
55 histo.SetDirectory(0)
56
57 histos[aJetDefProv][aVal] = histo
58
59 # Done reading, close the file
60 rootFile.Close()
61
62
76
77 return histos
78