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 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 1378 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.

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

◆ Map() [2/2]

Map::Map ( )

Definition at line 1446 of file JetPlusTrackCorrector.cc.

References clear().

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

◆ ~Map()

Map::~Map ( )

Definition at line 1450 of file JetPlusTrackCorrector.cc.

References clear().

1450 { clear(); }

Member Function Documentation

◆ binCenterEta()

double Map::binCenterEta ( uint32_t  eta_bin) const

Definition at line 1491 of file JetPlusTrackCorrector.cc.

References eta_.

Referenced by JetPlusTrackCorrector::pionEfficiency().

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

◆ binCenterPt()

double Map::binCenterPt ( uint32_t  pt_bin) const

Definition at line 1506 of file JetPlusTrackCorrector.cc.

References pt_.

Referenced by JetPlusTrackCorrector::pionEfficiency().

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

◆ clear()

void Map::clear ( void  )

Definition at line 1454 of file JetPlusTrackCorrector.cc.

References data_, eta_, and pt_.

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

1454  {
1455  eta_.clear();
1456  pt_.clear();
1457  data_.clear();
1458 }
std::vector< double > pt_
std::vector< double > eta_

◆ eta()

double Map::eta ( uint32_t  eta_bin) const

Definition at line 1461 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().

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

◆ etaBin()

uint32_t Map::etaBin ( double  eta) const

Definition at line 1521 of file JetPlusTrackCorrector.cc.

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

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

1521  {
1522  val = fabs(val);
1523  for (uint32_t ieta = 0; ieta < nEtaBins() - 1; ++ieta) { //@@ "-1" is bug?
1524  if (val > eta(ieta) && (ieta + 1 == nEtaBins() || val < eta(ieta + 1))) {
1525  return ieta;
1526  }
1527  }
1528  return nEtaBins();
1529 }
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 1560 of file JetPlusTrackCorrector.cc.

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

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

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

◆ pt()

double Map::pt ( uint32_t  pt_bin) const

Definition at line 1476 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().

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

◆ ptBin()

uint32_t Map::ptBin ( double  pt) const

Definition at line 1533 of file JetPlusTrackCorrector.cc.

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

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

1533  {
1534  val = fabs(val);
1535  for (uint32_t ipt = 0; ipt < nPtBins() - 1; ++ipt) { //@@ "-1" is bug?
1536  if (val > pt(ipt) && ((ipt + 1) == nPtBins() || val < pt(ipt + 1))) {
1537  return ipt;
1538  }
1539  }
1540  return nPtBins();
1541 }
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 1545 of file JetPlusTrackCorrector.cc.

References data_.

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

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

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().