ATLAS Offline Software
Functions | Variables
AddGammaJetsWeights Namespace Reference

Functions

def generateGammapTMapping (dictionary)
 
def main (argv)
 

Variables

string __author__ = "John Anders"
 
string __doc__ = """Script to add Sherpa Systematic Weight branches to existing file."""
 

Function Documentation

◆ generateGammapTMapping()

def AddGammaJetsWeights.generateGammapTMapping (   dictionary)

Definition at line 12 of file AddGammaJetsWeights.py.

12 def generateGammapTMapping(dictionary):
13 
14  # 0-70, bin 1, 70-140 bin 2 etc.
15  print "Adding gamma+jets to the dictionary"
16  print "Range 0-70"
17  for i in range(361039, 361042):
18  dictionary[i] = 1
19  print i
20 
21  print "Range 70-140"
22  for i in range(361042, 361045):
23  dictionary[i] = 2
24  print i
25 
26  print "Range 140-280"
27  for i in range(361045, 361048):
28  dictionary[i] = 3
29  print i
30 
31 
32  print "Range 280-500"
33  for i in range(361048, 361051):
34  dictionary[i] = 4
35  print i
36 
37  print "Range 500-1000"
38  for i in range(361051, 361054):
39  dictionary[i] = 5
40  print i
41 
42  print "Range 1000-2000"
43  for i in range(361054, 361057):
44  dictionary[i] = 6
45  print i
46 
47  print "Range 2000-ECMS"
48  for i in range(361057, 361061):
49  dictionary[i] = 7
50  print i
51 
52  return dictionary
53 
54 

◆ main()

def AddGammaJetsWeights.main (   argv)

Definition at line 55 of file AddGammaJetsWeights.py.

55 def main(argv):
56 
57  # infile should be the ZJets file to add the weights to.
58  script, infile = argv
59 
60  print "Creating MCID, GammapT mapping"
61  GammapTMapping = dict()
62  generateGammapTMapping(GammapTMapping)
63 
64  print "Loading histograms with weights"
65  Histograms = []
66 
67  # Change here to the location of the variation file:
68  fileWithWeights = "/cvmfs/atlas.cern.ch/repo/sw/database/GroupData/dev/SUSYTools/GammaJets_SysParameterization/AllVariationsGamma.root"
69 
70  g = ROOT.TFile(fileWithWeights)
71  systList = ["ckkw15", "ckkw30", "fact025", "fact4", "renorm025", "renorm4", "qsf025", "qsf4"]
72 
73  for syst in systList:
74  print 'syst',syst
75  h = ROOT.TH2F(g.Get(syst))
76  Histograms.append(h)
77 
78  print "Loading File"
79  f = ROOT.TFile(infile,"update")
80 
81  # Change here to the name of your nominal tree:
82  #treeName = "CollectionTree_"
83  #treeName = "Z_CRWT"#"CollectionTree_"
84  #treeName = "Z_SRAll"
85  #treeName = "Z_CRZ"
86  treeName = "GAMMA_CRY"
87  #treeName = "Z_VRWT"
88  #treeName = "GAMMA_CR3L"
89 
90 
91  print "Loading Tree"
92 
93  # empty arrays for adding branches
94  ckkw15 = array('f', [0.])
95  ckkw30 = array('f', [0.])
96  fact025 = array('f', [0.])
97  fact4 = array('f', [0.])
98  renorm025 = array('f', [0.])
99  renorm4 = array('f', [0.])
100  qsf025 = array('f', [0.])
101  qsf4 = array('f', [0.])
102 
103  # Add branches
104  T = f.Get(treeName)
105  ckkw15branch = T.Branch("ckkw15_Weight", ckkw15,"ckkw15_Weight/F")
106  ckkw30branch = T.Branch("ckkw30_Weight", ckkw30,"ckkw30_Weight/F")
107  fact025branch = T.Branch("fact025_Weight", fact025,"fact025_Weight/F")
108  fact4branch = T.Branch("fact4_Weight", fact4,"fact4_Weight/F")
109  renorm025branch = T.Branch("renorm025_Weight", renorm025,"renorm025_Weight/F")
110  renorm4branch = T.Branch("renorm4_Weight", renorm4,"renorm4_Weight/F")
111  qsf025branch = T.Branch("qsf025_Weight", qsf025,"qsf025_Weight/F")
112  qsf4branch = T.Branch("qsf4_Weight", qsf4,"qsf4_Weight/F")
113 
114  print "Adding Weights"
115  nEvts = T.GetEntries()
116  for iEvt in range(nEvts):
117 
118  if iEvt%1000 == 0:
119  print "Current Event being Processed is: ", iEvt
120 
121  T.GetEntry(iEvt)
122 
123  # change this to whatever the MCID and nTruthJet variables are saved as in your tree
124  MCID = T.RunNumber #mcID
125  nTruthJets = T.nJet
126 
127  # find which ZpT bin we want
128  GammapTBin = GammapTMapping.get(MCID)
129  TruthJetBin = nTruthJets+1
130  if nTruthJets >= 11:
131  TruthJetBin = 12
132  if GammapTBin == None:
133  #this MCID isn't in the mapping, so skip and default to 1
134  ckkw15[0] = 1
135  ckkw30[0] = 1
136  fact025[0] = 1
137  fact4[0] = 1
138  renorm025[0] = 1
139  renorm4[0] = 1
140  qsf025[0] = 1
141  qsf4[0] = 1
142 
143  else:
144  ckkw15[0] = Histograms[0].GetBinContent(GammapTBin,TruthJetBin)
145  ckkw30[0] = Histograms[1].GetBinContent(GammapTBin,TruthJetBin)
146  fact025[0] = Histograms[2].GetBinContent(GammapTBin,TruthJetBin)
147  fact4[0] = Histograms[3].GetBinContent(GammapTBin,TruthJetBin)
148  renorm025[0] = Histograms[4].GetBinContent(GammapTBin,TruthJetBin)
149  renorm4[0] = Histograms[5].GetBinContent(GammapTBin,TruthJetBin)
150  qsf025[0] = Histograms[6].GetBinContent(GammapTBin,TruthJetBin)
151  qsf4[0] = Histograms[7].GetBinContent(GammapTBin,TruthJetBin)
152 
153  ckkw15branch.Fill()
154  ckkw30branch.Fill()
155  fact025branch.Fill()
156  fact4branch.Fill()
157  renorm025branch.Fill()
158  renorm4branch.Fill()
159  qsf025branch.Fill()
160  qsf4branch.Fill()
161 
162 
163 
164  T.Write()
165 
166  print "Done."
167 

Variable Documentation

◆ __author__

string AddGammaJetsWeights.__author__ = "John Anders"
private

Definition at line 10 of file AddGammaJetsWeights.py.

◆ __doc__

string AddGammaJetsWeights.__doc__ = """Script to add Sherpa Systematic Weight branches to existing file."""
private

Definition at line 11 of file AddGammaJetsWeights.py.

AddGammaJetsWeights.main
def main(argv)
Definition: AddGammaJetsWeights.py:55
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
array
AddGammaJetsWeights.generateGammapTMapping
def generateGammapTMapping(dictionary)
Definition: AddGammaJetsWeights.py:12