From cc489922ca062bcd775f7a336b979c4e73088b96 Mon Sep 17 00:00:00 2001 From: Oksana Shadura Date: Tue, 13 Feb 2024 14:44:51 +0100 Subject: [PATCH] Add test ADL1 for coffeacalver --- tests/test_adl1.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 tests/test_adl1.py diff --git a/tests/test_adl1.py b/tests/test_adl1.py new file mode 100644 index 0000000..f305b66 --- /dev/null +++ b/tests/test_adl1.py @@ -0,0 +1,38 @@ +import time + +import awkward as ak +import hist +import matplotlib.pyplot as plt +import numpy as np +from coffea.nanoevents import NanoEventsFactory, NanoAODSchema +from coffea import processor + +import dask +import dask_awkward as dak +import hist.dask as hda + +from distributed import Client +client=Client() + +# The opendata files are non-standard NanoAOD, so some optional data columns are missing +NanoAODSchema.warn_missing_crossrefs = False + +# The warning emitted below indicates steps_per_file is for initial data exploration +# and test. When running at scale there are better ways to specify processing chunks +# of files. +events = NanoEventsFactory.from_root( + "root://eospublic.cern.ch//eos/root-eos/Run2012B_SingleMu.root:Events", + steps_per_file=500, + metadata={"dataset": "SingleMu"} + ).events() + + +@pytest.mark.coffeacalver +def test_adl1(): + q1_hist = ( + hda.Hist.new.Reg(100, 0, 200, name="met", label="$E_{T}^{miss}$ [GeV]") + .Double() + .fill(events.MET.pt) + ) + q1_hist.compute().plot1d(flow="none") + dak.necessary_columns(q1_hist)