CMS 3D CMS Logo

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