Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unit test for Run 3 Scouting formats #41834

Merged
merged 3 commits into from
Jun 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions DataFormats/Scouting/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# DataFormats/Scouting

## Scouting Data Formats

Any changes to the Scouting data formats must be backwards compatible. In order to ensure the Scouting formats can be read by all future CMSSW releases, there is a `TestRun3ScoutingDataFormats` unit test, which makes use of the `TestReadRun3Scouting` analyzer and the `TestWriteRun3Scouting` producer. The unit test checks that the objects can be read properly from

* a file written by the same release
* files written by (some) earlier releases

If the persistent format of any Scouting data format gets changed in the future, please adjust the `TestReadRun3Scouting` and `TestWriteRun3Scouting` modules accordingly. It is important that every member container has some content in this test. Please also add a new file to the [https://github.com/cms-data/DataFormats-Scouting/](https://github.com/cms-data/DataFormats-Scouting/) repository, and update the `TestRun3ScoutingDataFormats` unit test to read the newly created file. The file name should contain the version numbers of the data format classes (from classes_def.xml) in alphabetical order and the release or pre-release with which it was written. If the latest file of Run 3 scouting before the update has not been used in data taking, the file can be deleted.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It wouldn't be bad to also rearrange classes_def.xml in order to have the classes listed there in alphabetical order, in order to avoid some head hache to who's trying to associate the versions in the name of the data file to the classes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @perrotta for the suggestion, I agree a matching order in the classes_def.xml would help. @wddgit Could you take care of it (either as part of the Run2 scouting PR, or in a separate PR)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll include it in the Run 2 Scouting PR which I am currently implementing. A good idea.


There will probably be analogous tests added in the future for Run 2 and for runs after Run 3 which will need similar maintenance, although it is unlikely the Run 2 formats will change anymore.
11 changes: 11 additions & 0 deletions DataFormats/Scouting/test/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
<use name="DataFormats/Scouting"/>

<library name="testRun3ScoutingDataFormats" file="TestReadRun3Scouting.cc,TestWriteRun3Scouting.cc">
<flags EDM_PLUGIN="1"/>
<use name="FWCore/Framework"/>
<use name="FWCore/ParameterSet"/>
<use name="FWCore/Utilities"/>
</library>

<test name="TestRun3ScoutingDataFormats" command="TestRun3ScoutingFormats.sh"/>

<test name="testDataFormatsScoutingRun2" command="testDataFormatsScoutingRun2.sh"/>
<test name="testDataFormatsScoutingRun3" command="testDataFormatsScoutingRun3.sh"/>
1,097 changes: 1,097 additions & 0 deletions DataFormats/Scouting/test/TestReadRun3Scouting.cc

Large diffs are not rendered by default.

55 changes: 55 additions & 0 deletions DataFormats/Scouting/test/TestRun3ScoutingFormats.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/sh -ex

function die { echo $1: status $2 ; exit $2; }

LOCAL_TEST_DIR=${SCRAM_TEST_PATH}

cmsRun ${LOCAL_TEST_DIR}/create_Run3Scouting_test_file_cfg.py || die 'Failure using create_Run3Scouting_test_file_cfg.py' $?

file=testRun3Scouting.root

cmsRun ${LOCAL_TEST_DIR}/test_readRun3Scouting_cfg.py "$file" || die "Failure using test_readRun3Scouting_cfg.py $file" $?

# The old files read below were generated as follows.
#
# testRun3Scouting_v3_v5_v3_v4_v5_v3_v5_v3_v3_CMSSW_12_4_0.root:
# Check out the 12_4_0 release and cherry pick the commit that
# adds the original version of the file
# DataFormats/Scouting/test/TestWriteRun3Scouting.cc
# (6 files added by that commit). There will be a conflict
# with BuildFile.xml and you will need to delete the two
# unrelated lines).
#
# testRun3Scouting_v3_v6_v3_v4_v5_v3_v5_v3_v3_CMSSW_13_0_3.root
# Check out the 13_0_3 release and cherry pick the commit that
# adds the original version of the file
# DataFormats/Scouting/test/TestWriteRun3Scouting.cc
# (6 files added by that commit). There will be the same
# conflict with BuildFile.xml and you will need to delete
# the two unrelated lines). Also, add the second commit modifying
# that file.
#
# Run the create_Run3Scouting_test_file_cfg.py configuration and
# rename the file it creates.
#
# The versions of the classes are encoded in the filenames in
# alphabetical order. The only version that changed from 12_4_0
# to 13_0_3 was the Run3ScoutingElectron class.
#
# 12_4_0 was chosen because the 12_4_X release cycle was used
# for 2022 data, and the scouting data formats were not updated
# after 12_4_0.
#
# 13_0_3 was chosen because the 13_0_X release cycle was used
# for 2023 data, and the scouting data formats and ROOT were
# not updated after 13_0_3.

file=testRun3Scouting_v3_v5_v3_v4_v5_v3_v5_v3_v3_CMSSW_12_4_0.root
inputfile=$(edmFileInPath DataFormats/Scouting/data/$file) || die "Failure edmFileInPath DataFormats/Scouting/data/$file" $?
cmsRun ${LOCAL_TEST_DIR}/test_readRun3Scouting_CMSSW_12_4_0_cfg.py "$inputfile" || die "Failed to read old file $file" $?

file=testRun3Scouting_v3_v6_v3_v4_v5_v3_v5_v3_v3_CMSSW_13_0_3.root
inputfile=$(edmFileInPath DataFormats/Scouting/data/$file) || die "Failure edmFileInPath DataFormats/Scouting/data/$file" $?
cmsRun ${LOCAL_TEST_DIR}/test_readRun3Scouting_cfg.py "$inputfile" || die "Failed to read old file $file" $?

exit 0
Loading