ATLAS Offline Software
Loading...
Searching...
No Matches
PrintTrkAnaSummary Namespace Reference

Functions

 fround (c, e)
 processFile (inFileName, dirName, label, data, dataDict, index, updateIndex=True, printMultiplicity=True)
 getRatio (a, ae, b, be)
 computeRatios (ltest, lref, data, dataDict, printMultiplicity=True)
 initializeLatexTable ()

Variables

dict sampleDict
 commandName = os.path.basename( sys.argv[0] )
str summaryDirDefault = "InDetTrackPerfMonPlots/&TrkAnaName&/Offline/Tracks/"
 parser = argparse.ArgumentParser( description = commandName+" options:" )
 help
 default
 action
 MyArgs = parser.parse_args()
 anaList = MyArgs.analyses.strip().split(',')
str outFile = MyArgs.outName.replace( "&TrkAnaName&", "" ) if "&TrkAnaName&" in MyArgs.outName else MyArgs.outName
 Remove final .html if it exists.
 outFileLatex = MyArgs.outNameLatex
 Remove final .tex if it exists.
 latex_table_lines = initializeLatexTable()
 Prepare latex table.
dict data = {}
 Looping over all the track analyses.
dict dataDict = {}
list index = []
 anaDirName = MyArgs.dirName.replace( "&TrkAnaName&", anaName )
str anaOutName = MyArgs.outName.replace( "&TrkAnaName&", anaName ) if "&TrkAnaName&" in MyArgs.outName else MyArgs.outName.replace( ".html", "_"+anaName+".html" )
 testFile = ROOT.TFile.Open( MyArgs.testFile, "READ" )
 testMultiplicity = testFile.Get( anaDirName+"Multiplicities/summary" )
 refFile = ROOT.TFile.Open( MyArgs.refFile, "READ" )
 refMultiplicity = refFile.Get( anaDirName+"Multiplicities/summary" )
 printMultiplicity = refMultiplicity or testMultiplicity
 inFileName
 Processing test file.
 dirName
 label
 updateIndex
 ltest
 Processing ratios.
 lref
 df = pd.DataFrame( data, index=index )
 Printing table to screen.
str titleStr = f"Summary for TrackAnalysis = {anaName}:"
 file
 Printing table to html output file.
 row = df.loc[['Eff_vs_truth']]
 Appending html table to final .html summary file.
tuple latex_table_line
 l
 Printing final latex table to .tex output file.

Function Documentation

◆ computeRatios()

PrintTrkAnaSummary.computeRatios ( ltest,
lref,
data,
dataDict,
printMultiplicity = True )

Definition at line 167 of file PrintTrkAnaSummary.py.

167def computeRatios( ltest, lref, data, dataDict, printMultiplicity=True ):
168 sList = []
169
170
171 if printMultiplicity:
172 for i in range( 1, 8 ) :
173 if "mult_"+str(i) in dataDict[ltest] and "mult_"+str(i) in dataDict[lref] :
174 c, e = getRatio( dataDict[ltest]["mult_"+str(i)][0],
175 dataDict[ltest]["mult_"+str(i)][1],
176 dataDict[lref]["mult_"+str(i)][0],
177 dataDict[lref]["mult_"+str(i)][1] )
178 sList.append( f"{fround( c, e )}" )
179 else:
180 sList.append( "-" )
181
182 # efficiencies
183 sList.append( " " )
184 if "eff" in dataDict[ltest] and "eff" in dataDict[lref] :
185 c, e = getRatio( dataDict[ltest]["eff"][0],
186 dataDict[ltest]["eff"][1],
187 dataDict[lref]["eff"][0],
188 dataDict[lref]["eff"][1] )
189 c = 100*c
190 e = 100*e
191 sList.append( f"{fround( c, e )} %" )
192 else : sList.append( "-" )
193
194
195 if "tech_eff" in dataDict[ltest] and "tech_eff" in dataDict[lref] :
196 c, e = getRatio( dataDict[ltest]["tech_eff"][0],
197 dataDict[ltest]["tech_eff"][1],
198 dataDict[lref]["tech_eff"][0],
199 dataDict[lref]["tech_eff"][1] )
200 c = 100*c
201 e = 100*e
202 sList.append( f"{fround( c, e )} %" )
203 else : sList.append( "-" )
204
205
206
207 sList.append( " " )
208 if "res_pt" in dataDict[ltest] and "res_pt" in dataDict[lref] :
209 c, e = getRatio( dataDict[ltest]["res_pt"][0],
210 dataDict[ltest]["res_pt"][1],
211 dataDict[lref]["res_pt"][0],
212 dataDict[lref]["res_pt"][1] )
213 sList.append( f"{fround( c, e )}" )
214 else : sList.append( "-" )
215
216
217
218 if "res_d0" in dataDict[ltest] and "res_d0" in dataDict[lref] :
219 c, e = getRatio( dataDict[ltest]["res_d0"][0],
220 dataDict[ltest]["res_d0"][1],
221 dataDict[lref]["res_d0"][0],
222 dataDict[lref]["res_d0"][1] )
223 sList.append( f"{fround( c, e )}" )
224 else : sList.append( "-" )
225
226
227
228 if "res_z0" in dataDict[ltest] and "res_z0" in dataDict[lref] :
229 c, e = getRatio( dataDict[ltest]["res_z0"][0],
230 dataDict[ltest]["res_z0"][1],
231 dataDict[lref]["res_z0"][0],
232 dataDict[lref]["res_z0"][1] )
233 sList.append( f"{fround( c, e )}" )
234 else : sList.append( "-" )
235
236
237
238 sList.append( " " )
239 if "fake" in dataDict[ltest] and "fake" in dataDict[lref] :
240 c, e = getRatio( dataDict[ltest]["fake"][0],
241 dataDict[ltest]["fake"][1],
242 dataDict[lref]["fake"][0],
243 dataDict[lref]["fake"][1] )
244 sList.append( f"{fround( c, e )}" )
245 else : sList.append( "-" )
246
247
248
249 if "dupl" in dataDict[ltest] and "dupl" in dataDict[lref] :
250 c, e = getRatio( dataDict[ltest]["dupl"][0],
251 dataDict[ltest]["dupl"][1],
252 dataDict[lref]["dupl"][0],
253 dataDict[lref]["dupl"][1] )
254 sList.append( f"{fround( c, e )}" )
255 else : sList.append( "-" )
256
257
258
259 data.update( { ltest + " / " + lref : sList } )
260

◆ fround()

PrintTrkAnaSummary.fround ( c,
e )

Definition at line 39 of file PrintTrkAnaSummary.py.

39def fround( c, e ):
40 e = math.fabs( e )
41 res = str( rd( c, e ) )
42 return res.replace( '+/-', ' \u00b1 ' ).replace( '(', '( ' ).replace( ')', ' )' )
43
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition hcg.cxx:310

◆ getRatio()

PrintTrkAnaSummary.getRatio ( a,
ae,
b,
be )

Definition at line 159 of file PrintTrkAnaSummary.py.

159def getRatio( a, ae, b, be ):
160 if b==0 :
161 return ( 0., 0. )
162
163 c = a / b
164 ce = math.sqrt( ( ae / b )**2 + ( a * be / b**2 )**2 )
165 return ( c, ce )
166

◆ initializeLatexTable()

PrintTrkAnaSummary.initializeLatexTable ( )

Definition at line 261 of file PrintTrkAnaSummary.py.

261def initializeLatexTable():
262
263 lines = []
264 lines.append('\\begin{tabular}{lccc}')
265 lines.append('\\hline')
266 lines.append(f' & {MyArgs.testLabel} & {MyArgs.refLabel} & {MyArgs.testLabel} / {MyArgs.refLabel} \\\\')
267 lines.append('\\hline')
268 lines.append('\\hline')
269 lines.append("\\end{tabular}")
270
271 return lines

◆ processFile()

PrintTrkAnaSummary.processFile ( inFileName,
dirName,
label,
data,
dataDict,
index,
updateIndex = True,
printMultiplicity = True )

Definition at line 44 of file PrintTrkAnaSummary.py.

44def processFile( inFileName, dirName, label, data, dataDict, index, updateIndex=True, printMultiplicity=True ):
45 if updateIndex: index.clear()
46 sList = []
47 sDict = {}
48 inFile = ROOT.TFile.Open( inFileName, "READ" )
49
50
51 if printMultiplicity:
52 hs = inFile.Get( dirName+"Multiplicities/summary" )
53 for i in range( 1, 8 ) :
54 if hs:
55 if updateIndex : index.append( hs.GetXaxis().GetBinLabel(i) )
56 c = hs.GetBinContent(i)
57 e = hs.GetBinError(i)
58 sList.append( f"{c:.0f} \u00b1 {e:.0f}" )
59 sDict.update( { "mult_"+str(i) : [ c, e ] } )
60 else:
61 if updateIndex : index.append(" ")
62 sList.append( "-" )
63
64 # efficiencies
65 he = inFile.Get( dirName+"Efficiencies/eff_vs_truth_inclusive" )
66 if updateIndex : index.append( " " )
67 sList.append( " " )
68 if updateIndex : index.append( "Eff_vs_truth" )
69 if he:
70 c = 100*he.GetEfficiency(1)
71 eu = 100*he.GetEfficiencyErrorUp(1)
72 el = 100*he.GetEfficiencyErrorLow(1)
73 e = max( [ eu, el ] )
74 sList.append( f"{fround( c, e )} %" )
75 sDict.update( { "eff" : [ c, e ] } )
76 else : sList.append( "-" )
77
78
79 het = inFile.Get( dirName+"Efficiencies/Technical/eff_vs_truth_inclusive" )
80 if updateIndex : index.append( "Tech_eff_vs_truth" )
81 if het:
82 c = 100*het.GetEfficiency(1)
83 eu = 100*het.GetEfficiencyErrorUp(1)
84 el = 100*het.GetEfficiencyErrorLow(1)
85 e = max( [ eu, el ] )
86 sList.append( f"{fround( c, e )} %" )
87 sDict.update( { "tech_eff" : [ c, e ] } )
88 else : sList.append( "-" )
89
90
91
92 hrpt = inFile.Get( dirName+"Resolutions/resolution_pt_vs_truth_inclusive" )
93 if updateIndex : index.append( " " )
94 sList.append( " " )
95 if updateIndex : index.append( "Resolution_pT_vs_truth" )
96 if hrpt:
97 c = hrpt.GetBinContent(1)
98 e = hrpt.GetBinError(1)
99 sList.append( f"{fround( c, e )} GeV" )
100 sDict.update( { "res_pt" : [ c, e ] } )
101 else : sList.append( "-" )
102
103
104
105 hrd0 = inFile.Get( dirName+"Resolutions/resolution_d0_vs_truth_inclusive" )
106 if updateIndex : index.append( "Resolution_d0_vs_truth" )
107 if hrd0:
108 c = hrd0.GetBinContent(1)
109 e = hrd0.GetBinError(1)
110 sList.append( f"{fround( c, e )} \u03BCm" )
111 sDict.update( { "res_d0" : [ c, e ] } )
112 else : sList.append( "-" )
113
114
115
116 hrz0 = inFile.Get( dirName+"Resolutions/resolution_z0_vs_truth_inclusive" )
117 if updateIndex : index.append( "Resolution_z0_vs_truth" )
118 if hrz0:
119 c = hrz0.GetBinContent(1)
120 e = hrz0.GetBinError(1)
121 sList.append( f"{fround( c, e )} \u03BCm" )
122 sDict.update( { "res_z0" : [ c, e ] } )
123 else : sList.append( "-" )
124
125
126
127 hf = inFile.Get( dirName+"FakeRates/fakerate_vs_offl_inclusive" )
128 if updateIndex : index.append( " " )
129 sList.append( " " )
130 if updateIndex : index.append( "FakeRate_vs_reco" )
131 if hf:
132 c = 100*hf.GetEfficiency(1)
133 eu = 100*hf.GetEfficiencyErrorUp(1)
134 el = 100*hf.GetEfficiencyErrorLow(1)
135 e = max( [ eu, el ] )
136 sList.append( f"{fround( c, e )} %" )
137 sDict.update( { "fake" : [ c, e ] } )
138 else : sList.append( "-" )
139
140
141
142 hd = inFile.Get( dirName+"Duplicates/duplrate_vs_truth_inclusive" )
143 if updateIndex : index.append( "DuplicateRate_vs_truth" )
144 if hd:
145 c = 100*hd.GetEfficiency(1)
146 eu = 100*hd.GetEfficiencyErrorUp(1)
147 el = 100*hd.GetEfficiencyErrorLow(1)
148 e = max( [ eu, el ] )
149 sList.append( f"{fround( c, e )} %" )
150 sDict.update( { "dupl" : [ c, e ] } )
151 else : sList.append( "-" )
152
153
154
155 data.update( { label : sList } )
156 dataDict.update( { label : sDict } )
157 inFile.Close()
158
#define max(a, b)
Definition cfImp.cxx:41

Variable Documentation

◆ action

PrintTrkAnaSummary.action

Definition at line 31 of file PrintTrkAnaSummary.py.

◆ anaDirName

PrintTrkAnaSummary.anaDirName = MyArgs.dirName.replace( "&TrkAnaName&", anaName )

Definition at line 293 of file PrintTrkAnaSummary.py.

◆ anaList

PrintTrkAnaSummary.anaList = MyArgs.analyses.strip().split(',')

Definition at line 33 of file PrintTrkAnaSummary.py.

◆ anaOutName

str PrintTrkAnaSummary.anaOutName = MyArgs.outName.replace( "&TrkAnaName&", anaName ) if "&TrkAnaName&" in MyArgs.outName else MyArgs.outName.replace( ".html", "_"+anaName+".html" )

Definition at line 294 of file PrintTrkAnaSummary.py.

◆ commandName

PrintTrkAnaSummary.commandName = os.path.basename( sys.argv[0] )

Definition at line 20 of file PrintTrkAnaSummary.py.

◆ data

PrintTrkAnaSummary.data = {}

Looping over all the track analyses.

Track-analysis specific quantities

Definition at line 290 of file PrintTrkAnaSummary.py.

◆ dataDict

PrintTrkAnaSummary.dataDict = {}

Definition at line 291 of file PrintTrkAnaSummary.py.

◆ default

PrintTrkAnaSummary.default

Definition at line 24 of file PrintTrkAnaSummary.py.

◆ df

PrintTrkAnaSummary.df = pd.DataFrame( data, index=index )

Printing table to screen.

Definition at line 340 of file PrintTrkAnaSummary.py.

◆ dirName

PrintTrkAnaSummary.dirName

Definition at line 308 of file PrintTrkAnaSummary.py.

◆ file

PrintTrkAnaSummary.file

Printing table to html output file.

Printing final latex table to .tex output file.

Definition at line 347 of file PrintTrkAnaSummary.py.

◆ help

PrintTrkAnaSummary.help

Definition at line 23 of file PrintTrkAnaSummary.py.

◆ index

PrintTrkAnaSummary.index = []

Definition at line 292 of file PrintTrkAnaSummary.py.

◆ inFileName

PrintTrkAnaSummary.inFileName

Processing test file.

Processing reference file.

Definition at line 307 of file PrintTrkAnaSummary.py.

◆ l

PrintTrkAnaSummary.l

Printing final latex table to .tex output file.

Definition at line 370 of file PrintTrkAnaSummary.py.

◆ label

PrintTrkAnaSummary.label

Definition at line 309 of file PrintTrkAnaSummary.py.

◆ latex_table_line

tuple PrintTrkAnaSummary.latex_table_line
Initial value:
1= (
2 sampleDict[anaName.split('_')[0]] + " & "
3 + " & ".join(" $ " + row.iloc[0].values + " $ ")
4 + " \\\\")

Definition at line 357 of file PrintTrkAnaSummary.py.

◆ latex_table_lines

PrintTrkAnaSummary.latex_table_lines = initializeLatexTable()

Prepare latex table.

Definition at line 284 of file PrintTrkAnaSummary.py.

◆ lref

PrintTrkAnaSummary.lref

Definition at line 333 of file PrintTrkAnaSummary.py.

◆ ltest

PrintTrkAnaSummary.ltest

Processing ratios.

Definition at line 332 of file PrintTrkAnaSummary.py.

◆ MyArgs

PrintTrkAnaSummary.MyArgs = parser.parse_args()

Definition at line 32 of file PrintTrkAnaSummary.py.

◆ outFile

str PrintTrkAnaSummary.outFile = MyArgs.outName.replace( "&TrkAnaName&", "" ) if "&TrkAnaName&" in MyArgs.outName else MyArgs.outName

Remove final .html if it exists.

Definition at line 273 of file PrintTrkAnaSummary.py.

◆ outFileLatex

PrintTrkAnaSummary.outFileLatex = MyArgs.outNameLatex

Remove final .tex if it exists.

Definition at line 279 of file PrintTrkAnaSummary.py.

◆ parser

PrintTrkAnaSummary.parser = argparse.ArgumentParser( description = commandName+" options:" )

Definition at line 22 of file PrintTrkAnaSummary.py.

◆ printMultiplicity

PrintTrkAnaSummary.printMultiplicity = refMultiplicity or testMultiplicity

Definition at line 304 of file PrintTrkAnaSummary.py.

◆ refFile

PrintTrkAnaSummary.refFile = ROOT.TFile.Open( MyArgs.refFile, "READ" )

Definition at line 300 of file PrintTrkAnaSummary.py.

◆ refMultiplicity

PrintTrkAnaSummary.refMultiplicity = refFile.Get( anaDirName+"Multiplicities/summary" )

Definition at line 301 of file PrintTrkAnaSummary.py.

◆ row

PrintTrkAnaSummary.row = df.loc[['Eff_vs_truth']]

Appending html table to final .html summary file.

Appending latex line to latex table

Definition at line 356 of file PrintTrkAnaSummary.py.

◆ sampleDict

dict PrintTrkAnaSummary.sampleDict
Initial value:
1= {
2 'TruthHighPtMuons': 'Muons with $p_{\\mathrm{T}}>10\\ \\mathrm{GeV}$',
3 'TruthLowPtMuons': 'Muons with $1\\ \\mathrm{GeV} < p_{\\mathrm{T}} < 10\\ \\mathrm{GeV}$',
4 'TruthHighPtPions': 'Pions with $p_{\\mathrm{T}}>10\\ \\mathrm{GeV}$',
5 'TruthLowPtPions': 'Pions with $1\\ \\mathrm{GeV} < p_{\\mathrm{T}} < 10\\ \\mathrm{GeV}$',
6 'TruthHighPtElectrons': 'Electrons with $p_{\\mathrm{T}}>20\\ \\mathrm{GeV}$',
7 'TruthLowPtElectrons': 'Electrons with $2\\ \\mathrm{GeV} < p_{\\mathrm{T}} < 20\\ \\mathrm{GeV}$',
8}

Definition at line 10 of file PrintTrkAnaSummary.py.

◆ summaryDirDefault

PrintTrkAnaSummary.summaryDirDefault = "InDetTrackPerfMonPlots/&TrkAnaName&/Offline/Tracks/"

Definition at line 21 of file PrintTrkAnaSummary.py.

◆ testFile

PrintTrkAnaSummary.testFile = ROOT.TFile.Open( MyArgs.testFile, "READ" )

Definition at line 296 of file PrintTrkAnaSummary.py.

◆ testMultiplicity

PrintTrkAnaSummary.testMultiplicity = testFile.Get( anaDirName+"Multiplicities/summary" )

Definition at line 297 of file PrintTrkAnaSummary.py.

◆ titleStr

str PrintTrkAnaSummary.titleStr = f"Summary for TrackAnalysis = {anaName}:"

Definition at line 341 of file PrintTrkAnaSummary.py.

◆ updateIndex

PrintTrkAnaSummary.updateIndex

Definition at line 325 of file PrintTrkAnaSummary.py.