CMS 3D CMS Logo

Public Member Functions | Private Attributes

EcalRecHitRecalib Class Reference

#include <CalibCalorimetry/CaloMiscalibTools.src/EcalRecHitRecalib.cc>

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

List of all members.

Public Member Functions

 EcalRecHitRecalib (const edm::ParameterSet &)
virtual void produce (edm::Event &, const edm::EventSetup &)
 ~EcalRecHitRecalib ()

Private Attributes

std::string barrelHits_
std::string ecalHitsProducer_
std::string endcapHits_
std::string RecalibBarrelHits_
std::string RecalibEndcapHits_
double refactor_
double refactor_mean_

Detailed Description

Description: Producer to miscalibrate (calibrated) Ecal RecHit

Implementation: <Notes on="" implementation>="">

Definition at line 40 of file EcalRecHitRecalib.h.


Constructor & Destructor Documentation

EcalRecHitRecalib::EcalRecHitRecalib ( const edm::ParameterSet iConfig) [explicit]

Definition at line 15 of file EcalRecHitRecalib.cc.

References barrelHits_, ecalHitsProducer_, endcapHits_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), RecalibBarrelHits_, RecalibEndcapHits_, refactor_, and refactor_mean_.

{
  ecalHitsProducer_ = iConfig.getParameter< std::string > ("ecalRecHitsProducer");
  barrelHits_ = iConfig.getParameter< std::string > ("barrelHitCollection");
  endcapHits_ = iConfig.getParameter< std::string > ("endcapHitCollection");
  RecalibBarrelHits_ = iConfig.getParameter< std::string > ("RecalibBarrelHitCollection");
  RecalibEndcapHits_ = iConfig.getParameter< std::string > ("RecalibEndcapHitCollection");
  refactor_ = iConfig.getUntrackedParameter<double> ("Refactor",(double)1);
  refactor_mean_ = iConfig.getUntrackedParameter<double> ("Refactor_mean",(double)1);

  //register your products
  produces< EBRecHitCollection >(RecalibBarrelHits_);
  produces< EERecHitCollection >(RecalibEndcapHits_);
}
EcalRecHitRecalib::~EcalRecHitRecalib ( )

Definition at line 31 of file EcalRecHitRecalib.cc.

{
 

}

Member Function Documentation

void EcalRecHitRecalib::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
) [virtual]

Implements edm::EDProducer.

Definition at line 40 of file EcalRecHitRecalib.cc.

References barrelHits_, egHLT::errCodes::EBRecHits, ecalHitsProducer_, egHLT::errCodes::EERecHits, endcapHits_, edm::EventSetup::get(), edm::Event::getByLabel(), EcalCondObjectContainer< T >::getMap(), LogDebug, edm::Event::put(), RecalibBarrelHits_, RecalibEndcapHits_, refactor_, and refactor_mean_.

{
  using namespace edm;
  using namespace std;

  Handle<EBRecHitCollection> barrelRecHitsHandle;
  Handle<EERecHitCollection> endcapRecHitsHandle;

  const EBRecHitCollection*  EBRecHits = 0;
  const EERecHitCollection*  EERecHits = 0; 
 
  iEvent.getByLabel(ecalHitsProducer_,barrelHits_,barrelRecHitsHandle);
  if (!barrelRecHitsHandle.isValid()) {
    LogDebug("") << "EcalREcHitMiscalib: Error! can't get product!" << std::endl;
  } else {
    EBRecHits = barrelRecHitsHandle.product(); // get a ptr to the product
  }

  iEvent.getByLabel(ecalHitsProducer_,endcapHits_,endcapRecHitsHandle);
  if (!endcapRecHitsHandle.isValid()) {
    LogDebug("") << "EcalREcHitMiscalib: Error! can't get product!" << std::endl;
  } else {
    EERecHits = endcapRecHitsHandle.product(); // get a ptr to the product
  }

  //Create empty output collections
  std::auto_ptr< EBRecHitCollection > RecalibEBRecHitCollection( new EBRecHitCollection );
  std::auto_ptr< EERecHitCollection > RecalibEERecHitCollection( new EERecHitCollection );


  // Intercalib constants
  edm::ESHandle<EcalIntercalibConstants> pIcal;
  iSetup.get<EcalIntercalibConstantsRcd>().get(pIcal);
  const EcalIntercalibConstants* ical = pIcal.product();

  if(EBRecHits)
    {

       //loop on all EcalRecHits (barrel)
      EBRecHitCollection::const_iterator itb;
      for (itb=EBRecHits->begin(); itb!=EBRecHits->end(); itb++) {
        
        // find intercalib constant for this xtal
        EcalIntercalibConstantMap::const_iterator icalit=ical->getMap().find(itb->id().rawId());
        EcalIntercalibConstant icalconst = -1;

        if( icalit!=ical->getMap().end() ){
          icalconst = (*icalit);
          // edm::LogDebug("EcalRecHitRecalib") << "Found intercalib for xtal " << EBDetId(itb->id()) << " " << icalconst ;

        } else {
          edm::LogError("EcalRecHitRecalib") << "No intercalib const found for xtal " << EBDetId(itb->id()) << "! something wrong with EcalIntercalibConstants in your DB? "
              ;
          }
          
          // make the rechit with rescaled energy and put in the output collection
        icalconst=refactor_mean_+(icalconst-refactor_mean_)*refactor_; //apply additional scaling factor (works if gaussian)
        EcalRecHit aHit(itb->id(),itb->energy()*icalconst,itb->time());
          
        RecalibEBRecHitCollection->push_back( aHit);
      }
    }

  if(EERecHits)
    {

       //loop on all EcalRecHits (barrel)
      EERecHitCollection::const_iterator ite;
      for (ite=EERecHits->begin(); ite!=EERecHits->end(); ite++) {
        
        // find intercalib constant for this xtal
        EcalIntercalibConstantMap::const_iterator icalit=ical->getMap().find(ite->id().rawId());
        EcalIntercalibConstant icalconst = -1;

        if( icalit!=ical->getMap().end() ){
          icalconst = (*icalit);
          // edm:: LogDebug("EcalRecHitRecalib") << "Found intercalib for xtal " << EEDetId(ite->id()) << " " << icalconst ;
          } else {
            edm::LogError("EcalRecHitRecalib") << "No intercalib const found for xtal " << EEDetId(ite->id()) << "! something wrong with EcalIntercalibConstants in your DB? "
              ;
          }
          
          // make the rechit with rescaled energy and put in the output collection
        
        icalconst=refactor_mean_+(icalconst-refactor_mean_)*refactor_; //apply additional scaling factor (works if gaussian)
        EcalRecHit aHit(ite->id(),ite->energy()*icalconst,ite->time());
        
        RecalibEERecHitCollection->push_back( aHit);
      }
    }


  //Put Recalibrated rechit in the event
  iEvent.put( RecalibEBRecHitCollection, RecalibBarrelHits_);
  iEvent.put( RecalibEERecHitCollection, RecalibEndcapHits_);
  
}

Member Data Documentation

std::string EcalRecHitRecalib::barrelHits_ [private]

Definition at line 51 of file EcalRecHitRecalib.h.

Referenced by EcalRecHitRecalib(), and produce().

std::string EcalRecHitRecalib::ecalHitsProducer_ [private]

Definition at line 50 of file EcalRecHitRecalib.h.

Referenced by EcalRecHitRecalib(), and produce().

std::string EcalRecHitRecalib::endcapHits_ [private]

Definition at line 52 of file EcalRecHitRecalib.h.

Referenced by EcalRecHitRecalib(), and produce().

Definition at line 53 of file EcalRecHitRecalib.h.

Referenced by EcalRecHitRecalib(), and produce().

Definition at line 54 of file EcalRecHitRecalib.h.

Referenced by EcalRecHitRecalib(), and produce().

double EcalRecHitRecalib::refactor_ [private]

Definition at line 55 of file EcalRecHitRecalib.h.

Referenced by EcalRecHitRecalib(), and produce().

Definition at line 56 of file EcalRecHitRecalib.h.

Referenced by EcalRecHitRecalib(), and produce().