CMS 3D CMS Logo

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