CMS 3D CMS Logo

MTDRecHitProducer.cc
Go to the documentation of this file.
5 
9 
11 
13 
15 
16  public:
17  explicit MTDRecHitProducer(const edm::ParameterSet& ps);
18  ~MTDRecHitProducer() override;
19  void produce(edm::Event& evt, const edm::EventSetup& es) override;
20 
21  private:
22 
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<MTDRecHitAlgoBase> barrel_,endcap_;
30 };
31 
33  ftlbURecHits_( consumes<FTLUncalibratedRecHitCollection>( ps.getParameter<edm::InputTag>("barrelUncalibratedRecHits") ) ),
34  ftleURecHits_( consumes<FTLUncalibratedRecHitCollection>( ps.getParameter<edm::InputTag>("endcapUncalibratedRecHits") ) ),
35  ftlbInstance_( ps.getParameter<std::string>("BarrelHitsName") ),
36  ftleInstance_( ps.getParameter<std::string>("EndcapHitsName") )
37 {
38 
39  produces< FTLRecHitCollection >(ftlbInstance_);
40  produces< FTLRecHitCollection >(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_.reset( MTDRecHitAlgoFactory::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_.reset( MTDRecHitAlgoFactory::get()->create(endcapAlgo, endcap, sumes) );
51 
52 }
53 
55 }
56 
57 void
59 
60 
61  // tranparently get things from event setup
62  barrel_->getEventSetup(es);
63  endcap_->getEventSetup(es);
64 
65  barrel_->getEvent(evt);
66  endcap_->getEvent(evt);
67 
68  // prepare output
69  auto barrelRechits = std::make_unique<FTLRecHitCollection>();
70  auto endcapRechits = std::make_unique<FTLRecHitCollection>();
71 
73  evt.getByToken( ftlbURecHits_, hBarrel );
74  barrelRechits->reserve(hBarrel->size()/2);
75  for(const auto& uhit : *hBarrel) {
76  uint32_t flags = FTLRecHit::kGood;
77  auto rechit = std::move( barrel_->makeRecHit(uhit, flags) );
78  if( flags == FTLRecHit::kGood ) barrelRechits->push_back( std::move(rechit) );
79  }
80 
82  evt.getByToken( ftleURecHits_, hEndcap );
83  endcapRechits->reserve(hEndcap->size()/2);
84  for(const auto& uhit : *hEndcap) {
85  uint32_t flags = FTLRecHit::kGood;
86  auto rechit = std::move( endcap_->makeRecHit(uhit, flags) );
87  if( flags == FTLRecHit::kGood ) endcapRechits->push_back( std::move(rechit) );
88  }
89 
90  // put the collection of recunstructed hits in the event
91  evt.put(std::move(barrelRechits), ftlbInstance_);
92  evt.put(std::move(endcapRechits), ftleInstance_);
93 }
94 
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
~MTDRecHitProducer() override
def create(alignables, pedeDump, additionalData, outputFile, config)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
MTDRecHitProducer(const edm::ParameterSet &ps)
std::vector< Variable::Flags > flags
Definition: MVATrainer.cc:135
std::unique_ptr< MTDRecHitAlgoBase > endcap_
const edm::EDGetTokenT< FTLUncalibratedRecHitCollection > ftleURecHits_
const std::string ftleInstance_
const std::string ftlbInstance_
ParameterSet const & getParameterSet(std::string const &) const
void produce(edm::Event &evt, const edm::EventSetup &es) override
HLT enums.
size_type size() const
std::unique_ptr< MTDRecHitAlgoBase > barrel_
const edm::EDGetTokenT< FTLUncalibratedRecHitCollection > ftlbURecHits_
def move(src, dest)
Definition: eostools.py:511
T get(const Candidate &c)
Definition: component.h:55