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.

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

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  } else if (iPurpose == "CSC-segments") {
69  addEntry("cscDetId().endcap()", 0, "ec");
70  addEntry("cscDetId().station()", 0, "st");
71  addEntry("cscDetId().ring()", 0, "rn");
72  } else if (iPurpose == "BTLclusters" || iPurpose == "BTLrechits") {
73  addEntry("energy()", 2, "E", "MeV");
74  addEntry("time()", 2, "T", "ns");
75  } else if (iPurpose == "ETLclusters" || iPurpose == "ETLrechits") {
76  addEntry("energy()", 3, "E", "MeV");
77  addEntry("time()", 2, "T", "ns");
78  } else if (iPurpose == "HGCal Trigger Cell" || iPurpose == "HGCal Trigger Cluster") {
79  addEntry("detId", 0);
80  } else if (iPurpose == "CaloParticle") {
81  addEntry("energy", 3);
82  addEntry("pdgId()", 3, "pdgId");
83  addEntry("simClusters().size()", 3, "SimClSize");
84  } else if (iPurpose == "Trackster" || iPurpose == "Trackster hits" || iPurpose == "Trackster layers") {
85  addEntry("raw_energy", 3, "E", "GeV");
86  addEntry("barycenter().Eta()", 3, "eta");
87  addEntry("barycenter().Phi()", 3, "phi");
88  } else if (iPurpose == "HGCal MultiCluster") {
89  addEntry("energy", 3);
90  } else {
91  // by the default add pt, et, or energy
92  bool x = addEntry("pt", 1);
93  if (!x)
94  x = addEntry("et", 1);
95  if (!x)
96  addEntry("energy", 1);
97  }
98 
99  if (addEntry("eta", 2))
100  addEntry("phi", 2);
101 }
bool addEntry(std::string iExpression, int iPrec=2, std::string iTitle="", std::string iUnit="")
edm::TypeWithDict m_type
std::string name() const

Member Function Documentation

◆ addEntry()

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

Definition at line 103 of file FWItemValueGetter.cc.

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

Referenced by FWItemValueGetter().

103  {
104  using namespace boost::spirit::classic;
105 
107  reco::parser::Grammar grammar(tmpPtr, m_type);
108 
109  if (m_type != edm::TypeWithDict() && !iExpression.empty()) {
110  using namespace fireworks::expression;
111 
112  //Backwards compatibility with old format
113  std::string temp = oldToNewFormat(iExpression);
114 
115  //now setup the parser
116  try {
117  if (parse(temp.c_str(), grammar.use_parser<1>() >> end_p, space_p).full) {
118  m_entries.push_back(Entry(tmpPtr, iExpression, iUnit, iTitle.empty() ? iExpression : iTitle, iPrec));
119  m_titleWidth = TMath::Max(m_titleWidth, (int)m_entries.back().m_title.size());
120  return true;
121  }
122  } catch (const reco::parser::BaseException& e) {
123  // std::cout <<"failed to parse "<<iExpression<<" because "<<reco::parser::baseExceptionWhat(e)<<std::endl;
124  }
125  }
126  return false;
127 }
vector< string > parse(string line, const string &delimiter)
boost::spirit::classic::parser_error< reco::parser::SyntaxErrors > BaseException
Definition: Exception.h:33
std::shared_ptr< ExpressionBase > ExpressionPtr
edm::TypeWithDict m_type
std::string oldToNewFormat(const std::string &iExpression)

◆ getTitles()

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

Definition at line 139 of file FWItemValueGetter.cc.

References mps_fire::i, m_entries, and SiStripCondTypes::titles.

Referenced by FWCollectionSummaryTableManager::getTitles().

139  {
140  std::vector<std::string> titles;
141  titles.reserve(m_entries.size());
142 
143  for (std::vector<Entry>::const_iterator i = m_entries.begin(); i != m_entries.end(); ++i)
144  titles.push_back((*i).m_title.empty() ? (*i).m_expression : (*i).m_title);
145 
146  return titles;
147 }
static const std::array< std::string, 5 > titles

◆ getToolTip()

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

Definition at line 152 of file FWItemValueGetter.cc.

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

Referenced by FWEventItem::modelInterestingValueAsString().

152  {
153  static std::string buff(128, 0);
154  static std::string fs = "\n %*s = %.*f";
155 
156  edm::ObjectWithDict o(m_type, const_cast<void*>(iObject));
157 
158  int off = 0;
159  for (std::vector<Entry>::const_iterator i = m_entries.begin(); i != m_entries.end(); ++i) {
160  const Entry& e = *i;
161  off += snprintf(&buff[off],
162  127,
163  fs.c_str(),
164  m_titleWidth,
165  e.m_title.c_str(),
166  e.m_precision ? (e.m_precision + 1) : 0,
167  e.m_expr->value(o));
168  }
169 
170  // std::cout << buff;
171  return buff;
172 }
edm::TypeWithDict m_type

◆ numValues()

int FWItemValueGetter::numValues ( ) const

Definition at line 149 of file FWItemValueGetter.cc.

References m_entries.

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

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

◆ precision()

UInt_t FWItemValueGetter::precision ( int  idx) const

◆ valueFor()

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

Definition at line 131 of file FWItemValueGetter.cc.

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

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

131  {
132  // std::cout << " value for " << idx << "size " << m_entries.size() <<std::endl;
133  edm::ObjectWithDict o(m_type, const_cast<void*>(iObject));
134  return m_entries[idx].m_expr->value(o);
135 }
edm::TypeWithDict m_type

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().