CMS 3D CMS Logo

Public Member Functions | Private Attributes

EcalRecalibRecHitProducer Class Reference

#include <EcalRecalibRecHitProducer.h>

Inheritance diagram for EcalRecalibRecHitProducer:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

 EcalRecalibRecHitProducer (const edm::ParameterSet &ps)
virtual void produce (edm::Event &evt, const edm::EventSetup &es)
 ~EcalRecalibRecHitProducer ()

Private Attributes

bool doEnergyScale_
bool doIntercalib_
bool doLaserCorrections_
EcalRecHitAbsAlgoEBalgo_
std::string EBRecalibRecHitCollection_
edm::InputTag EBRecHitCollection_
EcalRecHitAbsAlgoEEalgo_
std::string EERecalibRecHitCollection_
edm::InputTag EERecHitCollection_

Detailed Description

produce ECAL rechits from uncalibrated rechits

Id:
EcalRecalibRecHitProducer.cc,v 1.5 2011/09/22 17:32:18 meridian Exp
Date:
2011/09/22 17:32:18
Revision:
1.5
Author:
Federico Ferri, University of Milano Bicocca and INFN

produce ECAL rechits from uncalibrated rechits

Id:
EcalRecalibRecHitProducer.h,v 1.2 2008/12/10 02:20:30 ferriff Exp
Date:
2008/12/10 02:20:30
Revision:
1.2
Author:
Federico Ferri, University of Milano Bicocca and INFN

Definition at line 21 of file EcalRecalibRecHitProducer.h.


Constructor & Destructor Documentation

EcalRecalibRecHitProducer::EcalRecalibRecHitProducer ( const edm::ParameterSet ps) [explicit]

Definition at line 39 of file EcalRecalibRecHitProducer.cc.

References doEnergyScale_, doIntercalib_, doLaserCorrections_, EBalgo_, EBRecalibRecHitCollection_, EBRecHitCollection_, EEalgo_, EERecalibRecHitCollection_, EERecHitCollection_, and edm::ParameterSet::getParameter().

                                                                              {

   EBRecHitCollection_ = ps.getParameter<edm::InputTag>("EBRecHitCollection");
   EERecHitCollection_ = ps.getParameter<edm::InputTag>("EERecHitCollection");
   EBRecalibRecHitCollection_        = ps.getParameter<std::string>("EBRecalibRecHitCollection");
   EERecalibRecHitCollection_        = ps.getParameter<std::string>("EERecalibRecHitCollection");
   doEnergyScale_             = ps.getParameter<bool>("doEnergyScale");
   doIntercalib_              = ps.getParameter<bool>("doIntercalib");
   doLaserCorrections_        = ps.getParameter<bool>("doLaserCorrections");

   EBalgo_ = new EcalRecHitSimpleAlgo();
   EEalgo_ = new EcalRecHitSimpleAlgo();

   produces< EBRecHitCollection >(EBRecalibRecHitCollection_);
   produces< EERecHitCollection >(EERecalibRecHitCollection_);
}
EcalRecalibRecHitProducer::~EcalRecalibRecHitProducer ( )

Definition at line 56 of file EcalRecalibRecHitProducer.cc.

References EBalgo_, and EEalgo_.

                                                      {

  if (EBalgo_) delete EBalgo_;
  if (EEalgo_) delete EEalgo_;

}

Member Function Documentation

void EcalRecalibRecHitProducer::produce ( edm::Event evt,
const edm::EventSetup es 
) [virtual]

Implements edm::EDProducer.

Definition at line 63 of file EcalRecalibRecHitProducer.cc.

References doEnergyScale_, doIntercalib_, doLaserCorrections_, EBRecalibRecHitCollection_, EBRecHitCollection_, egHLT::errCodes::EBRecHits, EERecalibRecHitCollection_, EERecHitCollection_, egHLT::errCodes::EERecHits, EcalCondObjectContainer< T >::end(), EcalCondObjectContainer< T >::find(), edm::EventSetup::get(), edm::Event::getByLabel(), EcalCondObjectContainer< T >::getMap(), edm::InputTag::label(), LogDebug, edm::Event::put(), and edm::EventBase::time().

{
        using namespace edm;
        Handle< EBRecHitCollection > pEBRecHits;
        Handle< EERecHitCollection > pEERecHits;

        const EBRecHitCollection*  EBRecHits = 0;
        const EERecHitCollection*  EERecHits = 0; 

        //        if ( EBRecHitCollection_.label() != "" && EBRecHitCollection_.instance() != "" ) {
        if ( EBRecHitCollection_.label() != "" ) {
                evt.getByLabel( EBRecHitCollection_, pEBRecHits);
                if ( pEBRecHits.isValid() ) {
                        EBRecHits = pEBRecHits.product(); // get a ptr to the product
#ifdef DEBUG
                        LogDebug("EcalRecHitDebug") << "total # EB rechits to be re-calibrated: " << EBRecHits->size();
#endif
                } else {
                        edm::LogError("EcalRecHitError") << "Error! can't get the product " << EBRecHitCollection_.label() ;
                }
        }

        //        if ( EERecHitCollection_.label() != "" && EERecHitCollection_.instance() != "" ) {
        if ( EERecHitCollection_.label() != ""  ) {
                evt.getByLabel( EERecHitCollection_, pEERecHits);
                if ( pEERecHits.isValid() ) {
                        EERecHits = pEERecHits.product(); // get a ptr to the product
#ifdef DEBUG
                        LogDebug("EcalRecHitDebug") << "total # EE uncalibrated rechits to be re-calibrated: " << EERecHits->size();
#endif
                } else {
                        edm::LogError("EcalRecHitError") << "Error! can't get the product " << EERecHitCollection_.label() ;
                }
        }

        // collection of rechits to put in the event
        std::auto_ptr< EBRecHitCollection > EBRecalibRecHits( new EBRecHitCollection );
        std::auto_ptr< EERecHitCollection > EERecalibRecHits( new EERecHitCollection );

        // now fetch all conditions we need to make rechits
        // ADC to GeV constant
        edm::ESHandle<EcalADCToGeVConstant> pAgc;
        const EcalADCToGeVConstant *agc = 0;
        float agc_eb = 1.;
        float agc_ee = 1.;
        if (doEnergyScale_) {
                es.get<EcalADCToGeVConstantRcd>().get(pAgc);
                agc = pAgc.product();
                // use this value in the algorithm
                agc_eb = float(agc->getEBValue());
                agc_ee = float(agc->getEEValue());
        }
        // Intercalib constants
        edm::ESHandle<EcalIntercalibConstants> pIcal;
        const EcalIntercalibConstants *ical = 0;
        if (doIntercalib_) {
                es.get<EcalIntercalibConstantsRcd>().get(pIcal);
                ical = pIcal.product();
        }
        // Laser corrections
        edm::ESHandle<EcalLaserDbService> pLaser;
        es.get<EcalLaserDbRecord>().get( pLaser );

        if (EBRecHits) {
                // loop over uncalibrated rechits to make calibrated ones
                for(EBRecHitCollection::const_iterator it  = EBRecHits->begin(); it != EBRecHits->end(); ++it) {

                        EcalIntercalibConstant icalconst = 1.;
                        if (doIntercalib_) {
                                // find intercalib constant for this xtal
                                const EcalIntercalibConstantMap &icalMap = ical->getMap();
                                EcalIntercalibConstantMap::const_iterator icalit = icalMap.find(it->id());
                                if( icalit!=icalMap.end() ){
                                        icalconst = (*icalit);
                                } else {
                                        edm::LogError("EcalRecHitError") << "No intercalib const found for xtal " << EBDetId(it->id()) << "! something wrong with EcalIntercalibConstants in your DB? "
                                                ;
                                }
                        }
                        // get laser coefficient
                        float lasercalib = 1;
                        if (doLaserCorrections_) {
                                lasercalib = pLaser->getLaserCorrection( EBDetId(it->id()), evt.time() );
                        }

                        // make the rechit and put in the output collection
                        // must implement op= for EcalRecHit
                        EcalRecHit aHit( (*it).id(), (*it).energy() * agc_eb * icalconst * lasercalib, (*it).time() );
                        EBRecalibRecHits->push_back( aHit );
                }
        }

        if (EERecHits)
        {
                // loop over uncalibrated rechits to make calibrated ones
                for(EERecHitCollection::const_iterator it  = EERecHits->begin();
                                it != EERecHits->end(); ++it) {

                        // find intercalib constant for this xtal
                        EcalIntercalibConstant icalconst = 1.;
                        if (doIntercalib_) {
                                const EcalIntercalibConstantMap &icalMap = ical->getMap();
                                EcalIntercalibConstantMap::const_iterator icalit=icalMap.find(it->id());
                                if( icalit!=icalMap.end() ) {
                                        icalconst = (*icalit);
                                } else {
                                        edm::LogError("EcalRecHitError") << "No intercalib const found for xtal " << EEDetId(it->id()) << "! something wrong with EcalIntercalibConstants in your DB? ";
                                }
                        }
                        // get laser coefficient
                        float lasercalib = 1;
                        if (doLaserCorrections_) {
                                lasercalib = pLaser->getLaserCorrection( EEDetId(it->id()), evt.time() );
                        }

                        // make the rechit and put in the output collection
                        // must implement op= for EcalRecHit
                        //EcalRecHit aHit( EEalgo_->makeRecHit(*it, icalconst * lasercalib) );
                        EcalRecHit aHit( (*it).id(), (*it).energy() * agc_ee * icalconst * lasercalib, (*it).time() );
                        EERecalibRecHits->push_back( aHit );
                }
        }
        // put the collection of recunstructed hits in the event   
        LogInfo("EcalRecalibRecHitInfo") << "total # EB re-calibrated rechits: " << EBRecalibRecHits->size();
        LogInfo("EcalRecalibRecHitInfo") << "total # EE re-calibrated rechits: " << EERecalibRecHits->size();

        evt.put( EBRecalibRecHits, EBRecalibRecHitCollection_ );
        evt.put( EERecalibRecHits, EERecalibRecHitCollection_ );
}

Member Data Documentation

Definition at line 35 of file EcalRecalibRecHitProducer.h.

Referenced by EcalRecalibRecHitProducer(), and produce().

Definition at line 36 of file EcalRecalibRecHitProducer.h.

Referenced by EcalRecalibRecHitProducer(), and produce().

Definition at line 37 of file EcalRecalibRecHitProducer.h.

Referenced by EcalRecalibRecHitProducer(), and produce().

Definition at line 32 of file EcalRecalibRecHitProducer.h.

Referenced by EcalRecalibRecHitProducer(), and produce().

Definition at line 30 of file EcalRecalibRecHitProducer.h.

Referenced by EcalRecalibRecHitProducer(), and produce().

Definition at line 33 of file EcalRecalibRecHitProducer.h.

Referenced by EcalRecalibRecHitProducer(), and produce().

Definition at line 31 of file EcalRecalibRecHitProducer.h.

Referenced by EcalRecalibRecHitProducer(), and produce().