Skip to content

Commit 095c9bb

Browse files
committed
Decorating the tests
1 parent d941d8d commit 095c9bb

13 files changed

+214
-10
lines changed

DataFormats/TrackSoA/test/TestReadHostTrackSoA.cc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,20 @@ namespace edmtest {
2323

2424
private:
2525
edm::EDGetTokenT<::reco::TracksHost> getToken_;
26+
const unsigned int trackSize_;
2627
};
2728

2829
TestReadHostTrackSoA::TestReadHostTrackSoA(edm::ParameterSet const& iPSet)
29-
: getToken_(consumes(iPSet.getParameter<edm::InputTag>("input"))) {}
30+
: getToken_(consumes(iPSet.getParameter<edm::InputTag>("input"))),
31+
trackSize_(iPSet.getParameter<unsigned int>("trackSize")) {}
3032

3133
void TestReadHostTrackSoA::analyze(edm::StreamID, edm::Event const& iEvent, edm::EventSetup const&) const {
3234
auto const& tracks = iEvent.get(getToken_);
3335
auto tracksView = tracks.view();
3436

35-
std::cout << "tracksView.metadata().size() = " << tracksView.metadata().size() << std::endl;
37+
assert(tracksView.metadata().size() == int(trackSize_));
38+
assert(tracksView.nTracks() == int(trackSize_));
39+
3640
for (int i = 0; i < tracksView.metadata().size(); ++i) {
3741
if (tracksView[i].eta() != float(i)) {
3842
throw cms::Exception("TestReadHostTrackSoA Failure") << "TestReadHostTrackSoA::analyze, entry. i = " << i;
@@ -43,6 +47,7 @@ namespace edmtest {
4347
void TestReadHostTrackSoA::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
4448
edm::ParameterSetDescription desc;
4549
desc.add<edm::InputTag>("input");
50+
desc.add<unsigned int>("trackSize", 1000);
4651
descriptions.addDefault(desc);
4752
}
4853
} // namespace edmtest

DataFormats/TrackSoA/test/TestWriteHostTrackSoA.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace edmtest {
2323
static void fillDescriptions(edm::ConfigurationDescriptions&);
2424

2525
private:
26-
unsigned int trackSize_;
26+
const unsigned int trackSize_;
2727
edm::EDPutTokenT<::reco::TracksHost> putToken_;
2828
};
2929

@@ -36,6 +36,7 @@ namespace edmtest {
3636
for (unsigned int i = 0; i < trackSize_; ++i) {
3737
tracksView[i].eta() = float(i);
3838
}
39+
tracksView.nTracks() = trackSize_;
3940
iEvent.emplace(putToken_, std::move(tracks));
4041
}
4142

DataFormats/TrackSoA/test/testReadHostTrackSoA.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
process.source = cms.Source("PoolSource", fileNames = cms.untracked.vstring("file:"+sys.argv[1]))
77

88
process.testReadHostTrackSoA = cms.EDAnalyzer("TestReadHostTrackSoA",
9-
input = cms.InputTag("trackSoA", "", "WRITE")
9+
input = cms.InputTag("trackSoA", "", "WRITE"),
10+
trackSize = cms.uint32(2708)
1011
)
1112

1213
process.out = cms.OutputModule("PoolOutputModule",

DataFormats/TrackingRecHitSoA/test/TestReadHostHitSoA.cc

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,23 @@ namespace edmtest {
2727

2828
private:
2929
edm::EDGetTokenT<HitsOnHost> getToken_;
30+
const unsigned int hitSize_;
31+
const unsigned int offsetBPIX2_;
3032
};
3133

3234
TestReadHostHitSoA::TestReadHostHitSoA(edm::ParameterSet const& iPSet)
33-
: getToken_(consumes(iPSet.getParameter<edm::InputTag>("input"))) {}
35+
: getToken_(consumes(iPSet.getParameter<edm::InputTag>("input"))),
36+
hitSize_(iPSet.getParameter<unsigned int>("hitSize")),
37+
offsetBPIX2_(iPSet.getParameter<unsigned int>("offsetBPIX2")) {}
3438

3539
void TestReadHostHitSoA::analyze(edm::StreamID, edm::Event const& iEvent, edm::EventSetup const&) const {
3640
auto const& hits = iEvent.get(getToken_);
3741
auto hitsView = hits.view();
3842

3943
std::cout << "hitsView.metadata().size() = " << hitsView.metadata().size() << std::endl;
44+
assert(hitsView.metadata().size() == int(hitSize_));
45+
assert(hitsView.offsetBPIX2() == int(offsetBPIX2_));
46+
4047
for (int i = 0; i < hitsView.metadata().size(); ++i) {
4148
if (hitsView[i].xGlobal() != float(i)) {
4249
throw cms::Exception("TestWriteHostHitSoA Failure") << "TestReadHostHitSoA::analyze, entry. i = " << i;
@@ -47,6 +54,8 @@ namespace edmtest {
4754
void TestReadHostHitSoA::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
4855
edm::ParameterSetDescription desc;
4956
desc.add<edm::InputTag>("input");
57+
desc.add<unsigned int>("hitSize", 1000);
58+
desc.add<unsigned int>("offsetBPIX2", 50);
5059
descriptions.addDefault(desc);
5160
}
5261
} // namespace edmtest

DataFormats/TrackingRecHitSoA/test/TestWriteHostHitSoA.cc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,30 @@ namespace edmtest {
2525
using HitsOnHost = ::reco::TrackingRecHitHost;
2626

2727
private:
28-
unsigned int hitSize_;
28+
const unsigned int hitSize_;
29+
const unsigned int offsetBPIX2_;
2930
edm::EDPutTokenT<HitsOnHost> putToken_;
3031
};
3132

3233
TestWriteHostHitSoA::TestWriteHostHitSoA(edm::ParameterSet const& iPSet)
33-
: hitSize_(iPSet.getParameter<unsigned int>("hitSize")), putToken_(produces()) {}
34+
: hitSize_(iPSet.getParameter<unsigned int>("hitSize")),
35+
offsetBPIX2_(iPSet.getParameter<unsigned int>("offsetBPIX2")),
36+
putToken_(produces()) {}
3437

3538
void TestWriteHostHitSoA::produce(edm::StreamID, edm::Event& iEvent, edm::EventSetup const&) const {
3639
HitsOnHost hits(cms::alpakatools::host(), hitSize_, 100);
3740
auto hitsView = hits.view();
3841
for (unsigned int i = 0; i < hitSize_; ++i) {
3942
hitsView[i].xGlobal() = float(i);
4043
}
44+
hitsView.offsetBPIX2() = offsetBPIX2_;
4145
iEvent.emplace(putToken_, std::move(hits));
4246
}
4347

4448
void TestWriteHostHitSoA::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
4549
edm::ParameterSetDescription desc;
4650
desc.add<unsigned int>("hitSize", 1000);
51+
desc.add<unsigned int>("offsetBPIX2", 50);
4752
descriptions.addDefault(desc);
4853
}
4954
} // namespace edmtest

DataFormats/TrackingRecHitSoA/test/testReadHostHitSoA.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
process.source = cms.Source("PoolSource", fileNames = cms.untracked.vstring("file:"+sys.argv[1]))
77

88
process.testReadHostHitSoA = cms.EDAnalyzer("TestReadHostHitSoA",
9-
input = cms.InputTag("hitSoA", "", "WRITE")
9+
input = cms.InputTag("hitSoA", "", "WRITE"),
10+
hitSize = cms.uint32(2708)
1011
)
1112

1213
process.out = cms.OutputModule("PoolOutputModule",

DataFormats/TrackingRecHitSoA/test/testWriteHostHitSoA.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
process.maxEvents.input = 5
99

1010
process.hitSoA = cms.EDProducer("TestWriteHostHitSoA",
11-
hitSize = cms.uint32(2708)
11+
hitSize = cms.uint32(2708),
1212
)
1313

1414
process.out = cms.OutputModule("PoolOutputModule",
15-
fileName = cms.untracked.string(sys.argv[1])
15+
fileName = cms.untracked.string(sys.argv[1]),
1616
)
1717

1818
process.path = cms.Path(process.hitSoA)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,25 @@
1+
<use name="alpaka"/>
2+
<use name="rootcore"/>
3+
<use name="eigen"/>
4+
<use name="DataFormats/Common"/>
5+
<use name="DataFormats/Portable"/>
6+
<use name="DataFormats/SoATemplate" source_only="1"/>
7+
8+
19
<bin file="alpaka/ZVertexSoA_test.cc alpaka/ZVertexSoA_test.dev.cc" name="ZVertexSoA_test">
210
<use name="alpaka"/>
311
<use name="eigen"/>
412
<use name="HeterogeneousCore/AlpakaInterface"/>
513
<flags ALPAKA_BACKENDS="1"/>
614
</bin>
15+
16+
<library name="testVertexSoA" file="TestWriteHostVertexSoA.cc,TestReadHostVertexSoA.cc,">
17+
<flags EDM_PLUGIN="1"/>
18+
<use name="alpaka"/>
19+
<use name="FWCore/Framework"/>
20+
<use name="FWCore/ParameterSet"/>
21+
<use name="FWCore/Utilities"/>
22+
</library>
23+
24+
<test name="testWriteAndReadVertexSoA" command="testWriteAndReadVertexSoA.sh" />
25+
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#include "DataFormats/DetId/interface/DetId.h"
2+
#include "FWCore/Framework/interface/Event.h"
3+
#include "FWCore/Framework/interface/Frameworkfwd.h"
4+
#include "FWCore/Framework/interface/global/EDAnalyzer.h"
5+
#include "FWCore/Framework/interface/MakerMacros.h"
6+
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
7+
#include "FWCore/ParameterSet/interface/ParameterSet.h"
8+
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
9+
#include "FWCore/Utilities/interface/EDGetToken.h"
10+
#include "FWCore/Utilities/interface/Exception.h"
11+
#include "FWCore/Utilities/interface/InputTag.h"
12+
#include "FWCore/Utilities/interface/StreamID.h"
13+
14+
#include "DataFormats/VertexSoA/interface/ZVertexHost.h"
15+
16+
namespace edmtest {
17+
18+
class TestReadHostVertexSoA : public edm::global::EDAnalyzer<> {
19+
public:
20+
TestReadHostVertexSoA(edm::ParameterSet const&);
21+
void analyze(edm::StreamID, edm::Event const&, edm::EventSetup const&) const override;
22+
static void fillDescriptions(edm::ConfigurationDescriptions&);
23+
24+
private:
25+
edm::EDGetTokenT<ZVertexHost> getToken_;
26+
};
27+
28+
TestReadHostVertexSoA::TestReadHostVertexSoA(edm::ParameterSet const& iPSet)
29+
: getToken_(consumes(iPSet.getParameter<edm::InputTag>("input"))) {}
30+
31+
void TestReadHostVertexSoA::analyze(edm::StreamID, edm::Event const& iEvent, edm::EventSetup const&) const {
32+
auto const& ZVertexs = iEvent.get(getToken_);
33+
auto ZVertexsView = ZVertexs.view();
34+
35+
std::cout << "ZVertexsView.metadata().size() " << ZVertexsView.metadata().size() << std::endl;
36+
std::cout << "ZVertexsView.chi2() " << ZVertexsView[10].chi2() << std::endl;
37+
for (int i = 0; i < ZVertexsView.metadata().size(); ++i) {
38+
if (ZVertexsView[i].chi2() != float(i)) {
39+
throw cms::Exception("TestReadHostVertexSoA Failure") << "TestReadHostVertexSoA::analyze, entry. i = " << i;
40+
}
41+
}
42+
}
43+
44+
void TestReadHostVertexSoA::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
45+
edm::ParameterSetDescription desc;
46+
desc.add<edm::InputTag>("input");
47+
descriptions.addDefault(desc);
48+
}
49+
} // namespace edmtest
50+
51+
using edmtest::TestReadHostVertexSoA;
52+
DEFINE_FWK_MODULE(TestReadHostVertexSoA);
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#include "FWCore/Framework/interface/Event.h"
2+
#include "FWCore/Framework/interface/Frameworkfwd.h"
3+
#include "FWCore/Framework/interface/global/EDProducer.h"
4+
#include "FWCore/Framework/interface/MakerMacros.h"
5+
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
6+
#include "FWCore/ParameterSet/interface/ParameterSet.h"
7+
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
8+
#include "FWCore/Utilities/interface/EDPutToken.h"
9+
#include "FWCore/Utilities/interface/StreamID.h"
10+
11+
#include "DataFormats/VertexSoA/interface/ZVertexHost.h"
12+
13+
#include <memory>
14+
#include <utility>
15+
#include <vector>
16+
17+
namespace edmtest {
18+
19+
class TestWriteHostVertexSoA : public edm::global::EDProducer<> {
20+
public:
21+
TestWriteHostVertexSoA(edm::ParameterSet const&);
22+
void produce(edm::StreamID, edm::Event&, edm::EventSetup const&) const override;
23+
static void fillDescriptions(edm::ConfigurationDescriptions&);
24+
25+
private:
26+
unsigned int vertexSize_;
27+
edm::EDPutTokenT<ZVertexHost> putToken_;
28+
};
29+
30+
TestWriteHostVertexSoA::TestWriteHostVertexSoA(edm::ParameterSet const& iPSet)
31+
: vertexSize_(iPSet.getParameter<unsigned int>("vertexSize")), putToken_(produces()) {}
32+
33+
void TestWriteHostVertexSoA::produce(edm::StreamID, edm::Event& iEvent, edm::EventSetup const&) const {
34+
ZVertexHost ZVertexs({{int(vertexSize_), int(4 * vertexSize_)}}, cms::alpakatools::host());
35+
auto ZVertexsView = ZVertexs.view();
36+
for (unsigned int i = 0; i < vertexSize_; ++i) {
37+
ZVertexsView[i].chi2() = float(i);
38+
}
39+
iEvent.emplace(putToken_, std::move(ZVertexs));
40+
}
41+
42+
void TestWriteHostVertexSoA::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
43+
edm::ParameterSetDescription desc;
44+
desc.add<unsigned int>("vertexSize", 1000);
45+
descriptions.addDefault(desc);
46+
}
47+
} // namespace edmtest
48+
49+
using edmtest::TestWriteHostVertexSoA;
50+
DEFINE_FWK_MODULE(TestWriteHostVertexSoA);

0 commit comments

Comments
 (0)