16 from prompt
import ValidationSettings
22 settings = ValidationSettings(name=
'CDC Tracking',
25 expert_config={
'file_extension':
'png',
32 def findLastIteration(job_path, algorithm):
33 root = f
"{job_path}/{algorithm}/"
34 list_dirs = [item
for item
in os.listdir(root)
if item !=
'outputdb']
35 list_dirs.sort(reverse=
True)
36 print(f
"The following iterations are available for {algorithm} algorithm: {list_dirs}")
40 def run_validation(job_path, input_data_path, requested_iov, expert_config):
45 expert_config = json.loads(expert_config)
46 file_extension = expert_config[
'file_extension']
47 algo_tz = expert_config[
'algo_tz']
48 algo_tw = expert_config[
'algo_tw']
49 algo_sr = expert_config[
'algo_sr']
50 algo_xt = expert_config[
'algo_xt']
55 ROOT.gROOT.SetBatch(
True)
56 ROOT.gStyle.SetOptStat(0)
58 plot_directory =
"plots"
59 if not os.path.exists(plot_directory):
60 os.makedirs(plot_directory)
63 print(
"**** T0 validation plots ****")
65 lastIt = findLastIteration(job_path, algo_tz)
66 histT0_tz = f
'{job_path}/{algo_tz}/{lastIt}/algorithm_output/histT0_{algo_tz}.root'
67 f_histT0_tz = ROOT.TFile(histT0_tz)
68 print(f
"Plots from {algo_tz}/{lastIt}/algorithm_output/histT0_{algo_tz}.root")
71 hm_All = f_histT0_tz.Get(
"hm_All")
73 hm_All.GetXaxis().SetRangeUser(-1, 0)
74 hm_All.GetXaxis().SetTitle(
r"<\Delta t> [ns]")
77 can1.SaveAs(f
"{plot_directory}/{algo_tz}_hm_All.{file_extension}")
79 hs_All = f_histT0_tz.Get(
"hs_All")
81 hs_All.GetXaxis().SetRangeUser(2, 8)
82 hs_All.GetXaxis().SetTitle(
r"\sigma(\Delta t) [ns]")
85 can2.SaveAs(f
"{plot_directory}/{algo_tz}_hs_All.{file_extension}")
88 hTotal = f_histT0_tz.Get(
"hTotal")
90 hTotal.GetXaxis().SetTitle(
r"<\Delta t> [ns]")
93 can3.SaveAs(f
"{plot_directory}/{algo_tz}_hTotal.{file_extension}")
96 gr1 = [f_histT0_tz.Get(f
'DeltaT0/lay{i}')
for i
in range(56)]
97 cs = [ROOT.TCanvas(f
'cs{i}',
'', 1200, 750)
for i
in range(7)]
101 pad = [cs[j].GetPrimitive(f
'cs{j}_{i + 1}')
for i
in range(8)]
111 cs[i].SaveAs(f
"{plot_directory}/{algo_tz}_layers-{i}.{file_extension}")
114 print(
"**** TW validation plots ****")
116 lastIt = findLastIteration(job_path, algo_tw)
117 histTW_tw = f
'{job_path}/{algo_tw}/{lastIt}/algorithm_output/histTW_{algo_tw}.root'
118 f_histTW_tw = ROOT.TFile(histTW_tw)
119 print(f
"Plots from {algo_tw}/{lastIt}/algorithm_output/histTW_{algo_tw}.root")
122 rangeBorad = range(1, 301)
123 board_1D = [f_histTW_tw.Get(f
'h1D/board_{boardID}_1')
for boardID
in rangeBorad]
124 can = [ROOT.TCanvas(f
'c{c}', f
'c{c}', 2000, 1500)
for c
in range(12)]
127 can[c].Divide(ni, nj)
128 for j
in range(ni * nj):
130 boardNumber = j + c * (ni * nj)
131 if board_1D[boardNumber]:
132 board_1D[boardNumber].SetMarkerStyle(2)
133 board_1D[boardNumber].SetTitle(f
'Board number {boardNumber}')
134 board_1D[boardNumber].GetXaxis().SetTitle(
"ADC count")
135 board_1D[boardNumber].GetYaxis().SetTitle(
r"$\Delta t$ [ns]")
136 board_1D[boardNumber].Draw()
138 can[c].SaveAs(f
"{plot_directory}/{algo_tw}_boards-{c}.{file_extension}")
141 print(
"**** sigma res validation plots ****")
143 lastIt = findLastIteration(job_path, algo_sr)
144 histsr_sr = f
'{job_path}/{algo_sr}/{lastIt}/algorithm_output/histSigma_{algo_sr}.root'
145 f_histsr_sr = ROOT.TFile(histsr_sr)
146 print(f
"Plots from {algo_sr}/{lastIt}/algorithm_output/histSigma_{algo_sr}.root")
151 histograms = [f_histsr_sr.Get(f
'lay_{ilay}/sigma2_lay{ilay}_lr{LR}_al{alpha}_th{theta}')
for ilay
in range(56)]
157 div, mod = count_h // ncols, count_h % ncols
162 print(f
"number of valid histograms = {count_h} => canvas layout = ({ncols}, {nrows})")
164 c2 = ROOT.TCanvas(
'c2',
'', ncols * 700, nrows * 400)
165 c2.Divide(ncols, nrows)
171 h.GetXaxis().SetTitle(
"drift lenght [cm]")
172 h.GetYaxis().SetTitle(
"#sigma_{r}^{2} = #sigma_{u}.#sigma_{d}")
176 c2.SaveAs(f
"{plot_directory}/{algo_sr}_lr{LR}_al{alpha}_th{theta}.{file_extension}")
179 print(
"**** XT validation plots ****")
181 lastIt = findLastIteration(job_path, algo_xt)
182 histXT_xt = f
'{job_path}/{algo_xt}/{lastIt}/algorithm_output/histXT_{algo_xt}.root'
183 f_histXT_xt = ROOT.TFile(histXT_xt)
184 print(f
"Plots from {algo_xt}/{lastIt}/algorithm_output/histXT_{algo_xt}.root")
190 histograms = [f_histXT_xt.Get(f
'lay_{layer}/m_hProf{layer}_{LR}_{alphaID}_{thetaID}')
for layer
in range(56)]
197 div, mod = count_h // ncols, count_h % ncols
202 c2 = ROOT.TCanvas(
'c2',
'', ncols * 900, nrows * 600)
203 c2.Divide(ncols, nrows)
205 for histo
in histograms:
209 histo.GetYaxis().SetRangeUser(-1.2, 1.2)
210 histo.SetMarkerStyle(2)
213 c2.SaveAs(f
"{plot_directory}/{algo_xt}_lr{LR}_al{alphaID}_th{thetaID}.{file_extension}")
216 if __name__ ==
"__main__":