File indexing completed on 2025-07-03 00:42:11
0001 #include "DataFormats/DetId/interface/DetId.h"
0002 #include "FWCore/Framework/interface/Event.h"
0003 #include "FWCore/Framework/interface/Frameworkfwd.h"
0004 #include "FWCore/Framework/interface/global/EDAnalyzer.h"
0005 #include "FWCore/Framework/interface/MakerMacros.h"
0006 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0007 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0008 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0009 #include "FWCore/Utilities/interface/EDGetToken.h"
0010 #include "FWCore/Utilities/interface/Exception.h"
0011 #include "FWCore/Utilities/interface/InputTag.h"
0012 #include "FWCore/Utilities/interface/StreamID.h"
0013
0014 #include "DataFormats/TrackSoA/interface/TracksHost.h"
0015
0016 namespace edmtest {
0017
0018 class TestReadHostTrackSoA : public edm::global::EDAnalyzer<> {
0019 public:
0020 TestReadHostTrackSoA(edm::ParameterSet const&);
0021 void analyze(edm::StreamID, edm::Event const&, edm::EventSetup const&) const override;
0022 static void fillDescriptions(edm::ConfigurationDescriptions&);
0023
0024 private:
0025 edm::EDGetTokenT<::reco::TracksHost> getToken_;
0026 };
0027
0028 TestReadHostTrackSoA::TestReadHostTrackSoA(edm::ParameterSet const& iPSet)
0029 : getToken_(consumes(iPSet.getParameter<edm::InputTag>("input"))) {}
0030
0031 void TestReadHostTrackSoA::analyze(edm::StreamID, edm::Event const& iEvent, edm::EventSetup const&) const {
0032 auto const& tracks = iEvent.get(getToken_);
0033 auto tracksView = tracks.view();
0034
0035 for (int i = 0; i < tracksView.metadata().size(); ++i) {
0036 if (tracksView[i].eta() != float(i)) {
0037 throw cms::Exception("TestReadHostTrackSoA Failure") << "TestReadHostTrackSoA::analyze, entry. i = " << i;
0038 }
0039 }
0040 }
0041
0042 void TestReadHostTrackSoA::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0043 edm::ParameterSetDescription desc;
0044 desc.add<edm::InputTag>("input");
0045 descriptions.addDefault(desc);
0046 }
0047 }
0048
0049 using edmtest::TestReadHostTrackSoA;
0050 DEFINE_FWK_MODULE(TestReadHostTrackSoA);