diff --git a/DataFormats/Scouting/README.md b/DataFormats/Scouting/README.md new file mode 100644 index 0000000000000..d9a136e279508 --- /dev/null +++ b/DataFormats/Scouting/README.md @@ -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. + +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. diff --git a/DataFormats/Scouting/test/BuildFile.xml b/DataFormats/Scouting/test/BuildFile.xml index 1f6570eac7355..58591e8d97d2b 100644 --- a/DataFormats/Scouting/test/BuildFile.xml +++ b/DataFormats/Scouting/test/BuildFile.xml @@ -1,2 +1,13 @@ + + + + + + + + + + + diff --git a/DataFormats/Scouting/test/TestReadRun3Scouting.cc b/DataFormats/Scouting/test/TestReadRun3Scouting.cc new file mode 100644 index 0000000000000..2e092860cae62 --- /dev/null +++ b/DataFormats/Scouting/test/TestReadRun3Scouting.cc @@ -0,0 +1,1097 @@ +// -*- C++ -*- +// +// Package: DataFormats/Scouting +// Class: TestReadRun3Scouting +// +/**\class edmtest::TestReadRun3Scouting + Description: Used as part of tests that ensure the run 3 Scouting + data formats can be persistently written and in a subsequent process + read. First, this is done using the current release version for writing + and reading. In addition, the output file of the write process should + be saved permanently each time a run 3 Scouting persistent data + format changes. In unit tests, we read each of those saved files to verify + that the current releases can read older versions of these data formats. +*/ +// Original Author: W. David Dagenhart +// Created: 18 May 2023 + +#include "DataFormats/Scouting/interface/Run3ScoutingCaloJet.h" +#include "DataFormats/Scouting/interface/Run3ScoutingElectron.h" +#include "DataFormats/Scouting/interface/Run3ScoutingHitPatternPOD.h" +#include "DataFormats/Scouting/interface/Run3ScoutingMuon.h" +#include "DataFormats/Scouting/interface/Run3ScoutingParticle.h" +#include "DataFormats/Scouting/interface/Run3ScoutingPFJet.h" +#include "DataFormats/Scouting/interface/Run3ScoutingPhoton.h" +#include "DataFormats/Scouting/interface/Run3ScoutingTrack.h" +#include "DataFormats/Scouting/interface/Run3ScoutingVertex.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/global/EDAnalyzer.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" +#include "FWCore/Utilities/interface/EDGetToken.h" +#include "FWCore/Utilities/interface/Exception.h" +#include "FWCore/Utilities/interface/InputTag.h" +#include "FWCore/Utilities/interface/StreamID.h" + +#include + +namespace edmtest { + + class TestReadRun3Scouting : public edm::global::EDAnalyzer<> { + public: + TestReadRun3Scouting(edm::ParameterSet const&); + void analyze(edm::StreamID, edm::Event const&, edm::EventSetup const&) const override; + static void fillDescriptions(edm::ConfigurationDescriptions&); + + private: + void analyzeCaloJets(edm::Event const&) const; + void analyzeElectrons(edm::Event const&) const; + void analyzeMuons(edm::Event const&) const; + void analyzeParticles(edm::Event const&) const; + void analyzePFJets(edm::Event const&) const; + void analyzePhotons(edm::Event const&) const; + void analyzeTracks(edm::Event const&) const; + void analyzeVertexes(edm::Event const&) const; + + void throwWithMessageFromConstructor(const char*) const; + void throwWithMessage(const char*) const; + + // These expected values are meaningless other than we use them + // to check that values read from persistent storage match the values + // we know were written. + + const std::vector expectedCaloJetsValues_; + const edm::EDGetTokenT> caloJetsToken_; + + const int inputElectronClassVersion_; + const std::vector expectedElectronFloatingPointValues_; + const std::vector expectedElectronIntegralValues_; + const edm::EDGetTokenT> electronsToken_; + + const std::vector expectedMuonFloatingPointValues_; + const std::vector expectedMuonIntegralValues_; + const edm::EDGetTokenT> muonsToken_; + + const std::vector expectedParticleFloatingPointValues_; + const std::vector expectedParticleIntegralValues_; + const edm::EDGetTokenT> particlesToken_; + + const std::vector expectedPFJetFloatingPointValues_; + const std::vector expectedPFJetIntegralValues_; + const edm::EDGetTokenT> pfJetsToken_; + + const std::vector expectedPhotonFloatingPointValues_; + const std::vector expectedPhotonIntegralValues_; + const edm::EDGetTokenT> photonsToken_; + + const std::vector expectedTrackFloatingPointValues_; + const std::vector expectedTrackIntegralValues_; + const edm::EDGetTokenT> tracksToken_; + + const std::vector expectedVertexFloatingPointValues_; + const std::vector expectedVertexIntegralValues_; + const edm::EDGetTokenT> vertexesToken_; + }; + + TestReadRun3Scouting::TestReadRun3Scouting(edm::ParameterSet const& iPSet) + : expectedCaloJetsValues_(iPSet.getParameter>("expectedCaloJetsValues")), + caloJetsToken_(consumes(iPSet.getParameter("caloJetsTag"))), + inputElectronClassVersion_(iPSet.getParameter("electronClassVersion")), + expectedElectronFloatingPointValues_( + iPSet.getParameter>("expectedElectronFloatingPointValues")), + expectedElectronIntegralValues_(iPSet.getParameter>("expectedElectronIntegralValues")), + electronsToken_(consumes(iPSet.getParameter("electronsTag"))), + expectedMuonFloatingPointValues_(iPSet.getParameter>("expectedMuonFloatingPointValues")), + expectedMuonIntegralValues_(iPSet.getParameter>("expectedMuonIntegralValues")), + muonsToken_(consumes(iPSet.getParameter("muonsTag"))), + expectedParticleFloatingPointValues_( + iPSet.getParameter>("expectedParticleFloatingPointValues")), + expectedParticleIntegralValues_(iPSet.getParameter>("expectedParticleIntegralValues")), + particlesToken_(consumes(iPSet.getParameter("particlesTag"))), + expectedPFJetFloatingPointValues_(iPSet.getParameter>("expectedPFJetFloatingPointValues")), + expectedPFJetIntegralValues_(iPSet.getParameter>("expectedPFJetIntegralValues")), + pfJetsToken_(consumes(iPSet.getParameter("pfJetsTag"))), + expectedPhotonFloatingPointValues_( + iPSet.getParameter>("expectedPhotonFloatingPointValues")), + expectedPhotonIntegralValues_(iPSet.getParameter>("expectedPhotonIntegralValues")), + photonsToken_(consumes(iPSet.getParameter("photonsTag"))), + expectedTrackFloatingPointValues_(iPSet.getParameter>("expectedTrackFloatingPointValues")), + expectedTrackIntegralValues_(iPSet.getParameter>("expectedTrackIntegralValues")), + tracksToken_(consumes(iPSet.getParameter("tracksTag"))), + expectedVertexFloatingPointValues_( + iPSet.getParameter>("expectedVertexFloatingPointValues")), + expectedVertexIntegralValues_(iPSet.getParameter>("expectedVertexIntegralValues")), + vertexesToken_(consumes(iPSet.getParameter("vertexesTag"))) { + if (expectedCaloJetsValues_.size() != 16) { + throwWithMessageFromConstructor("test configuration error, expectedCaloJetsValues must have size 16"); + } + if (expectedElectronFloatingPointValues_.size() != 25) { + throwWithMessageFromConstructor( + "test configuration error, expectedElectronFloatingPointValues must have size 25"); + } + if (expectedElectronIntegralValues_.size() != 6) { + throwWithMessageFromConstructor("test configuration error, expectedElectronIntegralValues must have size 6"); + } + if (expectedMuonFloatingPointValues_.size() != 37) { + throwWithMessageFromConstructor("test configuration error, expectedMuonFloatingPointValues must have size 37"); + } + if (expectedMuonIntegralValues_.size() != 26) { + throwWithMessageFromConstructor("test configuration error, expectedMuonIntegralValues must have size 26"); + } + if (expectedParticleFloatingPointValues_.size() != 11) { + throwWithMessageFromConstructor( + "test configuration error, expectedParticleFloatingPointValues must have size 11"); + } + if (expectedParticleIntegralValues_.size() != 5) { + throwWithMessageFromConstructor("test configuration error, expectedParticleIntegralValues must have size 5"); + } + if (expectedPFJetFloatingPointValues_.size() != 15) { + throwWithMessageFromConstructor("test configuration error, expectedPFJetFloatingPointValues must have size 15"); + } + if (expectedPFJetIntegralValues_.size() != 8) { + throwWithMessageFromConstructor("test configuration error, expectedPFJetIntegralValues must have size 8"); + } + if (expectedPhotonFloatingPointValues_.size() != 14) { + throwWithMessageFromConstructor("test configuration error, expectedPhotonFloatingPointValues must have size 14"); + } + if (expectedPhotonIntegralValues_.size() != 3) { + throwWithMessageFromConstructor("test configuration error, expectedPhotonIntegralValues must have size 3"); + } + if (expectedTrackFloatingPointValues_.size() != 29) { + throwWithMessageFromConstructor("test configuration error, expectedTrackFloatingPointValues must have size 29"); + } + if (expectedTrackIntegralValues_.size() != 5) { + throwWithMessageFromConstructor("test configuration error, expectedTrackIntegralValues must have size 5"); + } + if (expectedVertexFloatingPointValues_.size() != 7) { + throwWithMessageFromConstructor("test configuration error, expectedVertexFloatingPointValues must have size 7"); + } + if (expectedVertexIntegralValues_.size() != 3) { + throwWithMessageFromConstructor("test configuration error, expectedVertexIntegralValues must have size 3"); + } + } + + void TestReadRun3Scouting::analyze(edm::StreamID, edm::Event const& iEvent, edm::EventSetup const&) const { + analyzeCaloJets(iEvent); + analyzeElectrons(iEvent); + analyzeMuons(iEvent); + analyzeParticles(iEvent); + analyzePFJets(iEvent); + analyzePhotons(iEvent); + analyzeTracks(iEvent); + analyzeVertexes(iEvent); + } + + void TestReadRun3Scouting::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + edm::ParameterSetDescription desc; + desc.add>("expectedCaloJetsValues"); + desc.add("caloJetsTag"); + desc.add("electronClassVersion"); + desc.add>("expectedElectronFloatingPointValues"); + desc.add>("expectedElectronIntegralValues"); + desc.add("electronsTag"); + desc.add>("expectedMuonFloatingPointValues"); + desc.add>("expectedMuonIntegralValues"); + desc.add("muonsTag"); + desc.add>("expectedParticleFloatingPointValues"); + desc.add>("expectedParticleIntegralValues"); + desc.add("particlesTag"); + desc.add>("expectedPFJetFloatingPointValues"); + desc.add>("expectedPFJetIntegralValues"); + desc.add("pfJetsTag"); + desc.add>("expectedPhotonFloatingPointValues"); + desc.add>("expectedPhotonIntegralValues"); + desc.add("photonsTag"); + desc.add>("expectedTrackFloatingPointValues"); + desc.add>("expectedTrackIntegralValues"); + desc.add("tracksTag"); + desc.add>("expectedVertexFloatingPointValues"); + desc.add>("expectedVertexIntegralValues"); + desc.add("vertexesTag"); + descriptions.addDefault(desc); + } + + void TestReadRun3Scouting::analyzeCaloJets(edm::Event const& iEvent) const { + auto const& caloJets = iEvent.get(caloJetsToken_); + unsigned int vectorSize = 2 + iEvent.id().event() % 4; + if (caloJets.size() != vectorSize) { + throwWithMessage("analyzeCaloJets, caloJets does not have expected size"); + } + unsigned int i = 0; + for (auto const& caloJet : caloJets) { + double offset = static_cast(iEvent.id().event() + i); + + if (caloJet.pt() != expectedCaloJetsValues_[0] + offset) { + throwWithMessage("analyzeCaloJets, pt does not equal expected value"); + } + if (caloJet.eta() != expectedCaloJetsValues_[1] + offset) { + throwWithMessage("analyzeCaloJets, eta does not equal expected value"); + } + if (caloJet.phi() != expectedCaloJetsValues_[2] + offset) { + throwWithMessage("analyzeCaloJets, phi does not equal expected value"); + } + if (caloJet.m() != expectedCaloJetsValues_[3] + offset) { + throwWithMessage("analyzeCaloJets, m does not equal expected value"); + } + if (caloJet.jetArea() != expectedCaloJetsValues_[4] + offset) { + throwWithMessage("analyzeCaloJets, jetArea does not equal expected value"); + } + if (caloJet.maxEInEmTowers() != expectedCaloJetsValues_[5] + offset) { + throwWithMessage("analyzeCaloJets, maxEInEmTowers() does not equal expected value"); + } + if (caloJet.maxEInHadTowers() != expectedCaloJetsValues_[6] + offset) { + throwWithMessage("analyzeCaloJets, maxEInHadTowers does not equal expected value"); + } + if (caloJet.hadEnergyInHB() != expectedCaloJetsValues_[7] + offset) { + throwWithMessage("analyzeCaloJets, hadEnergyInHB does not equal expected value"); + } + if (caloJet.hadEnergyInHE() != expectedCaloJetsValues_[8] + offset) { + throwWithMessage("analyzeCaloJets, hadEnergyInHE does not equal expected value"); + } + if (caloJet.hadEnergyInHF() != expectedCaloJetsValues_[9] + offset) { + throwWithMessage("analyzeCaloJets, hadEnergyInHF does not equal expected value"); + } + if (caloJet.emEnergyInEB() != expectedCaloJetsValues_[10] + offset) { + throwWithMessage("analyzeCaloJets, emEnergyInEB does not equal expected value"); + } + if (caloJet.emEnergyInEE() != expectedCaloJetsValues_[11] + offset) { + throwWithMessage("analyzeCaloJets, emEnergyInEE does not equal expected value"); + } + if (caloJet.emEnergyInHF() != expectedCaloJetsValues_[12] + offset) { + throwWithMessage("analyzeCaloJets, emEnergyInHF does not equal expected value"); + } + if (caloJet.towersArea() != expectedCaloJetsValues_[13] + offset) { + throwWithMessage("analyzeCaloJets, towersArea does not equal expected value"); + } + if (caloJet.mvaDiscriminator() != expectedCaloJetsValues_[14] + offset) { + throwWithMessage("analyzeCaloJets, mvaDiscriminator does not equal expected value"); + } + if (caloJet.btagDiscriminator() != expectedCaloJetsValues_[15] + offset) { + throwWithMessage("analyzeCaloJets, btagDiscriminator does not equal expected value"); + } + ++i; + } + } + + void TestReadRun3Scouting::analyzeElectrons(edm::Event const& iEvent) const { + auto const& electrons = iEvent.get(electronsToken_); + unsigned int vectorSize = 2 + iEvent.id().event() % 4; + if (electrons.size() != vectorSize) { + throwWithMessage("analyzeElectrons, electrons does not have expected size"); + } + unsigned int i = 0; + for (auto const& electron : electrons) { + double offset = static_cast(iEvent.id().event() + i); + int iOffset = static_cast(iEvent.id().event() + i); + + if (electron.pt() != expectedElectronFloatingPointValues_[0] + offset) { + throwWithMessage("analyzeElectrons, pt does not equal expected value"); + } + if (electron.eta() != expectedElectronFloatingPointValues_[1] + offset) { + throwWithMessage("analyzeElectrons, eta does not equal expected value"); + } + if (electron.phi() != expectedElectronFloatingPointValues_[2] + offset) { + throwWithMessage("analyzeElectrons, phi does not equal expected value"); + } + if (electron.m() != expectedElectronFloatingPointValues_[3] + offset) { + throwWithMessage("analyzeElectrons, m does not equal expected value"); + } + if (inputElectronClassVersion_ == 5) { + if (electron.trkd0().size() != 1) { + throwWithMessage("analyzeElectrons, trkd0 does not have expected size"); + } + if (electron.trkd0()[0] != expectedElectronFloatingPointValues_[4] + offset) { + throwWithMessage("analyzeElectrons, d0 does not equal expected value"); + } + if (electron.trkdz().size() != 1) { + throwWithMessage("analyzeElectrons, trkdz does not have expected size"); + } + if (electron.trkdz()[0] != expectedElectronFloatingPointValues_[5] + offset) { + throwWithMessage("analyzeElectrons, dz does not equal expected value"); + } + } + if (electron.dEtaIn() != expectedElectronFloatingPointValues_[6] + offset) { + throwWithMessage("analyzeElectrons, dEtaIn does not equal expected value"); + } + if (electron.dPhiIn() != expectedElectronFloatingPointValues_[7] + offset) { + throwWithMessage("analyzeElectrons, dPhiIn does not equal expected value"); + } + if (electron.sigmaIetaIeta() != expectedElectronFloatingPointValues_[8] + offset) { + throwWithMessage("analyzeElectrons, sigmaIetaIeta does not equal expected value"); + } + if (electron.hOverE() != expectedElectronFloatingPointValues_[9] + offset) { + throwWithMessage("analyzeElectrons, hOverE does not equal expected value"); + } + if (electron.ooEMOop() != expectedElectronFloatingPointValues_[10] + offset) { + throwWithMessage("analyzeElectrons, ooEMOop does not equal expected value"); + } + if (electron.missingHits() != expectedElectronIntegralValues_[0] + iOffset) { + throwWithMessage("analyzeElectrons, missingHits does not equal expected value"); + } + if (inputElectronClassVersion_ == 5) { + if (electron.trkcharge().size() != 1) { + throwWithMessage("analyzeElectrons, trkcharge does not have expected size"); + } + if (electron.trkcharge()[0] != expectedElectronIntegralValues_[1] + iOffset) { + throwWithMessage("analyzeElectrons, charge does not equal expected value"); + } + } + if (electron.ecalIso() != expectedElectronFloatingPointValues_[11] + offset) { + throwWithMessage("analyzeElectrons, ecalIso does not equal expected value"); + } + if (electron.hcalIso() != expectedElectronFloatingPointValues_[12] + offset) { + throwWithMessage("analyzeElectrons, hcalIso does not equal expected value"); + } + if (electron.trackIso() != expectedElectronFloatingPointValues_[13] + offset) { + throwWithMessage("analyzeElectrons, trackIso does not equal expected value"); + } + if (electron.r9() != expectedElectronFloatingPointValues_[14] + offset) { + throwWithMessage("analyzeElectrons, r9 does not equal expected value"); + } + if (electron.sMin() != expectedElectronFloatingPointValues_[15] + offset) { + throwWithMessage("analyzeElectrons, sMin does not equal expected value"); + } + if (electron.sMaj() != expectedElectronFloatingPointValues_[16] + offset) { + throwWithMessage("analyzeElectrons, sMaj does not equal expected value"); + } + if (electron.seedId() != static_cast(expectedElectronIntegralValues_[2] + iOffset)) { + throwWithMessage("analyzeElectrons, seedId does not equal expected value"); + } + if (electron.energyMatrix().size() != vectorSize) { + throwWithMessage("analyzeElectrons, energyMatrix does not have expected size"); + } + unsigned int j = 0; + for (auto const& val : electron.energyMatrix()) { + if (val != expectedElectronFloatingPointValues_[17] + offset + 10 * j) { + throwWithMessage("analyzeElectrons, energyMatrix does not contain expected value"); + } + ++j; + } + if (electron.detIds().size() != vectorSize) { + throwWithMessage("analyzeElectrons, detIds does not have expected size"); + } + j = 0; + for (auto const& val : electron.detIds()) { + if (val != expectedElectronIntegralValues_[3] + iOffset + 10 * j) { + throwWithMessage("analyzeElectrons, detIds does not contain expected value"); + } + ++j; + } + if (electron.timingMatrix().size() != vectorSize) { + throwWithMessage("analyzeElectrons, timingMatrix does not have expected size"); + } + j = 0; + for (auto const& val : electron.timingMatrix()) { + if (val != expectedElectronFloatingPointValues_[18] + offset + 10 * j) { + throwWithMessage("analyzeElectrons, timingMatrix does not contain expected value"); + } + ++j; + } + if (electron.rechitZeroSuppression() != static_cast((expectedElectronIntegralValues_[4] + iOffset) % 2)) { + throwWithMessage("analyzeElectrons, rechitZeroSuppression does not equal expected value"); + } + if (inputElectronClassVersion_ == 6) { + if (electron.trkd0().size() != vectorSize) { + throwWithMessage("analyzeElectrons, trkd0 does not have expected size"); + } + j = 0; + for (auto const& val : electron.trkd0()) { + if (val != expectedElectronFloatingPointValues_[19] + offset + 10 * j) { + throwWithMessage("analyzeElectrons, trkd0 does not contain expected value"); + } + ++j; + } + if (electron.trkdz().size() != vectorSize) { + throwWithMessage("analyzeElectrons, trkdz does not have expected size"); + } + j = 0; + for (auto const& val : electron.trkdz()) { + if (val != expectedElectronFloatingPointValues_[20] + offset + 10 * j) { + throwWithMessage("analyzeElectrons, trkdz does not contain expected value"); + } + ++j; + } + if (electron.trkpt().size() != vectorSize) { + throwWithMessage("analyzeElectrons, trkpt does not have expected size"); + } + j = 0; + for (auto const& val : electron.trkpt()) { + if (val != expectedElectronFloatingPointValues_[21] + offset + 10 * j) { + throwWithMessage("analyzeElectrons, trkpt does not contain expected value"); + } + ++j; + } + if (electron.trketa().size() != vectorSize) { + throwWithMessage("analyzeElectrons, trketa does not have expected size"); + } + j = 0; + for (auto const& val : electron.trketa()) { + if (val != expectedElectronFloatingPointValues_[22] + offset + 10 * j) { + throwWithMessage("analyzeElectrons, trketa does not contain expected value"); + } + ++j; + } + if (electron.trkphi().size() != vectorSize) { + throwWithMessage("analyzeElectrons, trkphi does not have expected size"); + } + j = 0; + for (auto const& val : electron.trkphi()) { + if (val != expectedElectronFloatingPointValues_[23] + offset + 10 * j) { + throwWithMessage("analyzeElectrons, trkphi does not contain expected value"); + } + ++j; + } + if (electron.trkchi2overndf().size() != vectorSize) { + throwWithMessage("analyzeElectrons, trkchi2overndf does not have expected size"); + } + j = 0; + for (auto const& val : electron.trkchi2overndf()) { + if (val != expectedElectronFloatingPointValues_[24] + offset + 10 * j) { + throwWithMessage("analyzeElectrons, trkchi2overndf does not contain expected value"); + } + ++j; + } + if (electron.trkcharge().size() != vectorSize) { + throwWithMessage("analyzeElectrons, trkcharge does not have expected size"); + } + j = 0; + for (auto const& val : electron.trkcharge()) { + if (val != static_cast(expectedElectronIntegralValues_[5] + iOffset + 10 * j)) { + throwWithMessage("analyzeElectrons, trkcharge does not contain expected value"); + } + ++j; + } + } + ++i; + } + } + + void TestReadRun3Scouting::analyzeMuons(edm::Event const& iEvent) const { + auto const& muons = iEvent.get(muonsToken_); + unsigned int vectorSize = 2 + iEvent.id().event() % 4; + if (muons.size() != vectorSize) { + throwWithMessage("analyzeMuons, muons does not have expected size"); + } + unsigned int i = 0; + for (auto const& muon : muons) { + double offset = static_cast(iEvent.id().event() + i); + int iOffset = static_cast(iEvent.id().event() + i); + + if (muon.pt() != expectedMuonFloatingPointValues_[0] + offset) { + throwWithMessage("analyzeMuons, pt does not equal expected value"); + } + if (muon.eta() != expectedMuonFloatingPointValues_[1] + offset) { + throwWithMessage("analyzeMuons, eta does not equal expected value"); + } + if (muon.phi() != expectedMuonFloatingPointValues_[2] + offset) { + throwWithMessage("analyzeMuons, phi does not equal expected value"); + } + if (muon.m() != expectedMuonFloatingPointValues_[3] + offset) { + throwWithMessage("analyzeMuons, m does not equal expected value"); + } + if (muon.type() != static_cast(expectedMuonIntegralValues_[0] + iOffset)) { + throwWithMessage("analyzeMuons, type does not equal expected value"); + } + if (muon.charge() != expectedMuonIntegralValues_[1] + iOffset) { + throwWithMessage("analyzeMuons, charge does not equal expected value"); + } + if (muon.normalizedChi2() != expectedMuonFloatingPointValues_[4] + offset) { + throwWithMessage("analyzeMuons, normalizedChi2 does not equal expected value"); + } + if (muon.ecalIso() != expectedMuonFloatingPointValues_[5] + offset) { + throwWithMessage("analyzeMuons, ecalIso does not equal expected value"); + } + if (muon.hcalIso() != expectedMuonFloatingPointValues_[6] + offset) { + throwWithMessage("analyzeMuons, hcalIso does not equal expected value"); + } + if (muon.trackIso() != expectedMuonFloatingPointValues_[7] + offset) { + throwWithMessage("analyzeMuons, trackIso does not equal expected value"); + } + if (muon.nValidStandAloneMuonHits() != expectedMuonIntegralValues_[2] + iOffset) { + throwWithMessage("analyzeMuons, nValidStandAloneMuonHits does not equal expected value"); + } + if (muon.nStandAloneMuonMatchedStations() != expectedMuonIntegralValues_[3] + iOffset) { + throwWithMessage("analyzeMuons, nStandAloneMuonMatchedStations does not equal expected value"); + } + if (muon.nValidRecoMuonHits() != expectedMuonIntegralValues_[4] + iOffset) { + throwWithMessage("analyzeMuons, nValidRecoMuonHits does not equal expected value"); + } + if (muon.nRecoMuonChambers() != expectedMuonIntegralValues_[5] + iOffset) { + throwWithMessage("analyzeMuons, nRecoMuonChambers does not equal expected value"); + } + if (muon.nRecoMuonChambersCSCorDT() != expectedMuonIntegralValues_[6] + iOffset) { + throwWithMessage("analyzeMuons, nRecoMuonChambersCSCorDT does not equal expected value"); + } + if (muon.nRecoMuonMatches() != expectedMuonIntegralValues_[7] + iOffset) { + throwWithMessage("analyzeMuons, nRecoMuonMatches does not equal expected value"); + } + if (muon.nRecoMuonMatchedStations() != expectedMuonIntegralValues_[8] + iOffset) { + throwWithMessage("analyzeMuons, nRecoMuonMatchedStations does not equal expected value"); + } + if (muon.nRecoMuonExpectedMatchedStations() != + static_cast(expectedMuonIntegralValues_[9] + iOffset)) { + throwWithMessage("analyzeMuons, nRecoMuonExpectedMatchedStations does not equal expected value"); + } + if (muon.recoMuonStationMask() != static_cast(expectedMuonIntegralValues_[10] + iOffset)) { + throwWithMessage("analyzeMuons, recoMuonStationMask does not equal expected value"); + } + if (muon.nRecoMuonMatchedRPCLayers() != expectedMuonIntegralValues_[11] + iOffset) { + throwWithMessage("analyzeMuons, nRecoMuonMatchedRPCLayers does not equal expected value"); + } + if (muon.recoMuonRPClayerMask() != static_cast(expectedMuonIntegralValues_[12] + iOffset)) { + throwWithMessage("analyzeMuons, recoMuonRPClayerMask does not equal expected value"); + } + if (muon.nValidPixelHits() != expectedMuonIntegralValues_[13] + iOffset) { + throwWithMessage("analyzeMuons, nValidPixelHits does not equal expected value"); + } + if (muon.nValidStripHits() != expectedMuonIntegralValues_[14] + iOffset) { + throwWithMessage("analyzeMuons, nValidStripHits does not equal expected value"); + } + if (muon.nPixelLayersWithMeasurement() != expectedMuonIntegralValues_[15] + iOffset) { + throwWithMessage("analyzeMuons, nPixelLayersWithMeasurement does not equal expected value"); + } + if (muon.nTrackerLayersWithMeasurement() != expectedMuonIntegralValues_[16] + iOffset) { + throwWithMessage("analyzeMuons, nTrackerLayersWithMeasurement does not equal expected value"); + } + if (muon.trk_chi2() != expectedMuonFloatingPointValues_[8] + offset) { + throwWithMessage("analyzeMuons, trk_chi2 does not equal expected value"); + } + if (muon.trk_ndof() != expectedMuonFloatingPointValues_[9] + offset) { + throwWithMessage("analyzeMuons, trk_ndof does not equal expected value"); + } + if (muon.trk_dxy() != expectedMuonFloatingPointValues_[10] + offset) { + throwWithMessage("analyzeMuons, trk_dxy does not equal expected value"); + } + if (muon.trk_dz() != expectedMuonFloatingPointValues_[11] + offset) { + throwWithMessage("analyzeMuons, trk_dz does not equal expected value"); + } + if (muon.trk_qoverp() != expectedMuonFloatingPointValues_[12] + offset) { + throwWithMessage("analyzeMuons, trk_qoverp does not equal expected value"); + } + if (muon.trk_lambda() != expectedMuonFloatingPointValues_[13] + offset) { + throwWithMessage("analyzeMuons, trk_lambda does not equal expected value"); + } + if (muon.trk_pt() != expectedMuonFloatingPointValues_[14] + offset) { + throwWithMessage("analyzeMuons, trk_pt does not equal expected value"); + } + if (muon.trk_phi() != expectedMuonFloatingPointValues_[15] + offset) { + throwWithMessage("analyzeMuons, trk_phi does not equal expected value"); + } + if (muon.trk_eta() != expectedMuonFloatingPointValues_[16] + offset) { + throwWithMessage("analyzeMuons, trk_eta does not equal expected value"); + } + if (muon.trk_dxyError() != expectedMuonFloatingPointValues_[17] + offset) { + throwWithMessage("analyzeMuons, trk_dxyError does not equal expected value"); + } + if (muon.trk_dzError() != expectedMuonFloatingPointValues_[18] + offset) { + throwWithMessage("analyzeMuons, trk_dzError does not equal expected value"); + } + if (muon.trk_qoverpError() != expectedMuonFloatingPointValues_[19] + offset) { + throwWithMessage("analyzeMuons, trk_qoverpError does not equal expected value"); + } + if (muon.trk_lambdaError() != expectedMuonFloatingPointValues_[20] + offset) { + throwWithMessage("analyzeMuons, trk_lambdaError does not equal expected value"); + } + if (muon.trk_phiError() != expectedMuonFloatingPointValues_[21] + offset) { + throwWithMessage("analyzeMuons, trk_phiError does not equal expected value"); + } + if (muon.trk_dsz() != expectedMuonFloatingPointValues_[22] + offset) { + throwWithMessage("analyzeMuons, trk_dsz does not equal expected value"); + } + if (muon.trk_dszError() != expectedMuonFloatingPointValues_[23] + offset) { + throwWithMessage("analyzeMuons, trk_dszError does not equal expected value"); + } + if (muon.trk_qoverp_lambda_cov() != expectedMuonFloatingPointValues_[24] + offset) { + throwWithMessage("analyzeMuons, trk_qoverp_lambda_cov does not equal expected value"); + } + if (muon.trk_qoverp_phi_cov() != expectedMuonFloatingPointValues_[25] + offset) { + throwWithMessage("analyzeMuons, trk_qoverp_phi_cov does not equal expected value"); + } + if (muon.trk_qoverp_dxy_cov() != expectedMuonFloatingPointValues_[26] + offset) { + throwWithMessage("analyzeMuons, trk_qoverp_dxy_cov does not equal expected value"); + } + if (muon.trk_qoverp_dsz_cov() != expectedMuonFloatingPointValues_[27] + offset) { + throwWithMessage("analyzeMuons, trk_qoverp_dsz_cov does not equal expected value"); + } + if (muon.trk_lambda_phi_cov() != expectedMuonFloatingPointValues_[28] + offset) { + throwWithMessage("analyzeMuons, trk_lambda_phi_cov does not equal expected value"); + } + if (muon.trk_lambda_dxy_cov() != expectedMuonFloatingPointValues_[29] + offset) { + throwWithMessage("analyzeMuons, trk_lambda_dxy_cov does not equal expected value"); + } + if (muon.trk_lambda_dsz_cov() != expectedMuonFloatingPointValues_[30] + offset) { + throwWithMessage("analyzeMuons, trk_lambda_dsz_cov does not equal expected value"); + } + if (muon.trk_phi_dxy_cov() != expectedMuonFloatingPointValues_[31] + offset) { + throwWithMessage("analyzeMuons, trk_phi_dxy_cov does not equal expected value"); + } + if (muon.trk_phi_dsz_cov() != expectedMuonFloatingPointValues_[32] + offset) { + throwWithMessage("analyzeMuons, trk_phi_dsz_cov does not equal expected value"); + } + if (muon.trk_dxy_dsz_cov() != expectedMuonFloatingPointValues_[33] + offset) { + throwWithMessage("analyzeMuons, trk_dxy_dsz_cov does not equal expected value"); + } + if (muon.trk_vx() != expectedMuonFloatingPointValues_[34] + offset) { + throwWithMessage("analyzeMuons, trk_vx does not equal expected value"); + } + if (muon.trk_vy() != expectedMuonFloatingPointValues_[35] + offset) { + throwWithMessage("analyzeMuons, trk_vy does not equal expected value"); + } + if (muon.trk_vz() != expectedMuonFloatingPointValues_[36] + offset) { + throwWithMessage("analyzeMuons, trk_vz does not equal expected value"); + } + int j = 0; + for (auto const& val : muon.vtxIndx()) { + if (val != expectedMuonIntegralValues_[17] + iOffset + 10 * j) { + throwWithMessage("analyzeMuons, vtxIndx does not contain expected value"); + } + ++j; + } + if (muon.trk_hitPattern().hitCount != static_cast(expectedMuonIntegralValues_[18] + iOffset)) { + throwWithMessage("analyzeMuons, hitCount does not equal expected value"); + } + if (muon.trk_hitPattern().beginTrackHits != static_cast(expectedMuonIntegralValues_[19] + iOffset)) { + throwWithMessage("analyzeMuons, beginTrackHits does not equal expected value"); + } + if (muon.trk_hitPattern().endTrackHits != static_cast(expectedMuonIntegralValues_[20] + iOffset)) { + throwWithMessage("analyzeMuons, endTrackHits does not equal expected value"); + } + if (muon.trk_hitPattern().beginInner != static_cast(expectedMuonIntegralValues_[21] + iOffset)) { + throwWithMessage("analyzeMuons, beginInner does not equal expected value"); + } + if (muon.trk_hitPattern().endInner != static_cast(expectedMuonIntegralValues_[22] + iOffset)) { + throwWithMessage("analyzeMuons, endInner does not equal expected value"); + } + if (muon.trk_hitPattern().beginOuter != static_cast(expectedMuonIntegralValues_[23] + iOffset)) { + throwWithMessage("analyzeMuons, beginOuter does not equal expected value"); + } + if (muon.trk_hitPattern().endOuter != static_cast(expectedMuonIntegralValues_[24] + iOffset)) { + throwWithMessage("analyzeMuons, endOuter does not equal expected value"); + } + j = 0; + for (auto const& val : muon.trk_hitPattern().hitPattern) { + if (val != static_cast(expectedMuonIntegralValues_[25] + iOffset + 10 * j)) { + throwWithMessage("analyzeMuons, hitPattern does not contain expected value"); + } + ++j; + } + ++i; + } + } + + void TestReadRun3Scouting::analyzeParticles(edm::Event const& iEvent) const { + auto const& particles = iEvent.get(particlesToken_); + unsigned int vectorSize = 2 + iEvent.id().event() % 4; + if (particles.size() != vectorSize) { + throwWithMessage("analyzeParticles, particles does not have expected size"); + } + unsigned int i = 0; + for (auto const& particle : particles) { + double offset = static_cast(iEvent.id().event() + i); + int iOffset = static_cast(iEvent.id().event() + i); + + if (particle.pt() != expectedParticleFloatingPointValues_[0] + offset) { + throwWithMessage("analyzeParticles, pt does not equal expected value"); + } + if (particle.eta() != expectedParticleFloatingPointValues_[1] + offset) { + throwWithMessage("analyzeParticles, eta does not equal expected value"); + } + if (particle.phi() != expectedParticleFloatingPointValues_[2] + offset) { + throwWithMessage("analyzeParticles, phi does not equal expected value"); + } + if (particle.pdgId() != expectedParticleIntegralValues_[0] + iOffset) { + throwWithMessage("analyzeParticles, pdgId does not equal expected value"); + } + if (particle.vertex() != expectedParticleIntegralValues_[1] + iOffset) { + throwWithMessage("analyzeParticles, vertex does not equal expected value"); + } + if (particle.normchi2() != expectedParticleFloatingPointValues_[3] + offset) { + throwWithMessage("analyzeParticles, normchi2 does not equal expected value"); + } + if (particle.dz() != expectedParticleFloatingPointValues_[4] + offset) { + throwWithMessage("analyzeParticles, dz does not equal expected value"); + } + if (particle.dxy() != expectedParticleFloatingPointValues_[5] + offset) { + throwWithMessage("analyzeParticles, dxy does not equal expected value"); + } + if (particle.dzsig() != expectedParticleFloatingPointValues_[6] + offset) { + throwWithMessage("analyzeParticles, dzsig does not equal expected value"); + } + if (particle.dxysig() != expectedParticleFloatingPointValues_[7] + offset) { + throwWithMessage("analyzeParticles, dxysig does not equal expected value"); + } + if (particle.lostInnerHits() != static_cast(expectedParticleIntegralValues_[2] + iOffset)) { + throwWithMessage("analyzeParticles, lostInnerHits does not equal expected value"); + } + if (particle.quality() != static_cast(expectedParticleIntegralValues_[3] + iOffset)) { + throwWithMessage("analyzeParticles, quality does not equal expected value"); + } + if (particle.trk_pt() != expectedParticleFloatingPointValues_[8] + offset) { + throwWithMessage("analyzeParticles, trk_pt does not equal expected value"); + } + if (particle.trk_eta() != expectedParticleFloatingPointValues_[9] + offset) { + throwWithMessage("analyzeParticles, trk_eta does not equal expected value"); + } + if (particle.trk_phi() != expectedParticleFloatingPointValues_[10] + offset) { + throwWithMessage("analyzeParticles, trk_phi does not equal expected value"); + } + if (particle.relative_trk_vars() != static_cast((expectedParticleIntegralValues_[4] + iOffset) % 2)) { + throwWithMessage("analyzeParticles, relative_trk_vars does not equal expected value"); + } + ++i; + } + } + + void TestReadRun3Scouting::analyzePFJets(edm::Event const& iEvent) const { + auto const& pfJets = iEvent.get(pfJetsToken_); + unsigned int vectorSize = 2 + iEvent.id().event() % 4; + if (pfJets.size() != vectorSize) { + throwWithMessage("analyzePFJets, pfJets does not have expected size"); + } + unsigned int i = 0; + for (auto const& pfJet : pfJets) { + double offset = static_cast(iEvent.id().event() + i); + int iOffset = static_cast(iEvent.id().event() + i); + + if (pfJet.pt() != expectedPFJetFloatingPointValues_[0] + offset) { + throwWithMessage("analyzePFJets, pt does not equal expected value"); + } + if (pfJet.eta() != expectedPFJetFloatingPointValues_[1] + offset) { + throwWithMessage("analyzePFJets, eta does not equal expected value"); + } + if (pfJet.phi() != expectedPFJetFloatingPointValues_[2] + offset) { + throwWithMessage("analyzePFJets, phi does not equal expected value"); + } + if (pfJet.m() != expectedPFJetFloatingPointValues_[3] + offset) { + throwWithMessage("analyzePFJets, m does not equal expected value"); + } + if (pfJet.jetArea() != expectedPFJetFloatingPointValues_[4] + offset) { + throwWithMessage("analyzePFJets, jetArea does not equal expected value"); + } + if (pfJet.chargedHadronEnergy() != expectedPFJetFloatingPointValues_[5] + offset) { + throwWithMessage("analyzePFJets, chargedHadronEnergy does not equal expected value"); + } + if (pfJet.neutralHadronEnergy() != expectedPFJetFloatingPointValues_[6] + offset) { + throwWithMessage("analyzePFJets, neutralHadronEnergy does not equal expected value"); + } + if (pfJet.photonEnergy() != expectedPFJetFloatingPointValues_[7] + offset) { + throwWithMessage("analyzePFJets, photonEnergy does not equal expected value"); + } + if (pfJet.electronEnergy() != expectedPFJetFloatingPointValues_[8] + offset) { + throwWithMessage("analyzePFJets, electronEnergy does not equal expected value"); + } + if (pfJet.muonEnergy() != expectedPFJetFloatingPointValues_[9] + offset) { + throwWithMessage("analyzePFJets, muonEnergy does not equal expected value"); + } + if (pfJet.HFHadronEnergy() != expectedPFJetFloatingPointValues_[10] + offset) { + throwWithMessage("analyzePFJets, HFHadronEnergy does not equal expected value"); + } + if (pfJet.HFEMEnergy() != expectedPFJetFloatingPointValues_[11] + offset) { + throwWithMessage("analyzePFJets, HFEMEnergy does not equal expected value"); + } + if (pfJet.chargedHadronMultiplicity() != expectedPFJetIntegralValues_[0] + iOffset) { + throwWithMessage("analyzePFJets, chargedHadronMultiplicity does not equal expected value"); + } + if (pfJet.neutralHadronMultiplicity() != expectedPFJetIntegralValues_[1] + iOffset) { + throwWithMessage("analyzePFJets, neutralHadronMultiplicity does not equal expected value"); + } + if (pfJet.photonMultiplicity() != expectedPFJetIntegralValues_[2] + iOffset) { + throwWithMessage("analyzePFJets, photonMultiplicity does not equal expected value"); + } + if (pfJet.electronMultiplicity() != expectedPFJetIntegralValues_[3] + iOffset) { + throwWithMessage("analyzePFJets, electronMultiplicity does not equal expected value"); + } + if (pfJet.muonMultiplicity() != expectedPFJetIntegralValues_[4] + iOffset) { + throwWithMessage("analyzePFJets, muonMultiplicity does not equal expected value"); + } + if (pfJet.HFHadronMultiplicity() != expectedPFJetIntegralValues_[5] + iOffset) { + throwWithMessage("analyzePFJets, HFHadronMultiplicity does not equal expected value"); + } + if (pfJet.HFEMMultiplicity() != expectedPFJetIntegralValues_[6] + iOffset) { + throwWithMessage("analyzePFJets, HFEMMultiplicity does not equal expected value"); + } + if (pfJet.HOEnergy() != expectedPFJetFloatingPointValues_[12] + offset) { + throwWithMessage("analyzePFJets, HOEnergy does not equal expected value"); + } + if (pfJet.csv() != expectedPFJetFloatingPointValues_[13] + offset) { + throwWithMessage("analyzePFJets, csv does not equal expected value"); + } + if (pfJet.mvaDiscriminator() != expectedPFJetFloatingPointValues_[14] + offset) { + throwWithMessage("analyzePFJets, mvaDiscriminator does not equal expected value"); + } + int j = 0; + for (auto const& val : pfJet.constituents()) { + if (val != expectedPFJetIntegralValues_[7] + iOffset + 10 * j) { + throwWithMessage("analyzePFJets, constituents does not contain expected value"); + } + ++j; + } + ++i; + } + } + + void TestReadRun3Scouting::analyzePhotons(edm::Event const& iEvent) const { + auto const& photons = iEvent.get(photonsToken_); + unsigned int vectorSize = 2 + iEvent.id().event() % 4; + if (photons.size() != vectorSize) { + throwWithMessage("analyzePhotons, photons does not have expected size"); + } + unsigned int i = 0; + for (auto const& photon : photons) { + double offset = static_cast(iEvent.id().event() + i); + int iOffset = static_cast(iEvent.id().event() + i); + + if (photon.pt() != expectedPhotonFloatingPointValues_[0] + offset) { + throwWithMessage("analyzePhotons, pt does not equal expected value"); + } + if (photon.eta() != expectedPhotonFloatingPointValues_[1] + offset) { + throwWithMessage("analyzePhotons, eta does not equal expected value"); + } + if (photon.phi() != expectedPhotonFloatingPointValues_[2] + offset) { + throwWithMessage("analyzePhotons, phi does not equal expected value"); + } + if (photon.m() != expectedPhotonFloatingPointValues_[3] + offset) { + throwWithMessage("analyzePhotons, m does not equal expected value"); + } + if (photon.sigmaIetaIeta() != expectedPhotonFloatingPointValues_[4] + offset) { + throwWithMessage("analyzePhotons, sigmaIetaIeta does not equal expected value"); + } + if (photon.hOverE() != expectedPhotonFloatingPointValues_[5] + offset) { + throwWithMessage("analyzePhotons, hOverE does not equal expected value"); + } + if (photon.ecalIso() != expectedPhotonFloatingPointValues_[6] + offset) { + throwWithMessage("analyzePhotons, ecalIso does not equal expected value"); + } + if (photon.hcalIso() != expectedPhotonFloatingPointValues_[7] + offset) { + throwWithMessage("analyzePhotons, hcalIso does not equal expected value"); + } + if (photon.trkIso() != expectedPhotonFloatingPointValues_[8] + offset) { + throwWithMessage("analyzePhotons, trkIso does not equal expected value"); + } + if (photon.r9() != expectedPhotonFloatingPointValues_[9] + offset) { + throwWithMessage("analyzePhotons, r9 does not equal expected value"); + } + if (photon.sMin() != expectedPhotonFloatingPointValues_[10] + offset) { + throwWithMessage("analyzePhotons, sMin does not equal expected value"); + } + if (photon.sMaj() != expectedPhotonFloatingPointValues_[11] + offset) { + throwWithMessage("analyzePhotons, sMaj does not equal expected value"); + } + if (photon.seedId() != static_cast(expectedPhotonIntegralValues_[0] + iOffset)) { + throwWithMessage("analyzePhotons, seedId does not equal expected value"); + } + + if (photon.energyMatrix().size() != vectorSize) { + throwWithMessage("analyzePhotons, energyMatrix does not have expected size"); + } + unsigned int j = 0; + for (auto const& val : photon.energyMatrix()) { + if (val != expectedPhotonFloatingPointValues_[12] + offset + 10 * j) { + throwWithMessage("analyzePhotons, energyMatrix does not contain expected value"); + } + ++j; + } + if (photon.detIds().size() != vectorSize) { + throwWithMessage("analyzePhotons, detIds does not have expected size"); + } + j = 0; + for (auto const& val : photon.detIds()) { + if (val != static_cast(expectedPhotonIntegralValues_[1] + iOffset + 10 * j)) { + throwWithMessage("analyzePhotons, detIds does not contain expected value"); + } + ++j; + } + if (photon.timingMatrix().size() != vectorSize) { + throwWithMessage("analyzePhotons, timingMatrix does not have expected size"); + } + j = 0; + for (auto const& val : photon.timingMatrix()) { + if (val != expectedPhotonFloatingPointValues_[13] + offset + 10 * j) { + throwWithMessage("analyzePhotons, timingMatrix does not contain expected value"); + } + ++j; + } + if (photon.rechitZeroSuppression() != static_cast((expectedPhotonIntegralValues_[2] + iOffset) % 2)) { + throwWithMessage("analyzePhotons, rechitZeroSuppression does not equal expected value"); + } + ++i; + } + } + + void TestReadRun3Scouting::analyzeTracks(edm::Event const& iEvent) const { + auto const& tracks = iEvent.get(tracksToken_); + unsigned int vectorSize = 2 + iEvent.id().event() % 4; + if (tracks.size() != vectorSize) { + throwWithMessage("analyzeTracks, tracks does not have expected size"); + } + unsigned int i = 0; + for (auto const& track : tracks) { + double offset = static_cast(iEvent.id().event() + i); + int iOffset = static_cast(iEvent.id().event() + i); + + if (track.tk_pt() != expectedTrackFloatingPointValues_[0] + offset) { + throwWithMessage("analyzeTracks, tk_pt does not equal expected value"); + } + if (track.tk_eta() != expectedTrackFloatingPointValues_[1] + offset) { + throwWithMessage("analyzeTracks, tk_eta does not equal expected value"); + } + if (track.tk_phi() != expectedTrackFloatingPointValues_[2] + offset) { + throwWithMessage("analyzeTracks, tk_phi does not equal expected value"); + } + if (track.tk_chi2() != expectedTrackFloatingPointValues_[3] + offset) { + throwWithMessage("analyzeTracks, tk_chi2 does not equal expected value"); + } + if (track.tk_ndof() != expectedTrackFloatingPointValues_[4] + offset) { + throwWithMessage("analyzeTracks, tk_ndof does not equal expected value"); + } + if (track.tk_charge() != expectedTrackIntegralValues_[0] + iOffset) { + throwWithMessage("analyzeTracks, tk_charge does not equal expected value"); + } + if (track.tk_dxy() != expectedTrackFloatingPointValues_[5] + offset) { + throwWithMessage("analyzeTracks, tk_dxy does not equal expected value"); + } + if (track.tk_dz() != expectedTrackFloatingPointValues_[6] + offset) { + throwWithMessage("analyzeTracks, tk_dz does not equal expected value"); + } + if (track.tk_nValidPixelHits() != expectedTrackIntegralValues_[1] + iOffset) { + throwWithMessage("analyzeTracks, tk_nValidPixelHits does not equal expected value"); + } + if (track.tk_nTrackerLayersWithMeasurement() != expectedTrackIntegralValues_[2] + iOffset) { + throwWithMessage("analyzeTracks, tk_nTrackerLayersWithMeasurement does not equal expected value"); + } + if (track.tk_nValidStripHits() != expectedTrackIntegralValues_[3] + iOffset) { + throwWithMessage("analyzeTracks, tk_nValidStripHits does not equal expected value"); + } + if (track.tk_qoverp() != expectedTrackFloatingPointValues_[7] + offset) { + throwWithMessage("analyzeTracks, tk_qoverp does not equal expected value"); + } + if (track.tk_lambda() != expectedTrackFloatingPointValues_[8] + offset) { + throwWithMessage("analyzeTracks, tk_lambda does not equal expected value"); + } + if (track.tk_dxy_Error() != expectedTrackFloatingPointValues_[9] + offset) { + throwWithMessage("analyzeTracks, tk_dxy_Error does not equal expected value"); + } + if (track.tk_dz_Error() != expectedTrackFloatingPointValues_[10] + offset) { + throwWithMessage("analyzeTracks, tk_dz_Error does not equal expected value"); + } + if (track.tk_qoverp_Error() != expectedTrackFloatingPointValues_[11] + offset) { + throwWithMessage("analyzeTracks, tk_qoverp_Error does not equal expected value"); + } + if (track.tk_lambda_Error() != expectedTrackFloatingPointValues_[12] + offset) { + throwWithMessage("analyzeTracks, tk_lambda_Error does not equal expected value"); + } + if (track.tk_phi_Error() != expectedTrackFloatingPointValues_[13] + offset) { + throwWithMessage("analyzeTracks, tk_phi_Error does not equal expected value"); + } + if (track.tk_dsz() != expectedTrackFloatingPointValues_[14] + offset) { + throwWithMessage("analyzeTracks, tk_dsz does not equal expected value"); + } + if (track.tk_dsz_Error() != expectedTrackFloatingPointValues_[15] + offset) { + throwWithMessage("analyzeTracks, tk_dsz_Error does not equal expected value"); + } + if (track.tk_qoverp_lambda_cov() != expectedTrackFloatingPointValues_[16] + offset) { + throwWithMessage("analyzeTracks, tk_qoverp_lambda_cov does not equal expected value"); + } + if (track.tk_qoverp_phi_cov() != expectedTrackFloatingPointValues_[17] + offset) { + throwWithMessage("analyzeTracks, tk_qoverp_phi_cov does not equal expected value"); + } + if (track.tk_qoverp_dxy_cov() != expectedTrackFloatingPointValues_[18] + offset) { + throwWithMessage("analyzeTracks, tk_qoverp_dxy_cov does not equal expected value"); + } + if (track.tk_qoverp_dsz_cov() != expectedTrackFloatingPointValues_[19] + offset) { + throwWithMessage("analyzeTracks, tk_qoverp_dsz_cov does not equal expected value"); + } + if (track.tk_lambda_phi_cov() != expectedTrackFloatingPointValues_[20] + offset) { + throwWithMessage("analyzeTracks, tk_lambda_phi_cov does not equal expected value"); + } + if (track.tk_lambda_dxy_cov() != expectedTrackFloatingPointValues_[21] + offset) { + throwWithMessage("analyzeTracks, tk_lambda_dxy_cov does not equal expected value"); + } + if (track.tk_lambda_dsz_cov() != expectedTrackFloatingPointValues_[22] + offset) { + throwWithMessage("analyzeTracks, tk_lambda_dsz_cov does not equal expected value"); + } + if (track.tk_phi_dxy_cov() != expectedTrackFloatingPointValues_[23] + offset) { + throwWithMessage("analyzeTracks, tk_phi_dxy_cov does not equal expected value"); + } + if (track.tk_phi_dsz_cov() != expectedTrackFloatingPointValues_[24] + offset) { + throwWithMessage("analyzeTracks, tk_phi_dsz_cov does not equal expected value"); + } + if (track.tk_dxy_dsz_cov() != expectedTrackFloatingPointValues_[25] + offset) { + throwWithMessage("analyzeTracks, tk_dxy_dsz_cov does not equal expected value"); + } + if (track.tk_vtxInd() != expectedTrackIntegralValues_[4] + iOffset) { + throwWithMessage("analyzeTracks, tk_vtxInd does not equal expected value"); + } + if (track.tk_vx() != expectedTrackFloatingPointValues_[26] + offset) { + throwWithMessage("analyzeTracks, tk_vx does not equal expected value"); + } + if (track.tk_vy() != expectedTrackFloatingPointValues_[27] + offset) { + throwWithMessage("analyzeTracks, tk_vy does not equal expected value"); + } + if (track.tk_vz() != expectedTrackFloatingPointValues_[28] + offset) { + throwWithMessage("analyzeTracks, float tk_vz does not equal expected value"); + } + ++i; + } + } + + void TestReadRun3Scouting::analyzeVertexes(edm::Event const& iEvent) const { + auto const& vertexes = iEvent.get(vertexesToken_); + unsigned int vectorSize = 2 + iEvent.id().event() % 4; + if (vertexes.size() != vectorSize) { + throwWithMessage("analyzeVertexes, vertexes does not have expected size"); + } + unsigned int i = 0; + for (auto const& vertex : vertexes) { + double offset = static_cast(iEvent.id().event() + i); + int iOffset = static_cast(iEvent.id().event() + i); + + if (vertex.x() != expectedVertexFloatingPointValues_[0] + offset) { + throwWithMessage("analyzeVertexes, x does not equal expected value"); + } + if (vertex.y() != expectedVertexFloatingPointValues_[1] + offset) { + throwWithMessage("analyzeVertexes, y does not equal expected value"); + } + if (vertex.z() != expectedVertexFloatingPointValues_[2] + offset) { + throwWithMessage("analyzeVertexes, z does not equal expected value"); + } + if (vertex.zError() != expectedVertexFloatingPointValues_[3] + offset) { + throwWithMessage("analyzeVertexes, zError does not equal expected value"); + } + if (vertex.xError() != expectedVertexFloatingPointValues_[4] + offset) { + throwWithMessage("analyzeVertexes, xError does not equal expected value"); + } + if (vertex.yError() != expectedVertexFloatingPointValues_[5] + offset) { + throwWithMessage("analyzeVertexes, yError does not equal expected value"); + } + if (vertex.tracksSize() != expectedVertexIntegralValues_[0] + iOffset) { + throwWithMessage("analyzeVertexes, tracksSize does not equal expected value"); + } + if (vertex.chi2() != expectedVertexFloatingPointValues_[6] + offset) { + throwWithMessage("analyzeVertexes, chi2 does not equal expected value"); + } + if (vertex.ndof() != expectedVertexIntegralValues_[1] + iOffset) { + throwWithMessage("analyzeVertexes, ndof does not equal expected value"); + } + if (vertex.isValidVtx() != static_cast((expectedVertexIntegralValues_[2] + iOffset) % 2)) { + throwWithMessage("analyzeVertexes, isValidVtx does not equal expected value"); + } + ++i; + } + } + + void TestReadRun3Scouting::throwWithMessageFromConstructor(const char* msg) const { + throw cms::Exception("TestFailure") << "TestReadRun3Scouting constructor, " << msg; + } + + void TestReadRun3Scouting::throwWithMessage(const char* msg) const { + throw cms::Exception("TestFailure") << "TestReadRun3Scouting::analyze, " << msg; + } + +} // namespace edmtest + +using edmtest::TestReadRun3Scouting; +DEFINE_FWK_MODULE(TestReadRun3Scouting); diff --git a/DataFormats/Scouting/test/TestRun3ScoutingFormats.sh b/DataFormats/Scouting/test/TestRun3ScoutingFormats.sh new file mode 100755 index 0000000000000..40ddd7df41603 --- /dev/null +++ b/DataFormats/Scouting/test/TestRun3ScoutingFormats.sh @@ -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 diff --git a/DataFormats/Scouting/test/TestWriteRun3Scouting.cc b/DataFormats/Scouting/test/TestWriteRun3Scouting.cc new file mode 100644 index 0000000000000..ae3f07be99cb6 --- /dev/null +++ b/DataFormats/Scouting/test/TestWriteRun3Scouting.cc @@ -0,0 +1,579 @@ +// -*- C++ -*- +// +// Package: DataFormats/Scouting +// Class: TestWriteRun3Scouting +// +/**\class edmtest::TestWriteRun3Scouting + Description: Used as part of tests that ensure the Run 3 scouting + data formats can be persistently written and in a subsequent process + read. First, this is done using the current release version for writing + and reading. In addition, the output file of the write process should + be saved permanently each time a Run 3 Scouting persistent data + format changes. In unit tests, we read each of those saved files to verify + that the current releases can read older versions of the data format. +*/ +// Original Author: W. David Dagenhart +// Created: 17 May 2023 + +#include "DataFormats/Scouting/interface/Run3ScoutingCaloJet.h" +#include "DataFormats/Scouting/interface/Run3ScoutingElectron.h" +#include "DataFormats/Scouting/interface/Run3ScoutingHitPatternPOD.h" +#include "DataFormats/Scouting/interface/Run3ScoutingMuon.h" +#include "DataFormats/Scouting/interface/Run3ScoutingParticle.h" +#include "DataFormats/Scouting/interface/Run3ScoutingPFJet.h" +#include "DataFormats/Scouting/interface/Run3ScoutingPhoton.h" +#include "DataFormats/Scouting/interface/Run3ScoutingTrack.h" +#include "DataFormats/Scouting/interface/Run3ScoutingVertex.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/global/EDProducer.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" +#include "FWCore/Utilities/interface/EDPutToken.h" +#include "FWCore/Utilities/interface/Exception.h" +#include "FWCore/Utilities/interface/StreamID.h" + +#include +#include +#include + +namespace edmtest { + + class TestWriteRun3Scouting : public edm::global::EDProducer<> { + public: + TestWriteRun3Scouting(edm::ParameterSet const&); + void produce(edm::StreamID, edm::Event&, edm::EventSetup const&) const override; + static void fillDescriptions(edm::ConfigurationDescriptions&); + + private: + void produceCaloJets(edm::Event&) const; + void produceElectrons(edm::Event&) const; + void produceMuons(edm::Event&) const; + void produceParticles(edm::Event&) const; + void producePFJets(edm::Event&) const; + void producePhotons(edm::Event&) const; + void produceTracks(edm::Event&) const; + void produceVertexes(edm::Event&) const; + + void throwWithMessage(const char*) const; + + const std::vector caloJetsValues_; + const edm::EDPutTokenT> caloJetsPutToken_; + + const std::vector electronsFloatingPointValues_; + const std::vector electronsIntegralValues_; + const edm::EDPutTokenT> electronsPutToken_; + + const std::vector muonsFloatingPointValues_; + const std::vector muonsIntegralValues_; + const edm::EDPutTokenT> muonsPutToken_; + + const std::vector particlesFloatingPointValues_; + const std::vector particlesIntegralValues_; + const edm::EDPutTokenT> particlesPutToken_; + + const std::vector pfJetsFloatingPointValues_; + const std::vector pfJetsIntegralValues_; + const edm::EDPutTokenT> pfJetsPutToken_; + + const std::vector photonsFloatingPointValues_; + const std::vector photonsIntegralValues_; + const edm::EDPutTokenT> photonsPutToken_; + + const std::vector tracksFloatingPointValues_; + const std::vector tracksIntegralValues_; + const edm::EDPutTokenT> tracksPutToken_; + + const std::vector vertexesFloatingPointValues_; + const std::vector vertexesIntegralValues_; + const edm::EDPutTokenT> vertexesPutToken_; + }; + + TestWriteRun3Scouting::TestWriteRun3Scouting(edm::ParameterSet const& iPSet) + : caloJetsValues_(iPSet.getParameter>("caloJetsValues")), + caloJetsPutToken_(produces()), + electronsFloatingPointValues_(iPSet.getParameter>("electronsFloatingPointValues")), + electronsIntegralValues_(iPSet.getParameter>("electronsIntegralValues")), + electronsPutToken_(produces()), + muonsFloatingPointValues_(iPSet.getParameter>("muonsFloatingPointValues")), + muonsIntegralValues_(iPSet.getParameter>("muonsIntegralValues")), + muonsPutToken_(produces()), + particlesFloatingPointValues_(iPSet.getParameter>("particlesFloatingPointValues")), + particlesIntegralValues_(iPSet.getParameter>("particlesIntegralValues")), + particlesPutToken_(produces()), + pfJetsFloatingPointValues_(iPSet.getParameter>("pfJetsFloatingPointValues")), + pfJetsIntegralValues_(iPSet.getParameter>("pfJetsIntegralValues")), + pfJetsPutToken_(produces()), + photonsFloatingPointValues_(iPSet.getParameter>("photonsFloatingPointValues")), + photonsIntegralValues_(iPSet.getParameter>("photonsIntegralValues")), + photonsPutToken_(produces()), + tracksFloatingPointValues_(iPSet.getParameter>("tracksFloatingPointValues")), + tracksIntegralValues_(iPSet.getParameter>("tracksIntegralValues")), + tracksPutToken_(produces()), + vertexesFloatingPointValues_(iPSet.getParameter>("vertexesFloatingPointValues")), + vertexesIntegralValues_(iPSet.getParameter>("vertexesIntegralValues")), + vertexesPutToken_(produces()) { + if (caloJetsValues_.size() != 16) { + throwWithMessage("caloJetsValues must have 16 elements and it does not"); + } + if (electronsFloatingPointValues_.size() != 25) { + throwWithMessage("electronsFloatingPointValues must have 25 elements and it does not"); + } + if (electronsIntegralValues_.size() != 6) { + throwWithMessage("electronsIntegralValues must have 6 elements and it does not"); + } + if (muonsFloatingPointValues_.size() != 37) { + throwWithMessage("muonsFloatingPointValues must have 37 elements and it does not"); + } + if (muonsIntegralValues_.size() != 26) { + throwWithMessage("muonsIntegralValues must have 26 elements and it does not"); + } + if (particlesFloatingPointValues_.size() != 11) { + throwWithMessage("particlesFloatingPointValues must have 11 elements and it does not"); + } + if (particlesIntegralValues_.size() != 5) { + throwWithMessage("particlesIntegralValues must have 5 elements and it does not"); + } + if (pfJetsFloatingPointValues_.size() != 15) { + throwWithMessage("pfJetsFloatingPointValues must have 15 elements and it does not"); + } + if (pfJetsIntegralValues_.size() != 8) { + throwWithMessage("pfJetsIntegralValues must have 8 elements and it does not"); + } + if (photonsFloatingPointValues_.size() != 14) { + throwWithMessage("photonsFloatingPointValues must have 14 elements and it does not"); + } + if (photonsIntegralValues_.size() != 3) { + throwWithMessage("photonsIntegralValues must have 3 elements and it does not"); + } + if (tracksFloatingPointValues_.size() != 29) { + throwWithMessage("tracksFloatingPointValues must have 29 elements and it does not"); + } + if (tracksIntegralValues_.size() != 5) { + throwWithMessage("tracksIntegralValues must have 5 elements and it does not"); + } + if (vertexesFloatingPointValues_.size() != 7) { + throwWithMessage("vertexesFloatingPointValues must have 7 elements and it does not"); + } + if (vertexesIntegralValues_.size() != 3) { + throwWithMessage("vertexesIntegralValues must have 3 elements and it does not"); + } + } + + void TestWriteRun3Scouting::produce(edm::StreamID, edm::Event& iEvent, edm::EventSetup const&) const { + // Fill Run3 scouting objects. Make sure all the containers inside + // of them have something in them (not empty). The values are meaningless. + // We will later check that after writing these objects to persistent storage + // and then reading them in a later process we obtain matching values for + // all this content. + + produceCaloJets(iEvent); + produceElectrons(iEvent); + produceMuons(iEvent); + produceParticles(iEvent); + producePFJets(iEvent); + producePhotons(iEvent); + produceTracks(iEvent); + produceVertexes(iEvent); + } + + void TestWriteRun3Scouting::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + edm::ParameterSetDescription desc; + desc.add>("caloJetsValues"); + desc.add>("electronsFloatingPointValues"); + desc.add>("electronsIntegralValues"); + desc.add>("muonsFloatingPointValues"); + desc.add>("muonsIntegralValues"); + desc.add>("particlesFloatingPointValues"); + desc.add>("particlesIntegralValues"); + desc.add>("pfJetsFloatingPointValues"); + desc.add>("pfJetsIntegralValues"); + desc.add>("photonsFloatingPointValues"); + desc.add>("photonsIntegralValues"); + desc.add>("tracksFloatingPointValues"); + desc.add>("tracksIntegralValues"); + desc.add>("vertexesFloatingPointValues"); + desc.add>("vertexesIntegralValues"); + descriptions.addDefault(desc); + } + + void TestWriteRun3Scouting::produceCaloJets(edm::Event& iEvent) const { + auto run3ScoutingCaloJets = std::make_unique>(); + unsigned int vectorSize = 2 + iEvent.id().event() % 4; + run3ScoutingCaloJets->reserve(vectorSize); + for (unsigned int i = 0; i < vectorSize; ++i) { + double offset = static_cast(iEvent.id().event() + i); + run3ScoutingCaloJets->emplace_back(static_cast(caloJetsValues_[0] + offset), + static_cast(caloJetsValues_[1] + offset), + static_cast(caloJetsValues_[2] + offset), + static_cast(caloJetsValues_[3] + offset), + static_cast(caloJetsValues_[4] + offset), + static_cast(caloJetsValues_[5] + offset), + static_cast(caloJetsValues_[6] + offset), + static_cast(caloJetsValues_[7] + offset), + static_cast(caloJetsValues_[8] + offset), + static_cast(caloJetsValues_[9] + offset), + static_cast(caloJetsValues_[10] + offset), + static_cast(caloJetsValues_[11] + offset), + static_cast(caloJetsValues_[12] + offset), + static_cast(caloJetsValues_[13] + offset), + static_cast(caloJetsValues_[14] + offset), + static_cast(caloJetsValues_[15] + offset)); + } + iEvent.put(caloJetsPutToken_, std::move(run3ScoutingCaloJets)); + } + + void TestWriteRun3Scouting::produceElectrons(edm::Event& iEvent) const { + auto run3ScoutingElectrons = std::make_unique>(); + unsigned int vectorSize = 2 + iEvent.id().event() % 4; + run3ScoutingElectrons->reserve(vectorSize); + for (unsigned int i = 0; i < vectorSize; ++i) { + double offset = static_cast(iEvent.id().event() + i); + int iOffset = static_cast(iEvent.id().event() + i); + + // Note the first seven of these vectors use an out of sequence index + // (starting at 19 or 5) because they are data members added in a format + // change. In the CMSSW_12_4_0 version, they didn't exist. + // Also the index values 4 and 5 in electronsFloatingPointValues_ + // and index 1 in electronsIntegralValues_ are not used because + // those data members were dropped in the same format change. + std::vector trkd0; + std::vector trkdz; + std::vector trkpt; + std::vector trketa; + std::vector trkphi; + std::vector trkchi2overndf; + std::vector trkcharge; + std::vector energyMatrix; + std::vector detIds; + std::vector timingMatrix; + trkd0.reserve(vectorSize); + trkdz.reserve(vectorSize); + trkpt.reserve(vectorSize); + trketa.reserve(vectorSize); + trkphi.reserve(vectorSize); + trkchi2overndf.reserve(vectorSize); + trkcharge.reserve(vectorSize); + energyMatrix.reserve(vectorSize); + detIds.reserve(vectorSize); + timingMatrix.reserve(vectorSize); + for (unsigned int j = 0; j < vectorSize; ++j) { + trkd0.push_back(static_cast(electronsFloatingPointValues_[19] + offset + j * 10)); + trkdz.push_back(static_cast(electronsFloatingPointValues_[20] + offset + j * 10)); + trkpt.push_back(static_cast(electronsFloatingPointValues_[21] + offset + j * 10)); + trketa.push_back(static_cast(electronsFloatingPointValues_[22] + offset + j * 10)); + trkphi.push_back(static_cast(electronsFloatingPointValues_[23] + offset + j * 10)); + trkchi2overndf.push_back(static_cast(electronsFloatingPointValues_[24] + offset + j * 10)); + trkcharge.push_back(static_cast(electronsIntegralValues_[5] + offset + j * 10)); + energyMatrix.push_back(static_cast(electronsFloatingPointValues_[17] + offset + j * 10)); + detIds.push_back(static_cast(electronsIntegralValues_[3] + iOffset + j * 10)); + timingMatrix.push_back(static_cast(electronsFloatingPointValues_[18] + offset + j * 10)); + } + run3ScoutingElectrons->emplace_back(static_cast(electronsFloatingPointValues_[0] + offset), + static_cast(electronsFloatingPointValues_[1] + offset), + static_cast(electronsFloatingPointValues_[2] + offset), + static_cast(electronsFloatingPointValues_[3] + offset), + std::move(trkd0), + std::move(trkdz), + std::move(trkpt), + std::move(trketa), + std::move(trkphi), + std::move(trkchi2overndf), + static_cast(electronsFloatingPointValues_[6] + offset), + static_cast(electronsFloatingPointValues_[7] + offset), + static_cast(electronsFloatingPointValues_[8] + offset), + static_cast(electronsFloatingPointValues_[9] + offset), + static_cast(electronsFloatingPointValues_[10] + offset), + electronsIntegralValues_[0] + iOffset, + std::move(trkcharge), + static_cast(electronsFloatingPointValues_[11] + offset), + static_cast(electronsFloatingPointValues_[12] + offset), + static_cast(electronsFloatingPointValues_[13] + offset), + static_cast(electronsFloatingPointValues_[14] + offset), + static_cast(electronsFloatingPointValues_[15] + offset), + static_cast(electronsFloatingPointValues_[16] + offset), + static_cast(electronsIntegralValues_[2] + iOffset), + std::move(energyMatrix), + std::move(detIds), + std::move(timingMatrix), + static_cast((electronsIntegralValues_[4] + iOffset) % 2)); + } + iEvent.put(electronsPutToken_, std::move(run3ScoutingElectrons)); + } + + void TestWriteRun3Scouting::produceMuons(edm::Event& iEvent) const { + auto run3ScoutingMuons = std::make_unique>(); + unsigned int vectorSize = 2 + iEvent.id().event() % 4; + run3ScoutingMuons->reserve(vectorSize); + for (unsigned int i = 0; i < vectorSize; ++i) { + double offset = static_cast(iEvent.id().event() + i); + int iOffset = static_cast(iEvent.id().event() + i); + + std::vector vtxIndx; + std::vector hitPattern; + vtxIndx.reserve(vectorSize); + hitPattern.reserve(vectorSize); + for (unsigned int j = 0; j < vectorSize; ++j) { + vtxIndx.push_back(static_cast(muonsIntegralValues_[17] + iOffset + j * 10)); + hitPattern.push_back(static_cast(muonsIntegralValues_[25] + iOffset + j * 10)); + } + + Run3ScoutingHitPatternPOD run3ScoutingHitPatternPOD; + run3ScoutingHitPatternPOD.hitCount = static_cast(muonsIntegralValues_[18] + iOffset); + run3ScoutingHitPatternPOD.beginTrackHits = static_cast(muonsIntegralValues_[19] + iOffset); + run3ScoutingHitPatternPOD.endTrackHits = static_cast(muonsIntegralValues_[20] + iOffset); + run3ScoutingHitPatternPOD.beginInner = static_cast(muonsIntegralValues_[21] + iOffset); + run3ScoutingHitPatternPOD.endInner = static_cast(muonsIntegralValues_[22] + iOffset); + run3ScoutingHitPatternPOD.beginOuter = static_cast(muonsIntegralValues_[23] + iOffset); + run3ScoutingHitPatternPOD.endOuter = static_cast(muonsIntegralValues_[24] + iOffset); + run3ScoutingHitPatternPOD.hitPattern = std::move(hitPattern); + + run3ScoutingMuons->emplace_back(static_cast(muonsFloatingPointValues_[0] + offset), + static_cast(muonsFloatingPointValues_[1] + offset), + static_cast(muonsFloatingPointValues_[2] + offset), + static_cast(muonsFloatingPointValues_[3] + offset), + static_cast(muonsIntegralValues_[0] + iOffset), + muonsIntegralValues_[1] + iOffset, + static_cast(muonsFloatingPointValues_[4] + offset), + static_cast(muonsFloatingPointValues_[5] + offset), + static_cast(muonsFloatingPointValues_[6] + offset), + static_cast(muonsFloatingPointValues_[7] + offset), + muonsIntegralValues_[2] + iOffset, + muonsIntegralValues_[3] + iOffset, + muonsIntegralValues_[4] + iOffset, + muonsIntegralValues_[5] + iOffset, + muonsIntegralValues_[6] + iOffset, + muonsIntegralValues_[7] + iOffset, + muonsIntegralValues_[8] + iOffset, + static_cast(muonsIntegralValues_[9] + iOffset), + static_cast(muonsIntegralValues_[10] + iOffset), + muonsIntegralValues_[11] + iOffset, + static_cast(muonsIntegralValues_[12] + iOffset), + muonsIntegralValues_[13] + iOffset, + muonsIntegralValues_[14] + iOffset, + muonsIntegralValues_[15] + iOffset, + muonsIntegralValues_[16] + iOffset, + static_cast(muonsFloatingPointValues_[8] + offset), + static_cast(muonsFloatingPointValues_[9] + offset), + static_cast(muonsFloatingPointValues_[10] + offset), + static_cast(muonsFloatingPointValues_[11] + offset), + static_cast(muonsFloatingPointValues_[12] + offset), + static_cast(muonsFloatingPointValues_[13] + offset), + static_cast(muonsFloatingPointValues_[14] + offset), + static_cast(muonsFloatingPointValues_[15] + offset), + static_cast(muonsFloatingPointValues_[16] + offset), + static_cast(muonsFloatingPointValues_[17] + offset), + static_cast(muonsFloatingPointValues_[18] + offset), + static_cast(muonsFloatingPointValues_[19] + offset), + static_cast(muonsFloatingPointValues_[20] + offset), + static_cast(muonsFloatingPointValues_[21] + offset), + static_cast(muonsFloatingPointValues_[22] + offset), + static_cast(muonsFloatingPointValues_[23] + offset), + static_cast(muonsFloatingPointValues_[24] + offset), + static_cast(muonsFloatingPointValues_[25] + offset), + static_cast(muonsFloatingPointValues_[26] + offset), + static_cast(muonsFloatingPointValues_[27] + offset), + static_cast(muonsFloatingPointValues_[28] + offset), + static_cast(muonsFloatingPointValues_[29] + offset), + static_cast(muonsFloatingPointValues_[30] + offset), + static_cast(muonsFloatingPointValues_[31] + offset), + static_cast(muonsFloatingPointValues_[32] + offset), + static_cast(muonsFloatingPointValues_[33] + offset), + static_cast(muonsFloatingPointValues_[34] + offset), + static_cast(muonsFloatingPointValues_[35] + offset), + static_cast(muonsFloatingPointValues_[36] + offset), + std::move(vtxIndx), + std::move(run3ScoutingHitPatternPOD)); + } + iEvent.put(muonsPutToken_, std::move(run3ScoutingMuons)); + } + + void TestWriteRun3Scouting::produceParticles(edm::Event& iEvent) const { + auto run3ScoutingParticles = std::make_unique>(); + unsigned int vectorSize = 2 + iEvent.id().event() % 4; + run3ScoutingParticles->reserve(vectorSize); + for (unsigned int i = 0; i < vectorSize; ++i) { + double offset = static_cast(iEvent.id().event() + i); + int iOffset = static_cast(iEvent.id().event() + i); + run3ScoutingParticles->emplace_back(static_cast(particlesFloatingPointValues_[0] + offset), + static_cast(particlesFloatingPointValues_[1] + offset), + static_cast(particlesFloatingPointValues_[2] + offset), + particlesIntegralValues_[0] + iOffset, + particlesIntegralValues_[1] + iOffset, + static_cast(particlesFloatingPointValues_[3] + offset), + static_cast(particlesFloatingPointValues_[4] + offset), + static_cast(particlesFloatingPointValues_[5] + offset), + static_cast(particlesFloatingPointValues_[6] + offset), + static_cast(particlesFloatingPointValues_[7] + offset), + static_cast(particlesIntegralValues_[2] + iOffset), + static_cast(particlesIntegralValues_[3] + iOffset), + static_cast(particlesFloatingPointValues_[8] + offset), + static_cast(particlesFloatingPointValues_[9] + offset), + static_cast(particlesFloatingPointValues_[10] + offset), + static_cast((particlesIntegralValues_[4] + iOffset) % 2)); + } + iEvent.put(particlesPutToken_, std::move(run3ScoutingParticles)); + } + + void TestWriteRun3Scouting::producePFJets(edm::Event& iEvent) const { + auto run3ScoutingPFJets = std::make_unique>(); + unsigned int vectorSize = 2 + iEvent.id().event() % 4; + run3ScoutingPFJets->reserve(vectorSize); + + for (unsigned int i = 0; i < vectorSize; ++i) { + double offset = static_cast(iEvent.id().event() + i); + int iOffset = static_cast(iEvent.id().event() + i); + + std::vector constituents; + constituents.reserve(vectorSize); + for (unsigned int j = 0; j < vectorSize; ++j) { + constituents.push_back(static_cast(pfJetsIntegralValues_[7] + iOffset + j * 10)); + } + + run3ScoutingPFJets->emplace_back(static_cast(pfJetsFloatingPointValues_[0] + offset), + static_cast(pfJetsFloatingPointValues_[1] + offset), + static_cast(pfJetsFloatingPointValues_[2] + offset), + static_cast(pfJetsFloatingPointValues_[3] + offset), + static_cast(pfJetsFloatingPointValues_[4] + offset), + static_cast(pfJetsFloatingPointValues_[5] + offset), + static_cast(pfJetsFloatingPointValues_[6] + offset), + static_cast(pfJetsFloatingPointValues_[7] + offset), + static_cast(pfJetsFloatingPointValues_[8] + offset), + static_cast(pfJetsFloatingPointValues_[9] + offset), + static_cast(pfJetsFloatingPointValues_[10] + offset), + static_cast(pfJetsFloatingPointValues_[11] + offset), + pfJetsIntegralValues_[0] + iOffset, + pfJetsIntegralValues_[1] + iOffset, + pfJetsIntegralValues_[2] + iOffset, + pfJetsIntegralValues_[3] + iOffset, + pfJetsIntegralValues_[4] + iOffset, + pfJetsIntegralValues_[5] + iOffset, + pfJetsIntegralValues_[6] + iOffset, + static_cast(pfJetsFloatingPointValues_[12] + offset), + static_cast(pfJetsFloatingPointValues_[13] + offset), + static_cast(pfJetsFloatingPointValues_[14] + offset), + std::move(constituents)); + } + iEvent.put(pfJetsPutToken_, std::move(run3ScoutingPFJets)); + } + + void TestWriteRun3Scouting::producePhotons(edm::Event& iEvent) const { + auto run3ScoutingPhotons = std::make_unique>(); + unsigned int vectorSize = 2 + iEvent.id().event() % 4; + run3ScoutingPhotons->reserve(vectorSize); + for (unsigned int i = 0; i < vectorSize; ++i) { + double offset = static_cast(iEvent.id().event() + i); + int iOffset = static_cast(iEvent.id().event() + i); + + std::vector energyMatrix; + std::vector detIds; + std::vector timingMatrix; + energyMatrix.reserve(vectorSize); + detIds.reserve(vectorSize); + timingMatrix.reserve(vectorSize); + for (unsigned int j = 0; j < vectorSize; ++j) { + energyMatrix.push_back(static_cast(photonsFloatingPointValues_[12] + offset + j * 10)); + detIds.push_back(static_cast(photonsIntegralValues_[1] + iOffset + j * 10)); + timingMatrix.push_back(static_cast(photonsFloatingPointValues_[13] + offset + j * 10)); + } + run3ScoutingPhotons->emplace_back(static_cast(photonsFloatingPointValues_[0] + offset), + static_cast(photonsFloatingPointValues_[1] + offset), + static_cast(photonsFloatingPointValues_[2] + offset), + static_cast(photonsFloatingPointValues_[3] + offset), + static_cast(photonsFloatingPointValues_[4] + offset), + static_cast(photonsFloatingPointValues_[5] + offset), + static_cast(photonsFloatingPointValues_[6] + offset), + static_cast(photonsFloatingPointValues_[7] + offset), + static_cast(photonsFloatingPointValues_[8] + offset), + static_cast(photonsFloatingPointValues_[9] + offset), + static_cast(photonsFloatingPointValues_[10] + offset), + static_cast(photonsFloatingPointValues_[11] + offset), + static_cast(photonsIntegralValues_[0] + iOffset), + std::move(energyMatrix), + std::move(detIds), + std::move(timingMatrix), + static_cast((photonsIntegralValues_[2] + iOffset) % 2)); + } + iEvent.put(photonsPutToken_, std::move(run3ScoutingPhotons)); + } + + void TestWriteRun3Scouting::produceTracks(edm::Event& iEvent) const { + auto run3ScoutingTracks = std::make_unique>(); + unsigned int vectorSize = 2 + iEvent.id().event() % 4; + run3ScoutingTracks->reserve(vectorSize); + + for (unsigned int i = 0; i < vectorSize; ++i) { + double offset = static_cast(iEvent.id().event() + i); + int iOffset = static_cast(iEvent.id().event() + i); + + run3ScoutingTracks->emplace_back(static_cast(tracksFloatingPointValues_[0] + offset), + static_cast(tracksFloatingPointValues_[1] + offset), + static_cast(tracksFloatingPointValues_[2] + offset), + static_cast(tracksFloatingPointValues_[3] + offset), + static_cast(tracksFloatingPointValues_[4] + offset), + tracksIntegralValues_[0] + iOffset, + static_cast(tracksFloatingPointValues_[5] + offset), + static_cast(tracksFloatingPointValues_[6] + offset), + tracksIntegralValues_[1] + iOffset, + tracksIntegralValues_[2] + iOffset, + tracksIntegralValues_[3] + iOffset, + static_cast(tracksFloatingPointValues_[7] + offset), + static_cast(tracksFloatingPointValues_[8] + offset), + static_cast(tracksFloatingPointValues_[9] + offset), + static_cast(tracksFloatingPointValues_[10] + offset), + static_cast(tracksFloatingPointValues_[11] + offset), + static_cast(tracksFloatingPointValues_[12] + offset), + static_cast(tracksFloatingPointValues_[13] + offset), + static_cast(tracksFloatingPointValues_[14] + offset), + static_cast(tracksFloatingPointValues_[15] + offset), + static_cast(tracksFloatingPointValues_[16] + offset), + static_cast(tracksFloatingPointValues_[17] + offset), + static_cast(tracksFloatingPointValues_[18] + offset), + static_cast(tracksFloatingPointValues_[19] + offset), + static_cast(tracksFloatingPointValues_[20] + offset), + static_cast(tracksFloatingPointValues_[21] + offset), + static_cast(tracksFloatingPointValues_[22] + offset), + static_cast(tracksFloatingPointValues_[23] + offset), + static_cast(tracksFloatingPointValues_[24] + offset), + static_cast(tracksFloatingPointValues_[25] + offset), + tracksIntegralValues_[4] + iOffset, + static_cast(tracksFloatingPointValues_[26] + offset), + static_cast(tracksFloatingPointValues_[27] + offset), + static_cast(tracksFloatingPointValues_[28] + offset)); + } + iEvent.put(tracksPutToken_, std::move(run3ScoutingTracks)); + } + + void TestWriteRun3Scouting::produceVertexes(edm::Event& iEvent) const { + auto run3ScoutingVertexes = std::make_unique>(); + unsigned int vectorSize = 2 + iEvent.id().event() % 4; + run3ScoutingVertexes->reserve(vectorSize); + + for (unsigned int i = 0; i < vectorSize; ++i) { + double offset = static_cast(iEvent.id().event() + i); + int iOffset = static_cast(iEvent.id().event() + i); + + run3ScoutingVertexes->emplace_back(static_cast(vertexesFloatingPointValues_[0] + offset), + static_cast(vertexesFloatingPointValues_[1] + offset), + static_cast(vertexesFloatingPointValues_[2] + offset), + static_cast(vertexesFloatingPointValues_[3] + offset), + static_cast(vertexesFloatingPointValues_[4] + offset), + static_cast(vertexesFloatingPointValues_[5] + offset), + vertexesIntegralValues_[0] + iOffset, + static_cast(vertexesFloatingPointValues_[6] + offset), + vertexesIntegralValues_[1] + iOffset, + static_cast((vertexesIntegralValues_[2] + iOffset) % 2)); + } + iEvent.put(vertexesPutToken_, std::move(run3ScoutingVertexes)); + } + + void TestWriteRun3Scouting::throwWithMessage(const char* msg) const { + throw cms::Exception("TestFailure") << "TestWriteRun3Scouting constructor, test configuration error, " << msg; + } + +} // namespace edmtest + +using edmtest::TestWriteRun3Scouting; +DEFINE_FWK_MODULE(TestWriteRun3Scouting); diff --git a/DataFormats/Scouting/test/create_Run3Scouting_test_file_cfg.py b/DataFormats/Scouting/test/create_Run3Scouting_test_file_cfg.py new file mode 100644 index 0000000000000..64863ed18059b --- /dev/null +++ b/DataFormats/Scouting/test/create_Run3Scouting_test_file_cfg.py @@ -0,0 +1,99 @@ +import FWCore.ParameterSet.Config as cms + +process = cms.Process("PROD") + +process.load("FWCore.MessageService.MessageLogger_cfi") + +process.source = cms.Source("EmptySource") +process.maxEvents.input = 10 + +process.run3ScoutingProducer = cms.EDProducer("TestWriteRun3Scouting", + # Test values below are meaningless. We just make sure when we read + # we get the same values. Note only values exactly convertible to + # float are used to avoid precision and rounding issues in + # in comparisons. + caloJetsValues = cms.vdouble( + 2.0, 4.0 , 6.0, 8.0, 10.0, + 12.0, 14.0, 16.0, 18.0, 20.0, + 22.0, 24.0, 26.0, 28.0, 30.0, + 32.0 + ), + electronsFloatingPointValues = cms.vdouble( + 10.0, 20.0, 30.0, 40.0, 50.0, + 60.0, 70.0, 80.0, 90.0, 100.0, + 110.0, 120.0, 130.0, 140.0, 150.0, + 160.0, 170.0, 180.0, 190.0, 200.0, + 210.0, 220.0, 230.0, 240.0, 250.0 + ), + electronsIntegralValues = cms.vint32( + 10, 20, 30, 40, 50, 60 + ), + muonsFloatingPointValues = cms.vdouble( + 10.0, 20.0, 30.0, 40.0, 50.0, + 60.0, 70.0, 80.0, 90.0, 100.0, + 110.0, 120.0, 130.0, 140.0, 150.0, + 160.0, 170.0, 180.0, 190.0, 200.0, + 210.0, 220.0, 230.0, 240.0, 250.0, + 260.0, 270.0, 280.0, 290.0, 300.0, + 310.0, 320.0, 330.0, 340.0, 350.0, + 360.0, 370.0 + ), + muonsIntegralValues = cms.vint32( + 10, 20, 30, 40, 50, + 60, 70, 80, 90, 100, + 110, 120, 130, 140, 150, + 160, 170, 180, 190, 200, + 210, 220, 230, 240, 250, + 260 + ), + particlesFloatingPointValues = cms.vdouble( + 11.0, 21.0, 31.0, 41.0, 51.0, + 61.0, 71.0, 81.0, 91.0, 101.0, + 111.0 + ), + particlesIntegralValues = cms.vint32( + 11, 21, 31, 41, 51 + ), + pfJetsFloatingPointValues = cms.vdouble( + 12.0, 22.0, 32.0, 42.0, 52.0, + 62.0, 72.0, 82.0, 92.0, 102.0, + 112.0, 122.0, 132.0, 142.0, 152.0 + ), + pfJetsIntegralValues = cms.vint32( + 12, 22, 32, 42, 52, + 62, 72, 82 + ), + photonsFloatingPointValues = cms.vdouble( + 14.0, 23.0, 33.0, 43.0, 53.0, + 63.0, 73.0, 83.0, 93.0, 103.0, + 113.0, 123.0, 133.0, 143.0 + ), + photonsIntegralValues = cms.vint32( + 14, 23, 33 + ), + tracksFloatingPointValues = cms.vdouble( + 14.0, 24.0, 34.0, 44.0, 54.0, + 64.0, 74.0, 84.0, 94.0, 104.0, + 114.0, 124.0, 134.0, 144.0, 154.0, + 164.0, 174.0, 184.0, 194.0, 204.0, + 214.0, 224.0, 234.0, 244.0, 254.0, + 264.0, 274.0, 284.0, 294.0 + ), + tracksIntegralValues = cms.vint32( + 14, 24, 34, 44, 54 + ), + vertexesFloatingPointValues = cms.vdouble( + 15.0, 25.0, 35.0, 45.0, 55.0, + 65.0, 75.0 + ), + vertexesIntegralValues = cms.vint32( + 15, 25, 35 + ) +) + +process.out = cms.OutputModule("PoolOutputModule", + fileName = cms.untracked.string('testRun3Scouting.root') +) + +process.path = cms.Path(process.run3ScoutingProducer) +process.endPath = cms.EndPath(process.out) diff --git a/DataFormats/Scouting/test/test_readRun3Scouting_CMSSW_12_4_0_cfg.py b/DataFormats/Scouting/test/test_readRun3Scouting_CMSSW_12_4_0_cfg.py new file mode 100644 index 0000000000000..2892846490011 --- /dev/null +++ b/DataFormats/Scouting/test/test_readRun3Scouting_CMSSW_12_4_0_cfg.py @@ -0,0 +1,101 @@ +import FWCore.ParameterSet.Config as cms +import sys + +process = cms.Process("READ") + +process.source = cms.Source("PoolSource", fileNames = cms.untracked.vstring("file:"+sys.argv[2])) + +process.testReadRun3Scouting = cms.EDAnalyzer("TestReadRun3Scouting", + # I stick to values exactly convertable to float + # to avoid potential rounding issues in the test. + expectedCaloJetsValues = cms.vdouble( + 2.0, 4.0 , 6.0, 8.0, 10.0, + 12.0, 14.0, 16.0, 18.0, 20.0, + 22.0, 24.0, 26.0, 28.0, 30.0, + 32.0), + caloJetsTag = cms.InputTag("run3ScoutingProducer", "", "PROD"), + electronClassVersion = cms.int32(5), + expectedElectronFloatingPointValues = cms.vdouble( + 10.0, 20.0, 30.0, 40.0, 50.0, + 60.0, 70.0, 80.0, 90.0, 100.0, + 110.0, 120.0, 130.0, 140.0, 150.0, + 160.0, 170.0, 180.0, 190.0, 200.0, + 210.0, 220.0, 230.0, 240.0, 250.0), + expectedElectronIntegralValues = cms.vint32(10, 20, 30, 40, 50, 60), + electronsTag = cms.InputTag("run3ScoutingProducer", "", "PROD"), + expectedMuonFloatingPointValues = cms.vdouble( + 10.0, 20.0, 30.0, 40.0, 50.0, + 60.0, 70.0, 80.0, 90.0, 100.0, + 110.0, 120.0, 130.0, 140.0, 150.0, + 160.0, 170.0, 180.0, 190.0, 200.0, + 210.0, 220.0, 230.0, 240.0, 250.0, + 260.0, 270.0, 280.0, 290.0, 300.0, + 310.0, 320.0, 330.0, 340.0, 350.0, + 360.0, 370.0 + ), + expectedMuonIntegralValues = cms.vint32( + 10, 20, 30, 40, 50, + 60, 70, 80, 90, 100, + 110, 120, 130, 140, 150, + 160, 170, 180, 190, 200, + 210, 220, 230, 240, 250, + 260 + ), + muonsTag = cms.InputTag("run3ScoutingProducer", "", "PROD"), + expectedParticleFloatingPointValues = cms.vdouble( + 11.0, 21.0, 31.0, 41.0, 51.0, + 61.0, 71.0, 81.0, 91.0, 101.0, + 111.0 + ), + expectedParticleIntegralValues = cms.vint32( + 11, 21, 31, 41, 51 + ), + particlesTag = cms.InputTag("run3ScoutingProducer", "", "PROD"), + expectedPFJetFloatingPointValues = cms.vdouble( + 12.0, 22.0, 32.0, 42.0, 52.0, + 62.0, 72.0, 82.0, 92.0, 102.0, + 112.0, 122.0, 132.0, 142.0, 152.0 + ), + expectedPFJetIntegralValues = cms.vint32( + 12, 22, 32, 42, 52, + 62, 72, 82 + ), + pfJetsTag = cms.InputTag("run3ScoutingProducer", "", "PROD"), + expectedPhotonFloatingPointValues = cms.vdouble( + 14.0, 23.0, 33.0, 43.0, 53.0, + 63.0, 73.0, 83.0, 93.0, 103.0, + 113.0, 123.0, 133.0, 143.0 + ), + expectedPhotonIntegralValues = cms.vint32( + 14, 23, 33 + ), + photonsTag = cms.InputTag("run3ScoutingProducer", "", "PROD"), + expectedTrackFloatingPointValues = cms.vdouble( + 14.0, 24.0, 34.0, 44.0, 54.0, + 64.0, 74.0, 84.0, 94.0, 104.0, + 114.0, 124.0, 134.0, 144.0, 154.0, + 164.0, 174.0, 184.0, 194.0, 204.0, + 214.0, 224.0, 234.0, 244.0, 254.0, + 264.0, 274.0, 284.0, 294.0 + ), + expectedTrackIntegralValues = cms.vint32( + 14, 24, 34, 44, 54 + ), + tracksTag = cms.InputTag("run3ScoutingProducer", "", "PROD"), + expectedVertexFloatingPointValues = cms.vdouble( + 15.0, 25.0, 35.0, 45.0, 55.0, + 65.0, 75.0 + ), + expectedVertexIntegralValues = cms.vint32( + 15, 25, 35 + ), + vertexesTag = cms.InputTag("run3ScoutingProducer", "", "PROD") +) + +process.out = cms.OutputModule("PoolOutputModule", + fileName = cms.untracked.string('testRun3Scouting2_CMSSW_12_4_0.root') +) + +process.path = cms.Path(process.testReadRun3Scouting) + +process.endPath = cms.EndPath(process.out) diff --git a/DataFormats/Scouting/test/test_readRun3Scouting_cfg.py b/DataFormats/Scouting/test/test_readRun3Scouting_cfg.py new file mode 100644 index 0000000000000..ba9eed4d706c6 --- /dev/null +++ b/DataFormats/Scouting/test/test_readRun3Scouting_cfg.py @@ -0,0 +1,101 @@ +import FWCore.ParameterSet.Config as cms +import sys + +process = cms.Process("READ") + +process.source = cms.Source("PoolSource", fileNames = cms.untracked.vstring("file:"+sys.argv[2])) + +process.testReadRun3Scouting = cms.EDAnalyzer("TestReadRun3Scouting", + # I stick to values exactly convertable to float + # to avoid potential rounding issues in the test. + expectedCaloJetsValues = cms.vdouble( + 2.0, 4.0 , 6.0, 8.0, 10.0, + 12.0, 14.0, 16.0, 18.0, 20.0, + 22.0, 24.0, 26.0, 28.0, 30.0, + 32.0), + caloJetsTag = cms.InputTag("run3ScoutingProducer", "", "PROD"), + electronClassVersion = cms.int32(6), + expectedElectronFloatingPointValues = cms.vdouble( + 10.0, 20.0, 30.0, 40.0, 50.0, + 60.0, 70.0, 80.0, 90.0, 100.0, + 110.0, 120.0, 130.0, 140.0, 150.0, + 160.0, 170.0, 180.0, 190.0, 200.0, + 210.0, 220.0, 230.0, 240.0, 250.0), + expectedElectronIntegralValues = cms.vint32(10, 20, 30, 40, 50, 60), + electronsTag = cms.InputTag("run3ScoutingProducer", "", "PROD"), + expectedMuonFloatingPointValues = cms.vdouble( + 10.0, 20.0, 30.0, 40.0, 50.0, + 60.0, 70.0, 80.0, 90.0, 100.0, + 110.0, 120.0, 130.0, 140.0, 150.0, + 160.0, 170.0, 180.0, 190.0, 200.0, + 210.0, 220.0, 230.0, 240.0, 250.0, + 260.0, 270.0, 280.0, 290.0, 300.0, + 310.0, 320.0, 330.0, 340.0, 350.0, + 360.0, 370.0 + ), + expectedMuonIntegralValues = cms.vint32( + 10, 20, 30, 40, 50, + 60, 70, 80, 90, 100, + 110, 120, 130, 140, 150, + 160, 170, 180, 190, 200, + 210, 220, 230, 240, 250, + 260 + ), + muonsTag = cms.InputTag("run3ScoutingProducer", "", "PROD"), + expectedParticleFloatingPointValues = cms.vdouble( + 11.0, 21.0, 31.0, 41.0, 51.0, + 61.0, 71.0, 81.0, 91.0, 101.0, + 111.0 + ), + expectedParticleIntegralValues = cms.vint32( + 11, 21, 31, 41, 51 + ), + particlesTag = cms.InputTag("run3ScoutingProducer", "", "PROD"), + expectedPFJetFloatingPointValues = cms.vdouble( + 12.0, 22.0, 32.0, 42.0, 52.0, + 62.0, 72.0, 82.0, 92.0, 102.0, + 112.0, 122.0, 132.0, 142.0, 152.0 + ), + expectedPFJetIntegralValues = cms.vint32( + 12, 22, 32, 42, 52, + 62, 72, 82 + ), + pfJetsTag = cms.InputTag("run3ScoutingProducer", "", "PROD"), + expectedPhotonFloatingPointValues = cms.vdouble( + 14.0, 23.0, 33.0, 43.0, 53.0, + 63.0, 73.0, 83.0, 93.0, 103.0, + 113.0, 123.0, 133.0, 143.0 + ), + expectedPhotonIntegralValues = cms.vint32( + 14, 23, 33 + ), + photonsTag = cms.InputTag("run3ScoutingProducer", "", "PROD"), + expectedTrackFloatingPointValues = cms.vdouble( + 14.0, 24.0, 34.0, 44.0, 54.0, + 64.0, 74.0, 84.0, 94.0, 104.0, + 114.0, 124.0, 134.0, 144.0, 154.0, + 164.0, 174.0, 184.0, 194.0, 204.0, + 214.0, 224.0, 234.0, 244.0, 254.0, + 264.0, 274.0, 284.0, 294.0 + ), + expectedTrackIntegralValues = cms.vint32( + 14, 24, 34, 44, 54 + ), + tracksTag = cms.InputTag("run3ScoutingProducer", "", "PROD"), + expectedVertexFloatingPointValues = cms.vdouble( + 15.0, 25.0, 35.0, 45.0, 55.0, + 65.0, 75.0 + ), + expectedVertexIntegralValues = cms.vint32( + 15, 25, 35 + ), + vertexesTag = cms.InputTag("run3ScoutingProducer", "", "PROD") +) + +process.out = cms.OutputModule("PoolOutputModule", + fileName = cms.untracked.string('testRun3Scouting2.root') +) + +process.path = cms.Path(process.testReadRun3Scouting) + +process.endPath = cms.EndPath(process.out)