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 
46  : eeUncalibRecHitCollection_(
47  consumes<HGCeeUncalibratedRecHitCollection>(ps.getParameter<edm::InputTag>("HGCEEuncalibRecHitCollection"))),
48  hefUncalibRecHitCollection_(consumes<HGChefUncalibratedRecHitCollection>(
49  ps.getParameter<edm::InputTag>("HGCHEFuncalibRecHitCollection"))),
50  hebUncalibRecHitCollection_(consumes<HGChebUncalibratedRecHitCollection>(
51  ps.getParameter<edm::InputTag>("HGCHEBuncalibRecHitCollection"))),
52  hfnoseUncalibRecHitCollection_(consumes<HGChfnoseUncalibratedRecHitCollection>(
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")),
58  worker_{HGCalRecHitWorkerFactory::get()->create(ps.getParameter<std::string>("algo"), ps)} {
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 
Handle.h
MessageLogger.h
edm::Handle::product
T const * product() const
Definition: Handle.h:70
HGCalRecHitProducer
Definition: HGCalRecHitProducer.cc:26
HGCalRecHitProducer::hebRechitCollection_
const std::string hebRechitCollection_
Definition: HGCalRecHitProducer.cc:39
ESHandle.h
edm::EDGetTokenT
Definition: EDGetToken.h:33
HGCalRecHitProducer::hebUncalibRecHitCollection_
const edm::EDGetTokenT< HGChebUncalibratedRecHitCollection > hebUncalibRecHitCollection_
Definition: HGCalRecHitProducer.cc:35
edm
HLT enums.
Definition: AlignableModifier.h:19
HGCalRecHitProducer::~HGCalRecHitProducer
~HGCalRecHitProducer() override
Definition: HGCalRecHitProducer.cc:65
HGCalRecHitProducer::hefRechitCollection_
const std::string hefRechitCollection_
Definition: HGCalRecHitProducer.cc:38
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89285
HGCalRecHitProducer::eeRechitCollection_
const std::string eeRechitCollection_
Definition: HGCalRecHitProducer.cc:37
EDProducer.h
edm::SortedCollection
Definition: SortedCollection.h:49
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
edm::Handle
Definition: AssociativeIterator.h:50
HGCalRecHitProducer::worker_
std::unique_ptr< HGCalRecHitWorkerBaseClass > worker_
Definition: HGCalRecHitProducer.cc:42
MakerMacros.h
HGCalRecHitWorkerFactory.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
HGCalRecHitProducer::HGCalRecHitProducer
HGCalRecHitProducer(const edm::ParameterSet &ps)
Definition: HGCalRecHitProducer.cc:45
HGCalRecHitProducer::produce
void produce(edm::Event &evt, const edm::EventSetup &es) override
Definition: HGCalRecHitProducer.cc:67
edm::SortedCollection::begin
const_iterator begin() const
Definition: SortedCollection.h:262
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:535
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HGCRecHitCollections.h
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
HGCalRecHitProducer::hfnoseUncalibRecHitCollection_
const edm::EDGetTokenT< HGChfnoseUncalibratedRecHitCollection > hfnoseUncalibRecHitCollection_
Definition: HGCalRecHitProducer.cc:36
edm::SortedCollection::end
const_iterator end() const
Definition: SortedCollection.h:267
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
edm::stream::EDProducer
Definition: EDProducer.h:38
edm::EventSetup
Definition: EventSetup.h:58
get
#define get
HGCalDetId.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
HGCalRecHitProducer::eeUncalibRecHitCollection_
const edm::EDGetTokenT< HGCeeUncalibratedRecHitCollection > eeUncalibRecHitCollection_
Definition: HGCalRecHitProducer.cc:33
HGCalRecHitWorkerBaseClass.h
HGCalRecHitProducer::hfnoseRechitCollection_
const std::string hfnoseRechitCollection_
Definition: HGCalRecHitProducer.cc:40
EventSetup.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
ParameterSet.h
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::Event
Definition: Event.h:73
HGCalRecHitProducer::hefUncalibRecHitCollection_
const edm::EDGetTokenT< HGChefUncalibratedRecHitCollection > hefUncalibRecHitCollection_
Definition: HGCalRecHitProducer.cc:34