CMS 3D CMS Logo

MTDUncalibratedRecHitProducer.cc
Go to the documentation of this file.
5 
9 
11 
13 
15 
16  public:
19  void produce(edm::Event& evt, const edm::EventSetup& es) override;
20 
21  private:
22 
23  const edm::EDGetTokenT<BTLDigiCollection> ftlbDigis_; // collection of BTL digis
24  const edm::EDGetTokenT<ETLDigiCollection> ftleDigis_; // collection of ETL digis
25 
26  const std::string ftlbInstance_; // instance name of barrel hits
27  const std::string ftleInstance_; // instance name of endcap hits
28 
29  std::unique_ptr<BTLUncalibratedRecHitAlgoBase> barrel_;
30  std::unique_ptr<ETLUncalibratedRecHitAlgoBase> endcap_;
31 };
32 
34  ftlbDigis_( consumes<BTLDigiCollection>( ps.getParameter<edm::InputTag>("barrelDigis") ) ),
35  ftleDigis_( consumes<ETLDigiCollection>( ps.getParameter<edm::InputTag>("endcapDigis") ) ),
36  ftlbInstance_( ps.getParameter<std::string>("BarrelHitsName") ),
37  ftleInstance_( ps.getParameter<std::string>("EndcapHitsName") ) {
38 
39  produces< FTLUncalibratedRecHitCollection >(ftlbInstance_);
40  produces< FTLUncalibratedRecHitCollection >(ftleInstance_);
41 
42  auto sumes = consumesCollector();
43 
44  const edm::ParameterSet& barrel = ps.getParameterSet("barrel");
45  const std::string& barrelAlgo = barrel.getParameter<std::string>("algoName");
46  barrel_ = std::unique_ptr<BTLUncalibratedRecHitAlgoBase>{ BTLUncalibratedRecHitAlgoFactory::get()->create(barrelAlgo, barrel, sumes) };
47 
48  const edm::ParameterSet& endcap = ps.getParameterSet("endcap");
49  const std::string& endcapAlgo = endcap.getParameter<std::string>("algoName");
50  endcap_ = std::unique_ptr<ETLUncalibratedRecHitAlgoBase>{ ETLUncalibratedRecHitAlgoFactory::get()->create(endcapAlgo, endcap, sumes) };
51 }
52 
54 }
55 
56 void
58 
59  // tranparently get things from event setup
60  barrel_->getEventSetup(es);
61  endcap_->getEventSetup(es);
62 
63  barrel_->getEvent(evt);
64  endcap_->getEvent(evt);
65 
66  // prepare output
67  auto barrelRechits = std::make_unique<FTLUncalibratedRecHitCollection>();
68  auto endcapRechits = std::make_unique<FTLUncalibratedRecHitCollection>();
69 
71  evt.getByToken( ftlbDigis_, hBarrel );
72  barrelRechits->reserve(hBarrel->size()/2);
73  for(const auto& digi : *hBarrel) {
74  barrelRechits->emplace_back( barrel_->makeRecHit(digi) );
75  }
76 
78  evt.getByToken( ftleDigis_, hEndcap );
79  endcapRechits->reserve(hEndcap->size()/2);
80  for(const auto& digi : *hEndcap) {
81  endcapRechits->emplace_back( endcap_->makeRecHit(digi) );
82  }
83 
84  // put the collection of recunstructed hits in the event
85  evt.put(std::move(barrelRechits), ftlbInstance_);
86  evt.put(std::move(endcapRechits), ftleInstance_);
87 }
88 
T getParameter(std::string const &) const
const edm::EDGetTokenT< ETLDigiCollection > ftleDigis_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
MTDUncalibratedRecHitProducer(const edm::ParameterSet &ps)
std::unique_ptr< ETLUncalibratedRecHitAlgoBase > endcap_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
const edm::EDGetTokenT< BTLDigiCollection > ftlbDigis_
void produce(edm::Event &evt, const edm::EventSetup &es) override
ParameterSet const & getParameterSet(std::string const &) const
HLT enums.
size_type size() const
std::unique_ptr< BTLUncalibratedRecHitAlgoBase > barrel_
def move(src, dest)
Definition: eostools.py:511
T get(const Candidate &c)
Definition: component.h:55