CMS 3D CMS Logo

LegacyPFRecHitProducer.cc
Go to the documentation of this file.
1 #include <unordered_map>
2 
19 
21 public:
23  : alpakaPfRecHitsToken_(consumes(config.getParameter<edm::InputTag>("src"))),
24  legacyPfRecHitsToken_(produces()),
25  geomToken_(esConsumes<edm::Transition::BeginRun>()) {}
26 
27  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
29  desc.add<edm::InputTag>("src", edm::InputTag(""));
30  descriptions.addWithDefaultLabel(desc);
31  }
32 
33 private:
34  void beginRun(edm::Run const&, edm::EventSetup const&) override;
35  void produce(edm::Event&, const edm::EventSetup&) override;
36 
39 
41  std::unordered_map<PFLayer::Layer, const CaloSubdetectorGeometry*> caloGeo_;
42 };
43 
45  const CaloGeometry& geo = setup.getData(geomToken_);
50 }
51 
53  const reco::PFRecHitHostCollection& pfRecHitsAlpakaSoA = event.get(alpakaPfRecHitsToken_);
54  const reco::PFRecHitHostCollection::ConstView& alpakaPfRecHits = pfRecHitsAlpakaSoA.const_view();
55 
57 
58  if (alpakaPfRecHits.metadata().size() != 0) {
59  out.reserve(alpakaPfRecHits.size());
60  for (size_t i = 0; i < alpakaPfRecHits.size(); i++) {
61  reco::PFRecHit& pfrh =
62  out.emplace_back(caloGeo_.at(alpakaPfRecHits[i].layer())->getGeometry(alpakaPfRecHits[i].detId()),
63  alpakaPfRecHits[i].detId(),
64  alpakaPfRecHits[i].layer(),
65  alpakaPfRecHits[i].energy());
66  pfrh.setTime(alpakaPfRecHits[i].time());
67  pfrh.setDepth(alpakaPfRecHits[i].depth());
68 
69  // order in Alpaka: N, S, E, W,NE,SW,SE,NW
70  const short eta[8] = {0, 0, 1, -1, 1, -1, 1, -1};
71  const short phi[8] = {1, -1, 0, 0, 1, -1, -1, 1};
72  for (size_t k = 0; k < 8; k++)
73  if (alpakaPfRecHits[i].neighbours()(k) != -1)
74  pfrh.addNeighbour(eta[k], phi[k], 0, alpakaPfRecHits[i].neighbours()(k));
75  }
76  }
77 
78  event.emplace(legacyPfRecHitsToken_, out);
79 }
80 
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > geomToken_
void setDepth(int depth)
Definition: PFRecHit.h:74
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
void addNeighbour(short x, short y, short z, unsigned int)
Definition: PFRecHit.cc:5
std::vector< PFRecHit > PFRecHitCollection
collection of PFRecHit objects
Definition: PFRecHitFwd.h:9
Definition: config.py:1
ConstView const & const_view() const
Particle flow rechit (rechit + geometry and topology information). See clustering algorithm in PFClus...
Definition: PFRecHit.h:31
const edm::EDPutTokenT< reco::PFRecHitCollection > legacyPfRecHitsToken_
Transition
Definition: Transition.h:12
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void setTime(double time)
Definition: PFRecHit.h:73
std::unordered_map< PFLayer::Layer, const CaloSubdetectorGeometry * > caloGeo_
typename Layout::ConstView ConstView
const edm::EDGetTokenT< reco::PFRecHitHostCollection > alpakaPfRecHitsToken_
HLT enums.
void produce(edm::Event &, const edm::EventSetup &) override
void beginRun(edm::Run const &, edm::EventSetup const &) override
LegacyPFRecHitProducer(edm::ParameterSet const &config)
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:34
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: event.py:1
Definition: Run.h:45