You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

662 lines
24 KiB

10 months ago
8 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
8 months ago
10 months ago
8 months ago
10 months ago
10 months ago
10 months ago
10 months ago
8 months ago
8 months ago
10 months ago
8 months ago
9 months ago
8 months ago
9 months ago
8 months ago
8 months ago
9 months ago
8 months ago
8 months ago
9 months ago
8 months ago
9 months ago
8 months ago
9 months ago
8 months ago
8 months ago
10 months ago
8 months ago
10 months ago
8 months ago
8 months ago
10 months ago
8 months ago
10 months ago
8 months ago
10 months ago
8 months ago
10 months ago
8 months ago
8 months ago
8 months ago
8 months ago
10 months ago
8 months ago
8 months ago
10 months ago
8 months ago
10 months ago
8 months ago
10 months ago
8 months ago
10 months ago
8 months ago
8 months ago
8 months ago
8 months ago
10 months ago
8 months ago
10 months ago
8 months ago
10 months ago
8 months ago
10 months ago
8 months ago
8 months ago
8 months ago
10 months ago
  1. # flake8: noqa
  2. """
  3. Takes data from Recent_get_resolution_and_eff_data.py and calculates efficiencies
  4. python scripts/MyPrCheckerEfficiency.py --filename data/resolutions_and_effs_B_normal_weights.root data/resolutions_and_effs_B_electron_weights.root
  5. --outfile data_results/PrCheckerNormalElectron.root --label normal electron --trackers Match BestLong
  6. python scripts/MyPrCheckerEfficiency.py --filename data/resolutions_and_effs_D_electron_weights.root --outfile data_results/PrCheckerDElectron.root
  7. python scripts/PrCheckerEfficiency.py --filename data/resolutions_and_effs_B_thesis.root
  8. --outfile data_results/PrCheckerTestThesis.root --label particle --plot-velo --plot-velo-only --trackers Match Seed --savepdf
  9. """
  10. import argparse
  11. from ROOT import TMultiGraph, TLatex, TCanvas, TFile, TGaxis
  12. from ROOT import (
  13. kGreen,
  14. kBlue,
  15. kBlack,
  16. kAzure,
  17. kOrange,
  18. kMagenta,
  19. kCyan,
  20. kGray,
  21. kViolet,
  22. kTeal,
  23. )
  24. from ROOT import gROOT, gStyle, gPad
  25. from ROOT import TEfficiency
  26. from array import array
  27. gROOT.SetBatch(True)
  28. from utils.components import unique_name_ext_re, findRootObjByName
  29. def getEfficiencyHistoNames():
  30. return ["p", "pt", "phi", "eta", "nPV"]
  31. def getTrackers(trackers):
  32. return trackers
  33. # data/resolutions_and_effs_Bd2KstEE_MDmaster.root:Track/...
  34. def getOriginFolders():
  35. basedict = {
  36. "Velo": {},
  37. "Upstream": {},
  38. "Forward": {},
  39. "Match": {},
  40. "BestLong": {},
  41. "Seed": {},
  42. "MergedMatch": {},
  43. "DefaultMatch": {},
  44. }
  45. # evtl anpassen wenn die folders anders heissen
  46. basedict["Velo"]["folder"] = "VeloTrackChecker/"
  47. basedict["Upstream"]["folder"] = "UpstreamTrackChecker/"
  48. basedict["Forward"]["folder"] = "ForwardTrackChecker" + unique_name_ext_re() + "/"
  49. basedict["Match"]["folder"] = "MatchTrackChecker" + unique_name_ext_re() + "/"
  50. basedict["BestLong"]["folder"] = "BestLongTrackChecker" + unique_name_ext_re() + "/"
  51. basedict["Seed"]["folder"] = "SeedTrackChecker" + unique_name_ext_re() + "/"
  52. basedict["MergedMatch"]["folder"] = (
  53. "MergedMatchTrackChecker" + unique_name_ext_re() + "/"
  54. )
  55. basedict["DefaultMatch"]["folder"] = (
  56. "DefaultMatchTrackChecker" + unique_name_ext_re() + "/"
  57. )
  58. # basedict["Forward"]["folder"] = "ForwardTrackChecker_7a0dbfa7/"
  59. # basedict["Match"]["folder"] = "MatchTrackChecker_29e3152a/"
  60. # basedict["BestLong"]["folder"] = "BestLongTrackChecker_4ddacce1/"
  61. # basedict["Seed"]["folder"] = "SeedTrackChecker_1b1d5575/"
  62. return basedict
  63. def getTrackNames():
  64. basedict = {
  65. "Velo": {},
  66. "Upstream": {},
  67. "Forward": {},
  68. "Match": {},
  69. "BestLong": {},
  70. "Seed": {},
  71. "MergedMatch": {},
  72. "DefaultMatch": {},
  73. }
  74. basedict["Velo"] = "Velo"
  75. basedict["Upstream"] = "VeloUT"
  76. basedict["Forward"] = "Forward"
  77. basedict["Match"] = "Match"
  78. basedict["BestLong"] = "BestLong"
  79. basedict["Seed"] = "Seed"
  80. basedict["MergedMatch"] = "MergedMatch"
  81. basedict["DefaultMatch"] = "DefaultMatch"
  82. return basedict
  83. def get_colors():
  84. # [kBlack, kGreen + 3, kAzure, kMagenta + 2, kOrange, kCyan + 2]
  85. return [kBlack, kAzure, kGreen + 3, kMagenta + 2, kOrange, kCyan + 2]
  86. def get_elec_colors():
  87. # [kBlack, kGreen + 3, kAzure, kMagenta + 2, kOrange, kCyan + 2]
  88. return [kBlue - 7, kGray + 2, kGreen + 1, kViolet, kOrange - 3, kTeal - 1]
  89. def get_markers():
  90. # [20, 24, 21, 22, 23, 25]
  91. return [20, 21, 22, 23, 24, 25, 26, 32]
  92. def get_elec_markers():
  93. # [20, 24, 21, 22, 23, 25]
  94. return [24, 25, 26, 32, 22, 23, 26, 32]
  95. def get_fillstyles():
  96. return [1003, 3001, 3002, 3325, 3144, 3244, 3444]
  97. def getGhostHistoNames():
  98. basedict = {
  99. "Velo": {},
  100. "Upstream": {},
  101. "Forward": {},
  102. "Match": {},
  103. "MergedMatch": {},
  104. "DefaultMatch": {},
  105. "BestLong": {},
  106. "Seed": {},
  107. }
  108. basedict["Velo"] = ["eta", "nPV"]
  109. basedict["Upstream"] = ["eta", "p", "pt", "nPV"]
  110. basedict["Forward"] = ["eta", "p", "pt", "nPV"]
  111. basedict["Match"] = ["eta", "p", "pt", "nPV"]
  112. basedict["MergedMatch"] = basedict["Match"]
  113. basedict["DefaultMatch"] = basedict["Match"]
  114. basedict["BestLong"] = ["eta", "p", "pt", "nPV"]
  115. basedict["Seed"] = ["eta", "p", "pt", "nPV"]
  116. return basedict
  117. def argument_parser():
  118. parser = argparse.ArgumentParser(description="location of the tuple file")
  119. parser.add_argument(
  120. "--filename",
  121. type=str,
  122. default=["data/resolutions_and_effs_B.root"],
  123. nargs="+",
  124. help="input files, including path",
  125. )
  126. parser.add_argument(
  127. "--outfile",
  128. type=str,
  129. default="data_results/efficiency_plots.root",
  130. help="output file",
  131. )
  132. parser.add_argument(
  133. "--trackers",
  134. type=str,
  135. nargs="+",
  136. default=["Forward", "Match", "BestLong", "Seed"], # DefaultMatch
  137. help="Trackers to plot.",
  138. )
  139. parser.add_argument(
  140. "--label",
  141. nargs="+",
  142. default=["EffChecker"],
  143. help="label for files",
  144. )
  145. parser.add_argument(
  146. "--savepdf",
  147. action="store_true",
  148. help="save plots in pdf format",
  149. )
  150. parser.add_argument(
  151. "--plot-electrons",
  152. action="store_true",
  153. default=True,
  154. help="plot electrons",
  155. )
  156. parser.add_argument(
  157. "--plot-electrons-only",
  158. action="store_true",
  159. help="plot only electrons",
  160. )
  161. parser.add_argument(
  162. "--plot-velo",
  163. action="store_true",
  164. help="plot using momentum at EndVelo",
  165. )
  166. parser.add_argument(
  167. "--plot-velo-only",
  168. action="store_true",
  169. help="plot using only momentum at EndVelo",
  170. )
  171. return parser
  172. def get_files(tf, filename, label):
  173. for i, f in enumerate(filename):
  174. tf[label[i]] = TFile(f, "read")
  175. return tf
  176. def get_nicer_var_string(var: str):
  177. nice_vars = dict(pt="p_{T}", eta="#eta", phi="#phi")
  178. try:
  179. return nice_vars[var]
  180. except KeyError:
  181. return var
  182. def get_eff(eff, hist, tf, histoName, label, var):
  183. eff = {}
  184. hist = {}
  185. var = get_nicer_var_string(var)
  186. for i, lab in enumerate(label):
  187. numeratorName = histoName + "_reconstructed"
  188. numerator = findRootObjByName(tf[lab], numeratorName)
  189. denominatorName = histoName + "_reconstructible"
  190. denominator = findRootObjByName(tf[lab], denominatorName)
  191. if numerator.GetEntries() == 0 or denominator.GetEntries() == 0:
  192. continue
  193. teff = TEfficiency(numerator, denominator)
  194. teff.SetStatisticOption(7)
  195. eff[lab] = teff.CreateGraph()
  196. eff[lab].SetName(lab)
  197. eff[lab].SetTitle(lab + " not e^{-}")
  198. if histoName.find("Forward") != -1:
  199. if histoName.find("electron") != -1:
  200. eff[lab].SetTitle(lab + " Forward, e^{-}")
  201. else:
  202. eff[lab].SetTitle(lab + " Forward, not e^{-}")
  203. if histoName.find("Merged") != -1:
  204. if histoName.find("electron") != -1:
  205. eff[lab].SetTitle(lab + " MergedMatch, e^{-}")
  206. else:
  207. eff[lab].SetTitle(lab + " MergedMatch, not e^{-}")
  208. if histoName.find("DefaultMatch") != -1:
  209. if histoName.find("electron") != -1:
  210. eff[lab].SetTitle(lab + " DefaultMatch, e^{-}")
  211. else:
  212. eff[lab].SetTitle(lab + " DefaultMatch, not e^{-}")
  213. if histoName.find("Match") != -1:
  214. if histoName.find("electron") != -1:
  215. eff[lab].SetTitle(lab + " Match, e^{-}")
  216. else:
  217. eff[lab].SetTitle(lab + " Match, not e^{-}")
  218. if histoName.find("Seed") != -1:
  219. if histoName.find("electron") != -1:
  220. eff[lab].SetTitle(lab + " Seed, e^{-}")
  221. else:
  222. eff[lab].SetTitle(lab + " Seed, not e^{-}")
  223. if histoName.find("BestLong") != -1:
  224. if histoName.find("electron") != -1:
  225. eff[lab].SetTitle(lab + " BestLong, e^{-}")
  226. else:
  227. eff[lab].SetTitle(lab + " BestLong, not e^{-}")
  228. if histoName.find("EndVelo") != -1:
  229. eff[lab].SetTitle(eff[lab].GetTitle() + " EndVelo")
  230. # if histoName.find("EndUT") != -1:
  231. # eff[lab].SetTitle(eff[lab].GetTitle() + " EndUT")
  232. hist[lab] = denominator.Clone()
  233. hist[lab].SetName("h_numerator_notElectrons")
  234. hist[lab].SetTitle(var + " distribution, not e^{-}")
  235. if histoName.find("strange") != -1:
  236. hist[lab].SetTitle(var + " distribution, stranges")
  237. if histoName.find("electron") != -1:
  238. hist[lab].SetTitle(var + " distribution, e^{-}")
  239. if histoName.find("EndVelo") != -1:
  240. hist[lab].SetTitle(hist[lab].GetTitle() + ", EndVelo")
  241. # if histoName.find("EndUT") != -1:
  242. # hist[lab].SetTitle(hist[lab].GetTitle() + ", EndUT")
  243. return eff, hist
  244. def get_ghost(eff, hist, tf, histoName, label):
  245. ghost = {}
  246. for i, lab in enumerate(label):
  247. numeratorName = histoName + "_Ghosts"
  248. denominatorName = histoName + "_Total"
  249. numerator = findRootObjByName(tf[lab], numeratorName)
  250. denominator = findRootObjByName(tf[lab], denominatorName)
  251. print("Numerator = " + numeratorName.replace(unique_name_ext_re(), ""))
  252. print("Denominator = " + denominatorName.replace(unique_name_ext_re(), ""))
  253. teff = TEfficiency(numerator, denominator)
  254. teff.SetStatisticOption(7)
  255. ghost[lab] = teff.CreateGraph()
  256. print(lab)
  257. ghost[lab].SetName(lab)
  258. return ghost
  259. def PrCheckerEfficiency(
  260. filename,
  261. outfile,
  262. label,
  263. trackers,
  264. savepdf,
  265. plot_electrons,
  266. plot_electrons_only,
  267. plot_velo,
  268. plot_velo_only,
  269. ):
  270. from utils.LHCbStyle import setLHCbStyle, set_style
  271. from utils.ConfigHistos import (
  272. efficiencyHistoDict,
  273. ghostHistoDict,
  274. categoriesDict,
  275. getCuts,
  276. )
  277. from utils.Legend import place_legend
  278. # from utils.components import unique_name_ext_re, findRootObjByName
  279. setLHCbStyle()
  280. markers = get_markers()
  281. elec_markers = get_elec_markers()
  282. colors = get_colors()
  283. elec_colors = get_elec_colors()
  284. styles = get_fillstyles()
  285. tf = {}
  286. tf = get_files(tf, filename, label)
  287. outputfile = TFile(outfile, "recreate")
  288. latex = TLatex()
  289. latex.SetNDC()
  290. latex.SetTextSize(0.05)
  291. efficiencyHistoDict = efficiencyHistoDict()
  292. efficiencyHistos = getEfficiencyHistoNames()
  293. ghostHistos = getGhostHistoNames()
  294. ghostHistoDict = ghostHistoDict()
  295. categories = categoriesDict()
  296. cuts = getCuts()
  297. trackers = getTrackers(trackers)
  298. folders = getOriginFolders()
  299. # names = getTrackNames()
  300. for tracker in trackers:
  301. outputfile.cd()
  302. trackerDir = outputfile.mkdir(tracker)
  303. trackerDir.cd()
  304. for cut in cuts[tracker]:
  305. cutDir = trackerDir.mkdir(cut)
  306. cutDir.cd()
  307. folder = folders[tracker]["folder"]
  308. print("folder: " + folder.replace(unique_name_ext_re(), ""))
  309. histoBaseName = "Track/" + folder + tracker + "/" + cut + "_"
  310. # calculate efficiency
  311. for histo in efficiencyHistos:
  312. canvastitle = (
  313. "efficiency_" + histo + ", " + categories[tracker][cut]["title"]
  314. )
  315. # get efficiency for not electrons category
  316. histoName = histoBaseName + "" + efficiencyHistoDict[histo]["variable"]
  317. print("not electrons: " + histoName.replace(unique_name_ext_re(), ""))
  318. eff = {}
  319. hist_den = {}
  320. eff, hist_den = get_eff(eff, hist_den, tf, histoName, label, histo)
  321. if categories[tracker][cut]["plotElectrons"] and plot_electrons:
  322. histoNameElec = (
  323. "Track/"
  324. + folder
  325. + tracker
  326. + "/"
  327. + categories[tracker][cut]["Electrons"]
  328. )
  329. histoName_e = (
  330. histoNameElec + "_" + efficiencyHistoDict[histo]["variable"]
  331. )
  332. print("electrons: " + histoName_e.replace(unique_name_ext_re(), ""))
  333. eff_elec = {}
  334. hist_elec = {}
  335. eff_elec, hist_elec = get_eff(
  336. eff_elec,
  337. hist_elec,
  338. tf,
  339. histoName_e,
  340. label,
  341. histo,
  342. )
  343. if (
  344. categories[tracker][cut]["plotEndVelo"]
  345. and plot_velo
  346. and (histo == "p" or histo == "pt")
  347. ):
  348. histoNameEndVelo = (
  349. "Track/"
  350. + folder
  351. + tracker
  352. + "/"
  353. + categories[tracker][cut]["EndVelo"]
  354. )
  355. histoName_v = (
  356. histoNameEndVelo
  357. + "_"
  358. + efficiencyHistoDict[histo]["variable"]
  359. )
  360. print(
  361. "EndVelo: " + histoName_v.replace(unique_name_ext_re(), "")
  362. )
  363. eff_velo = {}
  364. hist_velo = {}
  365. eff_velo, hist_velo = get_eff(
  366. eff_velo,
  367. hist_velo,
  368. tf,
  369. histoName_v,
  370. label,
  371. histo,
  372. )
  373. name = "efficiency_" + histo
  374. canvas = TCanvas(name, canvastitle)
  375. canvas.SetRightMargin(0.1)
  376. mg = TMultiGraph()
  377. for i, lab in enumerate(label):
  378. if (
  379. categories[tracker][cut]["plotEndVelo"]
  380. and plot_velo
  381. and (histo == "p" or histo == "pt")
  382. ): # and not plot_velo_only:
  383. mg.Add(eff_velo[lab])
  384. set_style(eff_velo[lab], colors[i], markers[i], styles[i])
  385. if categories[tracker][cut]["plotElectrons"] and plot_electrons:
  386. if (not plot_velo_only) or (
  387. histo == "phi" or histo == "eta" or histo == "nPV"
  388. ):
  389. mg.Add(eff_elec[lab])
  390. set_style(
  391. eff_elec[lab],
  392. elec_colors[i],
  393. elec_markers[i],
  394. styles[i],
  395. )
  396. mg.Draw("AP")
  397. mg.GetYaxis().SetRangeUser(0, 1.05)
  398. xtitle = efficiencyHistoDict[histo]["xTitle"]
  399. unit_l = xtitle.split("[")
  400. if "]" in unit_l[-1]:
  401. unit = unit_l[-1].replace("]", "")
  402. else:
  403. unit = "a.u."
  404. print(unit)
  405. mg.GetXaxis().SetTitle(xtitle)
  406. mg.GetXaxis().SetTitleSize(0.06)
  407. mg.GetYaxis().SetTitle(
  408. "Efficiency of Long Tracks",
  409. ) # (" + str(round(hist_den[label[0]].GetBinWidth(1), 2)) + f"{unit})"+"^{-1}")
  410. mg.GetYaxis().SetTitleSize(0.06)
  411. mg.GetYaxis().SetTitleOffset(1.1)
  412. mg.GetXaxis().SetRangeUser(*efficiencyHistoDict[histo]["range"])
  413. mg.GetXaxis().SetNdivisions(10, 5, 0)
  414. mygray = 18
  415. myblue = kBlue - 10
  416. mypurple = kMagenta - 10
  417. for i, lab in enumerate(label):
  418. rightmax = 1.05 * hist_den[lab].GetMaximum()
  419. scale = gPad.GetUymax() / rightmax
  420. hist_den[lab].Scale(scale)
  421. if categories[tracker][cut]["plotElectrons"] and plot_electrons:
  422. rightmax = 1.05 * hist_elec[lab].GetMaximum()
  423. scale = gPad.GetUymax() / rightmax
  424. hist_elec[lab].Scale(scale)
  425. if (
  426. categories[tracker][cut]["plotEndVelo"]
  427. and plot_velo
  428. and (histo == "p" or histo == "pt")
  429. ):
  430. rightmax = 1.05 * hist_velo[lab].GetMaximum()
  431. scale = gPad.GetUymax() / rightmax
  432. hist_velo[lab].Scale(scale)
  433. if i == 0:
  434. if (
  435. categories[tracker][cut]["plotEndVelo"]
  436. and plot_velo
  437. and (histo == "p" or histo == "pt")
  438. ):
  439. set_style(hist_velo[lab], mygray, markers[i], styles[i])
  440. gStyle.SetPalette(2, array("i", [mygray - 1, myblue + 1]))
  441. hist_velo[lab].Draw("HIST PLC SAME")
  442. if categories[tracker][cut]["plotElectrons"] and plot_electrons:
  443. if not plot_velo_only or (
  444. histo == "phi" or histo == "eta" or histo == "nPV"
  445. ):
  446. set_style(
  447. hist_elec[lab], myblue, elec_markers[i], styles[i]
  448. )
  449. hist_elec[lab].SetFillColorAlpha(myblue, 0.5)
  450. hist_elec[lab].Draw("HIST PLC SAME")
  451. # else:
  452. # print(
  453. # "No distribution plotted for other labels.",
  454. # "Can be added by uncommenting the code below this print statement.",
  455. # )
  456. # set_style(hist_den[lab], mygray, markers[i], styles[i])
  457. # gStyle.SetPalette(2, array("i", [mygray - 1, myblue + 1]))
  458. # hist_den[lab].Draw("HIST PLC SAME")
  459. if histo == "p":
  460. pos = [0.5, 0.35, 1.0, 0.7] # [0.53, 0.4, 1.01, 0.71]
  461. elif histo == "pt":
  462. pos = [0.5, 0.3, 0.99, 0.5] # [0.5, 0.4, 0.98, 0.71]
  463. elif histo == "phi":
  464. pos = [0.4, 0.3, 0.9, 0.5]
  465. elif histo == "eta":
  466. pos = [0.5, 0.25, 1.0, 0.45]
  467. else:
  468. pos = [0.35, 0.25, 0.85, 0.45]
  469. if histo == "p":
  470. legend = place_legend(
  471. canvas, *pos, header="LHCb Simulation", option="LPE"
  472. )
  473. for le in legend.GetListOfPrimitives():
  474. if "distribution" in le.GetLabel():
  475. le.SetOption("LF")
  476. legend.SetTextFont(132)
  477. legend.SetTextSize(0.04)
  478. legend.Draw()
  479. for lab in label:
  480. if (
  481. categories[tracker][cut]["plotEndVelo"]
  482. and plot_velo
  483. and (histo == "p" or histo == "pt")
  484. ):
  485. eff_velo[lab].Draw("P SAME")
  486. if categories[tracker][cut]["plotElectrons"] and plot_electrons:
  487. if not plot_velo_only or (
  488. histo == "phi" or histo == "eta" or histo == "nPV"
  489. ):
  490. eff_elec[lab].Draw("P SAME")
  491. cutName = categories[tracker][cut]["title"]
  492. latex.DrawLatex(legend.GetX1() + 0.01, legend.GetY1() - 0.05, cutName)
  493. low = 0
  494. high = 1.05
  495. gPad.Update()
  496. axis = TGaxis(
  497. gPad.GetUxmax(),
  498. gPad.GetUymin(),
  499. gPad.GetUxmax(),
  500. gPad.GetUymax(),
  501. low,
  502. high,
  503. 510,
  504. "+U",
  505. )
  506. axis.SetTitleFont(132)
  507. axis.SetTitleSize(0.06)
  508. axis.SetTitleOffset(0.55)
  509. axis.SetTitle(
  510. "# Tracks " + get_nicer_var_string(histo) + " distribution [a.u.]",
  511. )
  512. axis.SetLabelSize(0)
  513. axis.Draw()
  514. canvas.RedrawAxis()
  515. if savepdf:
  516. filestypes = ["pdf"] # , "png", "eps", "C", "ps", "tex"]
  517. for ftype in filestypes:
  518. if not plot_electrons_only:
  519. canvasName = tracker + "_" + cut + "_" + histo + "." + ftype
  520. else:
  521. canvasName = (
  522. tracker + "Electrons_" + cut + "_" + histo + "." + ftype
  523. )
  524. canvas.SaveAs("checks/" + canvasName)
  525. # canvas.SetRightMargin(0.05)
  526. canvas.Write()
  527. # calculate ghost rate
  528. print("\ncalculate ghost rate: ")
  529. histoBaseName = "Track/" + folder + tracker + "/"
  530. for histo in ghostHistos[tracker]:
  531. trackerDir.cd()
  532. title = "ghost_rate_vs_" + histo
  533. gPad.SetTicks()
  534. histoName = histoBaseName + ghostHistoDict[histo]["variable"]
  535. ghost = {}
  536. hist_den = {}
  537. ghost = get_ghost(ghost, hist_den, tf, histoName, label)
  538. canvas = TCanvas(title, title)
  539. mg = TMultiGraph()
  540. for i, lab in enumerate(label):
  541. mg.Add(ghost[lab])
  542. set_style(ghost[lab], colors[i], markers[2 * i], styles[i])
  543. xtitle = ghostHistoDict[histo]["xTitle"]
  544. mg.GetXaxis().SetTitle(xtitle)
  545. mg.GetYaxis().SetTitle("Fraction of fake tracks")
  546. mg.Draw("ap")
  547. mg.GetXaxis().SetTitleSize(0.06)
  548. mg.GetYaxis().SetTitleSize(0.06)
  549. mg.GetYaxis().SetTitleOffset(1.1)
  550. mg.GetXaxis().SetRangeUser(*efficiencyHistoDict[histo]["range"])
  551. mg.GetXaxis().SetNdivisions(10, 5, 0)
  552. # for lab in label:
  553. # ghost[lab].Draw("P SAME")
  554. if histo == "p":
  555. pos = [0.53, 0.4, 1.00, 0.71]
  556. elif histo == "pt":
  557. pos = [0.5, 0.4, 0.98, 0.71]
  558. elif histo == "eta":
  559. pos = [0.35, 0.6, 0.85, 0.9]
  560. elif histo == "phi":
  561. pos = [0.3, 0.3, 0.9, 0.6]
  562. else:
  563. pos = [0.4, 0.37, 0.80, 0.68]
  564. legend = place_legend(canvas, *pos, header="LHCb Simulation", option="LPE")
  565. legend.SetTextFont(132)
  566. legend.SetTextSize(0.04)
  567. legend.Draw()
  568. # if histo != "nPV":
  569. # latex.DrawLatex(0.7, 0.85, "LHCb simulation")
  570. # else:
  571. # latex.DrawLatex(0.2, 0.85, "LHCb simulation")
  572. # mg.GetYaxis().SetRangeUser(0, 0.4)
  573. if histo == "eta":
  574. mg.GetYaxis().SetRangeUser(0, 0.4)
  575. # track_name = names[tracker] + " tracks"
  576. # latex.DrawLatex(0.7, 0.75, track_name)
  577. # canvas.PlaceLegend()
  578. if savepdf:
  579. filestypes = ["pdf"] # , "png", "eps", "C", "ps", "tex"]
  580. for ftype in filestypes:
  581. canvas.SaveAs(
  582. "checks/" + tracker + "ghost_rate_" + histo + "." + ftype,
  583. )
  584. canvas.Write()
  585. outputfile.Write()
  586. outputfile.Close()
  587. if __name__ == "__main__":
  588. parser = argument_parser()
  589. args = parser.parse_args()
  590. PrCheckerEfficiency(**vars(args))