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

Member Typedef Documentation

◆ VDouble

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

Definition at line 74 of file JetPlusTrackCorrector.h.

◆ VVDouble

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

Definition at line 75 of file JetPlusTrackCorrector.h.

Constructor & Destructor Documentation

◆ Map() [1/2]

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

Definition at line 1399 of file JetPlusTrackCorrector.cc.

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 }

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

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

References clear().

◆ ~Map()

Map::~Map ( )

Definition at line 1471 of file JetPlusTrackCorrector.cc.

1471 { clear(); }

References clear().

Member Function Documentation

◆ binCenterEta()

double Map::binCenterEta ( uint32_t  eta_bin) const

Definition at line 1512 of file JetPlusTrackCorrector.cc.

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 }

References eta_.

Referenced by JetPlusTrackCorrector::pionEfficiency().

◆ binCenterPt()

double Map::binCenterPt ( uint32_t  pt_bin) const

Definition at line 1527 of file JetPlusTrackCorrector.cc.

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 }

References pt_.

Referenced by JetPlusTrackCorrector::pionEfficiency().

◆ clear()

void Map::clear ( void  )

Definition at line 1475 of file JetPlusTrackCorrector.cc.

1475  {
1476  eta_.clear();
1477  pt_.clear();
1478  data_.clear();
1479 }

References data_, eta_, and pt_.

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

◆ eta()

double Map::eta ( uint32_t  eta_bin) const

Definition at line 1482 of file JetPlusTrackCorrector.cc.

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 }

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

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 }

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

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 }

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

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 }

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

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 }

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

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 }

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

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

◆ eta_

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

Definition at line 77 of file JetPlusTrackCorrector.h.

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

◆ pt_

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

Definition at line 78 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:82
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:1482
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
jpt::Map::data_
VVDouble data_
Definition: JetPlusTrackCorrector.h:79
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
jpt::Map::pt_
std::vector< double > pt_
Definition: JetPlusTrackCorrector.h:78
edm::FileInPath
Definition: FileInPath.h:64
jpt::Map::eta_
std::vector< double > eta_
Definition: JetPlusTrackCorrector.h:77
jpt::Map::nPtBins
uint32_t nPtBins() const
Definition: JetPlusTrackCorrector.h:83
verbose
static constexpr int verbose
Definition: HLTExoticaSubAnalysis.cc:25
jpt
Definition: JetPlusTrackCorrector.h:37
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
LEDCalibrationChannels.ieta
ieta
Definition: LEDCalibrationChannels.py:63
edm::LogError
Definition: MessageLogger.h:183
recoMuon::in
Definition: RecoMuonEnumerators.h:6
jpt::Map::pt
double pt(uint32_t) const
Definition: JetPlusTrackCorrector.cc:1497
FrontierConditions_GlobalTag_cff.file
file
Definition: FrontierConditions_GlobalTag_cff.py:13
jpt::Map::VDouble
std::vector< double > VDouble
Definition: JetPlusTrackCorrector.h:74
jpt::Map::clear
void clear()
Definition: JetPlusTrackCorrector.cc:1475
jpt::Map::print
void print(std::stringstream &ss) const
Definition: JetPlusTrackCorrector.cc:1581
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:71
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:671
mps_splice.line
line
Definition: mps_splice.py:76
edm::FileInPath::fullPath
std::string fullPath() const
Definition: FileInPath.cc:163