CMS 3D CMS Logo

Public Types | Public Member Functions | Private Member Functions | Private Attributes

EgammaSCEnergyCorrectionAlgo Class Reference

#include <EgammaSCEnergyCorrectionAlgo.h>

List of all members.

Public Types

enum  VerbosityLevel { pDEBUG = 0, pWARNING = 1, pINFO = 2, pERROR = 3 }

Public Member Functions

reco::SuperCluster applyCorrection (const reco::SuperCluster &cl, const EcalRecHitCollection &rhc, reco::CaloCluster::AlgoId theAlgo, const CaloSubdetectorGeometry *geometry, EcalClusterFunctionBaseClass *energyCorrectionFunction)
reco::SuperCluster applyCrackCorrection (const reco::SuperCluster &cl, EcalClusterFunctionBaseClass *crackCorrectionFunction)
 EgammaSCEnergyCorrectionAlgo (float noise, reco::CaloCluster::AlgoId theAlgo, const edm::ParameterSet &pset, VerbosityLevel verbosity=pERROR)
void setVerbosity (VerbosityLevel verbosity)
 ~EgammaSCEnergyCorrectionAlgo ()

Private Member Functions

float fNCrystals (int nCry, reco::CaloCluster::AlgoId theAlgo, EcalSubdetector theBase) const
int nCrystalsGT2Sigma (reco::BasicCluster const &seed, EcalRecHitCollection const &rhc) const

Private Attributes

float sigmaElectronicNoise_
reco::CaloCluster::AlgoId theAlgo_
VerbosityLevel verbosity_

Detailed Description

Definition at line 20 of file EgammaSCEnergyCorrectionAlgo.h.


Member Enumeration Documentation

Enumerator:
pDEBUG 
pWARNING 
pINFO 
pERROR 

Definition at line 23 of file EgammaSCEnergyCorrectionAlgo.h.

{ pDEBUG = 0, pWARNING = 1, pINFO = 2, pERROR = 3 }; 

Constructor & Destructor Documentation

EgammaSCEnergyCorrectionAlgo::EgammaSCEnergyCorrectionAlgo ( float  noise,
reco::CaloCluster::AlgoId  theAlgo,
const edm::ParameterSet pset,
EgammaSCEnergyCorrectionAlgo::VerbosityLevel  verbosity = pERROR 
)
EgammaSCEnergyCorrectionAlgo::~EgammaSCEnergyCorrectionAlgo ( ) [inline]

Definition at line 31 of file EgammaSCEnergyCorrectionAlgo.h.

{}

Member Function Documentation

reco::SuperCluster EgammaSCEnergyCorrectionAlgo::applyCorrection ( const reco::SuperCluster cl,
const EcalRecHitCollection rhc,
reco::CaloCluster::AlgoId  theAlgo,
const CaloSubdetectorGeometry geometry,
EcalClusterFunctionBaseClass energyCorrectionFunction 
)

Definition at line 23 of file EgammaSCEnergyCorrectionAlgo.cc.

References SuperClusterShapeAlgo::Calculate_Covariances(), gather_cfg::cout, reco::CaloCluster::dynamicHybrid, reco::CaloCluster::energy(), SuperClusterShapeAlgo::etaWidth(), fNCrystals(), EcalClusterFunctionBaseClass::getValue(), reco::CaloCluster::hybrid, reco::CaloCluster::multi5x5, nCrystalsGT2Sigma(), SuperClusterShapeAlgo::phiWidth(), pINFO, reco::SuperCluster::preshowerEnergy(), reco::SuperCluster::rawEnergy(), reco::SuperCluster::seed(), reco::CaloCluster::setEnergy(), reco::SuperCluster::setEtaWidth(), reco::SuperCluster::setPhiWidth(), tmp, and verbosity_.

Referenced by EgammaSCCorrectionMaker::produce().

                                                                                                                         {      

        
  // A little bit of trivial info to be sure all is well

  if (verbosity_ <= pINFO)
  {
    std::cout << "   EgammaSCEnergyCorrectionAlgo::applyCorrection" << std::endl;
    std::cout << "   SC has energy " << cl.energy() << std::endl;
    std::cout << "   Will correct now.... " << std::endl;
  }

  // Get the seed cluster       
  reco::CaloClusterPtr seedC = cl.seed();

  if (verbosity_ <= pINFO)
  {
    std::cout << "   Seed cluster energy... " << seedC->energy() << std::endl;
  }


  // Find the algorithm used to construct the basic clusters making up the supercluster 
  if (verbosity_ <= pINFO) 
  {
    std::cout << "   The seed cluster used algo " << theAlgo;  
  }
 
  // Find the detector region of the supercluster
  // where is the seed cluster?
  std::vector<std::pair<DetId, float> > seedHits = seedC->hitsAndFractions();  
  EcalSubdetector theBase = EcalSubdetector(seedHits.at(0).first.subdetId());

  if (verbosity_ <= pINFO)
  {
    std::cout << "   seed cluster location == " << theBase << std::endl;
  }

  // Get number of crystals 2sigma above noise in seed basiccluster      
  int nCryGT2Sigma = nCrystalsGT2Sigma(*seedC,rhc);
  if (verbosity_ <= pINFO)
  {
    std::cout << "   nCryGT2Sigma " << nCryGT2Sigma << std::endl;
  }

  // Supercluster enery - seed basiccluster energy
  float bremsEnergy = cl.energy() - seedC->energy();
  if (verbosity_ <= pINFO)
  {
    std::cout << "   bremsEnergy " << bremsEnergy << std::endl;
  }

  //Create the pointer ot class SuperClusterShapeAlgo
  //which calculates phiWidth and etaWidth
  SuperClusterShapeAlgo  SCShape(&rhc, geometry);

  double phiWidth = 0.;
  double etaWidth = 0.;
  //Calculate phiWidth & etaWidth for SuperClusters
  SCShape.Calculate_Covariances(cl);
  phiWidth = SCShape.phiWidth();
  etaWidth = SCShape.etaWidth();

  // Calculate the new supercluster energy 
  //as a function of number of crystals in the seed basiccluster for Endcap 
  //or apply new Enegry SCale correction
  float newEnergy = 0;

  reco::SuperCluster tmp = cl;
  tmp.setPhiWidth(phiWidth); 
  tmp.setEtaWidth(etaWidth); 
    
  if ( theAlgo == reco::CaloCluster::hybrid || theAlgo == reco::CaloCluster::dynamicHybrid ) {
    newEnergy = tmp.rawEnergy() + energyCorrectionFunction->getValue(tmp, 3);

  } else if  ( theAlgo == reco::CaloCluster::multi5x5 ) {     
    newEnergy = tmp.rawEnergy() + tmp.preshowerEnergy() + energyCorrectionFunction->getValue(tmp, 5);

  } else {  
    //Apply f(nCry) correction on island algo and fixedMatrix algo 
    newEnergy = seedC->energy()/fNCrystals(nCryGT2Sigma, theAlgo, theBase)+bremsEnergy;
  } 

  // Create a new supercluster with the corrected energy 
  if (verbosity_ <= pINFO)
    {
      std::cout << "   UNCORRECTED SC has energy... " << cl.energy() << std::endl;
      std::cout << "   CORRECTED SC has energy... " << newEnergy << std::endl;
    }

  reco::SuperCluster corrCl =cl;
  
  corrCl.setEnergy(newEnergy);
  corrCl.setPhiWidth(phiWidth);
  corrCl.setEtaWidth(etaWidth);
  
  return corrCl;
}
reco::SuperCluster EgammaSCEnergyCorrectionAlgo::applyCrackCorrection ( const reco::SuperCluster cl,
EcalClusterFunctionBaseClass crackCorrectionFunction 
)

Definition at line 242 of file EgammaSCEnergyCorrectionAlgo.cc.

References reco::SuperCluster::clustersBegin(), reco::SuperCluster::clustersEnd(), reco::CaloCluster::energy(), EcalClusterFunctionBaseClass::getValue(), reco::SuperCluster::rawEnergy(), and reco::CaloCluster::setEnergy().

Referenced by EgammaSCCorrectionMaker::produce().

                                                                                                         {


  double crackcor = 1.; 

  for(reco::CaloCluster_iterator cIt = cl.clustersBegin(); cIt != cl.clustersEnd(); ++cIt) {

    const reco::CaloClusterPtr cc = *cIt; 
    crackcor *= ( (cl.rawEnergy() +
                   cc->energy()*(crackCorrectionFunction->getValue(*cc)-1.)) / 
                   cl.rawEnergy() );   
  }// loop on BCs
  

  reco::SuperCluster corrCl=cl;
  corrCl.setEnergy(cl.energy()*crackcor);
  

  return corrCl;
}
float EgammaSCEnergyCorrectionAlgo::fNCrystals ( int  nCry,
reco::CaloCluster::AlgoId  theAlgo,
EcalSubdetector  theBase 
) const [private]

Definition at line 124 of file EgammaSCEnergyCorrectionAlgo.cc.

References gather_cfg::cout, EcalBarrel, EcalEndcap, f, reco::CaloCluster::hybrid, reco::CaloCluster::island, p1, p2, p3, p4, pERROR, pINFO, query::result, verbosity_, and x.

Referenced by applyCorrection().

                                                                                                                     {

  float p0 = 0, p1 = 0, p2 = 0, p3 = 0, p4 = 0;
  float x  =  nCry;
  float result =1.f;
 
  if((theBase == EcalBarrel) && (theAlgo == reco::CaloCluster::hybrid))  {
    if (nCry<=10) 
      {
        p0 =  6.32879e-01f; 
        p1 =  1.14893e-01f; 
        p2 = -2.45705e-02f; 
        p3 =  2.53074e-03f; 
        p4 = -9.29654e-05f; 
      } 
    else if (nCry>10 && nCry<=30) 
      {
        p0 =  6.93196e-01f; 
        p1 =  4.44034e-02f; 
        p2 = -2.82229e-03f; 
        p3 =  8.19495e-05f; 
        p4 = -8.96645e-07f; 
      } 
    else 
      {
        p0 =  5.65474e+00f; 
        p1 = -6.31640e-01f; 
        p2 =  3.14218e-02f; 
        p3 = -6.84256e-04f; 
        p4 =  5.50659e-06f; 
      }
    if (x > 40.f) x = 40.f;
  }
  
  else if((theBase == EcalEndcap) && (theAlgo == reco::CaloCluster::hybrid)) {
    if (verbosity_ <= pERROR)
      {
        std::cout << "ERROR! HybridEFRYsc called" << std::endl;
      } 
    return 1.f;
  }
  
  else if((theBase == EcalBarrel) && (theAlgo == reco::CaloCluster::island)) { 
    p0 = 4.69976e-01f;     // extracted from fit to all endcap classes with Ebrem = 0.
    p1 = 1.45900e-01f;
    p2 = -1.61359e-02f;
    p3 = 7.99423e-04f;
    p4 = -1.47873e-05f;
    if (x > 16.f) x = 16.f;
  }
  
  else if((theBase == EcalEndcap) && (theAlgo == reco::CaloCluster::island)) {    
    p0 = 4.69976e-01f;     // extracted from fit to all endcap classes with Ebrem = 0.
    p1 = 1.45900e-01f;
    p2 = -1.61359e-02f;
    p3 = 7.99423e-04f;
    p4 = -1.47873e-05f;
    if (x > 16.f) x = 16.f;
  }
  
  else {
    if (verbosity_ <= pINFO)
      {
        std::cout << "trying to correct unknown cluster!!!" << std::endl;
      }
    return 1.f;
  }
  result = p0 + x*(p1 + x*(p2 + x*(p3 + x*p4)));
  
  //Rescale energy scale correction to take into account change in calibrated
  //RecHit definition introduced in CMSSW_1_5_0
  float const ebfact = 1.f/0.965f; 
  float const eefact = 1.f/0.975f; 
    
  if(theBase == EcalBarrel) {
    result*=ebfact;
  } else {
    result*=eefact;
  }
  
  return result;  
}
int EgammaSCEnergyCorrectionAlgo::nCrystalsGT2Sigma ( reco::BasicCluster const &  seed,
EcalRecHitCollection const &  rhc 
) const [private]

Definition at line 207 of file EgammaSCEnergyCorrectionAlgo.cc.

References gather_cfg::cout, edm::SortedCollection< T, SORT >::find(), pINFO, sigmaElectronicNoise_, and verbosity_.

Referenced by applyCorrection().

{
  // return number of crystals 2Sigma above
  // electronic noise
  
  std::vector<std::pair<DetId,float > > const & hits = seed.hitsAndFractions();

  if (verbosity_ <= pINFO)
  {
    std::cout << "      EgammaSCEnergyCorrectionAlgo::nCrystalsGT2Sigma" << std::endl;
    std::cout << "      Will calculate number of crystals above 2sigma noise" << std::endl;
    std::cout << "      sigmaElectronicNoise = " << sigmaElectronicNoise_ << std::endl;
    std::cout << "      There are " << hits.size() << " recHits" << std::endl;
  }

  int nCry = 0;
  std::vector<std::pair<DetId,float > >::const_iterator hit;
  EcalRecHitCollection::const_iterator aHit;
  for(hit = hits.begin(); hit != hits.end(); hit++) {
      // need to get hit by DetID in order to get energy
      aHit = rhc.find((*hit).first);
      if((*aHit).energy()>2.f*sigmaElectronicNoise_) nCry++;
    }

  if (verbosity_ <= pINFO)
  {
    std::cout << "         " << nCry << " of these above 2sigma noise" << std::endl;  
  }
 
  return nCry;
}
void EgammaSCEnergyCorrectionAlgo::setVerbosity ( VerbosityLevel  verbosity) [inline]

Definition at line 45 of file EgammaSCEnergyCorrectionAlgo.h.

References verbosity, and verbosity_.


Member Data Documentation

Definition at line 65 of file EgammaSCEnergyCorrectionAlgo.h.