CMS 3D CMS Logo

HGCalRecHitProducer.cc
Go to the documentation of this file.
1 
11 
13 
16 
18 
23 
25 
27 
28  public:
29  explicit HGCalRecHitProducer(const edm::ParameterSet& ps);
30  ~HGCalRecHitProducer() override;
31  void produce(edm::Event& evt, const edm::EventSetup& es) override;
32 
33  private:
34 
38  const std::string eeRechitCollection_; // instance name for HGCEE
39  const std::string hefRechitCollection_; // instance name for HGCHEF
40  const std::string hebRechitCollection_; // instance name for HGCHEB
41 
42  std::unique_ptr<HGCalRecHitWorkerBaseClass> worker_;
43 };
44 
46  eeUncalibRecHitCollection_( consumes<HGCeeUncalibratedRecHitCollection>( ps.getParameter<edm::InputTag>("HGCEEuncalibRecHitCollection") ) ),
47  hefUncalibRecHitCollection_( consumes<HGChefUncalibratedRecHitCollection>( ps.getParameter<edm::InputTag>("HGCHEFuncalibRecHitCollection") ) ),
48  hebUncalibRecHitCollection_( consumes<HGChebUncalibratedRecHitCollection>( ps.getParameter<edm::InputTag>("HGCHEBuncalibRecHitCollection") ) ),
49  eeRechitCollection_( ps.getParameter<std::string>("HGCEErechitCollection") ),
50  hefRechitCollection_( ps.getParameter<std::string>("HGCHEFrechitCollection") ),
51  hebRechitCollection_( ps.getParameter<std::string>("HGCHEBrechitCollection") ),
53 {
54  produces< HGCeeRecHitCollection >(eeRechitCollection_);
55  produces< HGChefRecHitCollection >(hefRechitCollection_);
56  produces< HGChebRecHitCollection >(hebRechitCollection_);
57 }
58 
60 }
61 
62 void
64  using namespace edm;
65 
69 
70  const HGCeeUncalibratedRecHitCollection* eeUncalibRecHits = nullptr;
71  const HGChefUncalibratedRecHitCollection* hefUncalibRecHits = nullptr;
72  const HGChebUncalibratedRecHitCollection* hebUncalibRecHits = nullptr;
73 
74  // get the HGC uncalib rechit collection
75  evt.getByToken( eeUncalibRecHitCollection_, pHGCeeUncalibRecHits);
76  eeUncalibRecHits = pHGCeeUncalibRecHits.product();
77 
78  evt.getByToken( hefUncalibRecHitCollection_, pHGChefUncalibRecHits);
79  hefUncalibRecHits = pHGChefUncalibRecHits.product();
80 
81  evt.getByToken( hebUncalibRecHitCollection_, pHGChebUncalibRecHits);
82  hebUncalibRecHits = pHGChebUncalibRecHits.product();
83 
84  // collection of rechits to put in the event
85  auto eeRecHits = std::make_unique<HGCeeRecHitCollection>();
86  auto hefRecHits = std::make_unique<HGChefRecHitCollection>();
87  auto hebRecHits = std::make_unique<HGChebRecHitCollection>();
88 
89  worker_->set(es);
90 
91  // loop over uncalibrated rechits to make calibrated ones
92  for(auto it = eeUncalibRecHits->begin(); it != eeUncalibRecHits->end(); ++it) {
93  worker_->run(evt, *it, *eeRecHits);
94  }
95 
96  // loop over uncalibrated rechits to make calibrated ones
97  for(auto it = hefUncalibRecHits->begin(); it != hefUncalibRecHits->end(); ++it) {
98  worker_->run(evt, *it, *hefRecHits);
99  }
100 
101  // loop over uncalibrated rechits to make calibrated ones
102  for(auto it = hebUncalibRecHits->begin(); it != hebUncalibRecHits->end(); ++it) {
103  worker_->run(evt, *it, *hebRecHits);
104  }
105 
106  // sort collections before attempting recovery, to avoid insertion of double recHits
107  eeRecHits->sort();
108  hefRecHits->sort();
109  hebRecHits->sort();
110 
111  // put the collection of recunstructed hits in the event
112  LogInfo("HGCalRecHitInfo") << "total # HGCee calibrated rechits: " << eeRecHits->size();
113  LogInfo("HGCalRecHitInfo") << "total # HGChef calibrated rechits: " << hefRecHits->size();
114  LogInfo("HGCalRecHitInfo") << "total # HGCheb calibrated rechits: " << hebRecHits->size();
115 
116  evt.put(std::move(eeRecHits), eeRechitCollection_);
117  evt.put(std::move(hefRecHits), hefRechitCollection_);
118  evt.put(std::move(hebRecHits), hebRechitCollection_);
119 }
120 
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
void produce(edm::Event &evt, const edm::EventSetup &es) override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
const edm::EDGetTokenT< HGChefUncalibratedRecHitCollection > hefUncalibRecHitCollection_
const edm::EDGetTokenT< HGCeeUncalibratedRecHitCollection > eeUncalibRecHitCollection_
const std::string hefRechitCollection_
const_iterator end() const
const std::string eeRechitCollection_
T const * product() const
Definition: Handle.h:74
HGCalRecHitProducer(const edm::ParameterSet &ps)
const std::string hebRechitCollection_
HLT enums.
std::unique_ptr< HGCalRecHitWorkerBaseClass > worker_
const edm::EDGetTokenT< HGChebUncalibratedRecHitCollection > hebUncalibRecHitCollection_
def move(src, dest)
Definition: eostools.py:511
T get(const Candidate &c)
Definition: component.h:55
const_iterator begin() const