4 import sys, os, argparse, ROOT
8 commandName = os.path.basename( sys.argv[0] )
9 summaryDirDefault=
"InDetTrackPerfMonPlots/TrkAnaEF/Offline/Tracks/"
10 parser = argparse.ArgumentParser( description = commandName+
" options:" )
11 parser.add_argument(
"-t",
"--testFile", help=
"Path to input TEST file" )
12 parser.add_argument(
"-r",
"--refFile", default=
"", help=
"Path to input REFERENCE file" )
13 parser.add_argument(
"-T",
"--testLabel", default=
"TEST", help=
"Label for TEST" )
14 parser.add_argument(
"-R",
"--refLabel", default=
"REF", help=
"Label for REFERENCE" )
15 parser.add_argument(
"-d",
"--dirName", default=summaryDirDefault, help=
"Name of the TDirectory path with plots" )
16 parser.add_argument(
"-o",
"--outName", default=
"TrkAnaSummary.html", help=
"Name of the output html file" )
17 MyArgs = parser.parse_args()
19 if not MyArgs.testFile:
20 print(
"ERROR: input test file not provided" )
26 def processFile( inFileName, dirName, label, data, index, updateIndex=True ):
28 inFile = ROOT.TFile.Open( inFileName,
"READ" )
31 hs = inFile.Get( dirName+
"Multiplicities/summary" )
33 for i
in range( 1, hs.GetNbinsX()+1 ) :
34 if updateIndex : index.append( hs.GetXaxis().GetBinLabel(i) )
35 c = hs.GetBinContent(i)
37 sList.append( f
"{c:.1f} +/- {e:.1f}" )
40 he = inFile.Get( dirName+
"Efficiencies/eff_vs_truth_inclusive" )
41 if updateIndex : index.append(
" " )
43 if updateIndex : index.append(
"Eff_vs_truth" )
45 c = 100*he.GetEfficiency(1)
46 eu = 100*he.GetEfficiencyErrorUp(1)
47 el = 100*he.GetEfficiencyErrorLow(1)
48 sList.append( f
"{c:.2f} +{eu:.2f}/-{el:.2f} %" )
49 else : sList.append(
"-" )
52 het = inFile.Get( dirName+
"Efficiencies/Technical/eff_vs_truth_inclusive" )
53 if updateIndex : index.append(
"Tech_eff_vs_truth" )
55 c = 100*het.GetEfficiency(1)
56 eu = 100*het.GetEfficiencyErrorUp(1)
57 el = 100*het.GetEfficiencyErrorLow(1)
58 sList.append( f
"{c:.2f} +{eu:.2f}/-{el:.2f} %" )
59 else : sList.append(
"-" )
63 hrpt = inFile.Get( dirName+
"Resolutions/resolution_pt_vs_truth_inclusive" )
64 if updateIndex : index.append(
" " )
66 if updateIndex : index.append(
"Resolution_pT_vs_truth" )
68 c = hrpt.GetBinContent(1)
69 e = hrpt.GetBinError(1)
70 sList.append( f
"{c:.2f} +/- {e:.2f} GeV" )
71 else : sList.append(
"-" )
75 hrd0 = inFile.Get( dirName+
"Resolutions/resolution_d0_vs_truth_inclusive" )
76 if updateIndex : index.append(
"Resolution_d0_vs_truth" )
78 c = hrd0.GetBinContent(1)
79 e = hrd0.GetBinError(1)
80 sList.append( f
"{c:.2f} +/- {e:.2f} mm" )
81 else : sList.append(
"-" )
85 hrz0 = inFile.Get( dirName+
"Resolutions/resolution_z0_vs_truth_inclusive" )
86 if updateIndex : index.append(
"Resolution_z0_vs_truth" )
88 c = hrz0.GetBinContent(1)
89 e = hrz0.GetBinError(1)
90 sList.append( f
"{c:.2f} +/- {e:.2f} mm" )
91 else : sList.append(
"-" )
95 hf = inFile.Get( dirName+
"FakeRates/fakerate_vs_offl_inclusive" )
96 if updateIndex : index.append(
" " )
98 if updateIndex : index.append(
"FakeRate_vs_reco" )
100 c = 100*hf.GetEfficiency(1)
101 eu = 100*hf.GetEfficiencyErrorUp(1)
102 el = 100*hf.GetEfficiencyErrorLow(1)
103 sList.append( f
"{c:.2f} +{eu:.2f}/-{el:.2f} %" )
104 else : sList.append(
"-" )
108 hd = inFile.Get( dirName+
"Duplicates/duplrate_vs_truth_inclusive" )
109 if updateIndex : index.append(
"DuplicateRate_vs_truth" )
111 c = 100*hd.GetEfficiency(1)
112 eu = 100*hd.GetEfficiencyErrorUp(1)
113 el = 100*hd.GetEfficiencyErrorLow(1)
114 sList.append( f
"{c:.2f} +{eu:.2f}/-{el:.2f} %" )
115 else : sList.append(
"-" )
119 data.update( { label : sList } )
125 inFileName = MyArgs.testFile,
126 dirName = MyArgs.dirName,
127 label = MyArgs.testLabel,
135 inFileName = MyArgs.refFile,
136 dirName = MyArgs.dirName,
137 label = MyArgs.refLabel,
144 df = pd.DataFrame( data, index=index )
148 with open( MyArgs.outName,
'w' )
as f :