CMS 3D CMS Logo

ESRecHitProducer.cc
Go to the documentation of this file.
1 // ESRecHitProducer author : Chia-Ming, Kuo
2 
13 
14 #include "ESRecHitWorker.h"
15 
17 public:
18  explicit ESRecHitProducer(const edm::ParameterSet& ps);
19  void produce(edm::Event& e, const edm::EventSetup& es) override;
20 
21 private:
23  const std::string rechitCollection_; // secondary name to be given to collection of hits
24 
25  std::unique_ptr<ESRecHitWorkerBaseClass> worker_;
26 };
27 
29  : digiToken_(consumes<ESDigiCollection>(ps.getParameter<edm::InputTag>("ESdigiCollection"))),
30  rechitCollection_(ps.getParameter<std::string>("ESrechitCollection")),
31  worker_{ESRecHitWorkerFactory::get()->create(ps.getParameter<std::string>("algo"), ps, consumesCollector())} {
32  produces<ESRecHitCollection>(rechitCollection_);
33 }
34 
37  const ESDigiCollection* digi = nullptr;
38  e.getByToken(digiToken_, digiHandle);
39 
40  digi = digiHandle.product();
41  LogDebug("ESRecHitInfo") << "total # ESdigis: " << digi->size();
42 
43  // Create empty output
44  auto rec = std::make_unique<ESRecHitCollection>();
45 
46  if (digi) {
47  rec->reserve(digi->size());
48 
49  worker_->set(es);
50 
51  // run the algorithm
52  for (ESDigiCollection::const_iterator i(digi->begin()); i != digi->end(); i++) {
53  worker_->run(i, *rec);
54  }
55  }
56 
57  e.put(std::move(rec), rechitCollection_);
58 }
59 
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::unique_ptr< ESRecHitWorkerBaseClass > worker_
ESRecHitProducer(const edm::ParameterSet &ps)
T const * product() const
Definition: Handle.h:70
const std::string rechitCollection_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void produce(edm::Event &e, const edm::EventSetup &es) override
const edm::EDGetTokenT< ESDigiCollection > digiToken_
const_iterator end() const
const_iterator begin() const
The iterator returned can not safely be used across threads.
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
HLT enums.
#define get
def move(src, dest)
Definition: eostools.py:511
#define LogDebug(id)