CMS 3D CMS Logo

EcalMaxSampleUncalibRecHitProducer.cc

Go to the documentation of this file.
00001 
00010 #include "RecoLocalCalo/EcalRecProducers/interface/EcalMaxSampleUncalibRecHitProducer.h"
00011 #include "DataFormats/EcalDigi/interface/EcalDigiCollections.h"
00012 #include "DataFormats/EcalDigi/interface/EcalMGPASample.h"
00013 #include "DataFormats/Common/interface/Handle.h"
00014 
00015 #include <iostream>
00016 #include <iomanip>
00017 #include <cmath>
00018 
00019 #include "FWCore/Framework/interface/ESHandle.h"
00020 
00021 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00022 
00023 #include "DataFormats/EcalRecHit/interface/EcalUncalibratedRecHit.h"
00024 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
00025 
00026 #include <vector>
00027 
00028 EcalMaxSampleUncalibRecHitProducer::EcalMaxSampleUncalibRecHitProducer(const edm::ParameterSet& ps) {
00029 
00030   EBdigiCollection_ = ps.getParameter<edm::InputTag>("EBdigiCollection");
00031   EEdigiCollection_ = ps.getParameter<edm::InputTag>("EEdigiCollection");
00032   EBhitCollection_  = ps.getParameter<std::string>("EBhitCollection");
00033   EEhitCollection_  = ps.getParameter<std::string>("EEhitCollection");
00034   produces< EBUncalibratedRecHitCollection >(EBhitCollection_);
00035   produces< EEUncalibratedRecHitCollection >(EEhitCollection_);
00036 }
00037 
00038 EcalMaxSampleUncalibRecHitProducer::~EcalMaxSampleUncalibRecHitProducer() {
00039 }
00040 
00041 void
00042 EcalMaxSampleUncalibRecHitProducer::produce(edm::Event& evt, const edm::EventSetup& es) {
00043 
00044   using namespace edm;
00045 
00046   Handle< EBDigiCollection > pEBDigis;
00047   Handle< EEDigiCollection > pEEDigis;
00048 
00049   const EBDigiCollection* EBdigis =0;
00050   const EEDigiCollection* EEdigis =0;
00051 
00052   if ( EBdigiCollection_.label() != "" && EBdigiCollection_.instance() != "" ) {
00053           evt.getByLabel( EBdigiCollection_, pEBDigis);
00054           if ( pEBDigis.isValid() ) {
00055                   EBdigis = pEBDigis.product(); // get a ptr to the produc
00056                   edm::LogInfo("EcalUncalibRecHitInfo") << "total # EBdigis: " << EBdigis->size() ;
00057           } else {
00058                   edm::LogError("EcalUncalibRecHitError") << "Error! can't get the product " << EBdigiCollection_;
00059           }
00060   }
00061 
00062   if ( EEdigiCollection_.label() != "" && EEdigiCollection_.instance() != "" ) {
00063           evt.getByLabel( EEdigiCollection_, pEEDigis);
00064           if ( pEEDigis.isValid() ) {
00065                   EEdigis = pEEDigis.product(); // get a ptr to the product
00066                   edm::LogInfo("EcalUncalibRecHitInfo") << "total # EEdigis: " << EEdigis->size() ;
00067           } else {
00068                   edm::LogError("EcalUncalibRecHitError") << "Error! can't get the product " << EEdigiCollection_;
00069           }
00070   }
00071 
00072   // collection of reconstructed ampltudes to put in the event
00073 
00074   std::auto_ptr< EBUncalibratedRecHitCollection > EBuncalibRechits( new EBUncalibratedRecHitCollection );
00075   std::auto_ptr< EEUncalibratedRecHitCollection > EEuncalibRechits( new EEUncalibratedRecHitCollection );
00076 
00077   // loop over EB digis
00078   if (EBdigis)
00079     {
00080       EBuncalibRechits->reserve(EBdigis->size());
00081       for(EBDigiCollection::const_iterator itdg = EBdigis->begin(); itdg != EBdigis->end(); ++itdg) {
00082 
00083         EcalUncalibratedRecHit aHit =
00084           EBalgo_.makeRecHit(*itdg, 0, 0, 0, 0 );
00085         EBuncalibRechits->push_back( aHit );
00086 
00087       }// end loop eb
00088     }// end if EB
00089 
00090 
00091   // loop over EB digis
00092   if (EEdigis)
00093     {
00094       EEuncalibRechits->reserve(EEdigis->size());
00095 
00096       for(EEDigiCollection::const_iterator itdg = EEdigis->begin(); itdg != EEdigis->end(); ++itdg) {
00097 
00098         EcalUncalibratedRecHit aHit =
00099           EEalgo_.makeRecHit(*itdg, 0, 0, 0, 0 );
00100         EEuncalibRechits->push_back( aHit );
00101 
00102       }// loop EE
00103     }// if EE
00104 
00105   // put the collection of recunstructed hits in the event
00106   evt.put( EBuncalibRechits, EBhitCollection_ );
00107   evt.put( EEuncalibRechits, EEhitCollection_ );
00108 }

Generated on Tue Jun 9 17:43:47 2009 for CMSSW by  doxygen 1.5.4