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 40 of file JetPlusTrackCorrector.h.

Member Typedef Documentation

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

Definition at line 74 of file JetPlusTrackCorrector.h.

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

Definition at line 75 of file JetPlusTrackCorrector.h.

Constructor & Destructor Documentation

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

Definition at line 1399 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(), das-selected-lumis::jdata, mps_splice::line, LogTrace, print(), jpt::Map::Element::pt_, pt_, contentValuesCheck::ss, AlCaHLTBitMon_QueryRunRegistry::string, groupFilesInBlocks::temp, and jpt::Map::Element::val_.

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

Definition at line 1467 of file JetPlusTrackCorrector.cc.

References clear().

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

Definition at line 1471 of file JetPlusTrackCorrector.cc.

References clear().

1471 { clear(); }

Member Function Documentation

double Map::binCenterEta ( uint32_t  eta_bin) const

Definition at line 1512 of file JetPlusTrackCorrector.cc.

References eta_.

Referenced by JetPlusTrackCorrector::pionEfficiency().

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

Definition at line 1527 of file JetPlusTrackCorrector.cc.

References pt_.

Referenced by JetPlusTrackCorrector::pionEfficiency().

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

Definition at line 1475 of file JetPlusTrackCorrector.cc.

References data_, eta_, and pt_.

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

1475  {
1476  eta_.clear();
1477  pt_.clear();
1478  data_.clear();
1479 }
std::vector< double > pt_
std::vector< double > eta_
double Map::eta ( uint32_t  eta_bin) const

Definition at line 1482 of file JetPlusTrackCorrector.cc.

References eta_.

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

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

Definition at line 1542 of file JetPlusTrackCorrector.cc.

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

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

1542  {
1543  val = fabs(val);
1544  for (uint32_t ieta = 0; ieta < nEtaBins() - 1; ++ieta) { //@@ "-1" is bug?
1545  if (val > eta(ieta) && (ieta + 1 == nEtaBins() || val < eta(ieta + 1))) {
1546  return ieta;
1547  }
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 1581 of file JetPlusTrackCorrector.cc.

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

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

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

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

1497  {
1498  if (!pt_.empty() && pt_bin < pt_.size()) {
1499  return pt_[pt_bin];
1500  } else {
1501  // edm::LogWarning("JetPlusTrackCorrector")
1502  // << "[jpt::Map::" << __func__ << "]"
1503  // << " Trying to access element " << pt_bin
1504  // << " of a vector with size " << pt_.size()
1505  // << "!";
1506  return pt_[pt_.size() - 1];
1507  }
1508 }
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))) {
1558  return ipt;
1559  }
1560  }
1561  return nPtBins();
1562 }
double pt(uint32_t) const
uint32_t nPtBins() const
double Map::value ( uint32_t  eta_bin,
uint32_t  pt_bin 
) const

Definition at line 1566 of file JetPlusTrackCorrector.cc.

References data_.

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

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

Member Data Documentation

VVDouble jpt::Map::data_
private

Definition at line 79 of file JetPlusTrackCorrector.h.

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

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

Definition at line 77 of file JetPlusTrackCorrector.h.

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

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

Definition at line 78 of file JetPlusTrackCorrector.h.

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