Skip to content

Commit

Permalink
Run 3 Scouting Test CMSSW_13_0_3 version
Browse files Browse the repository at this point in the history
  • Loading branch information
wddgit committed May 30, 2023
1 parent 8503fc9 commit 21991a1
Show file tree
Hide file tree
Showing 5 changed files with 245 additions and 22 deletions.
110 changes: 99 additions & 11 deletions DataFormats/Scouting/test/TestReadRun3Scouting.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ namespace edmtest {
std::vector<double> expectedCaloJetsValues_;
edm::EDGetTokenT<std::vector<Run3ScoutingCaloJet>> caloJetsToken_;

int inputElectronClassVersion_;
std::vector<double> expectedElectronFloatingPointValues_;
std::vector<int> expectedElectronIntegralValues_;
edm::EDGetTokenT<std::vector<Run3ScoutingElectron>> electronsToken_;
Expand Down Expand Up @@ -97,6 +98,7 @@ namespace edmtest {
TestReadRun3Scouting::TestReadRun3Scouting(edm::ParameterSet const& iPSet)
: expectedCaloJetsValues_(iPSet.getParameter<std::vector<double>>("expectedCaloJetsValues")),
caloJetsToken_(consumes(iPSet.getParameter<edm::InputTag>("caloJetsTag"))),
inputElectronClassVersion_(iPSet.getParameter<int>("electronClassVersion")),
expectedElectronFloatingPointValues_(
iPSet.getParameter<std::vector<double>>("expectedElectronFloatingPointValues")),
expectedElectronIntegralValues_(iPSet.getParameter<std::vector<int>>("expectedElectronIntegralValues")),
Expand Down Expand Up @@ -138,6 +140,7 @@ namespace edmtest {
edm::ParameterSetDescription desc;
desc.add<std::vector<double>>("expectedCaloJetsValues");
desc.add<edm::InputTag>("caloJetsTag");
desc.add<int>("electronClassVersion");
desc.add<std::vector<double>>("expectedElectronFloatingPointValues");
desc.add<std::vector<int>>("expectedElectronIntegralValues");
desc.add<edm::InputTag>("electronsTag");
Expand Down Expand Up @@ -228,12 +231,12 @@ namespace edmtest {
}

void TestReadRun3Scouting::analyzeElectrons(edm::Event const& iEvent) const {
if (expectedElectronFloatingPointValues_.size() != 19) {
if (expectedElectronFloatingPointValues_.size() != 25) {
throwWithMessage(
"analyzeElectrons, test configuration error, expectedElectronFloatingPointValues must have size 19");
"analyzeElectrons, test configuration error, expectedElectronFloatingPointValues must have size 25");
}
if (expectedElectronIntegralValues_.size() != 5) {
throwWithMessage("analyzeElectrons, test configuration error, expectedElectronIntegralValues must have size 5");
if (expectedElectronIntegralValues_.size() != 6) {
throwWithMessage("analyzeElectrons, test configuration error, expectedElectronIntegralValues must have size 6");
}
auto const& electrons = iEvent.get(electronsToken_);
unsigned int vectorSize = 2 + iEvent.id().event() % 4;
Expand All @@ -257,11 +260,19 @@ namespace edmtest {
if (electron.m() != expectedElectronFloatingPointValues_[3] + offset) {
throwWithMessage("analyzeElectrons, m does not equal expected value");
}
if (electron.d0() != expectedElectronFloatingPointValues_[4] + offset) {
throwWithMessage("analyzeElectrons, d0 does not equal expected value");
}
if (electron.dz() != expectedElectronFloatingPointValues_[5] + offset) {
throwWithMessage("analyzeElectrons, dz 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");
Expand All @@ -281,8 +292,13 @@ namespace edmtest {
if (electron.missingHits() != expectedElectronIntegralValues_[0] + iOffset) {
throwWithMessage("analyzeElectrons, missingHits does not equal expected value");
}
if (electron.charge() != expectedElectronIntegralValues_[1] + iOffset) {
throwWithMessage("analyzeElectrons, charge 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");
Expand Down Expand Up @@ -338,6 +354,78 @@ namespace edmtest {
if (electron.rechitZeroSuppression() != static_cast<bool>((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<int>(expectedElectronIntegralValues_[5] + iOffset + 10 * j)) {
throwWithMessage("analyzeElectrons, trkcharge does not contain expected value");
}
++j;
}
}
++i;
}
}
Expand Down
45 changes: 38 additions & 7 deletions DataFormats/Scouting/test/TestWriteRun3Scouting.cc
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,13 @@ namespace edmtest {
}

void TestWriteRun3Scouting::produceElectrons(edm::Event& iEvent) const {
if (electronsFloatingPointValues_.size() != 19) {
if (electronsFloatingPointValues_.size() != 25) {
throw cms::Exception("TestFailure") << "TestReadRun3Scouting::produceElectrons, test configuration error, "
<< "electronsFloatingPointValues must have 19 elements and it does not";
<< "electronsFloatingPointValues must have 25 elements and it does not";
}
if (electronsIntegralValues_.size() != 5) {
if (electronsIntegralValues_.size() != 6) {
throw cms::Exception("TestFailure") << "TestReadRun3Scouting::produceElectrons, test configuration error, "
<< "electronsIntegralValues must have 5 elements and it does not";
<< "electronsIntegralValues must have 6 elements and it does not";
}
auto run3ScoutingElectrons = std::make_unique<std::vector<Run3ScoutingElectron>>();
unsigned int vectorSize = 2 + iEvent.id().event() % 4;
Expand All @@ -197,13 +197,40 @@ namespace edmtest {
double offset = static_cast<double>(iEvent.id().event() + i);
int iOffset = static_cast<int>(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<float> trkd0;
std::vector<float> trkdz;
std::vector<float> trkpt;
std::vector<float> trketa;
std::vector<float> trkphi;
std::vector<float> trkchi2overndf;
std::vector<int> trkcharge;
std::vector<float> energyMatrix;
std::vector<unsigned int> detIds;
std::vector<float> 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<float>(electronsFloatingPointValues_[19] + offset + j * 10));
trkdz.push_back(static_cast<float>(electronsFloatingPointValues_[20] + offset + j * 10));
trkpt.push_back(static_cast<float>(electronsFloatingPointValues_[21] + offset + j * 10));
trketa.push_back(static_cast<float>(electronsFloatingPointValues_[22] + offset + j * 10));
trkphi.push_back(static_cast<float>(electronsFloatingPointValues_[23] + offset + j * 10));
trkchi2overndf.push_back(static_cast<float>(electronsFloatingPointValues_[24] + offset + j * 10));
trkcharge.push_back(static_cast<int>(electronsIntegralValues_[5] + offset + j * 10));
energyMatrix.push_back(static_cast<float>(electronsFloatingPointValues_[17] + offset + j * 10));
detIds.push_back(static_cast<uint32_t>(electronsIntegralValues_[3] + iOffset + j * 10));
timingMatrix.push_back(static_cast<float>(electronsFloatingPointValues_[18] + offset + j * 10));
Expand All @@ -212,15 +239,19 @@ namespace edmtest {
static_cast<float>(electronsFloatingPointValues_[1] + offset),
static_cast<float>(electronsFloatingPointValues_[2] + offset),
static_cast<float>(electronsFloatingPointValues_[3] + offset),
static_cast<float>(electronsFloatingPointValues_[4] + offset),
static_cast<float>(electronsFloatingPointValues_[5] + offset),
std::move(trkd0),
std::move(trkdz),
std::move(trkpt),
std::move(trketa),
std::move(trkphi),
std::move(trkchi2overndf),
static_cast<float>(electronsFloatingPointValues_[6] + offset),
static_cast<float>(electronsFloatingPointValues_[7] + offset),
static_cast<float>(electronsFloatingPointValues_[8] + offset),
static_cast<float>(electronsFloatingPointValues_[9] + offset),
static_cast<float>(electronsFloatingPointValues_[10] + offset),
electronsIntegralValues_[0] + iOffset,
electronsIntegralValues_[1] + iOffset,
std::move(trkcharge),
static_cast<float>(electronsFloatingPointValues_[11] + offset),
static_cast<float>(electronsFloatingPointValues_[12] + offset),
static_cast<float>(electronsFloatingPointValues_[13] + offset),
Expand Down
5 changes: 3 additions & 2 deletions DataFormats/Scouting/test/create_Run3Scouting_test_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@
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
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
10, 20, 30, 40, 50, 60
),
muonsFloatingPointValues = cms.vdouble(
10.0, 20.0, 30.0, 40.0, 50.0,
Expand Down
101 changes: 101 additions & 0 deletions DataFormats/Scouting/test/test_readRun3Scouting_CMSSW_12_4_0_cfg.py
Original file line number Diff line number Diff line change
@@ -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)
6 changes: 4 additions & 2 deletions DataFormats/Scouting/test/test_readRun3Scouting_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@
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),
expectedElectronIntegralValues = cms.vint32(10, 20, 30, 40, 50),
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,
Expand Down

0 comments on commit 21991a1

Please sign in to comment.