atlas-schema 0.2.4__py3-none-any.whl → 0.3.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- atlas_schema/_version.py +9 -4
- atlas_schema/methods.py +14 -21
- atlas_schema/schema.py +31 -9
- atlas_schema/utils.py +6 -7
- {atlas_schema-0.2.4.dist-info → atlas_schema-0.3.0.dist-info}/METADATA +18 -19
- atlas_schema-0.3.0.dist-info/RECORD +13 -0
- atlas_schema-0.2.4.dist-info/RECORD +0 -13
- {atlas_schema-0.2.4.dist-info → atlas_schema-0.3.0.dist-info}/WHEEL +0 -0
- {atlas_schema-0.2.4.dist-info → atlas_schema-0.3.0.dist-info}/licenses/LICENSE +0 -0
atlas_schema/_version.py
CHANGED
@@ -1,8 +1,13 @@
|
|
1
|
-
# file generated by
|
1
|
+
# file generated by setuptools-scm
|
2
2
|
# don't change, don't track in version control
|
3
|
+
|
4
|
+
__all__ = ["__version__", "__version_tuple__", "version", "version_tuple"]
|
5
|
+
|
3
6
|
TYPE_CHECKING = False
|
4
7
|
if TYPE_CHECKING:
|
5
|
-
from typing import Tuple
|
8
|
+
from typing import Tuple
|
9
|
+
from typing import Union
|
10
|
+
|
6
11
|
VERSION_TUPLE = Tuple[Union[int, str], ...]
|
7
12
|
else:
|
8
13
|
VERSION_TUPLE = object
|
@@ -12,5 +17,5 @@ __version__: str
|
|
12
17
|
__version_tuple__: VERSION_TUPLE
|
13
18
|
version_tuple: VERSION_TUPLE
|
14
19
|
|
15
|
-
__version__ = version = '0.
|
16
|
-
__version_tuple__ = version_tuple = (0,
|
20
|
+
__version__ = version = '0.3.0'
|
21
|
+
__version_tuple__ = version_tuple = (0, 3, 0)
|
atlas_schema/methods.py
CHANGED
@@ -8,7 +8,6 @@ from operator import ior
|
|
8
8
|
import awkward
|
9
9
|
import particle
|
10
10
|
from coffea.nanoevents.methods import base, candidate, vector
|
11
|
-
from dask_awkward import dask_method
|
12
11
|
|
13
12
|
from atlas_schema.enums import PhotonID
|
14
13
|
from atlas_schema.typing_compat import Behavior
|
@@ -63,22 +62,9 @@ class Particle(vector.PtEtaPhiMLorentzVector):
|
|
63
62
|
- '{obj}_select'
|
64
63
|
"""
|
65
64
|
|
66
|
-
@property
|
67
|
-
def mass(self):
|
68
|
-
r"""Invariant mass (+, -, -, -)
|
69
|
-
|
70
|
-
:math:`\sqrt{t^2-x^2-y^2-z^2}`
|
71
|
-
"""
|
72
|
-
return self["mass"] / 1.0e3
|
73
|
-
|
74
|
-
@dask_method
|
75
65
|
def passes(self, name):
|
76
66
|
return self[f"select_{name}"] == 1
|
77
67
|
|
78
|
-
@passes.dask
|
79
|
-
def passes(self, dask_array, name):
|
80
|
-
return dask_array[f"select_{name}"] == 1
|
81
|
-
|
82
68
|
# NB: fields with the name 'pt' take precedence over this
|
83
69
|
# @dask_property
|
84
70
|
# def pt(self):
|
@@ -166,8 +152,8 @@ behavior.update(awkward._util.copy_behaviors("Particle", "Electron", behavior))
|
|
166
152
|
class Electron(Particle, base.NanoCollection, base.Systematic):
|
167
153
|
@property
|
168
154
|
def mass(self):
|
169
|
-
"""Electron mass in
|
170
|
-
return particle.literals.e_minus.mass
|
155
|
+
"""Electron mass in MeV"""
|
156
|
+
return awkward.ones_like(self.pt) * particle.literals.e_minus.mass
|
171
157
|
|
172
158
|
|
173
159
|
_set_repr_name("Electron")
|
@@ -184,8 +170,8 @@ behavior.update(awkward._util.copy_behaviors("Particle", "Muon", behavior))
|
|
184
170
|
class Muon(Particle, base.NanoCollection, base.Systematic):
|
185
171
|
@property
|
186
172
|
def mass(self):
|
187
|
-
"""Muon mass in
|
188
|
-
return particle.literals.mu_minus.mass
|
173
|
+
"""Muon mass in MeV"""
|
174
|
+
return awkward.ones_like(self.pt) * particle.literals.mu_minus.mass
|
189
175
|
|
190
176
|
|
191
177
|
_set_repr_name("Muon")
|
@@ -202,8 +188,8 @@ behavior.update(awkward._util.copy_behaviors("Particle", "Tau", behavior))
|
|
202
188
|
class Tau(Particle, base.NanoCollection, base.Systematic):
|
203
189
|
@property
|
204
190
|
def mass(self):
|
205
|
-
"""Tau mass in
|
206
|
-
return particle.literals.tau_minus.mass
|
191
|
+
"""Tau mass in MeV"""
|
192
|
+
return awkward.ones_like(self.pt) * particle.literals.tau_minus.mass
|
207
193
|
|
208
194
|
|
209
195
|
_set_repr_name("Tau")
|
@@ -218,7 +204,14 @@ behavior.update(awkward._util.copy_behaviors("Particle", "Jet", behavior))
|
|
218
204
|
|
219
205
|
|
220
206
|
@awkward.mixin_class(behavior)
|
221
|
-
class Jet(Particle, base.NanoCollection, base.Systematic):
|
207
|
+
class Jet(Particle, base.NanoCollection, base.Systematic):
|
208
|
+
@property
|
209
|
+
def mass(self):
|
210
|
+
r"""Invariant mass (+, -, -, -)
|
211
|
+
|
212
|
+
:math:`\sqrt{t^2-x^2-y^2-z^2}`
|
213
|
+
"""
|
214
|
+
return self["m"]
|
222
215
|
|
223
216
|
|
224
217
|
_set_repr_name("Jet")
|
atlas_schema/schema.py
CHANGED
@@ -7,6 +7,7 @@ from typing import Any, ClassVar
|
|
7
7
|
|
8
8
|
from coffea.nanoevents.schemas.base import BaseSchema, zip_forms
|
9
9
|
|
10
|
+
from atlas_schema.methods import behavior as roaster
|
10
11
|
from atlas_schema.typing_compat import Behavior, Self
|
11
12
|
|
12
13
|
|
@@ -190,7 +191,9 @@ class NtupleSchema(BaseSchema): # type: ignore[misc]
|
|
190
191
|
branch_forms = dict(zip(field_names, input_contents))
|
191
192
|
|
192
193
|
# parse into high-level records (collections, list collections, and singletons)
|
193
|
-
collections = {
|
194
|
+
collections = {
|
195
|
+
k.split("_")[0] for k in branch_forms if k not in self.singletons
|
196
|
+
}
|
194
197
|
collections -= self.event_ids
|
195
198
|
collections -= set(self.singletons)
|
196
199
|
|
@@ -227,17 +230,25 @@ class NtupleSchema(BaseSchema): # type: ignore[misc]
|
|
227
230
|
branch_forms[k.replace("_NOSYS", "") + "_NOSYS"] = branch_forms.pop(k)
|
228
231
|
|
229
232
|
# these are collections with systematic variations
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
233
|
+
try:
|
234
|
+
subcollections = {
|
235
|
+
k.split("__")[0].split("_", 1)[1].replace("_NOSYS", "")
|
236
|
+
for k in branch_forms
|
237
|
+
if "NOSYS" in k and k not in self.singletons
|
238
|
+
}
|
239
|
+
except IndexError as exc:
|
240
|
+
msg = "One of the branches does not follow the assumed pattern for this schema. [invalid-branch-name]"
|
241
|
+
raise RuntimeError(msg) from exc
|
235
242
|
|
236
243
|
# Check the presence of the event_ids
|
237
244
|
missing_event_ids = [
|
238
245
|
event_id for event_id in self.event_ids if event_id not in branch_forms
|
239
246
|
]
|
240
247
|
|
248
|
+
missing_singletons = [
|
249
|
+
singleton for singleton in self.singletons if singleton not in branch_forms
|
250
|
+
]
|
251
|
+
|
241
252
|
if len(missing_event_ids) > 0:
|
242
253
|
if self.error_missing_event_ids:
|
243
254
|
msg = f"There are missing event ID fields: {missing_event_ids} \n\n\
|
@@ -253,12 +264,25 @@ class NtupleSchema(BaseSchema): # type: ignore[misc]
|
|
253
264
|
stacklevel=2,
|
254
265
|
)
|
255
266
|
|
267
|
+
if len(missing_singletons) > 0:
|
268
|
+
# These singletons are simply branches we do not parse or handle
|
269
|
+
# explicitly in atlas-schema (e.g. they are copied directly to the
|
270
|
+
# output structure we provide you), however there can be false
|
271
|
+
# positives when you submit multiple files with different branch
|
272
|
+
# structures and this warning could be safely ignored.
|
273
|
+
warnings.warn(
|
274
|
+
f"Missing singletons : {missing_singletons}. [singleton-missing]",
|
275
|
+
RuntimeWarning,
|
276
|
+
stacklevel=2,
|
277
|
+
)
|
278
|
+
|
256
279
|
output = {}
|
257
280
|
|
258
281
|
# first, register singletons (event-level, others)
|
259
282
|
for name in {*self.event_ids, *self.singletons}:
|
260
|
-
if name in missing_event_ids:
|
283
|
+
if name in [*missing_event_ids, *missing_singletons]:
|
261
284
|
continue
|
285
|
+
|
262
286
|
output[name] = branch_forms[name]
|
263
287
|
|
264
288
|
# next, go through and start grouping up collections
|
@@ -354,8 +378,6 @@ class NtupleSchema(BaseSchema): # type: ignore[misc]
|
|
354
378
|
Returns:
|
355
379
|
dict[str | tuple['*', str], type[awkward.Record]]: an :data:`awkward.behavior` dictionary
|
356
380
|
"""
|
357
|
-
from atlas_schema.methods import behavior as roaster
|
358
|
-
|
359
381
|
return roaster
|
360
382
|
|
361
383
|
@classmethod
|
atlas_schema/utils.py
CHANGED
@@ -1,16 +1,15 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
|
3
3
|
from enum import Enum
|
4
|
-
from typing import TypeVar,
|
4
|
+
from typing import TypeVar, cast
|
5
5
|
|
6
6
|
import awkward as ak
|
7
|
-
import dask_awkward as dak
|
8
7
|
|
9
|
-
Array = TypeVar("Array", bound=
|
8
|
+
Array = TypeVar("Array", bound=ak.Array)
|
10
9
|
_E = TypeVar("_E", bound=Enum)
|
11
10
|
|
12
11
|
|
13
|
-
def isin(element: Array, test_elements:
|
12
|
+
def isin(element: Array, test_elements: ak.Array, axis: int = -1) -> Array:
|
14
13
|
"""
|
15
14
|
Find test_elements in element. Similar in API as :func:`numpy.isin`.
|
16
15
|
|
@@ -21,12 +20,12 @@ def isin(element: Array, test_elements: dak.Array | ak.Array, axis: int = -1) ->
|
|
21
20
|
comparison.
|
22
21
|
|
23
22
|
Args:
|
24
|
-
element (
|
25
|
-
test_elements (
|
23
|
+
element (ak.Array): input array of values.
|
24
|
+
test_elements (ak.Array): one-dimensional set of values against which to test each value of *element*.
|
26
25
|
axis (int): the axis along which the comparison is performed
|
27
26
|
|
28
27
|
Returns:
|
29
|
-
|
28
|
+
ak.Array: result of comparison for test_elements in *element*
|
30
29
|
|
31
30
|
Example:
|
32
31
|
>>> import awkward as ak
|
@@ -1,11 +1,11 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: atlas-schema
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.3.0
|
4
4
|
Summary: Helper python package for ATLAS Common NTuple Analysis work.
|
5
5
|
Project-URL: Homepage, https://github.com/scipp-atlas/atlas-schema
|
6
6
|
Project-URL: Bug Tracker, https://github.com/scipp-atlas/atlas-schema/issues
|
7
7
|
Project-URL: Discussions, https://github.com/scipp-atlas/atlas-schema/discussions
|
8
|
-
Project-URL: Documentation, https://atlas-schema.readthedocs.io/en/v0.
|
8
|
+
Project-URL: Documentation, https://atlas-schema.readthedocs.io/en/v0.3.0/
|
9
9
|
Project-URL: Releases, https://github.com/scipp-atlas/atlas-schema/releases
|
10
10
|
Project-URL: Release Notes, https://atlas-schema.readthedocs.io/en/latest/history.html
|
11
11
|
Author-email: Giordon Stark <kratsg@gmail.com>
|
@@ -227,7 +227,7 @@ Classifier: Programming Language :: Python :: 3.12
|
|
227
227
|
Classifier: Topic :: Scientific/Engineering
|
228
228
|
Classifier: Typing :: Typed
|
229
229
|
Requires-Python: >=3.9
|
230
|
-
Requires-Dist: coffea[dask]>=
|
230
|
+
Requires-Dist: coffea[dask]>=2025.7.0
|
231
231
|
Requires-Dist: particle>=0.25.0
|
232
232
|
Provides-Extra: dev
|
233
233
|
Requires-Dist: pytest-cov>=3; extra == 'dev'
|
@@ -251,7 +251,7 @@ Requires-Dist: tbump>=6.7.0; extra == 'test'
|
|
251
251
|
Requires-Dist: twine; extra == 'test'
|
252
252
|
Description-Content-Type: text/markdown
|
253
253
|
|
254
|
-
# atlas-schema v0.
|
254
|
+
# atlas-schema v0.3.0
|
255
255
|
|
256
256
|
[![Actions Status][actions-badge]][actions-link]
|
257
257
|
[![Documentation Status][rtd-badge]][rtd-link]
|
@@ -335,11 +335,9 @@ like below:
|
|
335
335
|
|
336
336
|
```python
|
337
337
|
import awkward as ak
|
338
|
-
import
|
339
|
-
import hist.dask as had
|
338
|
+
from hist import Hist
|
340
339
|
import matplotlib.pyplot as plt
|
341
340
|
from coffea import processor
|
342
|
-
from coffea.nanoevents import NanoEventsFactory
|
343
341
|
from distributed import Client
|
344
342
|
|
345
343
|
from atlas_schema.schema import NtupleSchema
|
@@ -352,7 +350,7 @@ class MyFirstProcessor(processor.ProcessorABC):
|
|
352
350
|
def process(self, events):
|
353
351
|
dataset = events.metadata["dataset"]
|
354
352
|
h_ph_pt = (
|
355
|
-
|
353
|
+
Hist.new.StrCat(["all", "pass", "fail"], name="isEM")
|
356
354
|
.Regular(200, 0.0, 2000.0, name="pt", label="$pt_{\gamma}$ [GeV]")
|
357
355
|
.Int64()
|
358
356
|
)
|
@@ -376,17 +374,18 @@ class MyFirstProcessor(processor.ProcessorABC):
|
|
376
374
|
if __name__ == "__main__":
|
377
375
|
client = Client()
|
378
376
|
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
out =
|
388
|
-
|
389
|
-
print(
|
377
|
+
fileset = {"700352.Zqqgamma.mc20d.v1": {"files": {"ntuple.root": "analysis"}}}
|
378
|
+
|
379
|
+
run = processor.Runner(
|
380
|
+
executor=processor.IterativeExecutor(compression=None),
|
381
|
+
schema=NtupleSchema,
|
382
|
+
savemetrics=True,
|
383
|
+
)
|
384
|
+
|
385
|
+
out, metrics = run(fileset, processor_instance=MyFirstProcessor())
|
386
|
+
|
387
|
+
print(out)
|
388
|
+
print(metrics)
|
390
389
|
|
391
390
|
fig, ax = plt.subplots()
|
392
391
|
computed["700352.Zqqgamma.mc20d.v1"]["ph_pt"].plot1d(ax=ax)
|
@@ -0,0 +1,13 @@
|
|
1
|
+
atlas_schema/__init__.py,sha256=ebY-rTiwSGnfvt1yWATze2GE7K3fVgJj6fT64Sl4sH8,469
|
2
|
+
atlas_schema/_version.py,sha256=AGmG_Lx0-9ztFw_7d9mYbaYuC-2abxE1oXOUNAY29YY,511
|
3
|
+
atlas_schema/_version.pyi,sha256=j5kbzfm6lOn8BzASXWjGIA1yT0OlHTWqlbyZ8Si_o0E,118
|
4
|
+
atlas_schema/enums.py,sha256=hwgOvFBmITNxL0MQkrNpbiPv9VMezFoE-eyGgjzem8E,3688
|
5
|
+
atlas_schema/methods.py,sha256=DPeEFofeD5_bCk7V3KudJaE_sAUMpBIh-gPnM4kWDe8,7124
|
6
|
+
atlas_schema/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
7
|
+
atlas_schema/schema.py,sha256=44i7ri-7OP4SK6_D_3JAGvoiIY-IcPBp1p6MlKfWK5I,21675
|
8
|
+
atlas_schema/typing_compat.py,sha256=3G8h4WfLoDmrtWZvtYKLCwEpCQ_O4Fwygb2WlDRSE4E,488
|
9
|
+
atlas_schema/utils.py,sha256=E3jCka-pf_0h_r3OO0hMLlbF6dQKoxr2T1Gd18-aJ4U,2034
|
10
|
+
atlas_schema-0.3.0.dist-info/METADATA,sha256=NCkA4ydLhlTHYJOTipTgZlR7_yhDsDe7zpa0jbnqw00,20069
|
11
|
+
atlas_schema-0.3.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
12
|
+
atlas_schema-0.3.0.dist-info/licenses/LICENSE,sha256=snem82NV8fgAi4DKaaUIfReaM5RqIWbH5OOXOvy40_w,11344
|
13
|
+
atlas_schema-0.3.0.dist-info/RECORD,,
|
@@ -1,13 +0,0 @@
|
|
1
|
-
atlas_schema/__init__.py,sha256=ebY-rTiwSGnfvt1yWATze2GE7K3fVgJj6fT64Sl4sH8,469
|
2
|
-
atlas_schema/_version.py,sha256=4gL0W4-u58XR5lRLpeoIPrGhcewTk0-527de6uTNmkg,411
|
3
|
-
atlas_schema/_version.pyi,sha256=j5kbzfm6lOn8BzASXWjGIA1yT0OlHTWqlbyZ8Si_o0E,118
|
4
|
-
atlas_schema/enums.py,sha256=hwgOvFBmITNxL0MQkrNpbiPv9VMezFoE-eyGgjzem8E,3688
|
5
|
-
atlas_schema/methods.py,sha256=hFdtKXnyCcx4M05WhAM24fKwzEhh_ubA7jNa6_xv67k,7238
|
6
|
-
atlas_schema/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
7
|
-
atlas_schema/schema.py,sha256=4OAvuPrOds-taVES32y4K8dvNDf8PKdu83DZqAlTdp8,20621
|
8
|
-
atlas_schema/typing_compat.py,sha256=3G8h4WfLoDmrtWZvtYKLCwEpCQ_O4Fwygb2WlDRSE4E,488
|
9
|
-
atlas_schema/utils.py,sha256=IqMbWqq0ib_kZdJCaM5ghURZatmb8pKidlewx3dpy0A,2164
|
10
|
-
atlas_schema-0.2.4.dist-info/METADATA,sha256=KZDH5fsZon5wFXuU-iSUeqgjoplOwAoqTM1I9LgaTiM,20107
|
11
|
-
atlas_schema-0.2.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
12
|
-
atlas_schema-0.2.4.dist-info/licenses/LICENSE,sha256=snem82NV8fgAi4DKaaUIfReaM5RqIWbH5OOXOvy40_w,11344
|
13
|
-
atlas_schema-0.2.4.dist-info/RECORD,,
|
File without changes
|
File without changes
|