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");
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  out.reserve(alpakaPfRecHits.size());
58 
59  for (size_t i = 0; i < alpakaPfRecHits.size(); i++) {
60  reco::PFRecHit& pfrh =
61  out.emplace_back(caloGeo_.at(alpakaPfRecHits[i].layer())->getGeometry(alpakaPfRecHits[i].detId()),
62  alpakaPfRecHits[i].detId(),
63  alpakaPfRecHits[i].layer(),
64  alpakaPfRecHits[i].energy());
65  pfrh.setTime(alpakaPfRecHits[i].time());
66  pfrh.setDepth(alpakaPfRecHits[i].depth());
67 
68  // order in Alpaka: N, S, E, W,NE,SW,SE,NW
69  const short eta[8] = {0, 0, 1, -1, 1, -1, 1, -1};
70  const short phi[8] = {1, -1, 0, 0, 1, -1, -1, 1};
71  for (size_t k = 0; k < 8; k++)
72  if (alpakaPfRecHits[i].neighbours()(k) != -1)
73  pfrh.addNeighbour(eta[k], phi[k], 0, alpakaPfRecHits[i].neighbours()(k));
74  }
75 
76  event.emplace(legacyPfRecHitsToken_, out);
77 }
78 
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