1693 from argparse
import ArgumentParser, RawDescriptionHelpFormatter
1695 parser = ArgumentParser(
1696 formatter_class=RawDescriptionHelpFormatter,
1698 to produce paper plots for systematics:
1699 python plot.py sys_eta_slices --beautify-sysnames --sys-order paper_run1 --superimpose-all --skip-null-sys --esmodels es2016PRE --min-sys-value -0.01 --max-sys-value 0.02 --symmetrize-labels --pt-bins-logspace 5E3 1E6 100
1701 # python plot.py sys_eta_slices --beautify-sysnames --sys-order paper_run1 --superimpose-all --skip-null-sys --esmodels es2016data_mc15c_summer_improved --min-sys-value -0.01 --max-sys-value 0.02 --symmetrize-labels --pt-bins-logspace 5E3 1E6 100
1703 to produce paper plot for resolution (the name of the esmodels here are the ones used by the internal class)
1704 python plot.py resolution-err --esmodels es2017 --abs-sys --pt-bins-linspace 5E3 200E3 200
1706 to compare systematics between tools vs pT:
1707 python plot.py compare_sys --particles electron converted unconverted --esmodels es2016data_mc15c_summer_improved es2016data_mc15c_summer --eta-bins 0 0.6 1.0 1.37 1.55 1.82 2.47 --pt-bins-logspace 5E3 1500E3 50 --abs-sys --log-x
1709 to plot all systematics in a 2d plot (eta, pt):
1710 python plot.py all_sys --esmodel es2016data_mc15c_summer es2012c --decorrelation=FULL_ETACORRELATED_v1 --eta-bins-linspace -2.5 2.5 50 --pt-bins-linspace 15E3 100E3 50 --particles converted unconverted --sys-filters *LARCALIB* *LARELECUNCONV*
1712 to produce scale factor correction (doScaleCorrection on/off):
1713 python plot.py scale --esmodels es2015PRE es2016data_mc15c_summer
1715 to list the systematics:
1716 python plot.py list-systematics --esmodels es2012c es2016data_mc15c_summer es2016data_mc15c_summer_improved es2017_R21_PRE
1719 parser.add_argument(
1743 parser.add_argument(
"--esmodels", nargs=
"*", help=
"esmodel to consider")
1744 parser.add_argument(
"--decorrelation", default=
"FULL_ETACORRELATED_v1")
1745 parser.add_argument(
1748 help=
"the particle (electron/converted/unconverted)",
1749 default=[
"electron"],
1751 parser.add_argument(
"--beautify-sysnames", action=
"store_true")
1752 parser.add_argument(
"--eta-bins", nargs=
"*", type=float, help=
"edges of the eta-bins")
1753 parser.add_argument(
1754 "--eta-bins-linspace", nargs=3, type=float, help=
"edge of the eta-bins as min max nbins"
1756 parser.add_argument(
"--pt-bins", nargs=
"*", type=float, help=
"edges of the pt-bins")
1757 parser.add_argument(
1758 "--pt-bins-linspace", nargs=3, type=float, help=
"edge of the eta-bins as min max nbins"
1760 parser.add_argument(
1761 "--pt-bins-logspace", nargs=3, type=float, help=
"edge of the eta-bins as min max nbins"
1763 parser.add_argument(
1764 "--super-sampling-eta", type=int, default=5, help=
"how many point to average inside a bin"
1766 parser.add_argument(
1768 choices=[
"paper_run1",
"paper_run2"],
1769 help=
"how to order systematics, options: paper_run1, paper_run2",
1771 parser.add_argument(
"--debug", action=
"store_true")
1772 parser.add_argument(
1773 "--superimpose-all", action=
"store_true", help=
"superimpose sum of systematics"
1775 parser.add_argument(
"--skip-null-sys", action=
"store_true", help=
"do not plot null systematics")
1776 parser.add_argument(
"--yrange", nargs=2, type=float)
1777 parser.add_argument(
"--add-down", action=
"store_true", help=
"plot also the down systematics")
1778 parser.add_argument(
1779 "--legend-outside", action=
"store_true", help=
"draw the legend outside the plot"
1781 parser.add_argument(
"--symmetrize-labels", action=
"store_true")
1782 parser.add_argument(
1783 "--abs-sys", action=
"store_true", help=
"consider the abs value of the systeamatics"
1785 parser.add_argument(
"--log-x", action=
"store_true", help=
"use log scale")
1786 parser.add_argument(
"--log-pt", action=
"store_true", help=
"use log scale for pT")
1787 parser.add_argument(
1788 "--sys-filters", nargs=
"*", help=
"list of wildcard to filter systematic names"
1790 parser.add_argument(
"--min-sys-value", type=float, help=
"min value for the systematic axis")
1791 parser.add_argument(
"--max-sys-value", type=float, help=
"max value for the systematic axis")
1792 parser.add_argument(
"--grid", action=
"store_true", help=
"show grid")
1793 parser.add_argument(
1795 action=
"store_true",
1796 help=
"plot the quadrature sum of the systematics for debug (should be equal to 1NP up)",
1798 parser.add_argument(
1799 "--atlas-label", default=
"Internal", help=
'Internal, Preliminary, ..., use "" for papers'
1801 args = parser.parse_args()
1804 log.setLevel(logging.DEBUG)
1805 log.debug(
"DEBUG activated")
1807 if args.eta_bins_linspace:
1808 args.eta_bins = np.linspace(
1809 args.eta_bins_linspace[0], args.eta_bins_linspace[1],
int(args.eta_bins_linspace[2] + 1)
1811 if args.pt_bins_linspace:
1812 args.pt_bins = np.linspace(
1813 args.pt_bins_linspace[0], args.pt_bins_linspace[1],
int(args.pt_bins_linspace[2] + 1)
1815 if args.pt_bins_logspace:
1816 args.pt_bins = np.logspace(
1817 np.log10(args.pt_bins_logspace[0]),
1818 np.log10(args.pt_bins_logspace[1]),
1819 int(args.pt_bins_logspace[2] + 1),
1823 if not os.path.exists(basedir):
1824 os.makedirs(basedir)
1826 if args.action ==
"list-systematics":
1829 if args.action ==
"compute_sys":
1830 log.info(
"computing systematics")
1831 for esmodel
in args.esmodels
or [
"es2012c"]:
1832 tool = ROOT.CP.EgammaCalibrationAndSmearingTool(
"tool")
1833 tool.setProperty(
"ESModel", esmodel)
1834 tool.setProperty(
"decorrelationModel",
"FULL_ETACORRELATED_v1")
1835 tool.setProperty[bool](
"doSmearing", 0)
1840 if args.action ==
"compare_sys":
1841 log.info(
"comparing systematics")
1844 ptypes=args.particles,
1845 decorrelation=args.decorrelation,
1846 eta_edges=args.eta_bins,
1847 pt_edges=args.pt_bins,
1848 abs_sys=args.abs_sys,
1852 if args.action ==
"resolution-err":
1853 log.info(
"plotting resolution error")
1856 if args.action ==
"zee" or args.action ==
"all":
1857 log.info(
"plotting scale systematics")
1860 if args.action ==
"all" or args.action ==
"uA2MeV":
1861 log.info(
"plotting uA2MeV")
1862 tool_es2015PRE_nouA2MeV = ROOT.CP.EgammaCalibrationAndSmearingTool(
1863 "tool_es2015PRE_nouA2MeV"
1865 tool_es2015PRE_nouA2MeV.setProperty(
"ESModel",
"es2015PRE")
1866 tool_es2015PRE_nouA2MeV.setProperty(
"decorrelationModel",
"FULL_ETACORRELATED_v1")
1867 tool_es2015PRE_nouA2MeV.setProperty[bool](
"doSmearing", 0)
1868 tool_es2015PRE_nouA2MeV.setProperty[bool](
"use_uA2MeV_2015_first2weeks_correction", 0)
1869 tool_es2015PRE_nouA2MeV.initialize()
1871 tool_es2015PRE = ROOT.CP.EgammaCalibrationAndSmearingTool(
"tool_es2015PRE")
1872 tool_es2015PRE.setProperty(
"ESModel",
"es2015PRE")
1873 tool_es2015PRE.setProperty(
"decorrelationModel",
"FULL_ETACORRELATED_v1")
1874 tool_es2015PRE.setProperty[bool](
"doSmearing", 0)
1875 tool_es2015PRE.initialize()
1879 tool_es2015PRE_nouA2MeV,
1884 title=
"with uA2MeV correction / without",
1885 particle=
"electron",
1888 del tool_es2015PRE_nouA2MeV
1891 if args.action ==
"all" or args.action ==
"scale":
1892 log.info(
"plotting scales")
1894 esmodels=args.esmodels,
1895 labels=args.esmodels,
1897 etas=np.arange(-2.5, 2.5, 0.01),
1901 if args.action ==
"all" or args.action ==
"fast":
1902 log.info(
"plotting full / fast scale")
1905 esmodels=(
"es2015PRE", (
"es2015PRE", (
"useFastSim",), (
True,), (bool,))),
1906 labels=(
"2015PRE",
"2015PRE FAST"),
1908 etas=np.arange(-2.5, 2.5, 0.01),
1910 if args.action ==
"all" or args.action ==
"cterm":
1911 log.info(
"plotting smearings")
1913 esmodels=(
"es2012c",
"es2012XX",
"es2015PRE"),
1914 labels=(
"2012",
"new",
"new + temp"),
1916 etas=np.arange(-2.5, 2.5, 0.01),
1919 if args.action ==
"gain" or args.action ==
"all":
1922 if args.action ==
"uniformity" or args.action ==
"all":
1926 if args.action ==
"sys_fixed_pt" or args.action ==
"all":
1927 tool_es2015PRE_notemp = ROOT.CP.EgammaCalibrationAndSmearingTool(
"tool_es2015PRE_notemp")
1928 tool_es2015PRE_notemp.setProperty(
"ESModel",
"es2015PRE")
1929 tool_es2015PRE_notemp.setProperty(
"decorrelationModel",
"FULL_ETACORRELATED_v1")
1930 tool_es2015PRE_notemp.setProperty[bool](
"doSmearing", 0)
1931 tool_es2015PRE_notemp.setProperty[bool](
"use_temp_correction201215", 0)
1932 tool_es2015PRE_notemp.initialize()
1936 (
"es2012c", tool_es2015PRE_notemp,
"es2015PRE"),
1937 names=(
"es2012c",
"es2015_no_temp",
"es2015PRE"),
1938 labels=(
"es2012c",
r"$\oplus$ 7/8 diff $\oplus$ 34/68 diff",
r"$\oplus$ LAr temperature"),
1941 if args.action ==
"sys_eta_slices" or args.action ==
"all":
1942 if not args.eta_bins:
1943 eta_bins = ((0.0, 0.6), (0.6, 1.45), (1.52, 1.7), (1.7, 1.9), (1.9, 2.5), (1.4, 1.6))
1944 log.warning(
"no eta-binning specified using %s", eta_bins)
1947 log.info(
"eta-bin: %s", eta_bins)
1948 for ptype
in "electron",
"unconverted",
"converted":
1949 log.debug(
"plot all sys FULL_ETACORRELATED_v1 eta slice %s", ptype)
1952 supersampling_eta=args.super_sampling_eta,
1953 esmodel=args.esmodels[0],
1954 decorrelation=
"FULL_ETACORRELATED_v1",
1957 beautify_sysnames=args.beautify_sysnames,
1958 sys_order=args.sys_order,
1959 superimpose_all=args.superimpose_all,
1960 skip_null_sys=args.skip_null_sys,
1961 max_sys=args.max_sys_value,
1962 min_sys=args.min_sys_value,
1964 only_up=
not args.add_down,
1965 symmetrize_labels=args.symmetrize_labels,
1966 legend_outside=args.legend_outside,
1969 plot_qsum=args.plot_qsum,
1970 abs_sys=args.abs_sys,
1971 atlas_label=args.atlas_label,
1974 if args.action ==
"material" or args.action ==
"all":
1975 if not os.path.exists(
"material"):
1976 os.makedirs(
"material")
1977 etabins = ((0.0, 0.6), (0.6, 1.45), (1.52, 1.7), (1.7, 1.9), (1.9, 2.5))
1978 for ptype
in "electron",
"unconverted",
"converted":
1981 supersampling_eta=args.super_sampling_eta,
1982 esmodel=args.esmodels[0],
1983 decorrelation=
"FULL_ETACORRELATED_v1",
1987 beautify_sysnames=args.beautify_sysnames,
1988 sys_order=args.sys_order,
1989 skip_null_sys=args.skip_null_sys,
1990 max_sys=args.max_sys_value,
1991 min_sys=args.min_sys_value,
1993 only_up=
not args.add_down,
1994 legend_outside=args.legend_outside,
1995 symmetrize_labels=args.symmetrize_labels,
1997 plot_qsum=args.plot_qsum,
1998 abs_sys=args.abs_sys,
1999 atlas_label=args.atlas_label,
2002 if args.action ==
"all_sys" or args.action ==
"all":
2003 for esmodel
in args.esmodels:
2004 for ptype
in args.particles:
2005 log.info(
"plotting sys for %s %s", ptype, esmodel)
2008 decorrelation=args.decorrelation,
2011 eta_range=args.eta_bins,
2012 pt_range=args.pt_bins,
2014 abs_sys=args.abs_sys,
2015 sys_filters=args.sys_filters,
2016 min_value=args.min_sys_value,
2017 max_value=args.max_sys_value,
2020 if args.action ==
"resolution" or args.action ==
"all":
2021 tool = ROOT.CP.EgammaCalibrationAndSmearingTool(
"tool")
2022 tool.setProperty(
"ESModel",
"es2015PRE")
2024 pts = np.logspace(3.2, 6, 50)
2025 etas = np.linspace(-2.49, 2.49, 100)
2027 basedir, tool, pts, etas,
"electron", title=
"resolution electron es2015PRE"
2030 basedir, tool, pts, etas,
"converted", title=
"resolution converted es2015PRE"
2033 basedir, tool, pts, etas,
"unconverted", title=
"resolution unconverted es2015PRE"