ATLAS Offline Software
Final2012/ParsebJESInput.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
2 
3 from ROOT import *
4 from array import array
5 import glob
6 import re
7 import math
8 import ProviderHistoHelpers
9 
10 
11 SystematicNameDictionary = {
12  'herwigpp' : 'bJES_Generator',
13  'distorted_geometry' : 'bJES_Geometry',
14  'FTFP_BERT' : 'bJES_HadIntModel'
15  }
16 
17 jetDefDict = {
18  'AntiKt4TopoEM' : 'AntiKt4Topo_EMJES',
19  'AntiKt6TopoEM' : 'AntiKt6Topo_EMJES',
20  'AntiKt4LCTopo' : 'AntiKt4Topo_LCJES',
21  'AntiKt6LCTopo' : 'AntiKt6Topo_LCJES'
22  }
23 
24 def ReadBJESHistograms(dirName):
25  if not dirName.endswith("/"):
26  dirName = dirName + "/"
27 
28  # Run over each file (one per jet definition)
29  # Skip files that don't start with b-JES and contain GSC
30  histos = {}
31  files = sorted(glob.glob(dirName+"b-JES*GSC.root"))
32  for aFileName in files:
33  # Determine the jet definition
34  jetDef = ""
35  for aFileDef,aJetDef in jetDefDict.iteritems():
36  if aFileDef in aFileName:
37  jetDef = aJetDef
38  break
39  if jetDef == "":
40  print "Failed to determine jet definition for file:",aFileName
41  return None
42  histos[jetDef] = {}
43 
44  # Read in the histograms of interest from the file
45  inFile = TFile(aFileName,"READ")
46  for aName,aSystName in SystematicNameDictionary.iteritems():
47  systematicName = aSystName + "_" + jetDef
48  histo = inFile.Get(aName)
49  if histo is None:
50  print "Failed to get histogram:",systematicName
51  return None
52 
53  histo2D = ProviderHistoHelpers.ConvertTGraphToProviderHisto(histo,systematicName)
54  histo2D.SetDirectory(0)
55 
56  # It's currently response, set to difference from 1
57  for ptBin in range(1,histo2D.GetNbinsX()+1):
58  for etaBin in range(1,histo2D.GetNbinsY()+1):
59  histo2D.SetBinContent(ptBin,etaBin,1-histo2D.GetBinContent(ptBin,etaBin))
60 
61  histos[jetDef][aSystName] = histo2D
62 
63  # Done reading, close the file
64  inFile.Close()
65 
66  # Make one quadrature sum histo of the desired components for now
67  # The new provider design should make this irrelevant for multijet components too, but for now...
68  for aDef,aHistoSet in histos.iteritems():
69  # We want one histo of herwigpp and distorted_geometry (leave out FTFP_BERT)
70  histos[aDef]['bJES'] = ProviderHistoHelpers.QuadratureSumHisto('bJES',[histos[aDef]['bJES_Generator'],histos[aDef]['bJES_Geometry']])
71  histos[aDef]['bJES'].SetDirectory(0)
72 
73  return histos
74 
ParsebJESInput.ReadBJESHistograms
def ReadBJESHistograms(dirName)
Definition: Final2012/ParsebJESInput.py:24
ProviderHistoHelpers.ConvertTGraphToProviderHisto
def ConvertTGraphToProviderHisto(graph, histoName)
Definition: Final2012/ProviderHistoHelpers.py:65
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
ProviderHistoHelpers.QuadratureSumHisto
def QuadratureSumHisto(histoName, histos)
Definition: Final2012/ProviderHistoHelpers.py:153
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.
RCU::SetDirectory
bool SetDirectory(TObject *object, TDirectory *directory)
effects: set the directory this object is associated with returns: whether the object type actively k...
Definition: RootUtils.cxx:28