IJazZ ============ Derive Scale and Smearing ------------------------- .. code-block:: bash ijazz_sas config/sas_config.yaml where the config file is `config/sas_config.yaml`: .. literalinclude:: ../../config/sas_config.yaml :language: yaml :caption: Example YAML Configuration Command-line tools ------------------ This package installs the following entry points: - ``ijazz_sas``: run the main Scale and Smearing fit from a YAML config. - ``ijazz_sas_mmg``: run the Photon->Electron scale workflow (MMG-specific). - ``ijazz_sas_smoothing``: smooth a JSON result vs pT and optionally build correctionlib output. - ``ijazz_plot``: plot IJazZ JSON results and comparisons. Run any command with ``-h`` to see available options. Outputs ------- By default, running ``ijazz_sas`` writes JSON results and plots under ``dir_results``. Typical outputs include: - ``SAS_syst-Nominal.json`` for the nominal fit. - ``SAS_syst-.json`` for each systematic variation. - ``SAS_syst-NominalWithSyst.json`` (and ``...Nominal2GWithSyst.json`` when 2G is enabled). - Plot images alongside the JSON files (e.g. ``.fig*.jpg``). - Correctionlib JSON: ``EGMScalesSmearing_.v.json``. ``ijazz_sas_smoothing`` can also produce a smoothed correctionlib JSON named ``EGMScalesSmearing__SMOOTH.v.json``. Input Ntuples ---------------- Input files must be **parquet** files with a column for the dilepton mass (``fitter.name_mll``) and columns for variables of each electron with ``1/2`` suffixes (e.g. ``ScEta1``, ``ScEta2``, ``r91``, ``r92``, ``pt1``, ``pt2``). MC weights can be used via ``fitter.name_weights``. For example: - ``mass``, ``weight_central``, ``ScEta1``, ``ScEta2``, ``r91``, ``r92``, ``pt1``, and ``pt2``. A reader to convert Higgs DNA output files to IJazZ input files is provided in this package. It is also used in the `law_ijazz `_ workflow. Python API (quick reference) ---------------------------- The following symbols are exported from ``ijazz``: - ``RegionalFitter`` - ``IJazZSAS``, ``compute_sas`` - ``parameters_from_json``, ``parameters_to_json``, ``ijazz_shape`` - ``plot_results_from_json`` See the inline docstrings for details. Plot the SaS Results -------------------- By default, plots are automatically generated. You can customize plot settings or compare two JSON files—either by overlaying their plots or by displaying the ratio between them. Plot Nominal Results ~~~~~~~~~~~~~~~~~~~~ To plot nominal results from a JSON file: .. code-block:: bash ijazz_plot FineEtaR9/SAS2024_syst-Nominal.json -d r9 AbsScEta --resp 0.98 1.03 --reso 0 0.06 -o FineEtaR9/SAS2024_syst-Nominal.jpg --latex higgsdna_cat_latex.json --ncol 2 --leg_fontsize small where ``higgsdna_cat_latex.json`` is a dictionary mapping variable names to LaTeX names for plotting: .. code-block:: json { "ScEta": "$\\eta_{SC}$", "AbsScEta": "$|\\eta_{SC}|$", "r9": "SC R9", "pt": "$p_T$ (GeV)", "seedGain": "SC Gain" } The option ``-d r9 AbsScEta`` defines the axis order for plotting. Here, ``r9`` is on the x-axis, and results as a function of ``AbsScEta`` are overlaid. You can also generate the plot in Python: .. code-block:: python import ijazz.plotting var_latex = { "ScEta": "$\\eta_{SC}$", "AbsScEta": "$|\\eta_{SC}|$", "r9": "Seed Cl. R9", "pt": "$p_T$ (GeV)", "seedGain": "Seed Cl. Gain" } figs, ax = ijazz.plotting.plot_results_from_json( 'Pho/FineEtaR9/SAS2024_syst-Nominal.json', resp_range=[0.98, 1.03], reso_range=[0.0, 0.06], cat_latex=var_latex, dim=['r9', 'AbsScEta'], leg_fontsize='small', leg_ncols=2 ) Compare SaS JSON Files ~~~~~~~~~~~~~~~~~~~~~~ You can compare JSON files by calculating the ratio or overlaying their plots. Ratio Comparison ^^^^^^^^^^^^^^^^ To plot the ratio of scale and smearing between electron and photon regression: .. code-block:: python import ijazz.plotting var_latex = { "ScEta": "$\\eta_{SC}$", "AbsScEta": "$|\\eta_{SC}|$", "r9": "Seed Cl. R9", "pt": "$p_T$ (GeV)", "seedGain": "Seed Cl. Gain" } jsonEle = 'Ele/FineEtaR9/SAS2024_syst-Nominal.json' jsonPho = 'Pho/FineEtaR9/SAS2024_syst-Nominal.json' figs, ax = ijazz.plotting.plot_results_from_json( {'syst': jsonEle, 'nominal': jsonPho}, jsons_mode='ratio', resp_range=[0.995, 1.008], reso_range=[0.50, 1.5], cat_latex=var_latex, leg_fontsize='small', leg_ncols=2 ) Overlay Comparison ^^^^^^^^^^^^^^^^^^ To overlay scale and smearing results from electron and photon regression: .. code-block:: python import ijazz.plotting var_latex = { "ScEta": "$\\eta_{SC}$", "AbsScEta": "$|\\eta_{SC}|$", "r9": "Seed Cl. R9", "pt": "$p_T$ (GeV)", "seedGain": "Seed Cl. Gain" } jsonEle = 'Ele/FineEtaR9/SAS2024_syst-Nominal.json' jsonPho = 'Pho/FineEtaR9/SAS2024_syst-Nominal.json' # Plot scale and smearing if SaS are functions of 1 or 2 variables figs, ax = ijazz.plotting.plot_results_from_json( {'Electron': jsonEle, 'Photon': jsonPho}, jsons_mode='compare', resp_range=[0.95, 1.08], reso_range=[0.0, 0.08], cat_latex=var_latex ) # Plot scale only if SaS are functions of 3 variables figs, ax = ijazz.plotting.plot_results_from_json( {'Electron': jsonEle, 'Photon': jsonPho}, jsons_mode='compare', resp_range=[0.95, 1.08], reso_range=[0.0, 0.08], cat_latex=var_latex, param_to_plot='resp' ) # Plot smearing only if SaS are functions of 3 variables figs, ax = ijazz.plotting.plot_results_from_json( {'Electron': jsonEle, 'Photon': jsonPho}, jsons_mode='compare', resp_range=[0.95, 1.08], reso_range=[0.0, 0.08], cat_latex=var_latex, param_to_plot='reso' ) .. note:: If the SaS are functions of three variables, the second dimension must have length 2 (e.g., low and high R9). It also works with more than two input JSONs: .. code-block:: python ijazz.plotting.plot_results_from_json({'2022': json22, '2023': json23, '2024': json24}, jsons_mode='compare')