CMS 3D CMS Logo

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

Container class for response & efficiency maps. More...

#include <JetPlusTrackCorrector.h>

Classes

class  Element
 

Public Member Functions

double binCenterEta (uint32_t) const
 
double binCenterPt (uint32_t) const
 
void clear ()
 
double eta (uint32_t) const
 
uint32_t etaBin (double eta) const
 
 Map (std::string, bool verbose=false)
 
 Map ()
 
uint32_t nEtaBins () const
 
uint32_t nPtBins () const
 
void print (std::stringstream &ss) const
 
double pt (uint32_t) const
 
uint32_t ptBin (double pt) const
 
double value (uint32_t eta_bin, uint32_t pt_bin) const
 
 ~Map ()
 

Private Types

typedef std::vector< double > VDouble
 
typedef std::vector< VDoubleVVDouble
 

Private Attributes

VVDouble data_
 
std::vector< double > eta_
 
std::vector< double > pt_
 

Detailed Description

Container class for response & efficiency maps.

Definition at line 41 of file JetPlusTrackCorrector.h.

Member Typedef Documentation

typedef std::vector<double> jpt::Map::VDouble
private

Definition at line 78 of file JetPlusTrackCorrector.h.

typedef std::vector<VDouble> jpt::Map::VVDouble
private

Definition at line 79 of file JetPlusTrackCorrector.h.

Constructor & Destructor Documentation

Map::Map ( std::string  input,
bool  verbose = false 
)

Definition at line 1395 of file JetPlusTrackCorrector.cc.

References clear(), data, data_, jpt::Map::Element::eta_, eta_, FrontierConditions_GlobalTag_cff::file, edm::FileInPath::fullPath(), jpt::Map::Element::ieta_, recoMuon::in, jpt::Map::Element::ipt_, edm::isDebugEnabled(), mps_splice::line, LogTrace, print(), jpt::Map::Element::pt_, pt_, AlCaHLTBitMon_QueryRunRegistry::string, groupFilesInBlocks::temp, and jpt::Map::Element::val_.

1396  : eta_(),
1397  pt_(),
1398  data_()
1399 {
1400 
1401  // Some init
1402  clear();
1403  std::vector<Element> data;
1404 
1405  // Parse file
1407  std::ifstream in( file.c_str() );
1408  string line;
1409  uint32_t ieta_old = 0;
1410  while ( std::getline( in, line ) ) {
1411  if ( line.empty() || line[0]=='#' ) { continue; }
1412  std::istringstream ss(line);
1413  Element temp;
1414  ss >> temp.ieta_ >> temp.ipt_ >> temp.eta_ >> temp.pt_ >> temp.val_;
1415  data.push_back(temp);
1416  if ( !ieta_old || temp.ieta_ != ieta_old ) {
1417  if ( eta_.size() < temp.ieta_+1 ) { eta_.resize(temp.ieta_+1,0.); }
1418  eta_[temp.ieta_] = temp.eta_;
1419  ieta_old = temp.ieta_;
1420  }
1421  if ( pt_.size() < temp.ipt_+1 ) { pt_.resize(temp.ipt_+1,0.); }
1422  pt_[temp.ipt_] = temp.pt_;
1423  }
1424 
1425  // Populate container
1426  data_.resize( eta_.size(), VDouble( pt_.size(), 0. ) );
1427  std::vector<Element>::const_iterator idata = data.begin();
1428  std::vector<Element>::const_iterator jdata = data.end();
1429  for ( ; idata != jdata; ++idata ) { data_[idata->ieta_][idata->ipt_] = idata->val_; }
1430 
1431  // Check
1432  if ( data_.empty() || data_[0].empty() ) {
1433  std::stringstream ss;
1434  ss << "[jpt::Map::" << __func__ << "]"
1435  << " Problem parsing map in location \""
1436  << file << "\"! ";
1437  edm::LogError("JetPlusTrackCorrector") << ss.str();
1438  }
1439 
1440  // Check
1441  if ( eta_.size() != data_.size() ||
1442  pt_.size() != ( data_.empty() ? 0 : data_[0].size() ) ) {
1443  std::stringstream ss;
1444  ss << "[jpt::Map::" << __func__ << "]"
1445  << " Discrepancy b/w number of bins!";
1446  edm::LogError("JetPlusTrackCorrector") << ss.str();
1447  }
1448 
1449  // Debug
1450  if ( verbose && edm::isDebugEnabled() ) {
1451  std::stringstream ss;
1452  ss << "[jpt::Map::" << __func__ << "]"
1453  << " Parsed contents of map at location:" << std::endl
1454  << "\"" << file << "\"" << std::endl;
1455  print(ss);
1456  LogTrace("JetPlusTrackCorrector") << ss.str();
1457  }
1458 
1459 }
bool isDebugEnabled()
static std::string const input
Definition: EdmProvDump.cc:48
void print(std::stringstream &ss) const
#define LogTrace(id)
std::vector< double > pt_
std::vector< double > eta_
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
std::string fullPath() const
Definition: FileInPath.cc:163
std::vector< double > VDouble
Map::Map ( )

Definition at line 1463 of file JetPlusTrackCorrector.cc.

References clear().

1464  : eta_(),
1465  pt_(),
1466  data_()
1467 {
1468  clear();
1469 }
std::vector< double > pt_
std::vector< double > eta_
Map::~Map ( )

Definition at line 1473 of file JetPlusTrackCorrector.cc.

References clear().

1473  {
1474  clear();
1475 }

Member Function Documentation

double Map::binCenterEta ( uint32_t  eta_bin) const

Definition at line 1514 of file JetPlusTrackCorrector.cc.

References eta_.

Referenced by JetPlusTrackCorrector::pionEfficiency().

1514  {
1515  if ( !eta_.empty() && eta_bin+1 < eta_.size() ) {
1516  return eta_[eta_bin] + ( eta_[eta_bin+1] - eta_[eta_bin] ) / 2.;
1517  } else {
1518 // edm::LogWarning("JetPlusTrackCorrector")
1519 // << "[jpt::Map::" << __func__ << "]"
1520 // << " Trying to access element " << eta_bin+1
1521 // << " of a vector with size " << eta_.size()
1522 // << "!";
1523  return eta_[eta_.size()-1];
1524  }
1525 }
std::vector< double > eta_
double Map::binCenterPt ( uint32_t  pt_bin) const

Definition at line 1529 of file JetPlusTrackCorrector.cc.

References pt_.

Referenced by JetPlusTrackCorrector::pionEfficiency().

1529  {
1530  if ( !pt_.empty() && pt_bin+1 < pt_.size() ) {
1531  return pt_[pt_bin] + ( pt_[pt_bin+1] - pt_[pt_bin] ) / 2.;
1532  } else {
1533 // edm::LogWarning("JetPlusTrackCorrector")
1534 // << "[jpt::Map::" << __func__ << "]"
1535 // << " Trying to access element " << pt_bin+1
1536 // << " of a vector with size " << pt_.size()
1537 // << "!";
1538  return pt_[pt_.size()-1];
1539  }
1540 }
std::vector< double > pt_
void Map::clear ( void  )

Definition at line 1479 of file JetPlusTrackCorrector.cc.

References data_, eta_, and pt_.

Referenced by Map(), and ~Map().

1479  {
1480  eta_.clear();
1481  pt_.clear();
1482  data_.clear();
1483 }
std::vector< double > pt_
std::vector< double > eta_
double Map::eta ( uint32_t  eta_bin) const

Definition at line 1486 of file JetPlusTrackCorrector.cc.

References eta_.

Referenced by Particle.Particle::__str__(), etaBin(), Jet.Jet::jetID(), and Jet.Jet::puJetId().

1486  {
1487  if ( !eta_.empty() && eta_bin < eta_.size() ) { return eta_[eta_bin]; }
1488  else {
1489 // edm::LogWarning("JetPlusTrackCorrector")
1490 // << "[jpt::Map::" << __func__ << "]"
1491 // << " Trying to access element " << eta_bin
1492 // << " of a vector with size " << eta_.size()
1493 // << "!";
1494  return eta_[eta_.size()-1];
1495  }
1496 }
std::vector< double > eta_
uint32_t Map::etaBin ( double  eta) const

Definition at line 1544 of file JetPlusTrackCorrector.cc.

References eta(), and nEtaBins().

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

1544  {
1545  val = fabs( val );
1546  for ( uint32_t ieta = 0; ieta < nEtaBins()-1; ++ieta ) { //@@ "-1" is bug?
1547  if ( val > eta(ieta) && ( ieta+1 == nEtaBins() || val < eta(ieta+1) ) ) { return ieta; }
1548  }
1549  return nEtaBins();
1550 }
uint32_t nEtaBins() const
double eta(uint32_t) const
uint32_t jpt::Map::nEtaBins ( ) const
inline
uint32_t jpt::Map::nPtBins ( ) const
inline
void Map::print ( std::stringstream &  ss) const

Definition at line 1579 of file JetPlusTrackCorrector.cc.

References data_, eta_, METSignificanceParams_cfi::jeta, and pt_.

Referenced by Map(), and jpt::Efficiency::print().

1579  {
1580  ss << " Number of bins in eta : " << data_.size() << std::endl
1581  << " Number of bins in pt : " << ( data_.empty() ? 0 : data_[0].size() ) << std::endl;
1582  VVDouble::const_iterator ieta = data_.begin();
1583  VVDouble::const_iterator jeta = data_.end();
1584  for ( ; ieta != jeta; ++ieta ) {
1585  VDouble::const_iterator ipt = ieta->begin();
1586  VDouble::const_iterator jpt = ieta->end();
1587  for ( ; ipt != jpt; ++ipt ) {
1588  uint32_t eta_bin = static_cast<uint32_t>( ieta - data_.begin() );
1589  uint32_t pt_bin = static_cast<uint32_t>( ipt - ieta->begin() );
1590  ss << " EtaBinNumber: " << eta_bin
1591  << " PtBinNumber: " << pt_bin
1592  << " EtaValue: " << eta_[ eta_bin ]
1593  << " PtValue: " << pt_[ pt_bin ]
1594  << " Value: " << data_[eta_bin][pt_bin]
1595  << std::endl;
1596  }
1597  }
1598 }
std::vector< double > pt_
std::vector< double > eta_
double Map::pt ( uint32_t  pt_bin) const

Definition at line 1500 of file JetPlusTrackCorrector.cc.

References pt_.

Referenced by Particle.Particle::__str__(), DiObject.DiMuon::__str__(), Photon.Photon::calScaledIsoValueExp(), Photon.Photon::calScaledIsoValueLin(), Photon.Photon::calScaledIsoValueQuadr(), Electron.Electron::mvaIDLoose(), Electron.Electron::mvaIDRun2(), Electron.Electron::mvaIDTight(), ptBin(), Electron.Electron::ptErr(), ntupleDataFormat.Track::ptPull(), Lepton.Lepton::relIso(), Lepton.Lepton::relIsoFromEA(), Lepton.Lepton::relIsoR(), and Jet.Jet::setCorrP4().

1500  {
1501  if ( !pt_.empty() && pt_bin < pt_.size() ) { return pt_[pt_bin]; }
1502  else {
1503 // edm::LogWarning("JetPlusTrackCorrector")
1504 // << "[jpt::Map::" << __func__ << "]"
1505 // << " Trying to access element " << pt_bin
1506 // << " of a vector with size " << pt_.size()
1507 // << "!";
1508  return pt_[pt_.size()-1];
1509  }
1510 }
std::vector< double > pt_
uint32_t Map::ptBin ( double  pt) const

Definition at line 1554 of file JetPlusTrackCorrector.cc.

References nPtBins(), and pt().

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

1554  {
1555  val = fabs( val );
1556  for ( uint32_t ipt = 0; ipt < nPtBins()-1; ++ipt ) { //@@ "-1" is bug?
1557  if ( val > pt(ipt) && ( (ipt+1) == nPtBins() || val < pt(ipt+1) ) ) { return ipt; }
1558  }
1559  return nPtBins();
1560 }
double pt(uint32_t) const
uint32_t nPtBins() const
double Map::value ( uint32_t  eta_bin,
uint32_t  pt_bin 
) const

Definition at line 1564 of file JetPlusTrackCorrector.cc.

References data_.

Referenced by JetPlusTrackCorrector::calculateCorr(), JetPlusTrackCorrector::correctAA(), jpt::Efficiency::inConeCorr(), and jpt::Efficiency::outOfConeCorr().

1564  {
1565  if ( eta_bin < data_.size() &&
1566  pt_bin < ( data_.empty() ? 0 : data_[0].size() ) ) { return data_[eta_bin][pt_bin]; }
1567  else {
1568 // edm::LogWarning("JetPlusTrackCorrector")
1569 // << "[jpt::Map::" << __func__ << "]"
1570 // << " Trying to access element (" << eta_bin << "," << pt_bin << ")"
1571 // << " of a vector with size (" << data_.size() << "," << ( data_.empty() ? 0 : data_[0].size() ) << ")"
1572 // << "!";
1573  return 1.;
1574  }
1575 }

Member Data Documentation

VVDouble jpt::Map::data_
private

Definition at line 83 of file JetPlusTrackCorrector.h.

Referenced by clear(), Map(), print(), and value().

std::vector<double> jpt::Map::eta_
private

Definition at line 81 of file JetPlusTrackCorrector.h.

Referenced by binCenterEta(), clear(), eta(), Map(), and print().

std::vector<double> jpt::Map::pt_
private

Definition at line 82 of file JetPlusTrackCorrector.h.

Referenced by binCenterPt(), clear(), Map(), print(), and pt().