CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 43 of file JetPlusTrackCorrector.h.

Member Typedef Documentation

◆ VDouble

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

Definition at line 77 of file JetPlusTrackCorrector.h.

◆ VVDouble

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

Definition at line 78 of file JetPlusTrackCorrector.h.

Constructor & Destructor Documentation

◆ Map() [1/2]

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

Definition at line 1375 of file JetPlusTrackCorrector.cc.

References clear(), data, data_, eta_, geometryDiff::file, edm::FileInPath::fullPath(), recoMuon::in, input, edm::isDebugEnabled(), das-selected-lumis::jdata, mps_splice::line, LogTrace, print(), pt_, contentValuesCheck::ss, AlCaHLTBitMon_QueryRunRegistry::string, groupFilesInBlocks::temp, and verbose.

1375  : eta_(), pt_(), data_() {
1376  // Some init
1377  clear();
1378  std::vector<Element> data;
1379 
1380  // Parse file
1382  std::ifstream in(file.c_str());
1383  string line;
1384  uint32_t ieta_old = 0;
1385  while (std::getline(in, line)) {
1386  if (line.empty() || line[0] == '#') {
1387  continue;
1388  }
1389  std::istringstream ss(line);
1390  Element temp;
1391  ss >> temp.ieta_ >> temp.ipt_ >> temp.eta_ >> temp.pt_ >> temp.val_;
1392  data.push_back(temp);
1393  if (!ieta_old || temp.ieta_ != ieta_old) {
1394  if (eta_.size() < temp.ieta_ + 1) {
1395  eta_.resize(temp.ieta_ + 1, 0.);
1396  }
1397  eta_[temp.ieta_] = temp.eta_;
1398  ieta_old = temp.ieta_;
1399  }
1400  if (pt_.size() < temp.ipt_ + 1) {
1401  pt_.resize(temp.ipt_ + 1, 0.);
1402  }
1403  pt_[temp.ipt_] = temp.pt_;
1404  }
1405 
1406  // Populate container
1407  data_.resize(eta_.size(), VDouble(pt_.size(), 0.));
1408  std::vector<Element>::const_iterator idata = data.begin();
1409  std::vector<Element>::const_iterator jdata = data.end();
1410  for (; idata != jdata; ++idata) {
1411  data_[idata->ieta_][idata->ipt_] = idata->val_;
1412  }
1413 
1414  // Check
1415  if (data_.empty() || data_[0].empty()) {
1416  std::stringstream ss;
1417  ss << "[jpt::Map::" << __func__ << "]"
1418  << " Problem parsing map in location \"" << file << "\"! ";
1419  edm::LogError("JetPlusTrackCorrector") << ss.str();
1420  }
1421 
1422  // Check
1423  if (eta_.size() != data_.size() || pt_.size() != (data_.empty() ? 0 : data_[0].size())) {
1424  std::stringstream ss;
1425  ss << "[jpt::Map::" << __func__ << "]"
1426  << " Discrepancy b/w number of bins!";
1427  edm::LogError("JetPlusTrackCorrector") << ss.str();
1428  }
1429 
1430  // Debug
1431  if (verbose && edm::isDebugEnabled()) {
1432  std::stringstream ss;
1433  ss << "[jpt::Map::" << __func__ << "]"
1434  << " Parsed contents of map at location:" << std::endl
1435  << "\"" << file << "\"" << std::endl;
1436  print(ss);
1437  LogTrace("JetPlusTrackCorrector") << ss.str();
1438  }
1439 }
bool isDebugEnabled()
std::string fullPath() const
Definition: FileInPath.cc:161
bool verbose
Log< level::Error, false > LogError
#define LogTrace(id)
static std::string const input
Definition: EdmProvDump.cc:50
std::vector< double > pt_
std::vector< double > eta_
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
void print(std::stringstream &ss) const
std::vector< double > VDouble

◆ Map() [2/2]

Map::Map ( )

Definition at line 1443 of file JetPlusTrackCorrector.cc.

References clear().

1443 : eta_(), pt_(), data_() { clear(); }
std::vector< double > pt_
std::vector< double > eta_

◆ ~Map()

Map::~Map ( )

Definition at line 1447 of file JetPlusTrackCorrector.cc.

References clear().

1447 { clear(); }

Member Function Documentation

◆ binCenterEta()

double Map::binCenterEta ( uint32_t  eta_bin) const

Definition at line 1488 of file JetPlusTrackCorrector.cc.

References eta_.

Referenced by JetPlusTrackCorrector::pionEfficiency().

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

◆ binCenterPt()

double Map::binCenterPt ( uint32_t  pt_bin) const

Definition at line 1503 of file JetPlusTrackCorrector.cc.

References pt_.

Referenced by JetPlusTrackCorrector::pionEfficiency().

1503  {
1504  if (!pt_.empty() && pt_bin + 1 < pt_.size()) {
1505  return pt_[pt_bin] + (pt_[pt_bin + 1] - pt_[pt_bin]) / 2.;
1506  } else {
1507  // edm::LogWarning("JetPlusTrackCorrector")
1508  // << "[jpt::Map::" << __func__ << "]"
1509  // << " Trying to access element " << pt_bin+1
1510  // << " of a vector with size " << pt_.size()
1511  // << "!";
1512  return pt_[pt_.size() - 1];
1513  }
1514 }
std::vector< double > pt_

◆ clear()

void Map::clear ( void  )

Definition at line 1451 of file JetPlusTrackCorrector.cc.

References data_, eta_, and pt_.

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

1451  {
1452  eta_.clear();
1453  pt_.clear();
1454  data_.clear();
1455 }
std::vector< double > pt_
std::vector< double > eta_

◆ eta()

double Map::eta ( uint32_t  eta_bin) const

Definition at line 1458 of file JetPlusTrackCorrector.cc.

References eta_.

Referenced by Particle.Particle::__str__(), datamodel.Object::DeltaR(), etaBin(), Jet.Jet::jetID(), datamodel.Object::p4(), and Jet.Jet::puJetId().

1458  {
1459  if (!eta_.empty() && eta_bin < eta_.size()) {
1460  return eta_[eta_bin];
1461  } else {
1462  // edm::LogWarning("JetPlusTrackCorrector")
1463  // << "[jpt::Map::" << __func__ << "]"
1464  // << " Trying to access element " << eta_bin
1465  // << " of a vector with size " << eta_.size()
1466  // << "!";
1467  return eta_[eta_.size() - 1];
1468  }
1469 }
std::vector< double > eta_

◆ etaBin()

uint32_t Map::etaBin ( double  eta) const

Definition at line 1518 of file JetPlusTrackCorrector.cc.

References eta(), hcalRecHitTable_cff::ieta, nEtaBins(), and heppy_batch::val.

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

1518  {
1519  val = fabs(val);
1520  for (uint32_t ieta = 0; ieta < nEtaBins() - 1; ++ieta) { //@@ "-1" is bug?
1521  if (val > eta(ieta) && (ieta + 1 == nEtaBins() || val < eta(ieta + 1))) {
1522  return ieta;
1523  }
1524  }
1525  return nEtaBins();
1526 }
uint32_t nEtaBins() const
double eta(uint32_t) const

◆ nEtaBins()

uint32_t jpt::Map::nEtaBins ( ) const
inline

◆ nPtBins()

uint32_t jpt::Map::nPtBins ( ) const
inline

◆ print()

void Map::print ( std::stringstream &  ss) const

Definition at line 1557 of file JetPlusTrackCorrector.cc.

References data_, eta_, hcalRecHitTable_cff::ieta, METSignificanceParams_cfi::jeta, pt_, and contentValuesCheck::ss.

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

1557  {
1558  ss << " Number of bins in eta : " << data_.size() << std::endl
1559  << " Number of bins in pt : " << (data_.empty() ? 0 : data_[0].size()) << std::endl;
1560  VVDouble::const_iterator ieta = data_.begin();
1561  VVDouble::const_iterator jeta = data_.end();
1562  for (; ieta != jeta; ++ieta) {
1563  VDouble::const_iterator ipt = ieta->begin();
1564  VDouble::const_iterator jpt = ieta->end();
1565  for (; ipt != jpt; ++ipt) {
1566  uint32_t eta_bin = static_cast<uint32_t>(ieta - data_.begin());
1567  uint32_t pt_bin = static_cast<uint32_t>(ipt - ieta->begin());
1568  ss << " EtaBinNumber: " << eta_bin << " PtBinNumber: " << pt_bin << " EtaValue: " << eta_[eta_bin]
1569  << " PtValue: " << pt_[pt_bin] << " Value: " << data_[eta_bin][pt_bin] << std::endl;
1570  }
1571  }
1572 }
std::vector< double > pt_
std::vector< double > eta_

◆ pt()

double Map::pt ( uint32_t  pt_bin) const

Definition at line 1473 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(), datamodel.Object::p4(), ptBin(), Electron.Electron::ptErr(), ntupleDataFormat.Track::ptPull(), Lepton.Lepton::relIso(), Lepton.Lepton::relIsoFromEA(), Lepton.Lepton::relIsoR(), and Jet.Jet::setCorrP4().

1473  {
1474  if (!pt_.empty() && pt_bin < pt_.size()) {
1475  return pt_[pt_bin];
1476  } else {
1477  // edm::LogWarning("JetPlusTrackCorrector")
1478  // << "[jpt::Map::" << __func__ << "]"
1479  // << " Trying to access element " << pt_bin
1480  // << " of a vector with size " << pt_.size()
1481  // << "!";
1482  return pt_[pt_.size() - 1];
1483  }
1484 }
std::vector< double > pt_

◆ ptBin()

uint32_t Map::ptBin ( double  pt) const

Definition at line 1530 of file JetPlusTrackCorrector.cc.

References nPtBins(), pt(), and heppy_batch::val.

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

1530  {
1531  val = fabs(val);
1532  for (uint32_t ipt = 0; ipt < nPtBins() - 1; ++ipt) { //@@ "-1" is bug?
1533  if (val > pt(ipt) && ((ipt + 1) == nPtBins() || val < pt(ipt + 1))) {
1534  return ipt;
1535  }
1536  }
1537  return nPtBins();
1538 }
uint32_t nPtBins() const
double pt(uint32_t) const

◆ value()

double Map::value ( uint32_t  eta_bin,
uint32_t  pt_bin 
) const

Definition at line 1542 of file JetPlusTrackCorrector.cc.

References data_.

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

1542  {
1543  if (eta_bin < data_.size() && pt_bin < (data_.empty() ? 0 : data_[0].size())) {
1544  return data_[eta_bin][pt_bin];
1545  } else {
1546  // edm::LogWarning("JetPlusTrackCorrector")
1547  // << "[jpt::Map::" << __func__ << "]"
1548  // << " Trying to access element (" << eta_bin << "," << pt_bin << ")"
1549  // << " of a vector with size (" << data_.size() << "," << ( data_.empty() ? 0 : data_[0].size() ) << ")"
1550  // << "!";
1551  return 1.;
1552  }
1553 }

Member Data Documentation

◆ data_

VVDouble jpt::Map::data_
private

Definition at line 82 of file JetPlusTrackCorrector.h.

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

◆ eta_

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

Definition at line 80 of file JetPlusTrackCorrector.h.

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

◆ pt_

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

Definition at line 81 of file JetPlusTrackCorrector.h.

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