4 import sys, os, argparse, ROOT
8 commandName = os.path.basename( sys.argv[0] )
9 summaryDirDefault=
"InDetTrackPerfMonPlots/&TrkAnaName&/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(
"-a",
"--analyses", default=
"TrkAnaEF", help=
"Comma-separeted list of track analyses to process" )
17 parser.add_argument(
"-o",
"--outName", default=
"TrkAnaSummary_&TrkAnaName&.html", help=
"Name of the output html files" )
18 MyArgs = parser.parse_args()
19 anaList = MyArgs.analyses.strip().
split(
',')
21 if not MyArgs.testFile:
22 print(
"ERROR: input test file not provided" )
25 def processFile( inFileName, dirName, label, data, index, updateIndex=True ):
27 inFile = ROOT.TFile.Open( inFileName,
"READ" )
30 hs = inFile.Get( dirName+
"Multiplicities/summary" )
32 for i
in range( 1, hs.GetNbinsX()+1 ) :
33 if updateIndex : index.append( hs.GetXaxis().GetBinLabel(i) )
34 c = hs.GetBinContent(i)
36 sList.append( f
"{c:.1f} +/- {e:.1f}" )
39 he = inFile.Get( dirName+
"Efficiencies/eff_vs_truth_inclusive" )
40 if updateIndex : index.append(
" " )
42 if updateIndex : index.append(
"Eff_vs_truth" )
44 c = 100*he.GetEfficiency(1)
45 eu = 100*he.GetEfficiencyErrorUp(1)
46 el = 100*he.GetEfficiencyErrorLow(1)
47 sList.append( f
"{c:.2f} +{eu:.2f}/-{el:.2f} %" )
48 else : sList.append(
"-" )
51 het = inFile.Get( dirName+
"Efficiencies/Technical/eff_vs_truth_inclusive" )
52 if updateIndex : index.append(
"Tech_eff_vs_truth" )
54 c = 100*het.GetEfficiency(1)
55 eu = 100*het.GetEfficiencyErrorUp(1)
56 el = 100*het.GetEfficiencyErrorLow(1)
57 sList.append( f
"{c:.2f} +{eu:.2f}/-{el:.2f} %" )
58 else : sList.append(
"-" )
62 hrpt = inFile.Get( dirName+
"Resolutions/resolution_pt_vs_truth_inclusive" )
63 if updateIndex : index.append(
" " )
65 if updateIndex : index.append(
"Resolution_pT_vs_truth" )
67 c = hrpt.GetBinContent(1)
68 e = hrpt.GetBinError(1)
69 sList.append( f
"{c:.2f} +/- {e:.2f} GeV" )
70 else : sList.append(
"-" )
74 hrd0 = inFile.Get( dirName+
"Resolutions/resolution_d0_vs_truth_inclusive" )
75 if updateIndex : index.append(
"Resolution_d0_vs_truth" )
77 c = hrd0.GetBinContent(1)
78 e = hrd0.GetBinError(1)
79 sList.append( f
"{c:.2f} +/- {e:.2f} mm" )
80 else : sList.append(
"-" )
84 hrz0 = inFile.Get( dirName+
"Resolutions/resolution_z0_vs_truth_inclusive" )
85 if updateIndex : index.append(
"Resolution_z0_vs_truth" )
87 c = hrz0.GetBinContent(1)
88 e = hrz0.GetBinError(1)
89 sList.append( f
"{c:.2f} +/- {e:.2f} mm" )
90 else : sList.append(
"-" )
94 hf = inFile.Get( dirName+
"FakeRates/fakerate_vs_offl_inclusive" )
95 if updateIndex : index.append(
" " )
97 if updateIndex : index.append(
"FakeRate_vs_reco" )
99 c = 100*hf.GetEfficiency(1)
100 eu = 100*hf.GetEfficiencyErrorUp(1)
101 el = 100*hf.GetEfficiencyErrorLow(1)
102 sList.append( f
"{c:.2f} +{eu:.2f}/-{el:.2f} %" )
103 else : sList.append(
"-" )
107 hd = inFile.Get( dirName+
"Duplicates/duplrate_vs_truth_inclusive" )
108 if updateIndex : index.append(
"DuplicateRate_vs_truth" )
110 c = 100*hd.GetEfficiency(1)
111 eu = 100*hd.GetEfficiencyErrorUp(1)
112 el = 100*hd.GetEfficiencyErrorLow(1)
113 sList.append( f
"{c:.2f} +{eu:.2f}/-{el:.2f} %" )
114 else : sList.append(
"-" )
118 data.update( { label : sList } )
122 outFile = MyArgs.outName.replace(
"_&TrkAnaName&",
"" )
123 if os.path.isfile( outFile ) :
127 for anaName
in anaList :
131 anaDirName = MyArgs.dirName.replace(
"&TrkAnaName&", anaName )
132 anaOutName = MyArgs.outName.replace(
"&TrkAnaName&", anaName )
136 inFileName = MyArgs.testFile,
137 dirName = anaDirName,
138 label = MyArgs.testLabel,
146 inFileName = MyArgs.refFile,
147 dirName = anaDirName,
148 label = MyArgs.refLabel,
155 df = pd.DataFrame( data, index=index )
156 titleStr = f
"Summary for TrackAnalysis = {anaName}:"
157 print( f
"\n\n---------------\n{titleStr}" )
161 with open( anaOutName,
'w' )
as f :
165 os.system( f
"echo \"<br><b>{titleStr}</b><br>\" >> {outFile}" )
166 os.system( f
"cat {anaOutName} >> {outFile}" )
167 os.remove( f
"{anaOutName}" )