atlas-ftag-tools 0.0.7__tar.gz → 0.0.9__tar.gz

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.
Files changed (27) hide show
  1. atlas-ftag-tools-0.0.9/PKG-INFO +76 -0
  2. atlas-ftag-tools-0.0.9/README.md +65 -0
  3. atlas-ftag-tools-0.0.9/atlas_ftag_tools.egg-info/PKG-INFO +76 -0
  4. {atlas-ftag-tools-0.0.7 → atlas-ftag-tools-0.0.9}/atlas_ftag_tools.egg-info/SOURCES.txt +1 -0
  5. atlas-ftag-tools-0.0.9/atlas_ftag_tools.egg-info/entry_points.txt +3 -0
  6. atlas-ftag-tools-0.0.9/ftag/__init__.py +25 -0
  7. {atlas-ftag-tools-0.0.7 → atlas-ftag-tools-0.0.9}/ftag/flavour.py +10 -0
  8. {atlas-ftag-tools-0.0.7 → atlas-ftag-tools-0.0.9}/ftag/hdf5/h5reader.py +23 -2
  9. {atlas-ftag-tools-0.0.7 → atlas-ftag-tools-0.0.9}/ftag/vds.py +23 -0
  10. {atlas-ftag-tools-0.0.7 → atlas-ftag-tools-0.0.9}/pyproject.toml +4 -0
  11. atlas-ftag-tools-0.0.7/PKG-INFO +0 -39
  12. atlas-ftag-tools-0.0.7/README.md +0 -28
  13. atlas-ftag-tools-0.0.7/atlas_ftag_tools.egg-info/PKG-INFO +0 -39
  14. atlas-ftag-tools-0.0.7/ftag/__init__.py +0 -23
  15. {atlas-ftag-tools-0.0.7 → atlas-ftag-tools-0.0.9}/MANIFEST.in +0 -0
  16. {atlas-ftag-tools-0.0.7 → atlas-ftag-tools-0.0.9}/atlas_ftag_tools.egg-info/dependency_links.txt +0 -0
  17. {atlas-ftag-tools-0.0.7 → atlas-ftag-tools-0.0.9}/atlas_ftag_tools.egg-info/requires.txt +0 -0
  18. {atlas-ftag-tools-0.0.7 → atlas-ftag-tools-0.0.9}/atlas_ftag_tools.egg-info/top_level.txt +0 -0
  19. {atlas-ftag-tools-0.0.7 → atlas-ftag-tools-0.0.9}/ftag/cuts.py +0 -0
  20. {atlas-ftag-tools-0.0.7 → atlas-ftag-tools-0.0.9}/ftag/flavours.yaml +0 -0
  21. {atlas-ftag-tools-0.0.7 → atlas-ftag-tools-0.0.9}/ftag/hdf5/__init__.py +0 -0
  22. {atlas-ftag-tools-0.0.7 → atlas-ftag-tools-0.0.9}/ftag/hdf5/h5utils.py +0 -0
  23. {atlas-ftag-tools-0.0.7 → atlas-ftag-tools-0.0.9}/ftag/hdf5/h5writer.py +0 -0
  24. {atlas-ftag-tools-0.0.7 → atlas-ftag-tools-0.0.9}/ftag/mock.py +0 -0
  25. {atlas-ftag-tools-0.0.7 → atlas-ftag-tools-0.0.9}/ftag/region.py +0 -0
  26. {atlas-ftag-tools-0.0.7 → atlas-ftag-tools-0.0.9}/ftag/sample.py +0 -0
  27. {atlas-ftag-tools-0.0.7 → atlas-ftag-tools-0.0.9}/setup.cfg +0 -0
@@ -0,0 +1,76 @@
1
+ Metadata-Version: 2.1
2
+ Name: atlas-ftag-tools
3
+ Version: 0.0.9
4
+ Summary: ATLAS Flavour Tagging Tools
5
+ Author: Sam Van Stroud, Philipp Gadow
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/umami-hep/atlas-ftag-tools/
8
+ Requires-Python: >=3.8
9
+ Description-Content-Type: text/markdown
10
+ Provides-Extra: dev
11
+
12
+ # ATLAS FTAG Python Tools
13
+
14
+ This is a collection of Python tools for working with files produced with the FTAG [ntuple dumper](https://gitlab.cern.ch/atlas-flavor-tagging-tools/training-dataset-dumper/).
15
+ The code is intended to be used a [library](https://iscinumpy.dev/post/app-vs-library/) for other projects.
16
+ Please see the [example notebook](ftag/example.ipynb) for usage.
17
+
18
+ ## Installation
19
+
20
+ To install the package you can install from pip using the [release on pypi](https://pypi.org/project/atlas-ftag-tools/) via
21
+
22
+ ```bash
23
+ pip install atlas-ftag-tools
24
+ ```
25
+
26
+ or you can clone the repository and install in editable mode with
27
+ ```bash
28
+ python -m pip install -e .
29
+ ```
30
+
31
+ To install optional development dependencies (for formatting and linting) you can instead install with either from pip
32
+ ```bash
33
+ pip install atlas-ftag-tools[dev]
34
+ ```
35
+
36
+ or from source
37
+ ```bash
38
+ python -m pip install -e ".[dev]"
39
+ ```
40
+
41
+
42
+ ## Create virtual file
43
+
44
+ This package contains a script to easily merge a set of H5 files.
45
+ A virtual file is a fast and lightweight way to wrap a set of files.
46
+ See the [h5py documentation](https://docs.h5py.org/en/stable/vds.html) for more information on virtual datasets.
47
+
48
+ The script is `vds.py` and can be run after installing this package with
49
+
50
+ ```
51
+ vds <pattern> <output path>
52
+ ```
53
+
54
+ The `<pattern>` argument should be a quotes enclosed [glob pattern](https://en.wikipedia.org/wiki/Glob_(programming)), for example `"dsid/path/*.h5"`
55
+
56
+
57
+ ## Calculate WPs
58
+
59
+ This package contains a script to calculate tagger working points (WPs).
60
+ The script is `working_points.py` and can be run after installing this package with
61
+
62
+ ```
63
+ wps \
64
+ --ttbar "path/to/ttbar/*.h5" \
65
+ --tagger GN120220509 \
66
+ --fx 0.1
67
+ ```
68
+
69
+ Both the `--tagger` and `--fx` options accept a list if you want to get the WPs for multiple taggers.
70
+
71
+ If you want to use the `ttbar` WPs get the efficiencies and rejections for the `zprime` sample, you can add `--zprime "path/to/zprime/*.h5"` to the command.
72
+ Note that a default selection of $p_T > 250 ~GeV$ to jets in the `zprime` sample.
73
+
74
+ By default the working points are printed to the terminal, but you can save the results to a YAML file with the `--outfile` option.
75
+
76
+ Use `--help` for more options and information.
@@ -0,0 +1,65 @@
1
+ # ATLAS FTAG Python Tools
2
+
3
+ This is a collection of Python tools for working with files produced with the FTAG [ntuple dumper](https://gitlab.cern.ch/atlas-flavor-tagging-tools/training-dataset-dumper/).
4
+ The code is intended to be used a [library](https://iscinumpy.dev/post/app-vs-library/) for other projects.
5
+ Please see the [example notebook](ftag/example.ipynb) for usage.
6
+
7
+ ## Installation
8
+
9
+ To install the package you can install from pip using the [release on pypi](https://pypi.org/project/atlas-ftag-tools/) via
10
+
11
+ ```bash
12
+ pip install atlas-ftag-tools
13
+ ```
14
+
15
+ or you can clone the repository and install in editable mode with
16
+ ```bash
17
+ python -m pip install -e .
18
+ ```
19
+
20
+ To install optional development dependencies (for formatting and linting) you can instead install with either from pip
21
+ ```bash
22
+ pip install atlas-ftag-tools[dev]
23
+ ```
24
+
25
+ or from source
26
+ ```bash
27
+ python -m pip install -e ".[dev]"
28
+ ```
29
+
30
+
31
+ ## Create virtual file
32
+
33
+ This package contains a script to easily merge a set of H5 files.
34
+ A virtual file is a fast and lightweight way to wrap a set of files.
35
+ See the [h5py documentation](https://docs.h5py.org/en/stable/vds.html) for more information on virtual datasets.
36
+
37
+ The script is `vds.py` and can be run after installing this package with
38
+
39
+ ```
40
+ vds <pattern> <output path>
41
+ ```
42
+
43
+ The `<pattern>` argument should be a quotes enclosed [glob pattern](https://en.wikipedia.org/wiki/Glob_(programming)), for example `"dsid/path/*.h5"`
44
+
45
+
46
+ ## Calculate WPs
47
+
48
+ This package contains a script to calculate tagger working points (WPs).
49
+ The script is `working_points.py` and can be run after installing this package with
50
+
51
+ ```
52
+ wps \
53
+ --ttbar "path/to/ttbar/*.h5" \
54
+ --tagger GN120220509 \
55
+ --fx 0.1
56
+ ```
57
+
58
+ Both the `--tagger` and `--fx` options accept a list if you want to get the WPs for multiple taggers.
59
+
60
+ If you want to use the `ttbar` WPs get the efficiencies and rejections for the `zprime` sample, you can add `--zprime "path/to/zprime/*.h5"` to the command.
61
+ Note that a default selection of $p_T > 250 ~GeV$ to jets in the `zprime` sample.
62
+
63
+ By default the working points are printed to the terminal, but you can save the results to a YAML file with the `--outfile` option.
64
+
65
+ Use `--help` for more options and information.
@@ -0,0 +1,76 @@
1
+ Metadata-Version: 2.1
2
+ Name: atlas-ftag-tools
3
+ Version: 0.0.9
4
+ Summary: ATLAS Flavour Tagging Tools
5
+ Author: Sam Van Stroud, Philipp Gadow
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/umami-hep/atlas-ftag-tools/
8
+ Requires-Python: >=3.8
9
+ Description-Content-Type: text/markdown
10
+ Provides-Extra: dev
11
+
12
+ # ATLAS FTAG Python Tools
13
+
14
+ This is a collection of Python tools for working with files produced with the FTAG [ntuple dumper](https://gitlab.cern.ch/atlas-flavor-tagging-tools/training-dataset-dumper/).
15
+ The code is intended to be used a [library](https://iscinumpy.dev/post/app-vs-library/) for other projects.
16
+ Please see the [example notebook](ftag/example.ipynb) for usage.
17
+
18
+ ## Installation
19
+
20
+ To install the package you can install from pip using the [release on pypi](https://pypi.org/project/atlas-ftag-tools/) via
21
+
22
+ ```bash
23
+ pip install atlas-ftag-tools
24
+ ```
25
+
26
+ or you can clone the repository and install in editable mode with
27
+ ```bash
28
+ python -m pip install -e .
29
+ ```
30
+
31
+ To install optional development dependencies (for formatting and linting) you can instead install with either from pip
32
+ ```bash
33
+ pip install atlas-ftag-tools[dev]
34
+ ```
35
+
36
+ or from source
37
+ ```bash
38
+ python -m pip install -e ".[dev]"
39
+ ```
40
+
41
+
42
+ ## Create virtual file
43
+
44
+ This package contains a script to easily merge a set of H5 files.
45
+ A virtual file is a fast and lightweight way to wrap a set of files.
46
+ See the [h5py documentation](https://docs.h5py.org/en/stable/vds.html) for more information on virtual datasets.
47
+
48
+ The script is `vds.py` and can be run after installing this package with
49
+
50
+ ```
51
+ vds <pattern> <output path>
52
+ ```
53
+
54
+ The `<pattern>` argument should be a quotes enclosed [glob pattern](https://en.wikipedia.org/wiki/Glob_(programming)), for example `"dsid/path/*.h5"`
55
+
56
+
57
+ ## Calculate WPs
58
+
59
+ This package contains a script to calculate tagger working points (WPs).
60
+ The script is `working_points.py` and can be run after installing this package with
61
+
62
+ ```
63
+ wps \
64
+ --ttbar "path/to/ttbar/*.h5" \
65
+ --tagger GN120220509 \
66
+ --fx 0.1
67
+ ```
68
+
69
+ Both the `--tagger` and `--fx` options accept a list if you want to get the WPs for multiple taggers.
70
+
71
+ If you want to use the `ttbar` WPs get the efficiencies and rejections for the `zprime` sample, you can add `--zprime "path/to/zprime/*.h5"` to the command.
72
+ Note that a default selection of $p_T > 250 ~GeV$ to jets in the `zprime` sample.
73
+
74
+ By default the working points are printed to the terminal, but you can save the results to a YAML file with the `--outfile` option.
75
+
76
+ Use `--help` for more options and information.
@@ -4,6 +4,7 @@ pyproject.toml
4
4
  atlas_ftag_tools.egg-info/PKG-INFO
5
5
  atlas_ftag_tools.egg-info/SOURCES.txt
6
6
  atlas_ftag_tools.egg-info/dependency_links.txt
7
+ atlas_ftag_tools.egg-info/entry_points.txt
7
8
  atlas_ftag_tools.egg-info/requires.txt
8
9
  atlas_ftag_tools.egg-info/top_level.txt
9
10
  ftag/__init__.py
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ vds = ftag.vds:main
3
+ wps = ftag.wps.working_points:main
@@ -0,0 +1,25 @@
1
+ """atlas-ftag-tools - Common tools for ATLAS flavour tagging software."""
2
+
3
+
4
+ __version__ = "v0.0.9"
5
+
6
+
7
+ import ftag.hdf5 as hdf5
8
+ from ftag.cuts import Cuts
9
+ from ftag.flavour import Flavour, Flavours
10
+ from ftag.mock import get_mock_file
11
+ from ftag.sample import Sample
12
+ from ftag.wps.discriminant import get_discriminant
13
+ from ftag.wps.working_points import get_working_points
14
+
15
+ __all__ = [
16
+ "Cuts",
17
+ "Flavour",
18
+ "Flavours",
19
+ "Sample",
20
+ "hdf5",
21
+ "get_mock_file",
22
+ "get_discriminant",
23
+ "get_working_points",
24
+ "__version__",
25
+ ]
@@ -2,6 +2,9 @@ from __future__ import annotations
2
2
 
3
3
  from collections.abc import Generator
4
4
  from dataclasses import dataclass
5
+ from pathlib import Path
6
+
7
+ import yaml
5
8
 
6
9
  from ftag.cuts import Cuts
7
10
 
@@ -74,3 +77,10 @@ class FlavourContainer:
74
77
  if flavour.cuts == cuts:
75
78
  return flavour
76
79
  raise KeyError(f"Flavour with {cuts} not found")
80
+
81
+
82
+ with open(Path(__file__).parent / "flavours.yaml") as f:
83
+ flavours_yaml = yaml.safe_load(f)
84
+ flavours_dict = {f["name"]: Flavour(cuts=Cuts.from_list(f.pop("cuts")), **f) for f in flavours_yaml}
85
+ assert len(flavours_dict) == len(flavours_yaml), "Duplicate flavour names detected"
86
+ Flavours = FlavourContainer(flavours_dict)
@@ -111,12 +111,33 @@ class H5SingleReader:
111
111
 
112
112
  @dataclass
113
113
  class H5Reader:
114
+ """Reads data from multiple HDF5 files.
115
+
116
+ Parameters
117
+ ----------
118
+ fname : Path | str | list[Path | str]
119
+ Path to the HDF5 file or list of paths
120
+ batch_size : int, optional
121
+ Number of jets to read at a time, by default 100_000
122
+ jets_name : str, optional
123
+ Name of the jets dataset, by default "jets"
124
+ precision : str | None, optional
125
+ Cast floats to given precision, by default None
126
+ shuffle : bool, optional
127
+ Read batches in a shuffled order, by default True
128
+ weights : list[float] | None, optional
129
+ Weights for different input datasets, by default None
130
+ do_remove_inf : bool, optional
131
+ Remove jets with inf values, by default False
132
+ """
133
+
114
134
  fname: Path | str | list[Path | str]
115
135
  batch_size: int = 100_000
116
136
  jets_name: str = "jets"
117
137
  precision: str | None = None
118
138
  shuffle: bool = True
119
139
  weights: list[float] | None = None
140
+ do_remove_inf: bool = False
120
141
 
121
142
  def __post_init__(self) -> None:
122
143
  if isinstance(self.fname, (str, Path)):
@@ -129,8 +150,8 @@ class H5Reader:
129
150
 
130
151
  # create readers
131
152
  self.readers = [
132
- H5SingleReader(fname, batch_size, self.jets_name, self.precision, self.shuffle)
133
- for fname, batch_size in zip(self.fname, self.batch_sizes)
153
+ H5SingleReader(f, b, self.jets_name, self.precision, self.shuffle, self.do_remove_inf)
154
+ for f, b in zip(self.fname, self.batch_sizes)
134
155
  ]
135
156
 
136
157
  @property
@@ -60,3 +60,26 @@ def create_virtual_file(
60
60
  f.create_virtual_dataset(group, layout)
61
61
 
62
62
  return out_fname
63
+
64
+
65
+ def main():
66
+ import argparse
67
+
68
+ parser = argparse.ArgumentParser(
69
+ description="Create a lightweight wrapper around a set of h5 files"
70
+ )
71
+ parser.add_argument("pattern", type=Path, help="quotes-enclosed glob pattern of files to merge")
72
+ parser.add_argument("output", type=Path, help="path to output virtual file")
73
+ args = parser.parse_args()
74
+
75
+ print(f"Globbing {args.pattern}...")
76
+ create_virtual_file(args.pattern, args.output, overwrite=True)
77
+ with h5py.File(args.output) as f:
78
+ key = list(f.keys())[0]
79
+ num = len(f[key])
80
+ print(f"Virtual dataset '{key}' has {num:,} entries")
81
+ print(f"Saved virtual file to {args.output.resolve()}")
82
+
83
+
84
+ if __name__ == "__main__":
85
+ main()
@@ -26,6 +26,10 @@ dev = [
26
26
  "ipykernel==6.21.3",
27
27
  ]
28
28
 
29
+ [project.scripts]
30
+ vds = "ftag.vds:main"
31
+ wps = "ftag.wps.working_points:main"
32
+
29
33
  [tool.setuptools]
30
34
  packages = ["ftag", "ftag.hdf5"]
31
35
  include-package-data = true
@@ -1,39 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: atlas-ftag-tools
3
- Version: 0.0.7
4
- Summary: ATLAS Flavour Tagging Tools
5
- Author: Sam Van Stroud, Philipp Gadow
6
- License: MIT
7
- Project-URL: Homepage, https://github.com/umami-hep/atlas-ftag-tools/
8
- Requires-Python: >=3.8
9
- Description-Content-Type: text/markdown
10
- Provides-Extra: dev
11
-
12
- # ATLAS FTAG Python Tools
13
-
14
- This is a collection of Python tools for working with files produced with the FTAG [ntuple dumper](https://gitlab.cern.ch/atlas-flavor-tagging-tools/training-dataset-dumper/).
15
- The code is intended to be used a [library](https://iscinumpy.dev/post/app-vs-library/) for other projects.
16
- Please see the [example notebook](ftag/example.ipynb) for usage.
17
-
18
- ## Installation
19
-
20
- To install the package you can install from pip using the [release on pypi](https://pypi.org/project/atlas-ftag-tools/) via
21
-
22
- ```bash
23
- pip install atlas-ftag-tools
24
- ```
25
-
26
- or you can clone the repository and install in editable mode with
27
- ```bash
28
- python -m pip install -e .
29
- ```
30
-
31
- To install optional development dependencies (for formatting and linting) you can instead install with either from pip
32
- ```bash
33
- pip install atlas-ftag-tools[dev]
34
- ```
35
-
36
- or from source
37
- ```bash
38
- python -m pip install -e ".[dev]"
39
- ```
@@ -1,28 +0,0 @@
1
- # ATLAS FTAG Python Tools
2
-
3
- This is a collection of Python tools for working with files produced with the FTAG [ntuple dumper](https://gitlab.cern.ch/atlas-flavor-tagging-tools/training-dataset-dumper/).
4
- The code is intended to be used a [library](https://iscinumpy.dev/post/app-vs-library/) for other projects.
5
- Please see the [example notebook](ftag/example.ipynb) for usage.
6
-
7
- ## Installation
8
-
9
- To install the package you can install from pip using the [release on pypi](https://pypi.org/project/atlas-ftag-tools/) via
10
-
11
- ```bash
12
- pip install atlas-ftag-tools
13
- ```
14
-
15
- or you can clone the repository and install in editable mode with
16
- ```bash
17
- python -m pip install -e .
18
- ```
19
-
20
- To install optional development dependencies (for formatting and linting) you can instead install with either from pip
21
- ```bash
22
- pip install atlas-ftag-tools[dev]
23
- ```
24
-
25
- or from source
26
- ```bash
27
- python -m pip install -e ".[dev]"
28
- ```
@@ -1,39 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: atlas-ftag-tools
3
- Version: 0.0.7
4
- Summary: ATLAS Flavour Tagging Tools
5
- Author: Sam Van Stroud, Philipp Gadow
6
- License: MIT
7
- Project-URL: Homepage, https://github.com/umami-hep/atlas-ftag-tools/
8
- Requires-Python: >=3.8
9
- Description-Content-Type: text/markdown
10
- Provides-Extra: dev
11
-
12
- # ATLAS FTAG Python Tools
13
-
14
- This is a collection of Python tools for working with files produced with the FTAG [ntuple dumper](https://gitlab.cern.ch/atlas-flavor-tagging-tools/training-dataset-dumper/).
15
- The code is intended to be used a [library](https://iscinumpy.dev/post/app-vs-library/) for other projects.
16
- Please see the [example notebook](ftag/example.ipynb) for usage.
17
-
18
- ## Installation
19
-
20
- To install the package you can install from pip using the [release on pypi](https://pypi.org/project/atlas-ftag-tools/) via
21
-
22
- ```bash
23
- pip install atlas-ftag-tools
24
- ```
25
-
26
- or you can clone the repository and install in editable mode with
27
- ```bash
28
- python -m pip install -e .
29
- ```
30
-
31
- To install optional development dependencies (for formatting and linting) you can instead install with either from pip
32
- ```bash
33
- pip install atlas-ftag-tools[dev]
34
- ```
35
-
36
- or from source
37
- ```bash
38
- python -m pip install -e ".[dev]"
39
- ```
@@ -1,23 +0,0 @@
1
- """atlas-ftag-tools - Common tools for ATLAS flavour tagging software."""
2
-
3
-
4
- __version__ = "v0.0.7"
5
-
6
- from pathlib import Path
7
-
8
- import yaml
9
-
10
- import ftag.hdf5 as hdf5
11
- from ftag.cuts import Cuts
12
- from ftag.flavour import Flavour, FlavourContainer
13
- from ftag.mock import get_mock_file
14
- from ftag.sample import Sample
15
-
16
- # load flavours
17
- with open(Path(__file__).parent / "flavours.yaml") as f:
18
- flavours_yaml = yaml.safe_load(f)
19
- flavours_dict = {f["name"]: Flavour(cuts=Cuts.from_list(f.pop("cuts")), **f) for f in flavours_yaml}
20
- assert len(flavours_dict) == len(flavours_yaml), "Duplicate flavour names detected"
21
- Flavours = FlavourContainer(flavours_dict)
22
-
23
- __all__ = ["Cuts", "Flavours", "Sample", "hdf5", "get_mock_file", "__version__"]