File indexing completed on 2024-04-06 12:04:02
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #include "DataFormats/DetId/interface/DetId.h"
0019 #include "FWCore/Framework/interface/Event.h"
0020 #include "FWCore/Framework/interface/Frameworkfwd.h"
0021 #include "FWCore/Framework/interface/global/EDProducer.h"
0022 #include "FWCore/Framework/interface/MakerMacros.h"
0023 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0024 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0025 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0026 #include "FWCore/Utilities/interface/EDPutToken.h"
0027 #include "FWCore/Utilities/interface/StreamID.h"
0028
0029 #include <memory>
0030 #include <utility>
0031 #include <vector>
0032
0033 namespace edmtest {
0034
0035 class TestWriteVectorDetId : public edm::global::EDProducer<> {
0036 public:
0037 TestWriteVectorDetId(edm::ParameterSet const&);
0038 void produce(edm::StreamID, edm::Event&, edm::EventSetup const&) const override;
0039 static void fillDescriptions(edm::ConfigurationDescriptions&);
0040
0041 private:
0042 unsigned int testValue_;
0043 edm::EDPutTokenT<std::vector<DetId>> putToken_;
0044 };
0045
0046 TestWriteVectorDetId::TestWriteVectorDetId(edm::ParameterSet const& iPSet)
0047 : testValue_(iPSet.getParameter<unsigned int>("testValue")), putToken_(produces()) {}
0048
0049 void TestWriteVectorDetId::produce(edm::StreamID, edm::Event& iEvent, edm::EventSetup const&) const {
0050
0051
0052
0053
0054
0055
0056
0057 auto vectorDetIds = std::make_unique<std::vector<DetId>>();
0058
0059 unsigned int numberDetIds = (iEvent.id().event() - 1) % 10;
0060 unsigned int detId = testValue_ + iEvent.id().event();
0061 for (unsigned int i = 0; i < numberDetIds; ++i) {
0062 detId += iEvent.id().event();
0063 vectorDetIds->emplace_back(detId);
0064 }
0065 iEvent.put(putToken_, std::move(vectorDetIds));
0066 }
0067
0068 void TestWriteVectorDetId::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0069 edm::ParameterSetDescription desc;
0070 desc.add<unsigned int>("testValue");
0071 descriptions.addDefault(desc);
0072 }
0073 }
0074
0075 using edmtest::TestWriteVectorDetId;
0076 DEFINE_FWK_MODULE(TestWriteVectorDetId);