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 Member Functions | Private Attributes
FWItemValueGetter Class Reference

#include <Fireworks/Core/interface/FWItemValueGetter.h>

Classes

struct  Entry
 

Public Member Functions

 FWItemValueGetter (const edm::TypeWithDict &, 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< EntryEntries_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
 
edm::TypeWithDict m_type
 

Detailed Description

Description: Retrieves a particular value from an item

Usage: <usage>

Definition at line 34 of file FWItemValueGetter.h.

Member Typedef Documentation

typedef std::vector<Entry > FWItemValueGetter::Entries_t
private

Definition at line 60 of file FWItemValueGetter.h.

Constructor & Destructor Documentation

FWItemValueGetter::FWItemValueGetter ( const edm::TypeWithDict iType,
const std::string &  iPurpose 
)

Definition at line 37 of file FWItemValueGetter.cc.

References addEntry(), edm::TypeWithDict::name(), and x.

37  :
38  m_type(iType),
39  m_titleWidth(0)
40 {
41  if (!strcmp(iType.name().c_str(), "CaloTower"))
42  {
43  if ( iPurpose == "ECal" )
44  addEntry("emEt", 1, "et", "GeV");
45  else if ( iPurpose == "HCal" )
46  addEntry("hadEt", 1, "et", "GeV");
47  else if (iPurpose == "HCal Outer")
48  addEntry("outerEt", 1, "et", "GeV");
49  }
50  else if (strstr(iPurpose.c_str(), "Beam Spot") )
51  {
52  addEntry("x0", 2, "x", "cm");
53  addEntry("y0", 2, "y", "cm");
54  addEntry("z0", 2, "z", "cm");
55  }
56  else if (strstr(iPurpose.c_str(), "Conversion") )
57  {
58  addEntry("pairMomentum().rho()", 1, "pt", "GeV" );
59  addEntry("pairMomentum().eta()", 2, "eta");
60  addEntry("pairMomentum().phi()", 2, "phi");
61  }
62  else if (strstr(iPurpose.c_str(), "Candidate") || strstr(iPurpose.c_str(), "GenParticle"))
63  {
64  addEntry("pdgId()", 0, "pdg");
65  bool x = addEntry("pt", 1);
66  if (!x) x = addEntry("et", 1);
67  if (!x) addEntry("energy", 1);
68  }
69  else if (iPurpose == "Jets" )
70  {
71  addEntry("et", 1);
72  }
73  else {
74  // by the default add pt, et, or energy
75  bool x = addEntry("pt", 1);
76  if (!x) x = addEntry("et", 1);
77  if (!x) addEntry("energy", 1);
78  }
79 
80  if (addEntry("eta", 2))
81  addEntry("phi", 2);
82 }
bool addEntry(std::string iExpression, int iPrec=2, std::string iTitle="", std::string iUnit="")
std::string name() const
edm::TypeWithDict m_type
Definition: DDAxes.h:10

Member Function Documentation

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 alignCSCRings::e, m_entries, m_titleWidth, m_type, siStripFEDMonitor_P5_cff::Max, fireworks::expression::oldToNewFormat(), triggerExpression::parse(), edm::TypeWithDict::size(), AlCaHLTBitMon_QueryRunRegistry::string, and groupFilesInBlocks::temp.

Referenced by FWItemValueGetter().

87 {
88  using namespace boost::spirit::classic;
89 
91  reco::parser::Grammar grammar(tmpPtr, m_type);
92 
93  if(m_type != edm::TypeWithDict() && iExpression.size())
94  {
95  using namespace fireworks::expression;
96 
97  //Backwards compatibility with old format
98  std::string temp = oldToNewFormat(iExpression);
99 
100  //now setup the parser
101  try
102  {
103  if(parse(temp.c_str(), grammar.use_parser<1>() >> end_p, space_p).full)
104  {
105  m_entries.push_back(Entry(tmpPtr, iExpression, iUnit, iTitle.empty() ? iExpression :iTitle , iPrec));
106  m_titleWidth = TMath::Max(m_titleWidth, (int) m_entries.back().m_title.size());
107  return true;
108  }
109  }
110  catch(const reco::parser::BaseException& e)
111  {
112  // std::cout <<"failed to parse "<<iExpression<<" because "<<reco::parser::baseExceptionWhat(e)<<std::endl;
113  }
114  }
115  return false;
116 }
boost::spirit::classic::parser_error< reco::parser::SyntaxErrors > BaseException
Definition: Exception.h:37
Evaluator * parse(const T &text)
Definition: Entry.h:18
boost::shared_ptr< ExpressionBase > ExpressionPtr
edm::TypeWithDict m_type
size_t size() const
std::string oldToNewFormat(const std::string &iExpression)
std::vector< std::string > FWItemValueGetter::getTitles ( ) const

Definition at line 136 of file FWItemValueGetter.cc.

References i, and m_entries.

Referenced by FWCollectionSummaryTableManager::getTitles().

137 {
138  std::vector<std::string> titles;
139  titles.reserve(m_entries.size());
140 
141  for (std::vector<Entry >::const_iterator i = m_entries.begin() ; i != m_entries.end(); ++i)
142  titles.push_back((*i).m_title.empty() ? (*i).m_expression : (*i).m_title );
143 
144  return titles;
145 }
int i
Definition: DBlmapReader.cc:9
const std::string & FWItemValueGetter::getToolTip ( const void *  iObject) const

Definition at line 155 of file FWItemValueGetter.cc.

References alignCSCRings::e, i, m_entries, FWItemValueGetter::Entry::m_expr, FWItemValueGetter::Entry::m_precision, FWItemValueGetter::Entry::m_title, m_titleWidth, m_type, python.connectstrParser::o, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by FWEventItem::modelInterestingValueAsString().

156 {
157  static std::string buff(128, 0);
158  static std::string fs = "\n %*s = %.*f";
159 
160  edm::ObjectWithDict o(m_type, const_cast<void *>(iObject));
161 
162  int off = 0;
163  for ( std::vector<Entry >::const_iterator i = m_entries.begin() ; i != m_entries.end(); ++i) {
164  const Entry& e = *i;
165  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));
166  }
167 
168  // std::cout << buff;
169  return buff;
170 }
int i
Definition: DBlmapReader.cc:9
Definition: Entry.h:18
ALIdouble value() const
Definition: Entry.h:55
edm::TypeWithDict m_type
int FWItemValueGetter::numValues ( ) const

Definition at line 148 of file FWItemValueGetter.cc.

References m_entries.

Referenced by FWCollectionSummaryTableManager::cellRenderer(), and FWCollectionSummaryTableManager::numberOfColumns().

149 {
150  return static_cast<int>(m_entries.size());
151 }
UInt_t FWItemValueGetter::precision ( int  idx) const

Definition at line 130 of file FWItemValueGetter.cc.

References customizeTrackingMonitorSeedNumber::idx, and m_entries.

Referenced by FWCollectionSummaryTableManager::cellRenderer().

131 {
132  return m_entries[idx].m_precision;
133 }
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
double FWItemValueGetter::valueFor ( const void *  iObject,
int  idx 
) const

Definition at line 122 of file FWItemValueGetter.cc.

References customizeTrackingMonitorSeedNumber::idx, m_entries, m_type, and python.connectstrParser::o.

Referenced by FWCollectionSummaryTableManager::cellRenderer(), and FWViewContextMenuHandlerGL::select().

123 {
124  // std::cout << " value for " << idx << "size " << m_entries.size() <<std::endl;
125  edm::ObjectWithDict o(m_type, const_cast<void *>(iObject));
126  return m_entries[idx].m_expr->value(o);
127 }
edm::TypeWithDict m_type
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...

Member Data Documentation

Entries_t::const_iterator FWItemValueGetter::Entries_i
private

Definition at line 61 of file FWItemValueGetter.h.

Entries_t FWItemValueGetter::m_entries
private

Definition at line 63 of file FWItemValueGetter.h.

Referenced by addEntry(), getTitles(), getToolTip(), numValues(), precision(), and valueFor().

int FWItemValueGetter::m_titleWidth
private

Definition at line 66 of file FWItemValueGetter.h.

Referenced by addEntry(), and getToolTip().

edm::TypeWithDict FWItemValueGetter::m_type
private

Definition at line 64 of file FWItemValueGetter.h.

Referenced by addEntry(), getToolTip(), and valueFor().