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.

652 lines
24 KiB

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