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::EDConsumerBase 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 applyCrackCorrection_
bool applyEnergyCorrection_
bool applyLocalContCorrection_
EcalClusterFunctionBaseClasscrackCorrectionFunction_
std::string crackCorrectorName_
EcalClusterFunctionBaseClassenergyCorrectionFunction_
EgammaSCEnergyCorrectionAlgoenergyCorrector_
std::string energyCorrectorName_
double etThresh_
EcalClusterFunctionBaseClasslocalContCorrectionFunction_
std::string localContCorrectorName_
int modeEB_
int modeEE_
std::string outputCollection_
edm::InputTag rHInputProducer_
reco::CaloCluster::AlgoId sCAlgo_
edm::InputTag sCInputProducer_
double sigmaElectronicNoise_

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 applyCrackCorrection_, applyEnergyCorrection_, applyLocalContCorrection_, crackCorrectionFunction_, crackCorrectorName_, reco::CaloCluster::dynamicHybrid, energyCorrectionFunction_, energyCorrector_, energyCorrectorName_, etThresh_, edm::ParameterSet::existsAs(), reco::get(), edm::ParameterSet::getParameter(), reco::CaloCluster::hybrid, reco::CaloCluster::island, localContCorrectionFunction_, localContCorrectorName_, modeEB_, modeEE_, reco::CaloCluster::multi5x5, outputCollection_, rHInputProducer_, sCAlgo_, sCInputProducer_, sigmaElectronicNoise_, and AlCaHLTBitMon_QueryRunRegistry::string.

{
 

  // 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");
  applyCrackCorrection_  = ps.getParameter<bool>("applyCrackCorrection");
  applyLocalContCorrection_= ps.existsAs<bool>("applyLocalContCorrection") ?  
    ps.getParameter<bool>("applyLocalContCorrection") : false;

  energyCorrectorName_ = ps.getParameter<std::string>("energyCorrectorName");
  crackCorrectorName_  = ps.existsAs<std::string>("crackCorrectorName") ?  
    ps.getParameter<std::string>("crackCorrectorName") : std::string("EcalClusterCrackCorrection");
  localContCorrectorName_= ps.existsAs<std::string>("localContCorrectorName") ? 
    ps.getParameter<std::string>("localContCorrectorName") : std::string("EcalBasicClusterLocalContCorrection") ;

  modeEB_ =  ps.getParameter<int>("modeEB");
  modeEE_ =  ps.getParameter<int>("modeEE");

  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);
  
  // energy correction class
  if (applyEnergyCorrection_ )
    energyCorrectionFunction_ = EcalClusterFunctionFactory::get()->create(energyCorrectorName_.c_str(), ps);
    //energyCorrectionFunction_ = EcalClusterFunctionFactory::get()->create("EcalClusterEnergyCorrection", ps);
  else
    energyCorrectionFunction_=0;

  if (applyCrackCorrection_ )
    crackCorrectionFunction_ = EcalClusterFunctionFactory::get()->create(crackCorrectorName_, ps);
  else
    crackCorrectionFunction_=0;


  if (applyLocalContCorrection_ )
    localContCorrectionFunction_ = EcalClusterFunctionFactory::get()->create(localContCorrectorName_, ps);
  else
    localContCorrectionFunction_=0;

}
EgammaSCCorrectionMaker::~EgammaSCCorrectionMaker ( )

Member Function Documentation

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

Implements edm::EDProducer.

Definition at line 113 of file EgammaSCCorrectionMaker.cc.

References EgammaSCEnergyCorrectionAlgo::applyCorrection(), EgammaSCEnergyCorrectionAlgo::applyCrackCorrection(), applyCrackCorrection_, applyEnergyCorrection_, EgammaSCEnergyCorrectionAlgo::applyLocalContCorrection(), applyLocalContCorrection_, crackCorrectionFunction_, DetId::Ecal, EcalBarrel, EcalEndcap, EcalPreshower, reco::CaloCluster::energy(), energyCorrectionFunction_, energyCorrector_, energyCorrectorName_, etThresh_, geometry, edm::EventSetup::get(), edm::Event::getByLabel(), reco_application_2006_simpleTBanalysis_cfg::hitCollection, i, EcalClusterFunctionBaseClass::init(), edm::InputTag::instance(), edm::InputTag::label(), localContCorrectionFunction_, modeEB_, modeEE_, outputCollection_, reco::CaloCluster::position(), edm::Event::put(), rHInputProducer_, sCAlgo_, sCInputProducer_, funct::sin(), and AlCaHLTBitMon_QueryRunRegistry::string.

{
  using namespace edm;

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

  // initialize energy correction class
  if(applyCrackCorrection_) 
    crackCorrectionFunction_->init(es);
  

  // initialize containemnt correction class
  if(applyLocalContCorrection_) 
    localContCorrectionFunction_->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;
  int i=0;
  for(aClus = rawClusters->begin(); aClus != rawClusters->end(); aClus++)
    {
      reco::SuperCluster enecorrClus,crackcorrClus,localContCorrClus;
 
      i++;

      if(applyEnergyCorrection_) 
        enecorrClus = energyCorrector_->applyCorrection(*aClus, *hitCollection, sCAlgo_, geometry_p, energyCorrectionFunction_, energyCorrectorName_, modeEB_, modeEE_);
      else
        enecorrClus=*aClus;


      if(applyCrackCorrection_)
        crackcorrClus=energyCorrector_->applyCrackCorrection(enecorrClus,crackCorrectionFunction_);
      else 
        crackcorrClus=enecorrClus;

      if (applyLocalContCorrection_)
        localContCorrClus = 
          energyCorrector_->applyLocalContCorrection(crackcorrClus,localContCorrectionFunction_);
      else
        localContCorrClus = crackcorrClus;
      

      if(localContCorrClus.energy()*sin(localContCorrClus.position().theta())>etThresh_) {
        
        corrClusters->push_back(localContCorrClus);
      }
    }

  // Put collection of corrected SuperClusters into the event
  evt.put(corrClusters, outputCollection_);   
  
}

Member Data Documentation

Definition at line 56 of file EgammaSCCorrectionMaker.h.

Referenced by EgammaSCCorrectionMaker(), and produce().

Definition at line 55 of file EgammaSCCorrectionMaker.h.

Referenced by EgammaSCCorrectionMaker(), and produce().

Definition at line 57 of file EgammaSCCorrectionMaker.h.

Referenced by EgammaSCCorrectionMaker(), and produce().

Definition at line 60 of file EgammaSCCorrectionMaker.h.

Referenced by EgammaSCCorrectionMaker().

Definition at line 59 of file EgammaSCCorrectionMaker.h.

Referenced by EgammaSCCorrectionMaker(), and produce().

Definition at line 68 of file EgammaSCCorrectionMaker.h.

Referenced by EgammaSCCorrectionMaker(), and produce().

Definition at line 61 of file EgammaSCCorrectionMaker.h.

Referenced by EgammaSCCorrectionMaker().

Definition at line 63 of file EgammaSCCorrectionMaker.h.

Referenced by EgammaSCCorrectionMaker(), and produce().

Definition at line 64 of file EgammaSCCorrectionMaker.h.

Referenced by EgammaSCCorrectionMaker(), and produce().

Definition at line 75 of file EgammaSCCorrectionMaker.h.

Referenced by EgammaSCCorrectionMaker(), and produce().

Definition at line 71 of file EgammaSCCorrectionMaker.h.

Referenced by EgammaSCCorrectionMaker(), and produce().

Definition at line 74 of file EgammaSCCorrectionMaker.h.

Referenced by EgammaSCCorrectionMaker(), and produce().

Definition at line 72 of file EgammaSCCorrectionMaker.h.

Referenced by EgammaSCCorrectionMaker(), and produce().

Definition at line 67 of file EgammaSCCorrectionMaker.h.

Referenced by EgammaSCCorrectionMaker().