CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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

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

Definition at line 77 of file JetPlusTrackCorrector.h.

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

Definition at line 78 of file JetPlusTrackCorrector.h.

Constructor & Destructor Documentation

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

Definition at line 1376 of file JetPlusTrackCorrector.cc.

References clear(), data, data_, jpt::Map::Element::eta_, eta_, mergeVDriftHistosByStation::file, edm::FileInPath::fullPath(), jpt::Map::Element::ieta_, recoMuon::in, jpt::Map::Element::ipt_, edm::isDebugEnabled(), das-selected-lumis::jdata, geometryCSVtoXML::line, LogTrace, print(), jpt::Map::Element::pt_, pt_, contentValuesCheck::ss, AlCaHLTBitMon_QueryRunRegistry::string, groupFilesInBlocks::temp, and jpt::Map::Element::val_.

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

Definition at line 1444 of file JetPlusTrackCorrector.cc.

References clear().

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

Definition at line 1448 of file JetPlusTrackCorrector.cc.

References clear().

1448 { clear(); }

Member Function Documentation

double Map::binCenterEta ( uint32_t  eta_bin) const

Definition at line 1489 of file JetPlusTrackCorrector.cc.

References eta_.

Referenced by JetPlusTrackCorrector::pionEfficiency().

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

Definition at line 1504 of file JetPlusTrackCorrector.cc.

References pt_.

Referenced by JetPlusTrackCorrector::pionEfficiency().

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

Definition at line 1452 of file JetPlusTrackCorrector.cc.

References data_, eta_, and pt_.

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

1452  {
1453  eta_.clear();
1454  pt_.clear();
1455  data_.clear();
1456 }
std::vector< double > pt_
std::vector< double > eta_
double Map::eta ( uint32_t  eta_bin) const

Definition at line 1459 of file JetPlusTrackCorrector.cc.

References eta_.

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

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

Definition at line 1519 of file JetPlusTrackCorrector.cc.

References eta(), and nEtaBins().

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

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

References data_, eta_, and pt_.

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

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

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

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

Definition at line 1531 of file JetPlusTrackCorrector.cc.

References nPtBins(), and pt().

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

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

Definition at line 1543 of file JetPlusTrackCorrector.cc.

References data_.

Referenced by Types.int32::__nonzero__(), Types.uint32::__nonzero__(), Types.int64::__nonzero__(), Types.uint64::__nonzero__(), Types.double::__nonzero__(), Types.bool::__nonzero__(), Types.string::__nonzero__(), JetPlusTrackCorrector::calculateCorr(), Types.string::configValue(), Types.FileInPath::configValue(), JetPlusTrackCorrector::correctAA(), jpt::Efficiency::inConeCorr(), Types.int32::insertInto(), Types.uint32::insertInto(), Types.int64::insertInto(), Types.uint64::insertInto(), Types.double::insertInto(), Types.bool::insertInto(), Types.string::insertInto(), Types.FileInPath::insertInto(), Types.vint32::insertInto(), Types.vuint32::insertInto(), Types.vint64::insertInto(), Types.vuint64::insertInto(), Types.vdouble::insertInto(), Types.vbool::insertInto(), Types.vstring::insertInto(), and jpt::Efficiency::outOfConeCorr().

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

Member Data Documentation

VVDouble jpt::Map::data_
private

Definition at line 82 of file JetPlusTrackCorrector.h.

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

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

Definition at line 80 of file JetPlusTrackCorrector.h.

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

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

Definition at line 81 of file JetPlusTrackCorrector.h.

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