ATLAS Offline Software
TRTPostProcessing.py
Go to the documentation of this file.
1 #
2 # Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 #
4 def hOccupancy(inputs):
5  import ROOT
6  element = inputs[0][0]['element']
7  name = 'hOccupancy' + element
8  if element == 'C': title = 'Chip'
9  if element == 'S': title = 'Straw'
10  rh = ROOT.TH1F(name, title + ' Occupancy Distribution', 201, 0, 1.005)
11  rh.GetXaxis().SetTitle('Occupancy')
12  rh.GetYaxis().SetTitle('Number of ' + title + 's')
13  plots = [_[1][0] for _ in inputs] # all plots passed as first element of list
14  for plot in plots:
15  nBins = plot.GetNbinsX()
16  for j in range(nBins): #range of the input histogram, not the output
17  rh.Fill(plot.GetBinContent(j + 1))
18  return [rh]
19 
20 def hHitXonTMap(inputs):
21  import ROOT
22  hist = inputs[1][0]['histogram'][9:] #removing "unscaled_" prefix
23  element = inputs[1][0]['element']
24  if element == 'S':
25  name = hist + 'S'
26  titleElement = 'Straws'
27  if element == 'C':
28  name = hist + 'C'
29  titleElement = 'Chips'
30  if hist == 'hHitHWonTMap': title = 'HL Hit(In time Window) on Track: '
31  if hist == 'hHitWonTMap': title = 'Leading Edge on Track in Time Window: '
32  if hist == 'hHitAonTMap': title = 'Any LL Bit on Track: '
33  if hist == 'hHitAWonTMap': title = 'Any LL Bit on Track in Time Window: '
34  if hist == 'hHitHonTMap': title = 'HL Hit on Track: '
35  rh = ROOT.TH1F(name, title + titleElement, 1, 0, 1)
36  rh.GetXaxis().SetTitle(titleElement[:-1] + ' Number in Stack')
37  rh.GetYaxis().SetTitle('Probability')
38  for i in range(len(inputs[0][1])):
39  plots = [_[1][i] for _ in inputs]
40  if i < 3:
41  for m in range(int(len(plots)/2)):
42  plot0 = plots[2*m]
43  plot1 = plots[2*m + 1]
44  nBins = plots[0].GetNbinsX()
45  rh.SetBins(nBins, 0, nBins)
46  for j in range(nBins): #range of the input histogram, not the output
47  if plot0.GetBinEntries(j + 1) > 0:
48  rh.SetBinContent(j + 1, plot1.GetBinContent(j + 1)*1./plot0.GetBinEntries(j + 1))
49  else:
50  rh.SetBinContent(j + 1, 0)
51  return [rh]
52 
53 def hHitXonTMap2(inputs):
54  # Refactored version of hHitXonTMap that works in online because it orders inputs
55  import ROOT
56  hist = inputs[0][0]['histogram'] #removing "unscaled_" prefix
57  element = inputs[0][0]['element']
58  if element == 'S':
59  name = hist + 'S'
60  titleElement = 'Straws'
61  if element == 'C':
62  name = hist + 'C'
63  titleElement = 'Chips'
64  if hist == 'hHitHWonTMap': title = 'HL Hit(In time Window) on Track: '
65  if hist == 'hHitWonTMap': title = 'Leading Edge on Track in Time Window: '
66  if hist == 'hHitAonTMap': title = 'Any LL Bit on Track: '
67  if hist == 'hHitAWonTMap': title = 'Any LL Bit on Track in Time Window: '
68  if hist == 'hHitHonTMap': title = 'HL Hit on Track: '
69  rh = ROOT.TProfile(name, title + titleElement, 1, 0, 1)
70  rh.GetXaxis().SetTitle(titleElement[:-1] + ' Number in Stack')
71  rh.GetYaxis().SetTitle('Probability')
72 
73  plot0 = inputs[0][1][1]
74  plot1 = inputs[0][1][0]
75  nBins = plot1.GetNbinsX()
76  rh.SetBins(nBins, 0, nBins)
77  for j in range(1,nBins+2): #range of the input histogram, not the output
78  if plot0.GetBinEntries(j) > 0:
79  rh.Fill(j, plot1.GetBinContent(j)*1./plot0.GetBinEntries(j))
80  else:
81  rh.Fill(j, 0)
82  return [rh]
83 
84 def hHitOnTrackVsAll(inputs):
85  import ROOT
86  element = inputs[0][0]['element']
87  if element == 'S':
88  name ='S'
89  titleElement = 'Straws'
90  if element == 'C':
91  name = 'C'
92  titleElement = 'Chips'
93  rh = ROOT.TH1F('hHitonTrackVsAll' + name, '(Hit on Track) / (Any LL Bit): ' + titleElement, 1, 0, 1)
94  rh.GetXaxis().SetTitle(titleElement[:-1] + ' Number in Stack')
95  rh.GetYaxis().SetTitle('Ratio')
96  for i in range(len(inputs[0][1])):
97  plots = [_[1][i] for _ in inputs]
98  if i < 4:
99  for m in range(int(len(plots)/3)):
100  plot0 = plots[3*m]
101  plot1 = plots[3*m + 1]
102  plot2 = plots[3*m + 2]
103  nBins = plots[0].GetNbinsX()
104  rh.SetBins(nBins, 0, nBins)
105  for j in range(nBins): #range of the input histogram, not the output
106  if (plot0.GetBinContent(j + 1)*plot1.GetBinContent(j + 1)) > 0:
107  rh.SetBinContent(j + 1, plot2.GetBinContent(j + 1)/(plot0.GetBinContent(j + 1)*plot1.GetBinContent(j + 1)))
108  else:
109  rh.SetBinContent(j + 1, 0)
110  return [rh]
111 
112 def hEfficiency(inputs):
113  import ROOT
114  region = inputs[0][0]['region']
115  side = inputs[0][0]['side']
116  if region == 'Barrel':
117  name = 'hEfficiencyBarrel' + str(side)
118  if region == 'Endcap':
119  name = 'hEfficiencyEndCap' + str(side)
120  rh = ROOT.TH1F(name, 'Straw Efficiency (' + name[11:] + ')', 500, -0.01, 1.01)
121  rh.GetXaxis().SetTitle('Efficiency')
122  rh.GetYaxis().SetTitle('Number of Straws')
123  for i in range(len(inputs[0][1])):
124  plots = [_[1][i] for _ in inputs]
125  for plot in plots:
126  for nStraw in range(plot.GetXaxis().GetNbins()):
127  rh.Fill(plot.GetBinContent(nStraw + 1))
128  return [rh]
129 
131  import ROOT
132  region = inputs[0][0]['region']
133  side = inputs[0][0]['side']
134  if region == 'Barrel':
135  name = 'hEfficiencyBarrel' + str(side)
136  if region == 'Endcap':
137  name = 'hEfficiencyEndCap' + str(side)
138  rh = ROOT.TH1F(name, 'Straw Efficiency (' + name[11:] + ')', 500, -0.01, 1.01)
139  rh.GetXaxis().SetTitle('Efficiency')
140  rh.GetYaxis().SetTitle('Fraction of Straws')
141  for i in range(len(inputs[0][1])):
142  plots = [_[1][i] for _ in inputs]
143  for plot in plots:
144  for nStraw in range(plot.GetXaxis().GetNbins()):
145  rh.Fill(plot.GetBinContent(nStraw + 1))
146  totalEntries = 0.
147  entries = rh.GetEntries()
148  for nStraw in range(rh.GetXaxis().GetNbins()):
149  totalEntries += rh.GetBinContent(nStraw + 1)
150  rh.SetBinContent(nStraw + 1, totalEntries/float(entries))
151  return [rh]
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
TRTPostProcessing.hHitXonTMap
def hHitXonTMap(inputs)
Definition: TRTPostProcessing.py:20
TRTPostProcessing.hOccupancy
def hOccupancy(inputs)
Definition: TRTPostProcessing.py:4
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
TRTPostProcessing.hEfficiencyIntegral
def hEfficiencyIntegral(inputs)
Definition: TRTPostProcessing.py:130
TRTPostProcessing.hHitXonTMap2
def hHitXonTMap2(inputs)
Definition: TRTPostProcessing.py:53
TRTPostProcessing.hEfficiency
def hEfficiency(inputs)
Definition: TRTPostProcessing.py:112
TRTPostProcessing.hHitOnTrackVsAll
def hHitOnTrackVsAll(inputs)
Definition: TRTPostProcessing.py:84
str
Definition: BTagTrackIpAccessor.cxx:11
readCCLHist.float
float
Definition: readCCLHist.py:83