ATLAS Offline Software
Loading...
Searching...
No Matches
ICHEP2016/ParseEtaIntercalInput.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
10SystematicNames = {'EtaIntercalibration_TotalStat' : 'EtaIntercalibration_TotalStat',\
11 'EtaIntercalibration_TotalSyst' : 'EtaIntercalibration_Modelling',\
12 'EtaIntercalibration_NonClosure' : 'EtaIntercalibration_NonClosure'
13 }
14
15jetDefDict = {
16 'AntiKt4EMTopo' : 'AntiKt4Topo_EMJES',
17 'AntiKt6EMTopo' : 'AntiKt6Topo_EMJES',
18 'AntiKt4LCTopo' : 'AntiKt4Topo_LCJES',
19 'AntiKt6LCTopo' : 'AntiKt6Topo_LCJES'
20 }
21
22def ReadEtaIntercalibrationHistograms(dirName):
23 if not dirName.endswith("/"):
24 dirName = dirName + "/"
25
26 # Run over each file (one per jet definition)
27 histos = {}
28 files = sorted(glob.glob(dirName+"*.root"))
29 for aFileName in files:
30 # Determine the jet definition
31 jetDef = ""
32 for aFileDef,aJetDef in jetDefDict.iteritems():
33 if aFileDef in aFileName:
34 jetDef = aJetDef
35 break
36 if jetDef == "":
37 print "Failed to determine jet definition for file:",aFileName
38 return None
39 if jetDef not in histos.keys() :
40 histos[jetDef] = {}
41
42 # Read in the histograms of interest from the file
43 inFile = TFile(aFileName,"READ")
44 for aName in SystematicNames.keys():
45 getsystematicName = aName + "_" + jetDef.replace("Topo","")
46 systematicName = SystematicNames[aName] + "_" + jetDef
47
48 histo = inFile.Get(getsystematicName)
49 if not histo :
50 print "Failed to get histogram:",getsystematicName
51 continue
52 histo.SetName(systematicName+"_old")
53
54 # Histo has different range, extend it
55 histoNew = ProviderHistoHelpers.ExtendPtRangeOfHisto(histo,systematicName)
56 histoNew.SetDirectory(0)
57 histos[jetDef][SystematicNames[aName]] = histoNew
58
59 # Done reading, close the file
60 inFile.Close()
61
62 return histos