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 
11 #include "CalorimeterDefinitions.h"
12 
13 #include "PFRecHitProducerKernel.h"
14 
16  using namespace particleFlowRecHitProducer;
17 
18  template <typename CAL>
20  public:
22  : topologyToken_(esConsumes(config.getParameter<edm::ESInputTag>("topology"))),
23  pfRecHitsToken_(produces()),
24  synchronise_(config.getUntrackedParameter<bool>("synchronise")) {
25  const std::vector<edm::ParameterSet> producers = config.getParameter<std::vector<edm::ParameterSet>>("producers");
26  recHitsToken_.reserve(producers.size());
27  for (const edm::ParameterSet& producer : producers) {
28  recHitsToken_.emplace_back(consumes(producer.getParameter<edm::InputTag>("src")),
29  esConsumes(producer.getParameter<edm::ESInputTag>("params")));
30  }
31  }
32 
34  const typename CAL::TopologyTypeDevice& topology = setup.getData(topologyToken_);
35 
36  uint32_t num_recHits = 0;
37  for (const auto& token : recHitsToken_)
38  num_recHits += event.get(token.first)->metadata().size();
39 
40  reco::PFRecHitDeviceCollection pfRecHits{(int)num_recHits, event.queue()};
41 
42  PFRecHitProducerKernel<CAL> kernel{event.queue(), num_recHits};
43  for (const auto& token : recHitsToken_)
44  kernel.processRecHits(event.queue(), event.get(token.first), setup.getData(token.second), topology, pfRecHits);
45  kernel.associateTopologyInfo(event.queue(), topology, pfRecHits);
46 
47  if (synchronise_)
48  alpaka::wait(event.queue());
49 
50  event.emplace(pfRecHitsToken_, std::move(pfRecHits));
51  }
52 
53  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
56  producers.add<edm::InputTag>("src")->setComment("Input CaloRecHitSoA");
57  producers.add<edm::ESInputTag>("params")->setComment("Quality cut parameters");
58  desc.addVPSet("producers", producers)->setComment("List of inputs and quality cuts");
59  desc.add<edm::ESInputTag>("topology")->setComment("Topology information");
60  desc.addUntracked<bool>("synchronise", false)
61  ->setComment("Add synchronisation point after execution (for benchmarking asynchronous execution)");
62  descriptions.addWithDefaultLabel(desc);
63  }
64 
65  private:
67  std::vector<std::pair<device::EDGetToken<typename CAL::CaloRecHitSoATypeDevice>,
71  const bool synchronise_;
72  };
73 
76 } // namespace ALPAKA_ACCELERATOR_NAMESPACE
77 
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