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< VDouble > | VVDouble |
Private Attributes | |
VVDouble | data_ |
std::vector< double > | eta_ |
std::vector< double > | pt_ |
Container class for response & efficiency maps.
Definition at line 37 of file JetPlusTrackCorrector.h.
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.
Map::Map | ( | std::string | input, |
bool | verbose = false |
||
) |
Definition at line 1220 of file JetPlusTrackCorrector.cc.
References clear(), runTheMatrix::data, data_, jpt::Map::Element::eta_, eta_, dbtoweb::file, edm::FileInPath::fullPath(), jpt::Map::Element::ieta_, recoMuon::in, jpt::Map::Element::ipt_, edm::isDebugEnabled(), geometryCSVtoXML::line, LogTrace, print(), pt_, jpt::Map::Element::pt_, cond::rpcobtemp::temp, and jpt::Map::Element::val_.
: eta_(), pt_(), data_() { // Some init clear(); std::vector<Element> data; // Parse file std::string file = edm::FileInPath(input).fullPath(); std::ifstream in( file.c_str() ); string line; uint32_t ieta_old = 0; while ( std::getline( in, line ) ) { if ( !line.size() || line[0]=='#' ) { continue; } std::istringstream ss(line); Element temp; ss >> temp.ieta_ >> temp.ipt_ >> temp.eta_ >> temp.pt_ >> temp.val_; data.push_back(temp); if ( !ieta_old || temp.ieta_ != ieta_old ) { if ( eta_.size() < temp.ieta_+1 ) { eta_.resize(temp.ieta_+1,0.); } eta_[temp.ieta_] = temp.eta_; ieta_old = temp.ieta_; } if ( pt_.size() < temp.ipt_+1 ) { pt_.resize(temp.ipt_+1,0.); } pt_[temp.ipt_] = temp.pt_; } // Populate container data_.resize( eta_.size(), VDouble( pt_.size(), 0. ) ); std::vector<Element>::const_iterator idata = data.begin(); std::vector<Element>::const_iterator jdata = data.end(); for ( ; idata != jdata; ++idata ) { data_[idata->ieta_][idata->ipt_] = idata->val_; } // Check if ( data_.empty() || data_[0].empty() ) { std::stringstream ss; ss << "[jpt::Map::" << __func__ << "]" << " Problem parsing map in location \"" << file << "\"! "; edm::LogError("JetPlusTrackCorrector") << ss.str(); } // Check if ( eta_.size() != data_.size() || pt_.size() != ( data_.empty() ? 0 : data_[0].size() ) ) { std::stringstream ss; ss << "[jpt::Map::" << __func__ << "]" << " Discrepancy b/w number of bins!"; edm::LogError("JetPlusTrackCorrector") << ss.str(); } // Debug if ( verbose && edm::isDebugEnabled() ) { std::stringstream ss; ss << "[jpt::Map::" << __func__ << "]" << " Parsed contents of map at location:" << std::endl << "\"" << file << "\"" << std::endl; print(ss); LogTrace("JetPlusTrackCorrector") << ss.str(); } }
Map::Map | ( | ) |
Map::~Map | ( | ) |
double Map::binCenterEta | ( | uint32_t | eta_bin | ) | const |
Definition at line 1339 of file JetPlusTrackCorrector.cc.
References eta_.
Referenced by JetPlusTrackCorrector::pionEfficiency().
{ if ( !eta_.empty() && eta_bin+1 < eta_.size() ) { return eta_[eta_bin] + ( eta_[eta_bin+1] - eta_[eta_bin] ) / 2.; } else { edm::LogWarning("JetPlusTrackCorrector") << "[jpt::Map::" << __func__ << "]" << " Trying to access element " << eta_bin+1 << " of a vector with size " << eta_.size() << "!"; return eta_[eta_.size()-1]; } }
double Map::binCenterPt | ( | uint32_t | pt_bin | ) | const |
Definition at line 1354 of file JetPlusTrackCorrector.cc.
References pt_.
Referenced by JetPlusTrackCorrector::pionEfficiency().
{ if ( !pt_.empty() && pt_bin+1 < pt_.size() ) { return pt_[pt_bin] + ( pt_[pt_bin+1] - pt_[pt_bin] ) / 2.; } else { edm::LogWarning("JetPlusTrackCorrector") << "[jpt::Map::" << __func__ << "]" << " Trying to access element " << pt_bin+1 << " of a vector with size " << pt_.size() << "!"; return pt_[pt_.size()-1]; } }
void Map::clear | ( | void | ) |
double Map::eta | ( | uint32_t | eta_bin | ) | const |
uint32_t Map::etaBin | ( | double | eta | ) | const |
Definition at line 1369 of file JetPlusTrackCorrector.cc.
References eta(), and nEtaBins().
Referenced by JetPlusTrackCorrector::calculateCorr(), and JetPlusTrackCorrector::correctAA().
uint32_t jpt::Map::nEtaBins | ( | ) | const [inline] |
Definition at line 83 of file JetPlusTrackCorrector.h.
References eta_.
Referenced by JetPlusTrackCorrector::calculateCorr(), JetPlusTrackCorrector::correctAA(), etaBin(), jpt::Efficiency::nEtaBins(), JetPlusTrackCorrector::pionEfficiency(), and jpt::Efficiency::reset().
{ return eta_.size(); }
uint32_t jpt::Map::nPtBins | ( | ) | const [inline] |
Definition at line 84 of file JetPlusTrackCorrector.h.
References pt_.
Referenced by JetPlusTrackCorrector::calculateCorr(), JetPlusTrackCorrector::correctAA(), jpt::Efficiency::nPtBins(), JetPlusTrackCorrector::pionEfficiency(), ptBin(), and jpt::Efficiency::reset().
{ return pt_.size(); }
void Map::print | ( | std::stringstream & | ss | ) | const |
Definition at line 1404 of file JetPlusTrackCorrector.cc.
References data_, eta_, and pt_.
Referenced by Map(), and jpt::Efficiency::print().
{ ss << " Number of bins in eta : " << data_.size() << std::endl << " Number of bins in pt : " << ( data_.empty() ? 0 : data_[0].size() ) << std::endl; VVDouble::const_iterator ieta = data_.begin(); VVDouble::const_iterator jeta = data_.end(); for ( ; ieta != jeta; ++ieta ) { VDouble::const_iterator ipt = ieta->begin(); VDouble::const_iterator jpt = ieta->end(); for ( ; ipt != jpt; ++ipt ) { uint32_t eta_bin = static_cast<uint32_t>( ieta - data_.begin() ); uint32_t pt_bin = static_cast<uint32_t>( ipt - ieta->begin() ); ss << " EtaBinNumber: " << eta_bin << " PtBinNumber: " << pt_bin << " EtaValue: " << eta_[ eta_bin ] << " PtValue: " << pt_[ pt_bin ] << " Value: " << data_[eta_bin][pt_bin] << std::endl; } } }
double Map::pt | ( | uint32_t | pt_bin | ) | const |
uint32_t Map::ptBin | ( | double | pt | ) | const |
Definition at line 1379 of file JetPlusTrackCorrector.cc.
References nPtBins(), and pt().
Referenced by JetPlusTrackCorrector::calculateCorr(), and JetPlusTrackCorrector::correctAA().
double Map::value | ( | uint32_t | eta_bin, |
uint32_t | pt_bin | ||
) | const |
Definition at line 1389 of file JetPlusTrackCorrector.cc.
References data_.
Referenced by JetPlusTrackCorrector::calculateCorr(), JetPlusTrackCorrector::correctAA(), jpt::Efficiency::inConeCorr(), and jpt::Efficiency::outOfConeCorr().
{ if ( eta_bin < data_.size() && pt_bin < ( data_.empty() ? 0 : data_[0].size() ) ) { return data_[eta_bin][pt_bin]; } else { edm::LogWarning("JetPlusTrackCorrector") << "[jpt::Map::" << __func__ << "]" << " Trying to access element (" << eta_bin << "," << pt_bin << ")" << " of a vector with size (" << data_.size() << "," << ( data_.empty() ? 0 : data_[0].size() ) << ")" << "!"; return 1.; } }
VVDouble jpt::Map::data_ [private] |
std::vector<double> jpt::Map::eta_ [private] |
Definition at line 77 of file JetPlusTrackCorrector.h.
Referenced by binCenterEta(), clear(), eta(), Map(), nEtaBins(), and print().
std::vector<double> jpt::Map::pt_ [private] |
Definition at line 78 of file JetPlusTrackCorrector.h.
Referenced by binCenterPt(), clear(), Map(), nPtBins(), print(), and pt().