-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding ScoutingNanoAODSchema and basic mixins that match collections …
…in the ScoutingNANO format. Add a small test suite for ScoutingNanoAODSchema Trimmed example root file down to 157K
- Loading branch information
Showing
5 changed files
with
68 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import os | ||
|
||
import pytest | ||
|
||
from coffea.nanoevents import NanoEventsFactory, ScoutingNanoAODSchema | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def events(tests_directory): | ||
path = os.path.join(tests_directory, "samples/scouting_nano.root") | ||
ScoutingNanoAODSchema.warn_missing_crossrefs = False | ||
events = NanoEventsFactory.from_root( | ||
{path: "Events"}, | ||
schemaclass=ScoutingNanoAODSchema, | ||
delayed=True, | ||
).events() | ||
return events | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"field", | ||
[ | ||
# Jet Sanity check | ||
"ScoutingJet", | ||
# associated PF candidate | ||
"ScoutingJet.pt", | ||
# FatJet sanity check | ||
"ScoutingFatJet", | ||
# Subjet collection (secondary sanity check) | ||
"ScoutingFatJet.pt", | ||
], | ||
) | ||
def test_nested_collections(events, field): | ||
def check_fields_recursive(coll, field): | ||
if "." not in field: | ||
assert hasattr(coll, field) | ||
else: | ||
split = field.split(".") | ||
return check_fields_recursive(getattr(coll, split[0]), ".".join(split[1:])) | ||
|
||
check_fields_recursive(events, field) |