ATLAS Offline Software
CalculateHighPtTerm_noMJB.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 # Following in-situ components need to be combined in quadrature to make the histogram from which to subtract
9 
10 from ParseInsituInput_MJB import ReadInSituHistograms
11 
12 InSituCompDictionary = ReadInSituHistograms("/afs/cern.ch/work/k/kpachal/JetUncertainties/JetUncertainties/athena/Reconstruction/Jet/JetUncertainties/inputs/Moriond2018/forMJBInputs_GammaZJet")
13 SingleParticleFile = TFile("/afs/cern.ch/work/k/kpachal/JetUncertainties/JetUncertainties/athena/Reconstruction/Jet/JetUncertainties/inputs/Moriond2018/HighPt2012/AggressiveHighPt_Final2014.root")
14 
15 jetDefList = [ 'AntiKt4Topo_EMJES',
16  'AntiKt4PFlow_EMJES',
17  ]
18 
19 outputFile = TFile("2012HighPtTerm_2017Moriond2018adjusted.root","RECREATE")
20 
21 for jetDef in jetDefList :
22 
23  inSituHist = InSituCompDictionary[jetDef]['Zjet_dPhi'].Clone("InSitu_Quad")
24  inSituHist.Reset()
25  inSituHist.SetDirectory(0)
26 
27  # Fill inSituHist with sum of squares of components.
28  for histkey in InSituCompDictionary[jetDef] :
29 
30  hist = InSituCompDictionary[jetDef][histkey]
31 
32  for bin in range(1, hist.GetNbinsX()+1) :
33  #print "Comparing Zjet_dPhi with",histkey,":",inSituHist.GetBinLowEdge(bin),"==",hist.GetBinLowEdge(bin),"and",inSituHist.GetBinWidth(bin),"==",hist.GetBinWidth(bin)
34  assert(inSituHist.GetBinLowEdge(bin) == hist.GetBinLowEdge(bin) and inSituHist.GetBinWidth(bin) == hist.GetBinWidth(bin))
35 
36  inSituHist.SetBinContent(bin,inSituHist.GetBinContent(bin)+math.pow(hist.GetBinContent(bin),2))
37 
38  # This is now (total in situ)^2
39 
40  # Fetch single particle hist
41  # For PFlow, we are using EM hist
42  spHist = SingleParticleFile.Get("SingleParticle_HighPt_AntiKt4Topo_EMJES")
43  print "Setting all to",spHist.GetBinContent(spHist.GetNbinsX())
44  for bin in range(1,spHist.GetNbinsX()+1) :
45  spHist.SetBinContent(bin,spHist.GetBinContent(spHist.GetNbinsX()))
46 
47  outputHist = spHist.Clone("adjustedInterpolatedSingleParticleUncertainty")
48  outputHist.SetDirectory(0)
49  outputHist.Reset()
50 
51  # Loop over in highpT bins and get an interpolated SP value in each;
52  # calculate difference and fill result
53  for bin in range(0,spHist.GetNbinsX()+2) :
54 
55  pT = spHist.GetXaxis().GetBinCenter(bin)
56  inSituBin = inSituHist.FindBin(pT)
57  if inSituBin > inSituHist.GetNbinsX() : inSituBin = inSituHist.GetNbinsX()
58  inSituVal2 = inSituHist.GetBinContent(inSituBin)
59  spVal = spHist.Interpolate(pT)
60 
61  diff = spVal*spVal - inSituVal2
62 
63  if diff < 0 :
64  keepSPVal = 0
65  else :
66  keepSPVal = math.sqrt(spVal*spVal - inSituVal2)
67 
68  if pT < 800 :
69  smoothedSPVal = 0
70  elif pT < 1000 :
71  smoothedSPVal = keepSPVal * ((pT - 800)/200)
72  else :
73  smoothedSPVal = keepSPVal
74 
75  outputHist.SetBinContent(bin,smoothedSPVal)
76 
77  outputFile.cd()
78  outputHist.Write("SingleParticle_HighPt_{0}".format(jetDef))
79 
80 outputFile.Close()
81 
vtune_athena.format
format
Definition: vtune_athena.py:14
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
ParseInsituInput.ReadInSituHistograms
def ReadInSituHistograms(dirName)
Definition: Final2012/ParseInsituInput.py:82