CMS 3D CMS Logo

HcalRecHitSoAToLegacy.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <string>
3 
13 
15 public:
16  explicit HcalRecHitSoAToLegacy(edm::ParameterSet const& ps);
17  ~HcalRecHitSoAToLegacy() override = default;
18 
20 
21 private:
22  void produce(edm::Event&, edm::EventSetup const&) override;
23 
24 private:
27 };
28 
31 
32  desc.add<edm::InputTag>("src", edm::InputTag{"hbheRecHitProducerPortable"});
33 
34  confDesc.addWithDefaultLabel(desc);
35 }
36 
38  : recHitsTokenIn_{consumes<hcal::RecHitHostCollection>(ps.getParameter<edm::InputTag>("src"))},
39  recHitsLegacyTokenOut_{produces<HBHERecHitCollection>()} {}
40 
42  // populate the legacy collection
43  auto recHitsLegacy = std::make_unique<HBHERecHitCollection>();
44 
45  // get input from host SoA
46  auto const& hcalRechitSoAView = event.get(recHitsTokenIn_).const_view();
47 
48  recHitsLegacy->reserve(hcalRechitSoAView.metadata().size());
49 
50  for (auto i = 0; i < hcalRechitSoAView.metadata().size(); i++) {
51  auto const& rechit = hcalRechitSoAView[i];
52  // skip bad channels
53  if (rechit.chi2() < 0)
54  continue;
55 
56  // build a legacy rechit with the computed detid and MAHI energy
57  recHitsLegacy->emplace_back(HcalDetId{rechit.detId()},
58  rechit.energy(),
59  0 // timeRising
60  );
61  // update the legacy rechit with the Chi2 and M0 values
62  recHitsLegacy->back().setChiSquared(rechit.chi2());
63  recHitsLegacy->back().setRawEnergy(rechit.energyM0());
64  }
65 
66  // put the legacy collection
67  event.put(recHitsLegacyTokenOut_, std::move(recHitsLegacy));
68 }
69 
void produce(edm::Event &, edm::EventSetup const &) override
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
static void fillDescriptions(edm::ConfigurationDescriptions &)
const edm::EDGetTokenT< hcal::RecHitHostCollection > recHitsTokenIn_
const edm::EDPutTokenT< HBHERecHitCollection > recHitsLegacyTokenOut_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
HcalRecHitSoAToLegacy(edm::ParameterSet const &ps)
~HcalRecHitSoAToLegacy() override=default
def move(src, dest)
Definition: eostools.py:511
Definition: event.py:1