CMS 3D CMS Logo

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

Member Typedef Documentation

◆ Entries_t

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

Definition at line 56 of file FWItemValueGetter.h.

Constructor & Destructor Documentation

◆ FWItemValueGetter()

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

Definition at line 34 of file FWItemValueGetter.cc.

35  : m_type(iType), m_titleWidth(0) {
36  if (!strcmp(iType.name().c_str(), "CaloTower")) {
37  if (iPurpose == "ECal")
38  addEntry("emEt", 1, "et", "GeV");
39  else if (iPurpose == "HCal")
40  addEntry("hadEt", 1, "et", "GeV");
41  else if (iPurpose == "HCal Outer")
42  addEntry("outerEt", 1, "et", "GeV");
43  } else if (strstr(iPurpose.c_str(), "Beam Spot")) {
44  addEntry("x0", 2, "x", "cm");
45  addEntry("y0", 2, "y", "cm");
46  addEntry("z0", 2, "z", "cm");
47  } else if (strstr(iPurpose.c_str(), "Vertices")) {
48  addEntry("x", 2, "x", "cm");
49  addEntry("y", 2, "y", "cm");
50  addEntry("z", 2, "z", "cm");
51  } else if (strstr(iPurpose.c_str(), "Conversion")) {
52  addEntry("pairMomentum().rho()", 1, "pt", "GeV");
53  addEntry("pairMomentum().eta()", 2, "eta");
54  addEntry("pairMomentum().phi()", 2, "phi");
55  } else if (strstr(iPurpose.c_str(), "Candidate") || strstr(iPurpose.c_str(), "GenParticle")) {
56  addEntry("pdgId()", 0, "pdg");
57  bool x = addEntry("pt", 1);
58  if (!x)
59  x = addEntry("et", 1);
60  if (!x)
61  addEntry("energy", 1);
62  } else if (iPurpose == "Jets") {
63  addEntry("et", 1);
64  } else if (iPurpose == "DT-segments") {
65  addEntry("chamberId().wheel()", 0, "wh");
66  addEntry("chamberId().station()", 0, "st");
67  addEntry("chamberId().sector()", 0, "sc");
68 
69  } else if (iPurpose == "CSC-segments") {
70  addEntry("cscDetId().endcap()", 0, "ec");
71  addEntry("cscDetId().station()", 0, "st");
72  addEntry("cscDetId().ring()", 0, "rn");
73  } else if (iPurpose == "HGCal Trigger Cell" || iPurpose == "HGCal Trigger Cluster") {
74  addEntry("detId", 0);
75  } else if (iPurpose == "CaloParticle") {
76  addEntry("energy", 3);
77  addEntry("pdgId()", 3, "pdgId");
78  addEntry("simClusters().size()", 3, "SimClSize");
79  } else if (iPurpose == "HGCal MultiCluster") {
80  addEntry("energy", 3);
81  } else {
82  // by the default add pt, et, or energy
83  bool x = addEntry("pt", 1);
84  if (!x)
85  x = addEntry("et", 1);
86  if (!x)
87  addEntry("energy", 1);
88  }
89 
90  if (addEntry("eta", 2))
91  addEntry("phi", 2);
92 }

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

Member Function Documentation

◆ addEntry()

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

Definition at line 94 of file FWItemValueGetter.cc.

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

References MillePedeFileConverter_cfg::e, m_entries, m_titleWidth, m_type, Max(), fireworks::expression::oldToNewFormat(), dumpparser::parse(), AlCaHLTBitMon_QueryRunRegistry::string, and groupFilesInBlocks::temp.

Referenced by FWItemValueGetter().

◆ getTitles()

std::vector< std::string > FWItemValueGetter::getTitles ( ) const

Definition at line 130 of file FWItemValueGetter.cc.

130  {
131  std::vector<std::string> titles;
132  titles.reserve(m_entries.size());
133 
134  for (std::vector<Entry>::const_iterator i = m_entries.begin(); i != m_entries.end(); ++i)
135  titles.push_back((*i).m_title.empty() ? (*i).m_expression : (*i).m_title);
136 
137  return titles;
138 }

References mps_fire::i, and m_entries.

Referenced by FWCollectionSummaryTableManager::getTitles().

◆ getToolTip()

const std::string & FWItemValueGetter::getToolTip ( const void *  iObject) const

Definition at line 143 of file FWItemValueGetter.cc.

143  {
144  static std::string buff(128, 0);
145  static std::string fs = "\n %*s = %.*f";
146 
147  edm::ObjectWithDict o(m_type, const_cast<void*>(iObject));
148 
149  int off = 0;
150  for (std::vector<Entry>::const_iterator i = m_entries.begin(); i != m_entries.end(); ++i) {
151  const Entry& e = *i;
152  off += snprintf(&buff[off],
153  127,
154  fs.c_str(),
155  m_titleWidth,
156  e.m_title.c_str(),
157  e.m_precision ? (e.m_precision + 1) : 0,
158  e.m_expr->value(o));
159  }
160 
161  // std::cout << buff;
162  return buff;
163 }

References MillePedeFileConverter_cfg::e, mps_fire::i, m_entries, m_titleWidth, m_type, EcalTangentSkim_cfg::o, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by FWEventItem::modelInterestingValueAsString().

◆ numValues()

int FWItemValueGetter::numValues ( ) const

Definition at line 140 of file FWItemValueGetter.cc.

140 { return static_cast<int>(m_entries.size()); }

References m_entries.

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

◆ precision()

UInt_t FWItemValueGetter::precision ( int  idx) const

Definition at line 128 of file FWItemValueGetter.cc.

128 { return m_entries[idx].m_precision; }

References training_settings::idx, and m_entries.

Referenced by FWCollectionSummaryTableManager::cellRenderer().

◆ valueFor()

double FWItemValueGetter::valueFor ( const void *  iObject,
int  idx 
) const

Definition at line 122 of file FWItemValueGetter.cc.

122  {
123  // std::cout << " value for " << idx << "size " << m_entries.size() <<std::endl;
124  edm::ObjectWithDict o(m_type, const_cast<void*>(iObject));
125  return m_entries[idx].m_expr->value(o);
126 }

References training_settings::idx, m_entries, m_type, and EcalTangentSkim_cfg::o.

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

Member Data Documentation

◆ Entries_i

Entries_t::const_iterator FWItemValueGetter::Entries_i
private

Definition at line 57 of file FWItemValueGetter.h.

◆ m_entries

Entries_t FWItemValueGetter::m_entries
private

Definition at line 59 of file FWItemValueGetter.h.

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

◆ m_titleWidth

int FWItemValueGetter::m_titleWidth
private

Definition at line 62 of file FWItemValueGetter.h.

Referenced by addEntry(), and getToolTip().

◆ m_type

edm::TypeWithDict FWItemValueGetter::m_type
private

Definition at line 60 of file FWItemValueGetter.h.

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

mps_fire.i
i
Definition: mps_fire.py:355
fireworks::expression::oldToNewFormat
std::string oldToNewFormat(const std::string &iExpression)
Definition: expressionFormatHelpers.cc:25
boost::spirit::classic
Definition: DDPartSelection.cc:10
edm::ObjectWithDict
Definition: ObjectWithDict.h:17
FWItemValueGetter::addEntry
bool addEntry(std::string iExpression, int iPrec=2, std::string iTitle="", std::string iUnit="")
Definition: FWItemValueGetter.cc:94
DDAxes::x
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
training_settings.idx
idx
Definition: training_settings.py:16
EcalTangentSkim_cfg.o
o
Definition: EcalTangentSkim_cfg.py:36
FWItemValueGetter::m_titleWidth
int m_titleWidth
Definition: FWItemValueGetter.h:62
FWItemValueGetter::m_entries
Entries_t m_entries
Definition: FWItemValueGetter.h:59
fireworks::expression
Definition: expressionFormatHelpers.cc:24
FWItemValueGetter::m_type
edm::TypeWithDict m_type
Definition: FWItemValueGetter.h:60
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
dumpparser.parse
def parse(path, config)
Definition: dumpparser.py:13
edm::TypeWithDict
Definition: TypeWithDict.h:38
reco::parser::BaseException
boost::spirit::classic::parser_error< reco::parser::SyntaxErrors > BaseException
Definition: Exception.h:33
Max
T Max(T a, T b)
Definition: MathUtil.h:44
reco::parser::ExpressionPtr
std::shared_ptr< ExpressionBase > ExpressionPtr
Definition: ExpressionBase.h:25
reco::parser::Grammar
Definition: Grammar.h:45
edm::TypeWithDict::name
std::string name() const
Definition: TypeWithDict.cc:456
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37