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 ()
 
 Map (std::string, bool verbose=false)
 
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 1376 of file JetPlusTrackCorrector.cc.

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 }

References clear(), data, data_, eta_, FrontierConditions_GlobalTag_cff::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.

◆ Map() [2/2]

Map::Map ( )

Definition at line 1444 of file JetPlusTrackCorrector.cc.

1444 : eta_(), pt_(), data_() { clear(); }

References clear().

◆ ~Map()

Map::~Map ( )

Definition at line 1448 of file JetPlusTrackCorrector.cc.

1448 { clear(); }

References clear().

Member Function Documentation

◆ binCenterEta()

double Map::binCenterEta ( uint32_t  eta_bin) const

Definition at line 1489 of file JetPlusTrackCorrector.cc.

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 }

References eta_.

Referenced by JetPlusTrackCorrector::pionEfficiency().

◆ binCenterPt()

double Map::binCenterPt ( uint32_t  pt_bin) const

Definition at line 1504 of file JetPlusTrackCorrector.cc.

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 }

References pt_.

Referenced by JetPlusTrackCorrector::pionEfficiency().

◆ clear()

void Map::clear ( void  )

Definition at line 1452 of file JetPlusTrackCorrector.cc.

1452  {
1453  eta_.clear();
1454  pt_.clear();
1455  data_.clear();
1456 }

References data_, eta_, and pt_.

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

◆ eta()

double Map::eta ( uint32_t  eta_bin) const

Definition at line 1459 of file JetPlusTrackCorrector.cc.

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 }

References eta_.

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

◆ etaBin()

uint32_t Map::etaBin ( double  eta) const

Definition at line 1519 of file JetPlusTrackCorrector.cc.

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 }

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

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

◆ 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 1558 of file JetPlusTrackCorrector.cc.

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 }

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

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

◆ pt()

double Map::pt ( uint32_t  pt_bin) const

Definition at line 1474 of file JetPlusTrackCorrector.cc.

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 }

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

◆ ptBin()

uint32_t Map::ptBin ( double  pt) const

Definition at line 1531 of file JetPlusTrackCorrector.cc.

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 }

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

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

◆ value()

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

Definition at line 1543 of file JetPlusTrackCorrector.cc.

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 }

References data_.

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

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

input
static const std::string input
Definition: EdmProvDump.cc:48
jpt::Map::nEtaBins
uint32_t nEtaBins() const
Definition: JetPlusTrackCorrector.h:85
das-selected-lumis.jdata
jdata
Definition: das-selected-lumis.py:10
METSignificanceParams_cfi.jeta
jeta
Definition: METSignificanceParams_cfi.py:12
jpt::Map::eta
double eta(uint32_t) const
Definition: JetPlusTrackCorrector.cc:1459
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
jpt::Map::data_
VVDouble data_
Definition: JetPlusTrackCorrector.h:82
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
jpt::Map::pt_
std::vector< double > pt_
Definition: JetPlusTrackCorrector.h:81
edm::FileInPath
Definition: FileInPath.h:64
jpt::Map::eta_
std::vector< double > eta_
Definition: JetPlusTrackCorrector.h:80
jpt::Map::nPtBins
uint32_t nPtBins() const
Definition: JetPlusTrackCorrector.h:86
verbose
static constexpr int verbose
Definition: HLTExoticaSubAnalysis.cc:25
jpt
Definition: JetPlusTrackCorrector.h:40
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
LEDCalibrationChannels.ieta
ieta
Definition: LEDCalibrationChannels.py:63
recoMuon::in
Definition: RecoMuonEnumerators.h:6
jpt::Map::pt
double pt(uint32_t) const
Definition: JetPlusTrackCorrector.cc:1474
FrontierConditions_GlobalTag_cff.file
file
Definition: FrontierConditions_GlobalTag_cff.py:13
jpt::Map::VDouble
std::vector< double > VDouble
Definition: JetPlusTrackCorrector.h:77
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
jpt::Map::clear
void clear()
Definition: JetPlusTrackCorrector.cc:1452
jpt::Map::print
void print(std::stringstream &ss) const
Definition: JetPlusTrackCorrector.cc:1558
heppy_batch.val
val
Definition: heppy_batch.py:351
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
edm::isDebugEnabled
bool isDebugEnabled()
Definition: MessageLogger.cc:12
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:234
mps_splice.line
line
Definition: mps_splice.py:76
edm::FileInPath::fullPath
std::string fullPath() const
Definition: FileInPath.cc:161