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 33 of file FWItemValueGetter.h.

Member Typedef Documentation

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

Definition at line 59 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 if ( iPurpose == "DT-segments")
79  {
80  addEntry("chamberId().wheel()", 0, "wh");
81  addEntry("chamberId().station()", 0, "st");
82  addEntry("chamberId().sector()", 0, "sc");
83 
84  }
85  else if ( iPurpose == "CSC-segments")
86  {
87  addEntry("cscDetId().endcap()", 0, "ec");
88  addEntry("cscDetId().station()", 0, "st");
89  addEntry("cscDetId().ring()", 0, "rn");
90  }
91  else {
92  // by the default add pt, et, or energy
93  bool x = addEntry("pt", 1);
94  if (!x) x = addEntry("et", 1);
95  if (!x) addEntry("energy", 1);
96  }
97 
98  if (addEntry("eta", 2))
99  addEntry("phi", 2);
100 }
bool addEntry(std::string iExpression, int iPrec=2, std::string iTitle="", std::string iUnit="")
std::string name() const
edm::TypeWithDict m_type

Member Function Documentation

bool FWItemValueGetter::addEntry ( std::string  iExpression,
int  iPrec = 2,
std::string  iTitle = "",
std::string  iUnit = "" 
)
private

Definition at line 104 of file FWItemValueGetter.cc.

References alignCSCRings::e, m_entries, m_titleWidth, m_type, Max(), fireworks::expression::oldToNewFormat(), triggerExpression::parse(), edm::TypeWithDict::size(), AlCaHLTBitMon_QueryRunRegistry::string, and groupFilesInBlocks::temp.

Referenced by FWItemValueGetter().

105 {
106  using namespace boost::spirit::classic;
107 
109  reco::parser::Grammar grammar(tmpPtr, m_type);
110 
111  if(m_type != edm::TypeWithDict() && iExpression.size())
112  {
113  using namespace fireworks::expression;
114 
115  //Backwards compatibility with old format
116  std::string temp = oldToNewFormat(iExpression);
117 
118  //now setup the parser
119  try
120  {
121  if(parse(temp.c_str(), grammar.use_parser<1>() >> end_p, space_p).full)
122  {
123  m_entries.push_back(Entry(tmpPtr, iExpression, iUnit, iTitle.empty() ? iExpression :iTitle , iPrec));
124  m_titleWidth = TMath::Max(m_titleWidth, (int) m_entries.back().m_title.size());
125  return true;
126  }
127  }
128  catch(const reco::parser::BaseException& e)
129  {
130  // std::cout <<"failed to parse "<<iExpression<<" because "<<reco::parser::baseExceptionWhat(e)<<std::endl;
131  }
132  }
133  return false;
134 }
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
T Max(T a, T b)
Definition: MathUtil.h:44
size_t size() const
std::string oldToNewFormat(const std::string &iExpression)
std::vector< std::string > FWItemValueGetter::getTitles ( ) const

Definition at line 154 of file FWItemValueGetter.cc.

References i, and m_entries.

Referenced by FWCollectionSummaryTableManager::getTitles().

155 {
156  std::vector<std::string> titles;
157  titles.reserve(m_entries.size());
158 
159  for (std::vector<Entry >::const_iterator i = m_entries.begin() ; i != m_entries.end(); ++i)
160  titles.push_back((*i).m_title.empty() ? (*i).m_expression : (*i).m_title );
161 
162  return titles;
163 }
int i
Definition: DBlmapReader.cc:9
const std::string & FWItemValueGetter::getToolTip ( const void *  iObject) const

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

174 {
175  static std::string buff(128, 0);
176  static std::string fs = "\n %*s = %.*f";
177 
178  edm::ObjectWithDict o(m_type, const_cast<void *>(iObject));
179 
180  int off = 0;
181  for ( std::vector<Entry >::const_iterator i = m_entries.begin() ; i != m_entries.end(); ++i) {
182  const Entry& e = *i;
183  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));
184  }
185 
186  // std::cout << buff;
187  return buff;
188 }
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 166 of file FWItemValueGetter.cc.

References m_entries.

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

167 {
168  return static_cast<int>(m_entries.size());
169 }
UInt_t FWItemValueGetter::precision ( int  idx) const

Definition at line 148 of file FWItemValueGetter.cc.

References customizeTrackingMonitorSeedNumber::idx, and m_entries.

Referenced by FWCollectionSummaryTableManager::cellRenderer().

149 {
150  return m_entries[idx].m_precision;
151 }
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 140 of file FWItemValueGetter.cc.

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

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

141 {
142  // std::cout << " value for " << idx << "size " << m_entries.size() <<std::endl;
143  edm::ObjectWithDict o(m_type, const_cast<void *>(iObject));
144  return m_entries[idx].m_expr->value(o);
145 }
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 60 of file FWItemValueGetter.h.

Entries_t FWItemValueGetter::m_entries
private

Definition at line 62 of file FWItemValueGetter.h.

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

int FWItemValueGetter::m_titleWidth
private

Definition at line 65 of file FWItemValueGetter.h.

Referenced by addEntry(), and getToolTip().

edm::TypeWithDict FWItemValueGetter::m_type
private

Definition at line 63 of file FWItemValueGetter.h.

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