CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EcalUncalibRecHitProducer.cc
Go to the documentation of this file.
2 
5 
7 
9 
11 
13 {
14  ebDigiCollection_ = ps.getParameter<edm::InputTag>("EBdigiCollection");
15  eeDigiCollection_ = ps.getParameter<edm::InputTag>("EEdigiCollection");
16  ebHitCollection_ = ps.getParameter<std::string>("EBhitCollection");
17  eeHitCollection_ = ps.getParameter<std::string>("EEhitCollection");
18  produces< EBUncalibratedRecHitCollection >(ebHitCollection_);
19  produces< EEUncalibratedRecHitCollection >(eeHitCollection_);
20 
21  std::string componentType = ps.getParameter<std::string>("algo");
22  worker_ = EcalUncalibRecHitWorkerFactory::get()->create(componentType, ps);
23 }
24 
26 {
27  delete worker_;
28 }
29 
30 void
32 
33  using namespace edm;
34 
37 
38  const EBDigiCollection* ebDigis =0;
39  const EEDigiCollection* eeDigis =0;
40 
41  if ( ebDigiCollection_.label() != "" && ebDigiCollection_.instance() != "" ) {
42  evt.getByLabel( ebDigiCollection_, pEBDigis);
43  //evt.getByLabel( digiProducer_, pEBDigis);
44  if ( pEBDigis.isValid() ) {
45  ebDigis = pEBDigis.product(); // get a ptr to the produc
46  edm::LogInfo("EcalUncalibRecHitInfo") << "total # ebDigis: " << ebDigis->size() ;
47  } else {
48  edm::LogError("EcalUncalibRecHitError") << "Error! can't get the product " << ebDigiCollection_;
49  }
50  }
51 
52  if ( eeDigiCollection_.label() != "" && eeDigiCollection_.instance() != "" ) {
53  evt.getByLabel( eeDigiCollection_, pEEDigis);
54  //evt.getByLabel( digiProducer_, pEEDigis);
55  if ( pEEDigis.isValid() ) {
56  eeDigis = pEEDigis.product(); // get a ptr to the product
57  edm::LogInfo("EcalUncalibRecHitInfo") << "total # eeDigis: " << eeDigis->size() ;
58  } else {
59  edm::LogError("EcalUncalibRecHitError") << "Error! can't get the product " << eeDigiCollection_;
60  }
61  }
62 
63  // tranparently get things from event setup
64  worker_->set(es);
65 
66  // prepare output
67  std::auto_ptr< EBUncalibratedRecHitCollection > ebUncalibRechits( new EBUncalibratedRecHitCollection );
68  std::auto_ptr< EEUncalibratedRecHitCollection > eeUncalibRechits( new EEUncalibratedRecHitCollection );
69 
70  // loop over EB digis
71  if (ebDigis)
72  {
73  ebUncalibRechits->reserve(ebDigis->size());
74  for(EBDigiCollection::const_iterator itdg = ebDigis->begin(); itdg != ebDigis->end(); ++itdg) {
75  worker_->run(evt, itdg, *ebUncalibRechits);
76  }
77  }
78 
79  // loop over EB digis
80  if (eeDigis)
81  {
82  eeUncalibRechits->reserve(eeDigis->size());
83  for(EEDigiCollection::const_iterator itdg = eeDigis->begin(); itdg != eeDigis->end(); ++itdg) {
84  worker_->run(evt, itdg, *eeUncalibRechits);
85  }
86  }
87 
88  // put the collection of recunstructed hits in the event
89  evt.put( ebUncalibRechits, ebHitCollection_ );
90  evt.put( eeUncalibRechits, eeHitCollection_ );
91 }
92 
T getParameter(std::string const &) const
virtual void produce(edm::Event &evt, const edm::EventSetup &es)
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
virtual void set(const edm::EventSetup &es)=0
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
EcalUncalibRecHitWorkerBaseClass * worker_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
EcalUncalibRecHitProducer(const edm::ParameterSet &ps)
virtual bool run(const edm::Event &evt, const EcalDigiCollection::const_iterator &digi, EcalUncalibratedRecHitCollection &result)=0
std::string const & label() const
Definition: InputTag.h:25
std::string const & instance() const
Definition: InputTag.h:26
T get(const Candidate &c)
Definition: component.h:56