CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 41 of file JetPlusTrackCorrector.h.

Member Typedef Documentation

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

Definition at line 78 of file JetPlusTrackCorrector.h.

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

Definition at line 79 of file JetPlusTrackCorrector.h.

Constructor & Destructor Documentation

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

Definition at line 1407 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(), geometryCSVtoXML::line, LogTrace, print(), jpt::Map::Element::pt_, pt_, contentValuesCheck::ss, AlCaHLTBitMon_QueryRunRegistry::string, groupFilesInBlocks::temp, and jpt::Map::Element::val_.

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

Definition at line 1475 of file JetPlusTrackCorrector.cc.

References clear().

1476  : eta_(),
1477  pt_(),
1478  data_()
1479 {
1480  clear();
1481 }
std::vector< double > pt_
std::vector< double > eta_
Map::~Map ( )

Definition at line 1485 of file JetPlusTrackCorrector.cc.

References clear().

1485  {
1486  clear();
1487 }

Member Function Documentation

double Map::binCenterEta ( uint32_t  eta_bin) const

Definition at line 1526 of file JetPlusTrackCorrector.cc.

References eta_.

Referenced by JetPlusTrackCorrector::pionEfficiency().

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

Definition at line 1541 of file JetPlusTrackCorrector.cc.

References pt_.

Referenced by JetPlusTrackCorrector::pionEfficiency().

1541  {
1542  if ( !pt_.empty() && pt_bin+1 < pt_.size() ) {
1543  return pt_[pt_bin] + ( pt_[pt_bin+1] - pt_[pt_bin] ) / 2.;
1544  } else {
1545 // edm::LogWarning("JetPlusTrackCorrector")
1546 // << "[jpt::Map::" << __func__ << "]"
1547 // << " Trying to access element " << pt_bin+1
1548 // << " of a vector with size " << pt_.size()
1549 // << "!";
1550  return pt_[pt_.size()-1];
1551  }
1552 }
std::vector< double > pt_
void Map::clear ( void  )

Definition at line 1491 of file JetPlusTrackCorrector.cc.

References data_, eta_, and pt_.

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

1491  {
1492  eta_.clear();
1493  pt_.clear();
1494  data_.clear();
1495 }
std::vector< double > pt_
std::vector< double > eta_
double Map::eta ( uint32_t  eta_bin) const

Definition at line 1498 of file JetPlusTrackCorrector.cc.

References eta_.

Referenced by etaBin().

1498  {
1499  if ( !eta_.empty() && eta_bin < eta_.size() ) { return eta_[eta_bin]; }
1500  else {
1501 // edm::LogWarning("JetPlusTrackCorrector")
1502 // << "[jpt::Map::" << __func__ << "]"
1503 // << " Trying to access element " << eta_bin
1504 // << " of a vector with size " << eta_.size()
1505 // << "!";
1506  return eta_[eta_.size()-1];
1507  }
1508 }
std::vector< double > eta_
uint32_t Map::etaBin ( double  eta) const

Definition at line 1556 of file JetPlusTrackCorrector.cc.

References eta(), and nEtaBins().

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

1556  {
1557  val = fabs( val );
1558  for ( uint32_t ieta = 0; ieta < nEtaBins()-1; ++ieta ) { //@@ "-1" is bug?
1559  if ( val > eta(ieta) && ( ieta+1 == nEtaBins() || val < eta(ieta+1) ) ) { return ieta; }
1560  }
1561  return nEtaBins();
1562 }
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 1591 of file JetPlusTrackCorrector.cc.

References data_, eta_, and pt_.

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

1591  {
1592  ss << " Number of bins in eta : " << data_.size() << std::endl
1593  << " Number of bins in pt : " << ( data_.empty() ? 0 : data_[0].size() ) << std::endl;
1594  VVDouble::const_iterator ieta = data_.begin();
1595  VVDouble::const_iterator jeta = data_.end();
1596  for ( ; ieta != jeta; ++ieta ) {
1597  VDouble::const_iterator ipt = ieta->begin();
1598  VDouble::const_iterator jpt = ieta->end();
1599  for ( ; ipt != jpt; ++ipt ) {
1600  uint32_t eta_bin = static_cast<uint32_t>( ieta - data_.begin() );
1601  uint32_t pt_bin = static_cast<uint32_t>( ipt - ieta->begin() );
1602  ss << " EtaBinNumber: " << eta_bin
1603  << " PtBinNumber: " << pt_bin
1604  << " EtaValue: " << eta_[ eta_bin ]
1605  << " PtValue: " << pt_[ pt_bin ]
1606  << " Value: " << data_[eta_bin][pt_bin]
1607  << std::endl;
1608  }
1609  }
1610 }
std::vector< double > pt_
std::vector< double > eta_
double Map::pt ( uint32_t  pt_bin) const

Definition at line 1512 of file JetPlusTrackCorrector.cc.

References pt_.

Referenced by ptBin().

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

Definition at line 1566 of file JetPlusTrackCorrector.cc.

References nPtBins(), and pt().

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

1566  {
1567  val = fabs( val );
1568  for ( uint32_t ipt = 0; ipt < nPtBins()-1; ++ipt ) { //@@ "-1" is bug?
1569  if ( val > pt(ipt) && ( (ipt+1) == nPtBins() || val < pt(ipt+1) ) ) { return ipt; }
1570  }
1571  return nPtBins();
1572 }
double pt(uint32_t) const
uint32_t nPtBins() const
double Map::value ( uint32_t  eta_bin,
uint32_t  pt_bin 
) const

Definition at line 1576 of file JetPlusTrackCorrector.cc.

References data_.

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

1576  {
1577  if ( eta_bin < data_.size() &&
1578  pt_bin < ( data_.empty() ? 0 : data_[0].size() ) ) { return data_[eta_bin][pt_bin]; }
1579  else {
1580 // edm::LogWarning("JetPlusTrackCorrector")
1581 // << "[jpt::Map::" << __func__ << "]"
1582 // << " Trying to access element (" << eta_bin << "," << pt_bin << ")"
1583 // << " of a vector with size (" << data_.size() << "," << ( data_.empty() ? 0 : data_[0].size() ) << ")"
1584 // << "!";
1585  return 1.;
1586  }
1587 }

Member Data Documentation

VVDouble jpt::Map::data_
private

Definition at line 83 of file JetPlusTrackCorrector.h.

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

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

Definition at line 81 of file JetPlusTrackCorrector.h.

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

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

Definition at line 82 of file JetPlusTrackCorrector.h.

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