ftag.find_metadata#
Attributes#
Classes#
Fetch and inject metadata into .h5 files. |
Functions#
|
Command line entry point to fetch and inject PMG metadata. |
Module Contents#
- ftag.find_metadata.XSECDB_MAP#
- ftag.find_metadata.XSECDB_URL_BASE = 'https://atlas-groupdata.web.cern.ch/atlas-groupdata/dev/PMGTools/'#
- class ftag.find_metadata.MetadataFinder(h5_path: str)#
Fetch and inject metadata into .h5 files.
- Parameters:
h5_path (str) – Path to the HDF5 file where metadata should be injected.
- h5_path#
- _extract_taskid() str | None#
Extract the 8-digit BigPanDA Task ID from the filename.
- Returns:
The extracted Task ID, or
Noneif no match is found.- Return type:
str | None
- _fetch_taskinfo(taskid: str) dict | None#
Fetch task details from the BigPanDA JSON API.
- Parameters:
taskid (str) – The BigPanDA Task ID.
- Returns:
The first task record from the API response, or
Noneif unavailable.- Return type:
dict | None
- _extract_container(info: dict) str | None#
Find the MC container name within the task information.
- Parameters:
info (dict) – The task information dictionary from BigPanDA.
- Returns:
The container name (e.g., ‘mc16_13TeV…’), or
Noneif not found.- Return type:
str | None
- _parse_info(container: str) tuple[int, str, str] | None#
Parse DSID, etag, and campaign from a container name.
- Parameters:
container (str) – The full MC container name.
- Returns:
A tuple of (DSID, etag, campaign), or
Noneif parsing fails. Note: ‘mc20’ is automatically mapped to ‘mc16’.- Return type:
tuple[int, str, str] | None
- _download_db(campaign: str) str#
Download the PMG database for a specific campaign.
- Parameters:
campaign (str) – The MC campaign name (e.g., ‘mc16’).
- Returns:
The local path to the downloaded database file.
- Return type:
str
- _query_xsecdb(campaign: str, dsid: int, etag: str) dict | None#
Search the PMG database for metadata matching a DSID and etag.
- Parameters:
campaign (str) – The MC campaign name.
dsid (int) – Dataset ID.
etag (str) – The AMI tag (e.g., ‘e1234’).
- Returns:
Dictionary containing ‘cross_section_pb’, ‘genFiltEff’, and ‘kfactor’, or
Noneif no matching record is found.- Return type:
dict | None
- inject_metadata() None#
Execute the full workflow to inject metadata into the HDF5 file.
This method coordinates Task ID extraction, API fetching, DB querying, and final HDF5 attribute writing. Metadata is stored in a group named
metadata/{dsid}.
- ftag.find_metadata.main() None#
Command line entry point to fetch and inject PMG metadata.