Skip to content

Commit

Permalink
Add validator test
Browse files Browse the repository at this point in the history
Adds invalid recid/doi testing and related test YAML files.
  • Loading branch information
ItIsJordan committed Jul 6, 2023
1 parent 2f73905 commit 6247c64
Show file tree
Hide file tree
Showing 3 changed files with 139 additions and 0 deletions.
58 changes: 58 additions & 0 deletions testsuite/test_data/invalid_submission_doi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
additional_resources: # additional references (e.g. experiment TWiki page for analysis)
- {location: "http://atlas.web.cern.ch/Atlas/GROUPS/PHYSICS/PAPERS/STDM-2012-02/", description: "web page with auxiliary material"}

comment: | # preserve newlines
CERN-LHC. Measurements of the cross section for ZZ production using the 4l and 2l2nu decay channels in proton-proton collisions at a centre-of-mass energy of 7 TeV with 4.6 fb^-1 of data collected in 2011. The final states used are 4 electrons, 4 muons, 2 electrons and 2 muons, 2 electrons and missing transverse momentum, and 2 muons and missing transverse momentum (MET).
The cross section values reported in the tables should be multiplied by a factor of 1.0141 to take into account the updated value of the integrated luminosity for the ATLAS 2011 data taking period. The uncertainty on the global normalisation ("Lumi") remains at 1.8%. See Eur.Phys.J. C73 (2013) 2518 for more details.
The 4l channel fiducial region is defined as:
- 4e, 4mu or 2e2mu
- Ambiguities in pairing are resolved by choosing the combination that results in the smaller value of the sum |mll - mZ| for the two pairs, where mll is the mass of the dilepton system.
- ptLepton > 7 GeV (at least one with ptLepton > 20 (25) GeV for muons (electrons))
- |etaLepton| < 3.16
- At least one lepton pair is required to have invariant mass between 66 and 116 GeV. If the second pair also satisfies this, the event is ZZ, otherwise if the second pair satisfies mll > 20 GeV it is ZZ*.
- min(DeltaR(l,l)) > 0.2.
The 2l2nu channel fiducial region is defined as:
- 2e+MET or 2mu+MET
- ptLepton > 20 GeV
- |etaLepton| < 2.5
- mll must be between 76 and 106 GeV
- -MET*cos(phi_METZ)>75 GeV, where phi_METZ is the angle between the Z and the MET
- |MET - pTZ| / pTZ < 0.4, where pTZ is the transverse momentum of the dilepton system
- No events with a jet for which ptJet > 25 GeV and |etaJet| < 4.5
- No events with a third lepton for which ptLepton > 10 GeV
- min(DeltaR(l,l)) > 0.3
---
# Start a new YAML document to indicate a new data table.
# This is Table 1.
name: "Table 1"
related_to_table_dois:
- "10.17182/hepdata.1.v1/t1"
- "10.17182/hepdaata.1.v1/t1"
location: Data from Page 17 of preprint
description: The measured fiducial cross sections. The first systematic uncertainty is the combined systematic uncertainty excluding luminosity, the second is the luminosity
keywords: # used for searching, possibly multiple values for each keyword
- {name: reactions, values: [P P --> Z0 Z0 X]}
- {name: observables, values: [SIG]}
- {name: cmenergies, values: [7000.0]} # centre-of-mass energy in GeV
- {name: phrases, values: [Inclusive, Integrated Cross Section, Cross Section, Proton-Proton Scattering, Z Production, Z pair Production]}
data_file: data1.yaml
data_license: # (optional) you can specify a license for the data
name: "GPL 2"
url: "url for license"
description: "Tell me about it. This can appear in the main record display" # (optional)
additional_resources: # (optional)
- location: "analysis_script.py"
description: "Analysis script"
- location: "http://github.com/HEPData/hepdata"
description: "Full source code for creating this data"
- location: "root_file.root"
description: "Some file"
license: # (optional)
name: 'GPL 2'
url: "url for license"
description: "Tell me about it. This can appear in the main record display" # (optional)
---
59 changes: 59 additions & 0 deletions testsuite/test_data/invalid_submission_recid.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
additional_resources: # additional references (e.g. experiment TWiki page for analysis)
- {location: "http://atlas.web.cern.ch/Atlas/GROUPS/PHYSICS/PAPERS/STDM-2012-02/", description: "web page with auxiliary material"}

comment: | # preserve newlines
CERN-LHC. Measurements of the cross section for ZZ production using the 4l and 2l2nu decay channels in proton-proton collisions at a centre-of-mass energy of 7 TeV with 4.6 fb^-1 of data collected in 2011. The final states used are 4 electrons, 4 muons, 2 electrons and 2 muons, 2 electrons and missing transverse momentum, and 2 muons and missing transverse momentum (MET).
The cross section values reported in the tables should be multiplied by a factor of 1.0141 to take into account the updated value of the integrated luminosity for the ATLAS 2011 data taking period. The uncertainty on the global normalisation ("Lumi") remains at 1.8%. See Eur.Phys.J. C73 (2013) 2518 for more details.
The 4l channel fiducial region is defined as:
- 4e, 4mu or 2e2mu
- Ambiguities in pairing are resolved by choosing the combination that results in the smaller value of the sum |mll - mZ| for the two pairs, where mll is the mass of the dilepton system.
- ptLepton > 7 GeV (at least one with ptLepton > 20 (25) GeV for muons (electrons))
- |etaLepton| < 3.16
- At least one lepton pair is required to have invariant mass between 66 and 116 GeV. If the second pair also satisfies this, the event is ZZ, otherwise if the second pair satisfies mll > 20 GeV it is ZZ*.
- min(DeltaR(l,l)) > 0.2.
The 2l2nu channel fiducial region is defined as:
- 2e+MET or 2mu+MET
- ptLepton > 20 GeV
- |etaLepton| < 2.5
- mll must be between 76 and 106 GeV
- -MET*cos(phi_METZ)>75 GeV, where phi_METZ is the angle between the Z and the MET
- |MET - pTZ| / pTZ < 0.4, where pTZ is the transverse momentum of the dilepton system
- No events with a jet for which ptJet > 25 GeV and |etaJet| < 4.5
- No events with a third lepton for which ptLepton > 10 GeV
- min(DeltaR(l,l)) > 0.3
related_to_hepdata_recids:
# Insert some random non-integer into the list
- aaaaaa
---
# Start a new YAML document to indicate a new data table.
# This is Table 1.
name: "Table 1"
location: Data from Page 17 of preprint
description: The measured fiducial cross sections. The first systematic uncertainty is the combined systematic uncertainty excluding luminosity, the second is the luminosity
keywords: # used for searching, possibly multiple values for each keyword
- {name: reactions, values: [P P --> Z0 Z0 X]}
- {name: observables, values: [SIG]}
- {name: cmenergies, values: [7000.0]} # centre-of-mass energy in GeV
- {name: phrases, values: [Inclusive, Integrated Cross Section, Cross Section, Proton-Proton Scattering, Z Production, Z pair Production]}
data_file: data1.yaml
data_license: # (optional) you can specify a license for the data
name: "GPL 2"
url: "url for license"
description: "Tell me about it. This can appear in the main record display" # (optional)
additional_resources: # (optional)
- location: "analysis_script.py"
description: "Analysis script"
- location: "http://github.com/HEPData/hepdata"
description: "Full source code for creating this data"
- location: "root_file.root"
description: "Some file"
license: # (optional)
name: 'GPL 2'
url: "url for license"
description: "Tell me about it. This can appear in the main record display" # (optional)
---
22 changes: 22 additions & 0 deletions testsuite/test_submission_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,3 +337,25 @@ def test_submission_with_no_data_tables(validator_v0, validator_v1, data_path, c

is_valid_v0 = validator_v0.validate(file_path=file, data=yaml_obj)
assert is_valid_v0

def test_related_submission_invalid(validator_v1, data_path, capsys):
"""
Tests all of the invalid related submission files at once
against their expected errors.
"""
yaml_files = [
{"file" : "invalid_submission_recid.yaml",
"error" : "error - 'aaaaaa' is not of type 'integer'"},
{"file" : "invalid_submission_doi.yaml",
"error" : "error - '10.17182/hepdaata.1.v1/t1' does not match "}]

for yf in yaml_files:
file = os.path.join(data_path, yf['file'])
with open(file, 'r') as submission:
yaml_obj = yaml.load_all(submission, Loader=YamlLoader)
is_valid = validator_v1.validate(file_path=file, data=yaml_obj)
validator_v1.print_errors(file)
assert is_valid is False

out, err = capsys.readouterr()
assert yf['error'] in out.strip()

0 comments on commit 6247c64

Please sign in to comment.