ATLAS Offline Software
January2018_specialStatTerms/CalculateHighPtTerm.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 import ReadInSituHistograms
11 
12 InSituCompDictionary = ReadInSituHistograms("/afs/cern.ch/work/k/kpachal/JetUncertainties/JetUncertainties/athena/Reconstruction/Jet/JetUncertainties/inputs/Fall2018/AllInSitu/")
13 SingleParticleFile = TFile("/afs/cern.ch/work/k/kpachal/JetUncertainties/JetUncertainties/athena/Reconstruction/Jet/JetUncertainties/inputs/Fall2018/HighPt/Release20p7_SingleParticle_FullRange.root")
14 
15 
16 jetDefList = [
17  'AntiKt4Topo_EMJES',
18  'AntiKt4PFlow_EMJES',
19  ]
20 
21 outputFile = TFile("Release20p7_HighPtTerm_Fall2018adjusted.root","RECREATE")
22 
23 for jetDef in jetDefList :
24 
25  print InSituCompDictionary.keys()
26  inSituHist = InSituCompDictionary[jetDef]['InSituProp_PunchThroughMC'].Clone("InSitu_Quad")
27  inSituHist.Reset()
28  inSituHist.SetDirectory(0)
29 
30  # Fill inSituHist with sum of squares of components.
31  for histkey in InSituCompDictionary[jetDef] :
32 
33  hist = InSituCompDictionary[jetDef][histkey]
34 
35  for bin in range(0, hist.GetNbinsX()+2) :
36  assert(inSituHist.GetBinLowEdge(bin) == hist.GetBinLowEdge(bin) and inSituHist.GetBinWidth(bin) == hist.GetBinWidth(bin))
37 
38  inSituHist.SetBinContent(bin,inSituHist.GetBinContent(bin)+math.pow(hist.GetBinContent(bin),2))
39 
40  # This is now (total in situ)^2
41 
42  # Fetch single particle hist
43  spHist = SingleParticleFile.Get("totalHist")
44 
45  outputHist = spHist.Clone("adjustedInterpolatedSingleParticleUncertainty")
46  outputHist.SetDirectory(0)
47  outputHist.Reset()
48 
49  # Loop over in highpT bins and get an interpolated SP value in each;
50  # calculate difference and fill result
51  for bin in range(0,spHist.GetNbinsX()+2) :
52 
53  pT = spHist.GetXaxis().GetBinCenter(bin)
54  inSituBin = inSituHist.FindBin(pT)
55  if inSituBin > inSituHist.GetNbinsX() : inSituBin = inSituHist.GetNbinsX()
56  inSituVal2 = inSituHist.GetBinContent(inSituBin)
57  spVal = spHist.Interpolate(pT)
58 
59  diff = spVal*spVal - inSituVal2
60 
61  if diff < 0 :
62  keepSPVal = 0
63  else :
64  keepSPVal = math.sqrt(spVal*spVal - inSituVal2)
65 
66  if pT < 2200 :
67  smoothedSPVal = 0
68  elif pT < 2400 :
69  smoothedSPVal = keepSPVal * ((pT - 2200)/200)
70  else :
71  smoothedSPVal = keepSPVal
72 
73  outputHist.SetBinContent(bin,smoothedSPVal)
74 
75  outputFile.cd()
76  outputHist.Write("SingleParticle_HighPt_{0}".format(jetDef))
77 
78 outputFile.Close()
79 
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