#include <Fireworks/Core/interface/FWItemValueGetter.h>
Classes | |
struct | Entry |
Public Member Functions | |
FWItemValueGetter (const ROOT::Reflex::Type &, const std::string &iPurpose) | |
std::vector< std::string > | getTitles () const |
const std::string & | getToolTip (const void *iObject) const |
int | numValues () const |
UInt_t | precision (int idx) const |
double | valueFor (const void *, int idx) const |
Private Types | |
typedef std::vector< Entry > | Entries_t |
Private Member Functions | |
bool | addEntry (std::string iExpression, int iPrec=2, std::string iTitle="", std::string iUnit="") |
Private Attributes | |
Entries_t::const_iterator | Entries_i |
Entries_t | m_entries |
int | m_titleWidth |
ROOT::Reflex::Type | m_type |
Description: Retrieves a particular value from an item
Usage: <usage>
Definition at line 35 of file FWItemValueGetter.h.
typedef std::vector<Entry > FWItemValueGetter::Entries_t [private] |
Definition at line 61 of file FWItemValueGetter.h.
FWItemValueGetter::FWItemValueGetter | ( | const ROOT::Reflex::Type & | iType, |
const std::string & | iPurpose | ||
) |
Definition at line 37 of file FWItemValueGetter.cc.
References addEntry(), and x.
: m_type(iType), m_titleWidth(0) { if ( iType.Name() == "CaloTower" ) { if ( iPurpose == "ECal" ) addEntry("emEt", 1, "et", "GeV"); else if ( iPurpose == "HCal" ) addEntry("hadEt", 1, "et", "GeV"); else if (iPurpose == "HCal Outer") addEntry("outerEt", 1, "et", "GeV"); } else if (strstr(iPurpose.c_str(), "Beam Spot") ) { addEntry("x0", 2, "x", "cm"); addEntry("y0", 2, "y", "cm"); addEntry("z0", 2, "z", "cm"); } else if (strstr(iPurpose.c_str(), "Conversion") ) { addEntry("pairMomentum().rho()", 1, "pt", "GeV" ); addEntry("pairMomentum().eta()", 2, "eta"); addEntry("pairMomentum().phi()", 2, "phi"); } else if (strstr(iPurpose.c_str(), "Candidate") ) { addEntry("pdgId()", 0, "pdg"); bool x = addEntry("pt", 1); if (!x) x = addEntry("et", 1); if (!x) addEntry("energy", 1); } else if (iPurpose == "Jets" ) { addEntry("et", 1); } else { // by the default add pt, et, or energy bool x = addEntry("pt", 1); if (!x) x = addEntry("et", 1); if (!x) addEntry("energy", 1); } if (addEntry("eta", 2)) addEntry("phi", 2); }
bool FWItemValueGetter::addEntry | ( | std::string | iExpression, |
int | iPrec = 2 , |
||
std::string | iTitle = "" , |
||
std::string | iUnit = "" |
||
) | [private] |
Definition at line 86 of file FWItemValueGetter.cc.
References m_entries, m_titleWidth, m_type, siStripFEDMonitor_P5_cff::Max, fireworks::expression::oldToNewFormat(), triggerExpression::parse(), and cond::rpcobtemp::temp.
Referenced by FWItemValueGetter().
{ using namespace boost::spirit::classic; reco::parser::ExpressionPtr tmpPtr; reco::parser::Grammar grammar(tmpPtr, m_type); if(m_type != ROOT::Reflex::Type() && iExpression.size()) { using namespace fireworks::expression; //Backwards compatibility with old format std::string temp = oldToNewFormat(iExpression); //now setup the parser try { if(parse(temp.c_str(), grammar.use_parser<1>() >> end_p, space_p).full) { m_entries.push_back(Entry(tmpPtr, iExpression, iUnit, iTitle.empty() ? iExpression :iTitle , iPrec)); m_titleWidth = TMath::Max(m_titleWidth, (int) m_entries.back().m_title.size()); return true; } } catch(const reco::parser::BaseException& e) { // std::cout <<"failed to parse "<<iExpression<<" because "<<reco::parser::baseExceptionWhat(e)<<std::endl; } } return false; }
std::vector< std::string > FWItemValueGetter::getTitles | ( | ) | const |
Definition at line 136 of file FWItemValueGetter.cc.
Referenced by FWCollectionSummaryTableManager::getTitles().
const std::string & FWItemValueGetter::getToolTip | ( | const void * | iObject | ) | const |
Definition at line 155 of file FWItemValueGetter.cc.
References i, m_entries, FWItemValueGetter::Entry::m_expr, FWItemValueGetter::Entry::m_precision, FWItemValueGetter::Entry::m_title, m_titleWidth, m_type, and connectstrParser::o.
Referenced by FWEventItem::modelInterestingValueAsString().
{ static std::string buff(128, 0); static std::string fs = "\n %*s = %.*f"; ROOT::Reflex::Object o(m_type, const_cast<void *>(iObject)); int off = 0; for ( std::vector<Entry >::const_iterator i = m_entries.begin() ; i != m_entries.end(); ++i) { const Entry& e = *i; off += snprintf(&buff[off], 127, fs.c_str(), m_titleWidth, e.m_title.c_str(), e.m_precision ? (e.m_precision+1) : 0, e.m_expr->value(o)); } // std::cout << buff; return buff; }
int FWItemValueGetter::numValues | ( | ) | const |
Definition at line 148 of file FWItemValueGetter.cc.
References m_entries.
Referenced by FWCollectionSummaryTableManager::cellRenderer(), and FWCollectionSummaryTableManager::numberOfColumns().
{ return static_cast<int>(m_entries.size()); }
UInt_t FWItemValueGetter::precision | ( | int | idx | ) | const |
Definition at line 130 of file FWItemValueGetter.cc.
References m_entries.
Referenced by FWCollectionSummaryTableManager::cellRenderer().
{ return m_entries[idx].m_precision; }
double FWItemValueGetter::valueFor | ( | const void * | iObject, |
int | idx | ||
) | const |
Definition at line 122 of file FWItemValueGetter.cc.
References m_entries, m_type, and connectstrParser::o.
Referenced by FWCollectionSummaryTableManager::cellRenderer(), and FWViewContextMenuHandlerGL::select().
Entries_t::const_iterator FWItemValueGetter::Entries_i [private] |
Definition at line 62 of file FWItemValueGetter.h.
Entries_t FWItemValueGetter::m_entries [private] |
Definition at line 64 of file FWItemValueGetter.h.
Referenced by addEntry(), getTitles(), getToolTip(), numValues(), precision(), and valueFor().
int FWItemValueGetter::m_titleWidth [private] |
Definition at line 67 of file FWItemValueGetter.h.
Referenced by addEntry(), and getToolTip().
ROOT::Reflex::Type FWItemValueGetter::m_type [private] |
Definition at line 65 of file FWItemValueGetter.h.
Referenced by addEntry(), getToolTip(), and valueFor().