File indexing completed on 2024-04-06 12:25:55
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "DataFormats/Common/interface/Handle.h"
0010 #include "FWCore/Framework/interface/ESHandle.h"
0011
0012 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0013
0014 #include "DataFormats/HGCRecHit/interface/HGCRecHitCollections.h"
0015 #include "DataFormats/ForwardDetId/interface/HGCalDetId.h"
0016
0017 #include "RecoLocalCalo/HGCalRecProducers/interface/HGCalRecHitWorkerFactory.h"
0018
0019 #include "FWCore/Framework/interface/stream/EDProducer.h"
0020 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0021 #include "FWCore/Framework/interface/Event.h"
0022 #include "FWCore/Framework/interface/EventSetup.h"
0023
0024 #include "RecoLocalCalo/HGCalRecProducers/interface/HGCalRecHitWorkerBaseClass.h"
0025
0026 class HGCalRecHitProducer : public edm::stream::EDProducer<> {
0027 public:
0028 explicit HGCalRecHitProducer(const edm::ParameterSet& ps);
0029 ~HGCalRecHitProducer() override;
0030 void produce(edm::Event& evt, const edm::EventSetup& es) override;
0031
0032 private:
0033 const edm::EDGetTokenT<HGCeeUncalibratedRecHitCollection> eeUncalibRecHitCollection_;
0034 const edm::EDGetTokenT<HGChefUncalibratedRecHitCollection> hefUncalibRecHitCollection_;
0035 const edm::EDGetTokenT<HGChebUncalibratedRecHitCollection> hebUncalibRecHitCollection_;
0036 const edm::EDGetTokenT<HGChfnoseUncalibratedRecHitCollection> hfnoseUncalibRecHitCollection_;
0037 const std::string eeRechitCollection_;
0038 const std::string hefRechitCollection_;
0039 const std::string hebRechitCollection_;
0040 const std::string hfnoseRechitCollection_;
0041
0042 std::unique_ptr<HGCalRecHitWorkerBaseClass> worker_;
0043 };
0044
0045 HGCalRecHitProducer::HGCalRecHitProducer(const edm::ParameterSet& ps)
0046 : eeUncalibRecHitCollection_(
0047 consumes<HGCeeUncalibratedRecHitCollection>(ps.getParameter<edm::InputTag>("HGCEEuncalibRecHitCollection"))),
0048 hefUncalibRecHitCollection_(consumes<HGChefUncalibratedRecHitCollection>(
0049 ps.getParameter<edm::InputTag>("HGCHEFuncalibRecHitCollection"))),
0050 hebUncalibRecHitCollection_(consumes<HGChebUncalibratedRecHitCollection>(
0051 ps.getParameter<edm::InputTag>("HGCHEBuncalibRecHitCollection"))),
0052 hfnoseUncalibRecHitCollection_(consumes<HGChfnoseUncalibratedRecHitCollection>(
0053 ps.getParameter<edm::InputTag>("HGCHFNoseuncalibRecHitCollection"))),
0054 eeRechitCollection_(ps.getParameter<std::string>("HGCEErechitCollection")),
0055 hefRechitCollection_(ps.getParameter<std::string>("HGCHEFrechitCollection")),
0056 hebRechitCollection_(ps.getParameter<std::string>("HGCHEBrechitCollection")),
0057 hfnoseRechitCollection_(ps.getParameter<std::string>("HGCHFNoserechitCollection")),
0058 worker_{HGCalRecHitWorkerFactory::get()->create(ps.getParameter<std::string>("algo"), ps, consumesCollector())} {
0059 produces<HGCeeRecHitCollection>(eeRechitCollection_);
0060 produces<HGChefRecHitCollection>(hefRechitCollection_);
0061 produces<HGChebRecHitCollection>(hebRechitCollection_);
0062 produces<HGChfnoseRecHitCollection>(hfnoseRechitCollection_);
0063 }
0064
0065 HGCalRecHitProducer::~HGCalRecHitProducer() {}
0066
0067 void HGCalRecHitProducer::produce(edm::Event& evt, const edm::EventSetup& es) {
0068 using namespace edm;
0069
0070 Handle<HGCeeUncalibratedRecHitCollection> pHGCeeUncalibRecHits;
0071 Handle<HGChefUncalibratedRecHitCollection> pHGChefUncalibRecHits;
0072 Handle<HGChebUncalibratedRecHitCollection> pHGChebUncalibRecHits;
0073 Handle<HGChfnoseUncalibratedRecHitCollection> pHGChfnoseUncalibRecHits;
0074
0075 const HGCeeUncalibratedRecHitCollection* eeUncalibRecHits = nullptr;
0076 const HGChefUncalibratedRecHitCollection* hefUncalibRecHits = nullptr;
0077 const HGChebUncalibratedRecHitCollection* hebUncalibRecHits = nullptr;
0078 const HGChfnoseUncalibratedRecHitCollection* hfnoseUncalibRecHits = nullptr;
0079
0080
0081 evt.getByToken(eeUncalibRecHitCollection_, pHGCeeUncalibRecHits);
0082 eeUncalibRecHits = pHGCeeUncalibRecHits.product();
0083
0084 evt.getByToken(hefUncalibRecHitCollection_, pHGChefUncalibRecHits);
0085 hefUncalibRecHits = pHGChefUncalibRecHits.product();
0086
0087 evt.getByToken(hebUncalibRecHitCollection_, pHGChebUncalibRecHits);
0088 hebUncalibRecHits = pHGChebUncalibRecHits.product();
0089
0090 evt.getByToken(hfnoseUncalibRecHitCollection_, pHGChfnoseUncalibRecHits);
0091 if (pHGChfnoseUncalibRecHits.isValid())
0092 hfnoseUncalibRecHits = pHGChfnoseUncalibRecHits.product();
0093
0094
0095 auto eeRecHits = std::make_unique<HGCeeRecHitCollection>();
0096 auto hefRecHits = std::make_unique<HGChefRecHitCollection>();
0097 auto hebRecHits = std::make_unique<HGChebRecHitCollection>();
0098
0099 worker_->set(es);
0100
0101
0102 for (auto it = eeUncalibRecHits->begin(); it != eeUncalibRecHits->end(); ++it) {
0103 worker_->run(evt, *it, *eeRecHits);
0104 }
0105
0106
0107 for (auto it = hefUncalibRecHits->begin(); it != hefUncalibRecHits->end(); ++it) {
0108 worker_->run(evt, *it, *hefRecHits);
0109 }
0110
0111
0112 for (auto it = hebUncalibRecHits->begin(); it != hebUncalibRecHits->end(); ++it) {
0113 worker_->run(evt, *it, *hebRecHits);
0114 }
0115
0116
0117 eeRecHits->sort();
0118 hefRecHits->sort();
0119 hebRecHits->sort();
0120
0121
0122 LogInfo("HGCalRecHitInfo") << "total # HGCee calibrated rechits: " << eeRecHits->size();
0123 LogInfo("HGCalRecHitInfo") << "total # HGChef calibrated rechits: " << hefRecHits->size();
0124 LogInfo("HGCalRecHitInfo") << "total # HGCheb calibrated rechits: " << hebRecHits->size();
0125
0126 evt.put(std::move(eeRecHits), eeRechitCollection_);
0127 evt.put(std::move(hefRecHits), hefRechitCollection_);
0128 evt.put(std::move(hebRecHits), hebRechitCollection_);
0129
0130
0131 if (pHGChfnoseUncalibRecHits.isValid()) {
0132 auto hfnoseRecHits = std::make_unique<HGChfnoseRecHitCollection>();
0133 for (auto it = hfnoseUncalibRecHits->begin(); it != hfnoseUncalibRecHits->end(); ++it) {
0134 worker_->run(evt, *it, *hfnoseRecHits);
0135 }
0136 hfnoseRecHits->sort();
0137 LogInfo("HGCalRecHitInfo") << "total # HGChfnose calibrated rechits: " << hfnoseRecHits->size();
0138 evt.put(std::move(hfnoseRecHits), hfnoseRechitCollection_);
0139 }
0140 }
0141
0142 #include "FWCore/Framework/interface/MakerMacros.h"
0143 DEFINE_FWK_MODULE(HGCalRecHitProducer);