ATLAS Offline Software
ICHEP2016/CalculateHighPtTerm.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 # Following in-situ components need to be combined in quadrature to make the histogram from which to subtract
11 
12 from ParseInsituInput import ReadInSituHistograms
13 
14 InSituCompDictionary = ReadInSituHistograms("/cluster/warehouse/kpachal/JetCalibration/JetUncertainties/JetUncertainties/inputs/Moriond2016/AllInSitu/")
15 SingleParticleFile = TFile("/cluster/warehouse/kpachal/JetCalibration/JetUncertainties/JetUncertainties/inputs/Moriond2016/HighPt2012/AggressiveHighPt_Final2014.root")
16 
17 jetDefDict = {
18  'EMJES_R4' : 'AntiKt4Topo_EMJES',
19 # 'EMJES_R6' : 'AntiKt6Topo_EMJES',
20  'LCJES_R4' : 'AntiKt4Topo_LCJES',
21 # 'LCJES_R6' : 'AntiKt6Topo_LCJES'
22  }
23 
24 outputFile = TFile("2012HighPtTerm_2015adjusted.root","RECREATE")
25 
26 for readJetDef in jetDefDict :
27 
28  jetDef = jetDefDict[readJetDef]
29 
30  inSituHist = InSituCompDictionary[jetDef]['InSituProp_PunchThroughMC'].Clone("InSitu_Quad")
31  inSituHist.Reset()
32  inSituHist.SetDirectory(0)
33 
34  # Fill inSituHist with sum of squares of components.
35  for histkey in InSituCompDictionary[jetDef] :
36 
37  hist = InSituCompDictionary[jetDef][histkey]
38 
39  for bin in range(0, hist.GetNbinsX()+2) :
40  assert(inSituHist.GetBinLowEdge(bin) == hist.GetBinLowEdge(bin) and inSituHist.GetBinWidth(bin) == hist.GetBinWidth(bin))
41 
42  inSituHist.SetBinContent(bin,inSituHist.GetBinContent(bin)+math.pow(hist.GetBinContent(bin),2))
43 
44  # This is now (total in situ)^2
45 
46  # Fetch single particle hist
47  spHist = SingleParticleFile.Get("SingleParticle_HighPt_{0}".format(jetDef))
48 
49  outputHist = spHist.Clone("adjustedInterpolatedSingleParticleUncertainty")
50  outputHist.SetDirectory(0)
51  outputHist.Reset()
52 
53  # Loop over in highpT bins and get an interpolated SP value in each;
54  # calculate difference and fill result
55  for bin in range(0,spHist.GetNbinsX()+2) :
56 
57  pT = spHist.GetXaxis().GetBinCenter(bin)
58  inSituBin = inSituHist.FindBin(pT)
59  if inSituBin > inSituHist.GetNbinsX() : inSituBin = inSituHist.GetNbinsX()
60  inSituVal2 = inSituHist.GetBinContent(inSituBin)
61  spVal = spHist.Interpolate(pT)
62 
63  diff = spVal*spVal - inSituVal2
64 
65  if diff < 0 :
66  keepSPVal = 0
67  else :
68  keepSPVal = math.sqrt(spVal*spVal - inSituVal2)
69 
70  if pT < 2000 :
71  smoothedSPVal = 0
72  elif pT < 2200 :
73  smoothedSPVal = keepSPVal * ((pT - 2000)/200)
74  else :
75  smoothedSPVal = keepSPVal
76 
77  outputHist.SetBinContent(bin,smoothedSPVal)
78 
79  outputFile.cd()
80  outputHist.Write("SingleParticle_HighPt_{0}".format(jetDef))
81 
82 outputFile.Close()
83 
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