ATLAS Offline Software
January2018_specialStatTerms/ParsePileupInput.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 # One file from Eric with the offset terms.
9 # A few extra files: rho topology terms are newly computed from values from
10 # Jamie and Jacob (by me, see script in input directory)
11 # and pt terms have been calculated once for 2015 by Steve Alkire.
12 # pT term inputs for both collections were collated in a single file.
13 
14 SystematicNames = ['Pileup_OffsetNPV','Pileup_OffsetMu','Pileup_PtTerm_npv','Pileup_PtTerm_mu','Pileup_RhoTopology']
15 
16 jetDefs = {'AntiKt4EMTopo':'AntiKt4Topo_EMJES','AntiKt4EMPFlow':'AntiKt4PFlow_EMJES'}
17 
18 def ReadPileupHistograms(dirName):
19  if not dirName.endswith("/"):
20  dirName = dirName + "/"
21 
22  # We're just taking it from the old ROOT file...
23  # Ensure there is just one such file
24  rootFileList = sorted(glob.glob(dirName+"*.root"))
25 
26  histos = {}
27 
28  for aJetDef in jetDefs.keys():
29  histos[jetDefs[aJetDef]] = {}
30 
31  for file in rootFileList :
32  rootFile = TFile(file,"READ")
33 
34  # Loop over the desired systematics
35  for aSystName in SystematicNames:
36  systematicName = aSystName + "_" + aJetDef
37  if systematicName not in rootFile.GetKeyNames() :
38  continue
39  histo = rootFile.Get(systematicName)
40  histo.SetDirectory(0)
41 
42  histos[jetDefs[aJetDef]][aSystName] = histo
43 
44  # Done reading, close the file
45  rootFile.Close()
46 
47 
48  # Did we get everything?
49  for aJetDef in jetDefs.keys():
50  print "Beginning jetDef",aJetDef
51  for aSystName in SystematicNames:
52  print "Beginning systName",aSystName
53  if not aSystName in histos[jetDefs[aJetDef]].keys() :
54  print "Failed to find histogram:",aSystName,"for jet definition",aJetDef
55 
56  return histos
57 
58 
59 
DerivationFramework::TriggerMatchingUtils::sorted
std::vector< typename T::value_type > sorted(T begin, T end)
Helper function to create a sorted vector from an unsorted one.
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:798
ParsePileupInput.ReadPileupHistograms
def ReadPileupHistograms(dirName)
Definition: Final2012/ParsePileupInput.py:15