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