ATLAS Offline Software
Loading...
Searching...
No Matches
Moriond2016/ParseNonClosureInput.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
10
11SystematicNameDictionary = {
12 'RelativeNonClosure_AFII_AntiKt4EMTopo' : 'RelativeNonClosure_AFII'
13 }
14
15jetDefDict = {
16 '4EM' : 'AntiKt4Topo_EMJES',
17# '6EM' : 'AntiKt6Topo_EMJES',
18# '4LC' : 'AntiKt4Topo_LCJES',
19# '6LC' : 'AntiKt6Topo_LCJES'
20 }
21
22def ReadNonClosureHistograms(dirName,freezepT=False):
23 if dirName.endswith(".root") :
24 files = [dirName]
25
26 elif not dirName.endswith("/") :
27 dirName = dirName + "/"
28 files = sorted(glob.glob(dirName+"*.root"))
29
30 # Run over each file (one per jet definition)
31 histos = {}
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 histogram 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 if freezepT :
54 # Loop over eta bins.
55 for ybin in range(histo.GetNbinsY()+2) :
56 # Loop out in pT.
57 freezeval = 0
58 for xbin in range(histo.GetNbinsX()+2) :
59 inbin = histo.GetBinContent(xbin,ybin)
60 #print "Bin at pT ",histo.GetXaxis().GetBinCenter(xbin)," and [ylow,y,yhigh] = ", binYLow, histo.GetYaxis().GetBinCenter(ybin), binYHigh
61 # Store bin contents as we go out: last one is one we want as frozen value.
62 if inbin > -0.5 :
63 freezeval = inbin
64 else :
65 histo.SetBinContent(xbin,ybin,freezeval)
66
67
68 histoSym = ProviderHistoHelpers.SymmetrizeHistoInEta(histo,systematicName)
69 histoSym.SetDirectory(0)
70 histos[jetDef][aSystName] = histoSym
71
72 # Also add a blank nonclosure histo for Pythia8
73 # Also add a blank Closeby histo for both AFII and Pythia8
75 histos[jetDef]["RelativeNonClosure_MC15"] = ProviderHistoHelpers.MakeProviderHisto("RelativeNonClosure_MC15",ptBins=[15,1000,2500],etaBins=etaBins)
76 histos[jetDef]["RelativeNonClosure_MC15"].SetDirectory(0)
77 histos[jetDef]["CloseBy_Pythia8"] = ProviderHistoHelpers.MakeProviderHisto("CloseBy_MC15",ptBins=[15,1000,2500],etaBins=etaBins)
78 histos[jetDef]["CloseBy_Pythia8"].SetDirectory(0)
79 histos[jetDef]["CloseBy_AFII"] = ProviderHistoHelpers.MakeProviderHisto("CloseBy_AFII",ptBins=[15,1000,2500],etaBins=etaBins)
80 histos[jetDef]["CloseBy_AFII"].SetDirectory(0)
81
82 # Done reading, close the file
83 inFile.Close()
84
85 return histos
#define min(a, b)
Definition cfImp.cxx:40
#define max(a, b)
Definition cfImp.cxx:41
MakeProviderHisto(histoName, ptBins=GetDefaultPtBins(), etaBins=GetDefaultEtaBins())