CMS 3D CMS Logo

Public Member Functions | Private Attributes

HiEgammaSCCorrectionMaker Class Reference

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

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

List of all members.

Public Member Functions

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

Private Attributes

bool applyEnergyCorrection_
EcalClusterFunctionBaseClassEnergyCorrection_
HiEgammaSCEnergyCorrectionAlgoenergyCorrector_
double etThresh_
std::string outputCollection_
edm::InputTag rHInputProducer_
reco::CaloCluster::AlgoId sCAlgo_
edm::InputTag sCInputProducer_
double sigmaElectronicNoise_
edm::ESHandle< CaloTopologytheCaloTopo_
HiEgammaSCEnergyCorrectionAlgo::VerbosityLevel verbosity_

Detailed Description

Description: Producer of corrected SuperClusters

Definition at line 39 of file HiEgammaSCCorrectionMaker.h.


Constructor & Destructor Documentation

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

Definition at line 30 of file HiEgammaSCCorrectionMaker.cc.

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

{
 
  // The verbosity level
  std::string debugString = ps.getParameter<std::string>("VerbosityLevel");
  if      (debugString == "DEBUG")   verbosity_ = HiEgammaSCEnergyCorrectionAlgo::pDEBUG;
  else if (debugString == "INFO")    verbosity_ = HiEgammaSCEnergyCorrectionAlgo::pINFO;
  else                               verbosity_ = HiEgammaSCEnergyCorrectionAlgo::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("HiEgammaSCCorrectionMakerError") 
      << "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 HiEgammaSCEnergyCorrectionAlgo(sigmaElectronicNoise_, sCAlgo_, fCorrPset, verbosity_);
  

  // energy correction class
  if (applyEnergyCorrection_ )
    EnergyCorrection_ = EcalClusterFunctionFactory::get()->create("EcalClusterEnergyCorrection", ps);
}
HiEgammaSCCorrectionMaker::~HiEgammaSCCorrectionMaker ( )

Definition at line 85 of file HiEgammaSCCorrectionMaker.cc.

References energyCorrector_.

{
  delete energyCorrector_;
}

Member Function Documentation

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

Implements edm::EDProducer.

Definition at line 91 of file HiEgammaSCCorrectionMaker.cc.

References HiEgammaSCEnergyCorrectionAlgo::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::ESHandle< T >::product(), edm::Event::put(), rHInputProducer_, sCAlgo_, sCInputProducer_, funct::sin(), and theCaloTopo_.

{
  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;

  edm::ESHandle<CaloTopology> pTopology;
  es.get<CaloTopologyRecord>().get(theCaloTopo_);
  const CaloTopology *topology = theCaloTopo_.product();

  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("HiEgammaSCCorrectionMakerError") 
      << "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("HiEgammaSCCorrectionMakerError") 
      << "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, topology, EnergyCorrection_);
     else
        newClus=*aClus;

     if(newClus.energy()*sin(newClus.position().theta())>etThresh_) {
        corrClusters->push_back(newClus);
     }
  }
  // Put collection of corrected SuperClusters into the event
  evt.put(corrClusters, outputCollection_);   
}

Member Data Documentation

Definition at line 57 of file HiEgammaSCCorrectionMaker.h.

Referenced by HiEgammaSCCorrectionMaker(), and produce().

Definition at line 48 of file HiEgammaSCCorrectionMaker.h.

Referenced by HiEgammaSCCorrectionMaker(), and produce().

Definition at line 60 of file HiEgammaSCCorrectionMaker.h.

Referenced by HiEgammaSCCorrectionMaker(), and produce().

Definition at line 67 of file HiEgammaSCCorrectionMaker.h.

Referenced by HiEgammaSCCorrectionMaker(), and produce().

Definition at line 63 of file HiEgammaSCCorrectionMaker.h.

Referenced by HiEgammaSCCorrectionMaker(), and produce().

Definition at line 66 of file HiEgammaSCCorrectionMaker.h.

Referenced by HiEgammaSCCorrectionMaker(), and produce().

Definition at line 64 of file HiEgammaSCCorrectionMaker.h.

Referenced by HiEgammaSCCorrectionMaker(), and produce().

Definition at line 59 of file HiEgammaSCCorrectionMaker.h.

Referenced by HiEgammaSCCorrectionMaker().

Definition at line 68 of file HiEgammaSCCorrectionMaker.h.

Referenced by produce().

Definition at line 51 of file HiEgammaSCCorrectionMaker.h.

Referenced by HiEgammaSCCorrectionMaker().