Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 10:00:11

0001 #include "RecoLocalCalo/HGCalRecProducers/plugins/HGCalUncalibRecHitProducer.h"
0002 
0003 #include "DataFormats/HGCDigi/interface/HGCDigiCollections.h"
0004 #include "DataFormats/Common/interface/Handle.h"
0005 
0006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0007 
0008 #include "RecoLocalCalo/HGCalRecProducers/interface/HGCalUncalibRecHitWorkerFactory.h"
0009 
0010 #include "DataFormats/HGCRecHit/interface/HGCRecHitCollections.h"
0011 
0012 HGCalUncalibRecHitProducer::HGCalUncalibRecHitProducer(const edm::ParameterSet& ps)
0013     : eeDigiCollection_(consumes<HGCalDigiCollection>(ps.getParameter<edm::InputTag>("HGCEEdigiCollection"))),
0014       hefDigiCollection_(consumes<HGCalDigiCollection>(ps.getParameter<edm::InputTag>("HGCHEFdigiCollection"))),
0015       hebDigiCollection_(consumes<HGCalDigiCollection>(ps.getParameter<edm::InputTag>("HGCHEBdigiCollection"))),
0016       hfnoseDigiCollection_(consumes<HGCalDigiCollection>(ps.getParameter<edm::InputTag>("HGCHFNosedigiCollection"))),
0017       ee_geometry_token_(esConsumes(edm::ESInputTag("", "HGCalEESensitive"))),
0018       hef_geometry_token_(esConsumes(edm::ESInputTag("", "HGCalHESiliconSensitive"))),
0019       heb_geometry_token_(esConsumes(edm::ESInputTag("", "HGCalHEScintillatorSensitive"))),
0020       hfnose_geometry_token_(esConsumes(edm::ESInputTag("", "HGCalHFNoseSensitive"))),
0021       eeHitCollection_(ps.getParameter<std::string>("HGCEEhitCollection")),
0022       hefHitCollection_(ps.getParameter<std::string>("HGCHEFhitCollection")),
0023       hebHitCollection_(ps.getParameter<std::string>("HGCHEBhitCollection")),
0024       hfnoseHitCollection_(ps.getParameter<std::string>("HGCHFNosehitCollection")),
0025       worker_{HGCalUncalibRecHitWorkerFactory::get()->create(
0026           ps.getParameter<std::string>("algo"), ps, consumesCollector())} {
0027   produces<HGCeeUncalibratedRecHitCollection>(eeHitCollection_);
0028   produces<HGChefUncalibratedRecHitCollection>(hefHitCollection_);
0029   produces<HGChebUncalibratedRecHitCollection>(hebHitCollection_);
0030   produces<HGChfnoseUncalibratedRecHitCollection>(hfnoseHitCollection_);
0031 }
0032 
0033 HGCalUncalibRecHitProducer::~HGCalUncalibRecHitProducer() {}
0034 
0035 void HGCalUncalibRecHitProducer::produce(edm::Event& evt, const edm::EventSetup& es) {
0036   using namespace edm;
0037 
0038   // prepare output
0039   auto eeUncalibRechits = std::make_unique<HGCeeUncalibratedRecHitCollection>();
0040   auto hefUncalibRechits = std::make_unique<HGChefUncalibratedRecHitCollection>();
0041   auto hebUncalibRechits = std::make_unique<HGChebUncalibratedRecHitCollection>();
0042   auto hfnoseUncalibRechits = std::make_unique<HGChfnoseUncalibratedRecHitCollection>();
0043 
0044   // loop over HGCEE digis
0045   const auto& pHGCEEDigis = evt.getHandle(eeDigiCollection_);
0046   if (pHGCEEDigis.isValid())
0047     worker_->runHGCEE(es.getHandle(ee_geometry_token_), *pHGCEEDigis, *eeUncalibRechits);
0048 
0049   // loop over HGCHEsil digis
0050   const auto& pHGCHEFDigis = evt.getHandle(hefDigiCollection_);
0051   if (pHGCHEFDigis.isValid())
0052     worker_->runHGCHEsil(es.getHandle(hef_geometry_token_), *pHGCHEFDigis, *hefUncalibRechits);
0053 
0054   // loop over HGCHEscint digis
0055   const auto& pHGCHEBDigis = evt.getHandle(hebDigiCollection_);
0056   if (pHGCHEBDigis.isValid())
0057     worker_->runHGCHEscint(es.getHandle(heb_geometry_token_), *pHGCHEBDigis, *hebUncalibRechits);
0058 
0059   // loop over HFNose digis
0060   const auto& pHGCHFNoseDigis = evt.getHandle(hfnoseDigiCollection_);
0061   if (pHGCHFNoseDigis.isValid())
0062     worker_->runHGCHFNose(es.getHandle(hfnose_geometry_token_), *pHGCHFNoseDigis, *hfnoseUncalibRechits);
0063 
0064   // put the collection of recunstructed hits in the event
0065   evt.put(std::move(eeUncalibRechits), eeHitCollection_);
0066   evt.put(std::move(hefUncalibRechits), hefHitCollection_);
0067   evt.put(std::move(hebUncalibRechits), hebHitCollection_);
0068   if (pHGCHFNoseDigis.isValid())
0069     evt.put(std::move(hfnoseUncalibRechits), hfnoseHitCollection_);
0070 }
0071 
0072 #include "FWCore/Framework/interface/MakerMacros.h"
0073 
0074 DEFINE_FWK_MODULE(HGCalUncalibRecHitProducer);