CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/RecoLocalCalo/EcalRecProducers/plugins/ESRecHitProducer.cc

Go to the documentation of this file.
00001 #include "RecoLocalCalo/EcalRecProducers/plugins/ESRecHitProducer.h"
00002 
00003 #include "RecoLocalCalo/EcalRecProducers/interface/ESRecHitWorkerFactory.h"
00004 
00005 #include "DataFormats/EcalDigi/interface/EcalDigiCollections.h"
00006 #include "DataFormats/EcalRecHit/interface/EcalRecHit.h"
00007 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
00008 #include "DataFormats/Common/interface/EDCollection.h"
00009 #include "DataFormats/Common/interface/Handle.h"
00010 
00011 #include "FWCore/Framework/interface/Selector.h"
00012 #include "FWCore/Framework/interface/ESHandle.h"
00013 #include "FWCore/Framework/interface/EventSetup.h"
00014 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00015 
00016 ESRecHitProducer::ESRecHitProducer(edm::ParameterSet const& ps) {
00017 
00018   digiCollection_ = ps.getParameter<edm::InputTag>("ESdigiCollection");
00019   rechitCollection_ = ps.getParameter<std::string>("ESrechitCollection");
00020   produces<ESRecHitCollection>(rechitCollection_);
00021   
00022   std::string componentType = ps.getParameter<std::string>("algo");
00023   worker_ = ESRecHitWorkerFactory::get()->create( componentType, ps );
00024 }
00025 
00026 ESRecHitProducer::~ESRecHitProducer() {
00027 
00028   delete worker_;
00029 }
00030 
00031 void ESRecHitProducer::produce(edm::Event& e, const edm::EventSetup& es) {
00032 
00033   edm::Handle<ESDigiCollection> digiHandle;  
00034   const ESDigiCollection* digi=0;
00035   e.getByLabel( digiCollection_, digiHandle);
00036   if ( digiHandle.isValid() ) {
00037     digi = digiHandle.product();
00038     LogDebug("ESRecHitInfo") << "total # ESdigis: " << digi->size();
00039   } else {
00040     edm::LogError("ESRecHitInfo") << "Error! can't get the product " << digiCollection_;
00041   }
00042   
00043   // Create empty output
00044   std::auto_ptr<ESRecHitCollection> rec(new ESRecHitCollection );
00045   
00046   if ( digi ) {
00047     rec->reserve(digi->size()); 
00048     
00049     worker_->set( es );
00050     
00051     // run the algorithm
00052     ESDigiCollection::const_iterator i;
00053     for (i=digi->begin(); i!=digi->end(); i++) {    
00054       worker_->run( e, i, *rec );
00055     }
00056   }
00057   
00058   e.put(rec,rechitCollection_);
00059 }
00060 
00061 #include "FWCore/Framework/interface/MakerMacros.h"  
00062 DEFINE_FWK_MODULE( ESRecHitProducer );
00063