File indexing completed on 2024-10-16 05:06:33
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 eeRecHits->reserve(eeUncalibRecHits->size());
0103 hefRecHits->reserve(hefUncalibRecHits->size());
0104 hebRecHits->reserve(hebUncalibRecHits->size());
0105
0106
0107 worker_->run(evt, *eeUncalibRecHits, *eeRecHits);
0108
0109
0110 worker_->run(evt, *hefUncalibRecHits, *hefRecHits);
0111
0112
0113 worker_->run(evt, *hebUncalibRecHits, *hebRecHits);
0114
0115 std::sort(eeRecHits->begin(), eeRecHits->end());
0116 std::sort(hefRecHits->begin(), hefRecHits->end());
0117 std::sort(hebRecHits->begin(), hebRecHits->end());
0118
0119
0120 LogInfo("HGCalRecHitInfo") << "total # HGCee calibrated rechits: " << eeRecHits->size();
0121 LogInfo("HGCalRecHitInfo") << "total # HGChef calibrated rechits: " << hefRecHits->size();
0122 LogInfo("HGCalRecHitInfo") << "total # HGCheb calibrated rechits: " << hebRecHits->size();
0123
0124 evt.put(std::move(eeRecHits), eeRechitCollection_);
0125 evt.put(std::move(hefRecHits), hefRechitCollection_);
0126 evt.put(std::move(hebRecHits), hebRechitCollection_);
0127
0128
0129 if (pHGChfnoseUncalibRecHits.isValid()) {
0130 auto hfnoseRecHits = std::make_unique<HGChfnoseRecHitCollection>();
0131 hfnoseRecHits->reserve(hfnoseUncalibRecHits->size());
0132 worker_->run(evt, *hfnoseUncalibRecHits, *hfnoseRecHits);
0133 std::sort(hfnoseRecHits->begin(), hfnoseRecHits->end());
0134 LogInfo("HGCalRecHitInfo") << "total # HGChfnose calibrated rechits: " << hfnoseRecHits->size();
0135 evt.put(std::move(hfnoseRecHits), hfnoseRechitCollection_);
0136 }
0137 }
0138
0139 #include "FWCore/Framework/interface/MakerMacros.h"
0140 DEFINE_FWK_MODULE(HGCalRecHitProducer);