CMS 3D CMS Logo

HGCalUncalibRecHitProducer.cc
Go to the documentation of this file.
2 
5 
7 
9 
11 
13  : eeDigiCollection_(consumes<HGCalDigiCollection>(ps.getParameter<edm::InputTag>("HGCEEdigiCollection"))),
14  hefDigiCollection_(consumes<HGCalDigiCollection>(ps.getParameter<edm::InputTag>("HGCHEFdigiCollection"))),
15  hebDigiCollection_(consumes<HGCalDigiCollection>(ps.getParameter<edm::InputTag>("HGCHEBdigiCollection"))),
16  hfnoseDigiCollection_(consumes<HGCalDigiCollection>(ps.getParameter<edm::InputTag>("HGCHFNosedigiCollection"))),
17  eeHitCollection_(ps.getParameter<std::string>("HGCEEhitCollection")),
18  hefHitCollection_(ps.getParameter<std::string>("HGCHEFhitCollection")),
19  hebHitCollection_(ps.getParameter<std::string>("HGCHEBhitCollection")),
20  hfnoseHitCollection_(ps.getParameter<std::string>("HGCHFNosehitCollection")),
21  worker_{HGCalUncalibRecHitWorkerFactory::get()->create(ps.getParameter<std::string>("algo"), ps)} {
22  produces<HGCeeUncalibratedRecHitCollection>(eeHitCollection_);
23  produces<HGChefUncalibratedRecHitCollection>(hefHitCollection_);
24  produces<HGChebUncalibratedRecHitCollection>(hebHitCollection_);
25  produces<HGChfnoseUncalibratedRecHitCollection>(hfnoseHitCollection_);
26 }
27 
29 
31  using namespace edm;
32 
33  // tranparently get things from event setup
34  worker_->set(es);
35 
36  // prepare output
37  auto eeUncalibRechits = std::make_unique<HGCeeUncalibratedRecHitCollection>();
38  auto hefUncalibRechits = std::make_unique<HGChefUncalibratedRecHitCollection>();
39  auto hebUncalibRechits = std::make_unique<HGChebUncalibratedRecHitCollection>();
40  auto hfnoseUncalibRechits = std::make_unique<HGChfnoseUncalibratedRecHitCollection>();
41 
42  // loop over HGCEE digis
44  evt.getByToken(eeDigiCollection_, pHGCEEDigis);
45  const HGCalDigiCollection* eeDigis = pHGCEEDigis.product();
46  eeUncalibRechits->reserve(eeDigis->size());
47  for (auto itdg = eeDigis->begin(); itdg != eeDigis->end(); ++itdg) {
48  worker_->runHGCEE(itdg, *eeUncalibRechits);
49  }
50 
51  // loop over HGCHEsil digis
53  evt.getByToken(hefDigiCollection_, pHGCHEFDigis);
54  const HGCalDigiCollection* hefDigis = pHGCHEFDigis.product();
55  hefUncalibRechits->reserve(hefDigis->size());
56  for (auto itdg = hefDigis->begin(); itdg != hefDigis->end(); ++itdg) {
57  worker_->runHGCHEsil(itdg, *hefUncalibRechits);
58  }
59 
60  // loop over HGCHEscint digis
62  evt.getByToken(hebDigiCollection_, pHGCHEBDigis);
63  const HGCalDigiCollection* hebDigis = pHGCHEBDigis.product();
64  hebUncalibRechits->reserve(hebDigis->size());
65  for (auto itdg = hebDigis->begin(); itdg != hebDigis->end(); ++itdg) {
66  worker_->runHGCHEscint(itdg, *hebUncalibRechits);
67  }
68 
69  // loop over HFNose digis
70  edm::Handle<HGCalDigiCollection> pHGCHFNoseDigis;
71  evt.getByToken(hfnoseDigiCollection_, pHGCHFNoseDigis);
72  if (pHGCHFNoseDigis.isValid()) {
73  const HGCalDigiCollection* hfnoseDigis = pHGCHFNoseDigis.product();
74  if (!(hfnoseDigis->empty())) {
75  hfnoseUncalibRechits->reserve(hfnoseDigis->size());
76  for (auto itdg = hfnoseDigis->begin(); itdg != hfnoseDigis->end(); ++itdg)
77  worker_->runHGCHFNose(itdg, *hfnoseUncalibRechits);
78  }
79  }
80 
81  // put the collection of recunstructed hits in the event
82  evt.put(std::move(eeUncalibRechits), eeHitCollection_);
83  evt.put(std::move(hefUncalibRechits), hefHitCollection_);
84  evt.put(std::move(hebUncalibRechits), hebHitCollection_);
85  if (pHGCHFNoseDigis.isValid())
86  evt.put(std::move(hfnoseUncalibRechits), hfnoseHitCollection_);
87 }
88 
90 
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
const edm::EDGetTokenT< HGCalDigiCollection > eeDigiCollection_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
edm::EDGetTokenT< HGCalDigiCollection > hebDigiCollection_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
bool isValid() const
Definition: HandleBase.h:70
edm::EDGetTokenT< HGCalDigiCollection > hfnoseDigiCollection_
const_iterator end() const
T const * product() const
Definition: Handle.h:69
const edm::EDGetTokenT< HGCalDigiCollection > hefDigiCollection_
std::unique_ptr< HGCalUncalibRecHitWorkerBaseClass > worker_
HGCalUncalibRecHitProducer(const edm::ParameterSet &ps)
HLT enums.
size_type size() const
void produce(edm::Event &evt, const edm::EventSetup &es) override
void reserve(size_type n)
def move(src, dest)
Definition: eostools.py:511
const_iterator begin() const