CMS 3D CMS Logo

Public Member Functions | Private Attributes

EgammaSCCorrectionMaker Class Reference

#include <EgammaSCCorrectionMaker/EgammaSCCorrectionMaker/src/EgammaSCCorrectionMaker.cc>

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

List of all members.

Public Member Functions

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

Private Attributes

bool applyEnergyCorrection_
EcalClusterFunctionBaseClassEnergyCorrection_
EgammaSCEnergyCorrectionAlgoenergyCorrector_
double etThresh_
std::string outputCollection_
edm::InputTag rHInputProducer_
reco::CaloCluster::AlgoId sCAlgo_
edm::InputTag sCInputProducer_
double sigmaElectronicNoise_
EgammaSCEnergyCorrectionAlgo::VerbosityLevel verbosity_

Detailed Description

Description: Producer of corrected SuperClusters

Definition at line 35 of file EgammaSCCorrectionMaker.h.


Constructor & Destructor Documentation

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

Definition at line 24 of file EgammaSCCorrectionMaker.cc.

References applyEnergyCorrection_, reco::CaloCluster::dynamicHybrid, EnergyCorrection_, energyCorrector_, etThresh_, reco::get(), edm::ParameterSet::getParameter(), reco::CaloCluster::hybrid, reco::CaloCluster::island, reco::CaloCluster::multi5x5, outputCollection_, EgammaSCEnergyCorrectionAlgo::pDEBUG, EgammaSCEnergyCorrectionAlgo::pERROR, EgammaSCEnergyCorrectionAlgo::pINFO, rHInputProducer_, sCAlgo_, sCInputProducer_, sigmaElectronicNoise_, and verbosity_.

{
 
  // The verbosity level
  std::string debugString = ps.getParameter<std::string>("VerbosityLevel");
  if      (debugString == "DEBUG")   verbosity_ = EgammaSCEnergyCorrectionAlgo::pDEBUG;
  else if (debugString == "INFO")    verbosity_ = EgammaSCEnergyCorrectionAlgo::pINFO;
  else                               verbosity_ = EgammaSCEnergyCorrectionAlgo::pERROR;

  // the input producers
  rHInputProducer_ = ps.getParameter<edm::InputTag>("recHitProducer");
  sCInputProducer_ = ps.getParameter<edm::InputTag>("rawSuperClusterProducer");
  std::string sCAlgo_str = ps.getParameter<std::string>("superClusterAlgo");

  // determine which BasicCluster algo we are correcting for
  //And obtain forrection parameters form cfg file
  edm::ParameterSet fCorrPset;
  if (sCAlgo_str=="Hybrid") {
    sCAlgo_= reco::CaloCluster::hybrid;
    fCorrPset = ps.getParameter<edm::ParameterSet>("hyb_fCorrPset"); 
  } else if (sCAlgo_str=="Island") {
    sCAlgo_= reco::CaloCluster::island;
    fCorrPset = ps.getParameter<edm::ParameterSet>("isl_fCorrPset");
  } else if (sCAlgo_str=="DynamicHybrid") {
    sCAlgo_ = reco::CaloCluster::dynamicHybrid;
    fCorrPset = ps.getParameter<edm::ParameterSet>("dyn_fCorrPset"); 
  } else if (sCAlgo_str=="Multi5x5") {
    sCAlgo_ = reco::CaloCluster::multi5x5;
    fCorrPset = ps.getParameter<edm::ParameterSet>("fix_fCorrPset");
  } else {
    edm::LogError("EgammaSCCorrectionMakerError") 
      << "Error! SuperClusterAlgo in config file must be Hybrid or Island: " 
      << sCAlgo_str << "  Using Hybrid by default";
    sCAlgo_=reco::CaloCluster::hybrid;
  }
  
  // set correction algo parameters
  applyEnergyCorrection_ = ps.getParameter<bool>("applyEnergyCorrection");
  sigmaElectronicNoise_ =  ps.getParameter<double>("sigmaElectronicNoise");

  etThresh_ =  ps.getParameter<double>("etThresh");

  // set the producer parameters
  outputCollection_ = ps.getParameter<std::string>("corectedSuperClusterCollection");
  produces<reco::SuperClusterCollection>(outputCollection_);

  // instanciate the correction algo object
  energyCorrector_ = new EgammaSCEnergyCorrectionAlgo(sigmaElectronicNoise_, sCAlgo_, fCorrPset, verbosity_);
  
  // energy correction class
  if (applyEnergyCorrection_ )
    EnergyCorrection_ = EcalClusterFunctionFactory::get()->create("EcalClusterEnergyCorrection", ps);
}
EgammaSCCorrectionMaker::~EgammaSCCorrectionMaker ( )

Definition at line 78 of file EgammaSCCorrectionMaker.cc.

References energyCorrector_.

{
  delete energyCorrector_;
}

Member Function Documentation

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

Implements edm::EDProducer.

Definition at line 84 of file EgammaSCCorrectionMaker.cc.

References EgammaSCEnergyCorrectionAlgo::applyCorrection(), applyEnergyCorrection_, DetId::Ecal, EcalBarrel, EcalEndcap, EcalPreshower, reco::CaloCluster::energy(), EnergyCorrection_, energyCorrector_, etThresh_, geometry, edm::EventSetup::get(), edm::Event::getByLabel(), reco_application_2006_simpleTBanalysis_cfg::hitCollection, EcalClusterFunctionBaseClass::init(), edm::InputTag::instance(), edm::InputTag::label(), outputCollection_, reco::CaloCluster::position(), edm::Event::put(), reco::SuperCluster::rawEnergy(), rHInputProducer_, sCAlgo_, sCInputProducer_, and funct::sin().

{
  using namespace edm;

  // initialize energy correction class
  if(applyEnergyCorrection_) 
    EnergyCorrection_->init(es);

  // get the collection geometry:
  edm::ESHandle<CaloGeometry> geoHandle;
  es.get<CaloGeometryRecord>().get(geoHandle);
  const CaloGeometry& geometry = *geoHandle;
  const CaloSubdetectorGeometry *geometry_p;

  std::string rHInputCollection = rHInputProducer_.instance();
  if(rHInputCollection == "EcalRecHitsEB") {
    geometry_p = geometry.getSubdetectorGeometry(DetId::Ecal, EcalBarrel);
  } else if(rHInputCollection == "EcalRecHitsEE") {
    geometry_p = geometry.getSubdetectorGeometry(DetId::Ecal, EcalEndcap);
  } else if(rHInputCollection == "EcalRecHitsPS") {
    geometry_p = geometry.getSubdetectorGeometry(DetId::Ecal, EcalPreshower);
  } else {
          std::string str = "\n\nSCCorrectionMaker encountered invalied ecalhitcollection type: " + rHInputCollection + ".\n\n";
          throw(std::runtime_error( str.c_str() ));
  }
  
  // Get raw SuperClusters from the event    
  Handle<reco::SuperClusterCollection> pRawSuperClusters;
  try { 
    evt.getByLabel(sCInputProducer_, pRawSuperClusters);
  } catch ( cms::Exception& ex ) {
    edm::LogError("EgammaSCCorrectionMakerError") 
      << "Error! can't get the rawSuperClusters " 
      << sCInputProducer_.label() ;
  }    
  
  // Get the RecHits from the event
  Handle<EcalRecHitCollection> pRecHits;
  try { 
    evt.getByLabel(rHInputProducer_, pRecHits);
  } catch ( cms::Exception& ex ) {
    edm::LogError("EgammaSCCorrectionMakerError") 
      << "Error! can't get the RecHits " 
      << rHInputProducer_.label();
  }    
  
  // Create a pointer to the RecHits and raw SuperClusters
  const EcalRecHitCollection *hitCollection = pRecHits.product();
  const reco::SuperClusterCollection *rawClusters = pRawSuperClusters.product();
   
  // Define a collection of corrected SuperClusters to put back into the event
  std::auto_ptr<reco::SuperClusterCollection> corrClusters(new reco::SuperClusterCollection);
  
  //  Loop over raw clusters and make corrected ones
  reco::SuperClusterCollection::const_iterator aClus;
  for(aClus = rawClusters->begin(); aClus != rawClusters->end(); aClus++)
    {
      reco::SuperCluster newClus;
      if(applyEnergyCorrection_) 
        newClus = energyCorrector_->applyCorrection(*aClus, *hitCollection, sCAlgo_, geometry_p, EnergyCorrection_);
      else
        newClus=*aClus;

      if(newClus.energy()*sin(newClus.position().theta())>etThresh_) {
        //and corrected energy of SC before placing SCs in collection
        //std::cout << " Check 1 " << "\n"
        //        << " Parameters of corrected SCs " << "\n"
        //        << " energy = " << newClus.energy() <<"\n"
        //        << " pw = " << newClus.phiWidth() << "\n"
        //        << " ew = " << newClus.etaWidth() << std::endl;

        newClus.rawEnergy();
        corrClusters->push_back(newClus);
      }
    }
  // Put collection of corrected SuperClusters into the event
  evt.put(corrClusters, outputCollection_);   
  
}

Member Data Documentation

Definition at line 53 of file EgammaSCCorrectionMaker.h.

Referenced by EgammaSCCorrectionMaker(), and produce().

Definition at line 44 of file EgammaSCCorrectionMaker.h.

Referenced by EgammaSCCorrectionMaker(), and produce().

Definition at line 56 of file EgammaSCCorrectionMaker.h.

Referenced by EgammaSCCorrectionMaker(), and produce().

Definition at line 63 of file EgammaSCCorrectionMaker.h.

Referenced by EgammaSCCorrectionMaker(), and produce().

Definition at line 59 of file EgammaSCCorrectionMaker.h.

Referenced by EgammaSCCorrectionMaker(), and produce().

Definition at line 62 of file EgammaSCCorrectionMaker.h.

Referenced by EgammaSCCorrectionMaker(), and produce().

Definition at line 60 of file EgammaSCCorrectionMaker.h.

Referenced by EgammaSCCorrectionMaker(), and produce().

Definition at line 55 of file EgammaSCCorrectionMaker.h.

Referenced by EgammaSCCorrectionMaker().

Definition at line 47 of file EgammaSCCorrectionMaker.h.

Referenced by EgammaSCCorrectionMaker().