CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes
jpt::Efficiency Class Reference

Generic container class. More...

#include <JetPlusTrackCorrector.h>

Public Types

typedef std::pair< uint16_t, double > Pair
 

Public Member Functions

void addE (uint32_t eta_bin, uint32_t pt_bin, double energy)
 
 Efficiency (const jpt::Map &response, const jpt::Map &efficiency, const jpt::Map &leakage)
 
bool empty () const
 
double inConeCorr (uint32_t eta_bin, uint32_t pt_bin) const
 
uint32_t nEtaBins () const
 
uint32_t nPtBins () const
 
uint16_t nTrks (uint32_t eta_bin, uint32_t pt_bin) const
 
double outOfConeCorr (uint32_t eta_bin, uint32_t pt_bin) const
 
void print () const
 
void reset ()
 
uint32_t size () const
 

Private Types

typedef std::vector< PairVPair
 
typedef std::vector< VPairVVPair
 

Private Member Functions

bool check (uint32_t eta_bin, uint32_t pt_bin, std::string name="check") const
 
 Efficiency ()=delete
 
double meanE (uint32_t eta_bin, uint32_t pt_bin) const
 
double sumE (uint32_t eta_bin, uint32_t pt_bin) const
 

Private Attributes

VVPair data_
 
const jpt::Mapefficiency_
 
const jpt::Mapleakage_
 
const jpt::Mapresponse_
 

Detailed Description

Generic container class.

Definition at line 91 of file JetPlusTrackCorrector.h.

Member Typedef Documentation

typedef std::pair<uint16_t,double> jpt::Efficiency::Pair

Definition at line 99 of file JetPlusTrackCorrector.h.

typedef std::vector<Pair> jpt::Efficiency::VPair
private

Definition at line 126 of file JetPlusTrackCorrector.h.

typedef std::vector<VPair> jpt::Efficiency::VVPair
private

Definition at line 127 of file JetPlusTrackCorrector.h.

Constructor & Destructor Documentation

Efficiency::Efficiency ( const jpt::Map response,
const jpt::Map efficiency,
const jpt::Map leakage 
)

Definition at line 1648 of file JetPlusTrackCorrector.cc.

References reset().

1651  : response_(response),
1652  efficiency_(efficiency),
1653  leakage_(leakage)
1654 {
1655  reset();
1656 }
const jpt::Map & efficiency_
const jpt::Map & response_
const jpt::Map & leakage_
jpt::Efficiency::Efficiency ( )
privatedelete

Member Function Documentation

void Efficiency::addE ( uint32_t  eta_bin,
uint32_t  pt_bin,
double  energy 
)

Definition at line 1708 of file JetPlusTrackCorrector.cc.

References check(), data_, and randomXiThetaGunProducer_cfi::energy.

Referenced by JetPlusTrackCorrector::calculateCorr().

1708  {
1709  if ( check(eta_bin,pt_bin,__func__) ) {
1710  data_[eta_bin][pt_bin].first++;
1711  data_[eta_bin][pt_bin].second += energy;
1712  }
1713 }
bool check(uint32_t eta_bin, uint32_t pt_bin, std::string name="check") const
bool Efficiency::check ( uint32_t  eta_bin,
uint32_t  pt_bin,
std::string  name = "check" 
) const
private

Definition at line 1717 of file JetPlusTrackCorrector.cc.

References data_.

Referenced by addE(), inConeCorr(), meanE(), nTrks(), outOfConeCorr(), and sumE().

1717  {
1718  if ( eta_bin < data_.size() && pt_bin < ( data_.empty() ? 0 : data_[0].size() ) ) { return true; }
1719  else {
1720 // edm::LogWarning("JetPlusTrackCorrector")
1721 // << "[jpt::Efficiency::" << method << "]"
1722 // << " Trying to access element (" << eta_bin << "," << pt_bin << ")"
1723 // << " of a vector with size (" << data_.size() << "," << ( data_.empty() ? 0 : data_[0].size() ) << ")"
1724 // << "!";
1725  return false;
1726  }
1727 }
bool jpt::Efficiency::empty ( void  ) const
inline

Definition at line 139 of file JetPlusTrackCorrector.h.

139 { return data_.empty(); }
double Efficiency::inConeCorr ( uint32_t  eta_bin,
uint32_t  pt_bin 
) const

Definition at line 1660 of file JetPlusTrackCorrector.cc.

References check(), leakage_, outOfConeCorr(), response_, and jpt::Map::value().

Referenced by JetPlusTrackCorrector::pionEfficiency().

1660  {
1661  if ( check(eta_bin,pt_bin,__func__) ) {
1662  return ( outOfConeCorr( eta_bin, pt_bin ) *
1663  leakage_.value( eta_bin, pt_bin ) *
1664  response_.value( eta_bin, pt_bin ) );
1665  } else { return 0.; }
1666 }
const jpt::Map & response_
double outOfConeCorr(uint32_t eta_bin, uint32_t pt_bin) const
bool check(uint32_t eta_bin, uint32_t pt_bin, std::string name="check") const
double value(uint32_t eta_bin, uint32_t pt_bin) const
const jpt::Map & leakage_
double Efficiency::meanE ( uint32_t  eta_bin,
uint32_t  pt_bin 
) const
private

Definition at line 1698 of file JetPlusTrackCorrector.cc.

References check(), data_, and tmp.

Referenced by outOfConeCorr().

1698  {
1699  if ( check(eta_bin,pt_bin,__func__) ) {
1700  Pair tmp = data_[eta_bin][pt_bin];
1701  if ( tmp.first ) { return tmp.second / tmp.first; }
1702  else { return 0.; }
1703  } else { return 0.; }
1704 }
std::pair< uint16_t, double > Pair
bool check(uint32_t eta_bin, uint32_t pt_bin, std::string name="check") const
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
uint32_t jpt::Efficiency::nEtaBins ( ) const
inline

Definition at line 136 of file JetPlusTrackCorrector.h.

136 { return response_.nEtaBins(); }
uint32_t nEtaBins() const
const jpt::Map & response_
uint32_t jpt::Efficiency::nPtBins ( ) const
inline

Definition at line 137 of file JetPlusTrackCorrector.h.

137 { return response_.nPtBins(); }
const jpt::Map & response_
uint32_t nPtBins() const
uint16_t Efficiency::nTrks ( uint32_t  eta_bin,
uint32_t  pt_bin 
) const

Definition at line 1682 of file JetPlusTrackCorrector.cc.

References check(), and data_.

Referenced by outOfConeCorr(), and JetPlusTrackCorrector::pionEfficiency().

1682  {
1683  if ( check(eta_bin,pt_bin,__func__) ) {
1684  return data_[eta_bin][pt_bin].first;
1685  } else { return 0; }
1686 }
bool check(uint32_t eta_bin, uint32_t pt_bin, std::string name="check") const
double Efficiency::outOfConeCorr ( uint32_t  eta_bin,
uint32_t  pt_bin 
) const

Definition at line 1670 of file JetPlusTrackCorrector.cc.

References check(), efficiency_, SiStripPI::mean, meanE(), nTrks(), and jpt::Map::value().

Referenced by inConeCorr(), and JetPlusTrackCorrector::pionEfficiency().

1670  {
1671  if ( check(eta_bin,pt_bin,__func__) ) {
1672  uint16_t ntrks = nTrks( eta_bin, pt_bin );
1673  double mean = meanE( eta_bin, pt_bin );
1674  double eff = ( 1. - efficiency_.value( eta_bin, pt_bin ) ) / efficiency_.value( eta_bin, pt_bin );
1675  if ( !ntrks ) { return 0.; }
1676  return ( ntrks * eff * mean );
1677  } else { return 0.; }
1678 }
double meanE(uint32_t eta_bin, uint32_t pt_bin) const
const jpt::Map & efficiency_
bool check(uint32_t eta_bin, uint32_t pt_bin, std::string name="check") const
uint16_t nTrks(uint32_t eta_bin, uint32_t pt_bin) const
double value(uint32_t eta_bin, uint32_t pt_bin) const
void Efficiency::print ( void  ) const

Definition at line 1738 of file JetPlusTrackCorrector.cc.

References efficiency_, edm::isDebugEnabled(), leakage_, LogTrace, jpt::Map::print(), and response_.

1738  {
1739  if ( edm::isDebugEnabled() ) {
1740  std::stringstream ss;
1741  ss << "[jpt::Efficiency::" << __func__ << "]"
1742  << " Contents of maps:" << std::endl;
1743  ss << "Response map: " << std::endl;
1744  response_.print(ss);
1745  ss << "Efficiency map: " << std::endl;
1746  efficiency_.print(ss);
1747  ss << "Leakage map: " << std::endl;
1748  leakage_.print(ss);
1749  LogTrace("JetPlusTrackCorrector") << ss.str();
1750  }
1751 }
bool isDebugEnabled()
const jpt::Map & efficiency_
const jpt::Map & response_
void print(std::stringstream &ss) const
#define LogTrace(id)
const jpt::Map & leakage_
void Efficiency::reset ( void  )

Definition at line 1731 of file JetPlusTrackCorrector.cc.

References data_, jpt::Map::nEtaBins(), jpt::Map::nPtBins(), and response_.

Referenced by JetPlusTrackCorrector::calculateCorr(), and Efficiency().

1731  {
1732  data_.clear();
1733  data_.resize( response_.nEtaBins(), VPair( response_.nPtBins(), Pair(0,0.) ) );
1734 }
uint32_t nEtaBins() const
std::pair< uint16_t, double > Pair
const jpt::Map & response_
std::vector< Pair > VPair
uint32_t nPtBins() const
uint32_t jpt::Efficiency::size ( void  ) const
inline
double Efficiency::sumE ( uint32_t  eta_bin,
uint32_t  pt_bin 
) const
private

Definition at line 1690 of file JetPlusTrackCorrector.cc.

References check(), and data_.

1690  {
1691  if ( check(eta_bin,pt_bin,__func__) ) {
1692  return data_[eta_bin][pt_bin].second;
1693  } else { return 0.; }
1694 }
bool check(uint32_t eta_bin, uint32_t pt_bin, std::string name="check") const

Member Data Documentation

VVPair jpt::Efficiency::data_
private

Definition at line 128 of file JetPlusTrackCorrector.h.

Referenced by addE(), check(), meanE(), nTrks(), reset(), and sumE().

const jpt::Map& jpt::Efficiency::efficiency_
private

Definition at line 131 of file JetPlusTrackCorrector.h.

Referenced by outOfConeCorr(), and print().

const jpt::Map& jpt::Efficiency::leakage_
private

Definition at line 132 of file JetPlusTrackCorrector.h.

Referenced by inConeCorr(), and print().

const jpt::Map& jpt::Efficiency::response_
private

Definition at line 130 of file JetPlusTrackCorrector.h.

Referenced by inConeCorr(), print(), and reset().