CMS 3D CMS Logo

PFRecHitSoAProducer.cc
Go to the documentation of this file.
1 #include <utility>
2 #include <vector>
3 
4 #include <alpaka/alpaka.hpp>
5 
13 
14 #include "CalorimeterDefinitions.h"
15 #include "PFRecHitProducerKernel.h"
16 
18  using namespace particleFlowRecHitProducer;
19 
20  template <typename CAL>
22  public:
24  : topologyToken_(esConsumes(config.getParameter<edm::ESInputTag>("topology"))),
25  pfRecHitsToken_(produces()),
26  synchronise_(config.getUntrackedParameter<bool>("synchronise")) {
27  const std::vector<edm::ParameterSet> producers = config.getParameter<std::vector<edm::ParameterSet>>("producers");
28  recHitsToken_.reserve(producers.size());
29  for (const edm::ParameterSet& producer : producers) {
30  recHitsToken_.emplace_back(consumes(producer.getParameter<edm::InputTag>("src")),
31  esConsumes(producer.getParameter<edm::ESInputTag>("params")));
32  }
33  }
34 
36  const typename CAL::TopologyTypeDevice& topology = setup.getData(topologyToken_);
37 
38  uint32_t num_recHits = 0;
39  for (const auto& token : recHitsToken_)
40  num_recHits += event.get(token.first)->metadata().size();
41 
42  reco::PFRecHitDeviceCollection pfRecHits{(int)num_recHits, event.queue()};
43 
44  if (num_recHits != 0) {
45  PFRecHitProducerKernel<CAL> kernel{event.queue(), num_recHits};
46  for (const auto& token : recHitsToken_)
47  kernel.processRecHits(
48  event.queue(), event.get(token.first), setup.getData(token.second), topology, pfRecHits);
49  kernel.associateTopologyInfo(event.queue(), topology, pfRecHits);
50  }
51 
52  if (synchronise_)
53  alpaka::wait(event.queue());
54 
55  event.emplace(pfRecHitsToken_, std::move(pfRecHits));
56  }
57 
58  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
61  producers.add<edm::InputTag>("src", edm::InputTag(""))->setComment("Input CaloRecHitSoA");
62  producers.add<edm::ESInputTag>("params", edm::ESInputTag(""))->setComment("Quality cut parameters");
63  std::vector<edm::ParameterSet> producersDefault(1);
64  producersDefault[0].addParameter<edm::InputTag>("src", edm::InputTag(""));
65  producersDefault[0].addParameter<edm::ESInputTag>("params", edm::ESInputTag(""));
66  desc.addVPSet("producers", producers, producersDefault)->setComment("List of inputs and quality cuts");
67  desc.add<edm::ESInputTag>("topology", edm::ESInputTag(""))->setComment("Topology information");
68  desc.addUntracked<bool>("synchronise", false)
69  ->setComment("Add synchronisation point after execution (for benchmarking asynchronous execution)");
70  descriptions.addWithDefaultLabel(desc);
71  }
72 
73  private:
75  std::vector<std::pair<device::EDGetToken<typename CAL::CaloRecHitSoATypeDevice>,
79  const bool synchronise_;
80  };
81 
84 } // namespace ALPAKA_ACCELERATOR_NAMESPACE
85 
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
Definition: config.py:1
PortableCollection<::reco::PFRecHitSoA > PFRecHitDeviceCollection
const device::EDPutToken< reco::PFRecHitDeviceCollection > pfRecHitsToken_
PFRecHitSoAProducer< HCAL > PFRecHitSoAProducerHCAL
void produce(edm::StreamID, device::Event &event, const device::EventSetup &setup) const override
const device::ESGetToken< typename CAL::TopologyTypeDevice, typename CAL::TopologyRecordType > topologyToken_
PFRecHitSoAProducer(edm::ParameterSet const &config)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
HLT enums.
void processRecHits(Queue &queue, const typename CAL::CaloRecHitSoATypeDevice &recHits, const typename CAL::ParameterType &params, const typename CAL::TopologyTypeDevice &topology, reco::PFRecHitDeviceCollection &pfRecHits)
#define DEFINE_FWK_ALPAKA_MODULE(name)
Definition: MakerMacros.h:16
std::vector< std::pair< device::EDGetToken< typename CAL::CaloRecHitSoATypeDevice >, device::ESGetToken< typename CAL::ParameterType, typename CAL::ParameterRecordType > > > recHitsToken_
def move(src, dest)
Definition: eostools.py:511
PFRecHitSoAProducer< ECAL > PFRecHitSoAProducerECAL
Definition: event.py:1