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 36 of file FWItemValueGetter.cc.

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

36  :
37  m_type(iType),
38  m_titleWidth(0)
39 {
40  if (!strcmp(iType.name().c_str(), "CaloTower"))
41  {
42  if ( iPurpose == "ECal" )
43  addEntry("emEt", 1, "et", "GeV");
44  else if ( iPurpose == "HCal" )
45  addEntry("hadEt", 1, "et", "GeV");
46  else if (iPurpose == "HCal Outer")
47  addEntry("outerEt", 1, "et", "GeV");
48  }
49  else if (strstr(iPurpose.c_str(), "Beam Spot") )
50  {
51  addEntry("x0", 2, "x", "cm");
52  addEntry("y0", 2, "y", "cm");
53  addEntry("z0", 2, "z", "cm");
54  }
55  else if (strstr(iPurpose.c_str(), "Vertices") )
56  {
57  addEntry("x", 2, "x", "cm");
58  addEntry("y", 2, "y", "cm");
59  addEntry("z", 2, "z", "cm");
60  }
61  else if (strstr(iPurpose.c_str(), "Conversion") )
62  {
63  addEntry("pairMomentum().rho()", 1, "pt", "GeV" );
64  addEntry("pairMomentum().eta()", 2, "eta");
65  addEntry("pairMomentum().phi()", 2, "phi");
66  }
67  else if (strstr(iPurpose.c_str(), "Candidate") || strstr(iPurpose.c_str(), "GenParticle"))
68  {
69  addEntry("pdgId()", 0, "pdg");
70  bool x = addEntry("pt", 1);
71  if (!x) x = addEntry("et", 1);
72  if (!x) addEntry("energy", 1);
73  }
74  else if (iPurpose == "Jets" )
75  {
76  addEntry("et", 1);
77  }
78  else {
79  // by the default add pt, et, or energy
80  bool x = addEntry("pt", 1);
81  if (!x) x = addEntry("et", 1);
82  if (!x) addEntry("energy", 1);
83  }
84 
85  if (addEntry("eta", 2))
86  addEntry("phi", 2);
87 }
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 91 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().

92 {
93  using namespace boost::spirit::classic;
94 
96  reco::parser::Grammar grammar(tmpPtr, m_type);
97 
98  if(m_type != edm::TypeWithDict() && iExpression.size())
99  {
100  using namespace fireworks::expression;
101 
102  //Backwards compatibility with old format
103  std::string temp = oldToNewFormat(iExpression);
104 
105  //now setup the parser
106  try
107  {
108  if(parse(temp.c_str(), grammar.use_parser<1>() >> end_p, space_p).full)
109  {
110  m_entries.push_back(Entry(tmpPtr, iExpression, iUnit, iTitle.empty() ? iExpression :iTitle , iPrec));
111  m_titleWidth = TMath::Max(m_titleWidth, (int) m_entries.back().m_title.size());
112  return true;
113  }
114  }
115  catch(const reco::parser::BaseException& e)
116  {
117  // std::cout <<"failed to parse "<<iExpression<<" because "<<reco::parser::baseExceptionWhat(e)<<std::endl;
118  }
119  }
120  return false;
121 }
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 141 of file FWItemValueGetter.cc.

References i, and m_entries.

Referenced by FWCollectionSummaryTableManager::getTitles().

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

Definition at line 160 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().

161 {
162  static std::string buff(128, 0);
163  static std::string fs = "\n %*s = %.*f";
164 
165  edm::ObjectWithDict o(m_type, const_cast<void *>(iObject));
166 
167  int off = 0;
168  for ( std::vector<Entry >::const_iterator i = m_entries.begin() ; i != m_entries.end(); ++i) {
169  const Entry& e = *i;
170  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));
171  }
172 
173  // std::cout << buff;
174  return buff;
175 }
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 153 of file FWItemValueGetter.cc.

References m_entries.

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

154 {
155  return static_cast<int>(m_entries.size());
156 }
UInt_t FWItemValueGetter::precision ( int  idx) const

Definition at line 135 of file FWItemValueGetter.cc.

References customizeTrackingMonitorSeedNumber::idx, and m_entries.

Referenced by FWCollectionSummaryTableManager::cellRenderer().

136 {
137  return m_entries[idx].m_precision;
138 }
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 127 of file FWItemValueGetter.cc.

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

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

128 {
129  // std::cout << " value for " << idx << "size " << m_entries.size() <<std::endl;
130  edm::ObjectWithDict o(m_type, const_cast<void *>(iObject));
131  return m_entries[idx].m_expr->value(o);
132 }
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().