CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Types | Public Member Functions | Static Public Attributes | Protected Types | Protected Member Functions | Protected Attributes | Private Member Functions | Friends
FWTableViewManager Class Reference

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

Inheritance diagram for FWTableViewManager:
FWViewManagerBase FWConfigurable

Classes

struct  TableEntry
 
class  TableHandle
 

Public Types

typedef std::vector< const
FWEventItem * > 
Items
 
typedef std::vector< TableEntryTableEntries
 
typedef std::map< std::string,
TableEntries
TableSpecs
 

Public Member Functions

void addTo (FWConfiguration &) const
 
void addToImpl (FWConfiguration &) const
 
FWViewBasebuildView (TEveWindowSlot *iParent, const std::string &type)
 
void destroyItem (const FWEventItem *item)
 
 FWTableViewManager (FWGUIManager *)
 
const Itemsitems () const
 
virtual void newItem (const FWEventItem *)
 
void notifyViews ()
 
void removeAllItems (void)
 
void setFrom (const FWConfiguration &)
 
virtual FWTypeToRepresentations supportedTypesAndRepresentations () const
 
TableSpecs::iterator tableFormats (const Reflex::Type &key)
 
TableSpecs::iterator tableFormats (const TClass &key)
 
virtual ~FWTableViewManager ()
 
- Public Member Functions inherited from FWViewManagerBase
void colorsChangedSlot ()
 
const fireworks::Contextcontext () const
 
virtual void eventBegin ()
 
virtual void eventEnd ()
 
void modelChangesComingSlot ()
 
void modelChangesDoneSlot ()
 
void setChangeManager (FWModelChangeManager *iCM)
 
void setColorManager (FWColorManager *iCM)
 
virtual void setContext (const fireworks::Context *x)
 
virtual ~FWViewManagerBase ()
 
- Public Member Functions inherited from FWConfigurable
 FWConfigurable ()
 
virtual ~FWConfigurable ()
 

Static Public Attributes

static const std::string kConfigColumns
 
static const std::string kConfigTypeNames = "typeNames"
 

Protected Types

typedef std::vector
< boost::shared_ptr
< FWTableView > > 
Views
 

Protected Member Functions

virtual void colorsChanged ()
 
void dataChanged ()
 
 FWTableViewManager ()
 
virtual void modelChangesComing ()
 
virtual void modelChangesDone ()
 
- Protected Member Functions inherited from FWViewManagerBase
FWModelChangeManagerchangeManager () const
 
FWColorManagercolorManager () const
 
void * createInstanceOf (const TClass *iBaseClass, const char *iNameOfClass)
 
 FWViewManagerBase ()
 

Protected Attributes

Items m_items
 
TableSpecs m_tableFormats
 
Views m_views
 

Private Member Functions

void beingDestroyed (const FWViewBase *)
 
 FWTableViewManager (const FWTableViewManager &)
 
const FWTableViewManageroperator= (const FWTableViewManager &)
 
TableHandle table (const char *collection)
 
TableSpecs::iterator tableFormatsImpl (const Reflex::Type &key)
 

Friends

class FWTableView
 
class FWTableViewTableManager
 

Detailed Description

Description: Base class for a Manger for a specific type of View

Usage: <usage>

Definition at line 39 of file FWTableViewManager.h.

Member Typedef Documentation

typedef std::vector<const FWEventItem *> FWTableViewManager::Items

Container for the event items which have a table.

Definition at line 52 of file FWTableViewManager.h.

Container for the description of the columns of a given table.

Definition at line 54 of file FWTableViewManager.h.

typedef std::map<std::string, TableEntries> FWTableViewManager::TableSpecs

Type for the collection specific (i.e. those that do not use default) table definition.

Definition at line 57 of file FWTableViewManager.h.

typedef std::vector<boost::shared_ptr<FWTableView> > FWTableViewManager::Views
protected

Definition at line 92 of file FWTableViewManager.h.

Constructor & Destructor Documentation

FWTableViewManager::FWTableViewManager ( FWGUIManager iGUIMgr)

Definition at line 45 of file FWTableViewManager.cc.

References FWTableViewManager::TableEntry::BOOL, buildView(), f, FWViewType::idToName(), FWTableViewManager::TableEntry::INT, FWViewType::kTable, FWGUIManager::registerViewBuilder(), and table().

47 {
49  f=boost::bind(&FWTableViewManager::buildView,
50  this, _1, _2);
52 
53  // ---------- for some object types, we have default table contents ----------
54  table("reco::GenParticle").
55  column("pT", 1, "pt").
56  column("eta", 3).
57  column("phi", 3).
58  column("status", TableEntry::INT).
59  column("pdgId", TableEntry::INT);
60 
61  table("reco::Muon").
62  column("q", TableEntry::INT, "charge").
63  column("pT", 1, "pt").
64  column("global", TableEntry::BOOL, "isGlobalMuon").
65  column("tracker", TableEntry::BOOL, "isTrackerMuon").
66  column("SA", TableEntry::BOOL, "isStandAloneMuon").
67  column("calo", TableEntry::BOOL, "isCaloMuon").
68  column("tr pt", 1, "track().pt()").
69  column("eta", 3).
70  column("phi", 3).
71  column("matches", TableEntry::INT, "numberOfMatches('SegmentArbitration')").
72  column("d0", 3, "track().d0()").
73  column("d0 / d0Err", 3, "track().d0() / track().d0Error()");
74 
75  table("reco::GsfElectron").
76  column("q", TableEntry::INT, "charge").
77  column("pT", 1, "pt").
78  column("eta", 3).
79  column("phi", 3).
80  column("E/p", 3, "eSuperClusterOverP").
81  column("H/E", 3, "hadronicOverEm").
82  column("fbrem", 3, "(trackMomentumAtVtx().R() - trackMomentumOut().R()) / trackMomentumAtVtx().R()").
83  column("dei", 3, "deltaEtaSuperClusterTrackAtVtx()").
84  column("dpi", 3, "deltaPhiSuperClusterTrackAtVtx()");
85 
86  table("reco::Photon").
87  column("pT", 1, "pt").
88  column("eta", 3).
89  column("phi", 3).
90  column("H/E", 3, "hadronicOverEm");
91 
92  table("reco::CaloJet").
93  column("pT", 1, "pt").
94  column("eta", 3).
95  column("phi", 3).
96  column("ECAL", 1, "p4().E() * emEnergyFraction()").
97  column("HCAL", 1, "p4().E() * energyFractionHadronic()").
98  column("emf", 3, "emEnergyFraction()");
99 
100  table("reco::Jet").
101  column("pT", 1, "pt").
102  column("eta", 3).
103  column("phi", 3);
104 
105  table("reco::MET").
106  column("et", 1).
107  column("phi", 3).
108  column("sumEt", 1).
109  column("mEtSig", 3);
110 
111  table("reco::Track").
112  column("q", TableEntry::INT, "charge").
113  column("pT", 1, "pt").
114  column("eta", 3).
115  column("phi", 3).
116  column("d0", 5).
117  column("d0Err", 5, "d0Error").
118  column("dz", 5).
119  column("dzErr", 5, "dzError").
120  column("vx", 5).
121  column("vy", 5).
122  column("vz", 5).
123  column("pixel hits", TableEntry::INT, "hitPattern().numberOfValidPixelHits()").
124  column("strip hits", TableEntry::INT, "hitPattern().numberOfValidStripHits()").
125  column("chi2", 3).
126  column("ndof", TableEntry::INT);
127 
128  table("reco::Vertex").
129  column("x", 5).
130  column("xError", 5).
131  column("y", 5).
132  column("yError", 5).
133  column("z", 5).
134  column("zError", 5).
135  column("tracks", TableEntry::INT, "tracksSize").
136  column("chi2", 3).
137  column("ndof", 3);
138 
139  table("CaloTower").
140  column("emEt", 1).
141  column("hadEt", 1).
142  column("et", 1, "Et").
143  column("eta", 3).
144  column("phi", 3);
145 
146  table("CaloRecHit").
147  column("id", TableEntry::INT,"detid.rawId").
148  column("energy",3).
149  column("time",3).
150  column("flags",TableEntry::INT,"flags");
151 }
TableHandle table(const char *collection)
boost::function2< FWViewBase *, TEveWindowSlot *, const std::string & > ViewBuildFunctor
Definition: FWGUIManager.h:100
void registerViewBuilder(const std::string &iName, ViewBuildFunctor &iBuilder)
double f[11][100]
static const std::string & idToName(int)
Definition: FWViewType.cc:90
FWViewBase * buildView(TEveWindowSlot *iParent, const std::string &type)
FWTableViewManager::~FWTableViewManager ( )
virtual

Definition at line 153 of file FWTableViewManager.cc.

154 {
155 }
FWTableViewManager::FWTableViewManager ( )
protected
FWTableViewManager::FWTableViewManager ( const FWTableViewManager )
private

Member Function Documentation

void FWTableViewManager::addTo ( FWConfiguration iTo) const
virtual

Implements FWConfigurable.

Definition at line 403 of file FWTableViewManager.cc.

References addToImpl(), and m_views.

404 {
405  // if there are views, it's the job of the first view to store
406  // the configuration (this is to avoid ordering problems in the
407  // case of multiple views)
408  if (!m_views.empty())
409  return;
410  // if there are no views, then it's up to us to store the column
411  // formats. This is done in addToImpl, which can be called by
412  // FWTableView as well
413  addToImpl(iTo);
414 }
void addToImpl(FWConfiguration &) const
void FWTableViewManager::addToImpl ( FWConfiguration iTo) const

Definition at line 417 of file FWTableViewManager.cc.

References FWConfiguration::addKeyValue(), FWConfiguration::addValue(), python.tagInventory::entries, FWTableViewManager::TableEntry::expression, kConfigTypeNames, m_tableFormats, FWTableViewManager::TableEntry::name, FWTableViewManager::TableEntry::precision, and FWViewBase::typeName().

Referenced by FWTableView::addTo(), and addTo().

418 {
419  FWConfiguration typeNames(1);
420  char prec[100];
421 
422  for (TableSpecs::const_iterator
423  iType = m_tableFormats.begin(),
424  iType_end = m_tableFormats.end();
425  iType != iType_end; ++iType)
426  {
427  const std::string &typeName = iType->first;
428  typeNames.addValue(typeName);
429  FWConfiguration columns(1);
430  const TableEntries &entries = iType->second;
431  for (size_t ei = 0, ee = entries.size(); ei != ee; ++ei)
432  {
433  const TableEntry &entry = entries[ei];
434  columns.addValue(entry.name);
435  columns.addValue(entry.expression);
436  columns.addValue((snprintf(prec, 100, "%d", entry.precision), prec));
437  }
438  iTo.addKeyValue(typeName, columns);
439  }
440  iTo.addKeyValue(kConfigTypeNames, typeNames);
441 }
std::pair< std::string, MonitorElement * > entry
Definition: ME_MAP.h:8
std::vector< TableEntry > TableEntries
FWConfiguration & addKeyValue(const std::string &, const FWConfiguration &)
static const std::string kConfigTypeNames
void FWTableViewManager::beingDestroyed ( const FWViewBase iView)
private

Definition at line 296 of file FWTableViewManager.cc.

References m_views.

Referenced by buildView().

297 {
298  for(Views::iterator it = m_views.begin(), itEnd = m_views.end();
299  it != itEnd;
300  ++it)
301  {
302  if(it->get() == iView)
303  {
304  m_views.erase(it);
305  return;
306  }
307  }
308 }
class FWViewBase * FWTableViewManager::buildView ( TEveWindowSlot *  iParent,
const std::string &  type 
)

Definition at line 284 of file FWTableViewManager.cc.

References beingDestroyed(), FWViewManagerBase::colorManager(), FWTableView, and m_views.

Referenced by FWTableViewManager().

285 {
286  TEveManager::TRedrawDisabler disableRedraw(gEve);
287  boost::shared_ptr<FWTableView> view(new FWTableView(iParent, this));
288  view->setBackgroundColor(colorManager().background());
289  m_views.push_back(view);
290  view->beingDestroyed_.connect(boost::bind(&FWTableViewManager::beingDestroyed,
291  this, _1));
292  return view.get();
293 }
FWColorManager & colorManager() const
friend class FWTableView
void beingDestroyed(const FWViewBase *)
void FWTableViewManager::colorsChanged ( )
protectedvirtual

Notify all the views that colors have changed

Implements FWViewManagerBase.

Definition at line 380 of file FWTableViewManager.cc.

References FWViewManagerBase::colorManager(), alignCSCRings::e, i, and m_views.

381 {
382  for(size_t i = 0, e = m_views.size(); i != e; ++i)
383  m_views[i].get()->resetColors(colorManager());
384 }
int i
Definition: DBlmapReader.cc:9
FWColorManager & colorManager() const
void FWTableViewManager::dataChanged ( )
protected

Definition at line 387 of file FWTableViewManager.cc.

References alignCSCRings::e, i, and m_views.

Referenced by FWTableView::addColumn(), FWTableView::deleteColumn(), modelChangesDone(), and FWTableView::modifyColumn().

388 {
389  for(size_t i = 0, e = m_views.size(); i != e; ++i)
390  m_views[i].get()->dataChanged();
391 }
int i
Definition: DBlmapReader.cc:9
void FWTableViewManager::destroyItem ( const FWEventItem iItem)

Remove iItem from the list

iItem the item to be removed.

Definition at line 337 of file FWTableViewManager.cc.

References alignCSCRings::e, i, m_items, and notifyViews().

Referenced by newItem().

338 {
339  // remove the item from the list
340  // FIXME: why doesn't it use erase?? Boh...
341  for (size_t i = 0, e = m_items.size(); i != e; ++i)
342  {
343  if (m_items[i] != iItem)
344  continue;
345  m_items[i] = 0;
346  }
347 
348  notifyViews();
349 }
int i
Definition: DBlmapReader.cc:9
const Items& FWTableViewManager::items ( ) const
inline
void FWTableViewManager::modelChangesComing ( )
protectedvirtual

Called when models have changed and so the display must be updated.

Implements FWViewManagerBase.

Definition at line 363 of file FWTableViewManager.cc.

364 {
365  gEve->DisableRedraw();
366 }
void FWTableViewManager::modelChangesDone ( )
protectedvirtual

Implements FWViewManagerBase.

Definition at line 369 of file FWTableViewManager.cc.

References dataChanged().

370 {
371  gEve->EnableRedraw();
372  // tell the views to update their item lists
373  // FIXME: doesn't this need to call updateItems as well
374  // and hence notifyViews would be more appropriate?? Boh...
375  dataChanged();
376 }
void FWTableViewManager::newItem ( const FWEventItem iItem)
virtual

Implements FWViewManagerBase.

Definition at line 311 of file FWTableViewManager.cc.

References destroyItem(), FWEventItem::goingToBeDestroyed_, m_items, and notifyViews().

312 {
313  m_items.push_back(iItem);
314  iItem->goingToBeDestroyed_.connect(boost::bind(&FWTableViewManager::destroyItem,
315  this, _1));
316  notifyViews();
317 }
FWItemChangeSignal goingToBeDestroyed_
Definition: FWEventItem.h:215
void destroyItem(const FWEventItem *item)
void FWTableViewManager::notifyViews ( void  )

Tell the views to update their item list.

Definition at line 321 of file FWTableViewManager.cc.

References FWTableView::dataChanged(), alignCSCRings::e, i, m_views, and FWTableView::updateItems().

Referenced by destroyItem(), newItem(), and removeAllItems().

322 {
323  for(size_t i = 0, e = m_views.size(); i != e; ++i)
324  {
325  FWTableView *view = m_views[i].get();
326  view->updateItems();
327  view->dataChanged();
328  }
329 }
int i
Definition: DBlmapReader.cc:9
void updateItems()
Definition: FWTableView.cc:546
void dataChanged()
Definition: FWTableView.cc:585
const FWTableViewManager& FWTableViewManager::operator= ( const FWTableViewManager )
private
void FWTableViewManager::removeAllItems ( void  )

Remove all items present in the view.

This should watch the FWEventItemsManager::goingToClearItems_ signal.

Definition at line 356 of file FWTableViewManager.cc.

References m_items, and notifyViews().

Referenced by CmsShowMainBase::setupViewManagers().

357 {
358  m_items.clear();
359  notifyViews();
360 }
void FWTableViewManager::setFrom ( const FWConfiguration iFrom)
virtual

Implements FWConfigurable.

Definition at line 444 of file FWTableViewManager.cc.

References FWTableViewManager::TableHandle::column(), fwLog, patZpeak::handle, kConfigTypeNames, fwlog::kWarning, mergeVDriftHistosByStation::name, FWConfiguration::stringValues(), table(), and FWConfiguration::valueForKey().

Referenced by FWTableView::setFrom().

445 {
446  try
447  {
448  const FWConfiguration *typeNames = iFrom.valueForKey(kConfigTypeNames);
449  if (typeNames == 0)
450  {
451  fwLog(fwlog::kWarning) << "no table column configuration stored, using defaults\n";
452  return;
453  }
454 
455  //NOTE: FWTableViewTableManagers hold pointers into m_tableFormats so if we
456  // clear it those pointers would be invalid
457  // instead we will just clear the lists and fill them with their new values
458  //m_tableFormats.clear();
460  iType = typeNames->stringValues()->begin(),
461  iTypeEnd = typeNames->stringValues()->end();
462  iType != iTypeEnd; ++iType)
463  {
464  //std::cout << "reading type " << *iType << std::endl;
465  const FWConfiguration *columns = iFrom.valueForKey(*iType);
466  assert(columns != 0);
467  TableHandle handle = table(iType->c_str());
469  it = columns->stringValues()->begin(),
470  itEnd = columns->stringValues()->end();
471  it != itEnd; ++it)
472  {
473  const std::string &name = *it++;
474  const std::string &expr = *it++;
475  int prec = atoi(it->c_str());
476  handle.column(name.c_str(), prec, expr.c_str());
477  }
478  }
479  }
480  catch (...)
481  {
482  // No info about types in the configuration; this is not an
483  // error, it merely means that the types are handled by the
484  // first FWTableView.
485  }
486 }
const StringValues * stringValues() const
TableHandle table(const char *collection)
tuple handle
Definition: patZpeak.py:22
#define fwLog(_level_)
Definition: fwLog.h:51
const FWConfiguration * valueForKey(const std::string &iKey) const
StringValues::const_iterator StringValuesIt
static const std::string kConfigTypeNames
FWTypeToRepresentations FWTableViewManager::supportedTypesAndRepresentations ( ) const
virtual

Implements FWViewManagerBase.

Definition at line 394 of file FWTableViewManager.cc.

395 {
396  FWTypeToRepresentations returnValue;
397  return returnValue;
398 }
FWTableViewManager::TableHandle FWTableViewManager::table ( const char *  name)
private

Define a new table for type name

name the typename of the object contained in the table.

Returns
the TableHandle for this table, which can be used to create columns via the ::columns() method. All subsequent calls for method column will be relative to this table.

If a table with the same name is already there, its entries are reset.

Definition at line 174 of file FWTableViewManager.cc.

References patZpeak::handle, and m_tableFormats.

Referenced by FWTableViewManager(), setFrom(), and tableFormats().

175 {
176  TableHandle handle(name, m_tableFormats);
177  return handle;
178 }
tuple handle
Definition: patZpeak.py:22
FWTableViewManager::TableSpecs::iterator FWTableViewManager::tableFormats ( const Reflex::Type &  key)

Find the entries for a given type key, possibly recursively searching recursively in the class hierarchy for a base class that matches.

  • If the recursion succeeds return the specific table.
  • Otherwise, create a dummy table with most common properties.

key the Reflex::Type of the collection for which we want to have the key definition.

FIXME: how about actually inspecting the type and show all the int and floats if no description is found??

Definition at line 235 of file FWTableViewManager.cc.

References FWTableViewManager::TableEntry::BOOL, FWTableViewManager::TableHandle::column(), patZpeak::handle, FWTableViewManager::TableEntry::INT, m_tableFormats, run_regression::ret, table(), and tableFormatsImpl().

Referenced by FWTableView::selectCollection(), and tableFormats().

236 {
237  std::string keyType = key.Name(Reflex::SCOPED);
238 
239  TableSpecs::iterator ret = m_tableFormats.find(keyType);
240 
241  if (ret != m_tableFormats.end())
242  return ret;
243 
244  ret = tableFormatsImpl(key); // recursive search for base classes
245 
246  if (ret != m_tableFormats.end())
247  return ret;
248 
249  TableHandle handle = table(keyType.c_str());
250  for (Reflex::Member_Iterator mi = key.Member_Begin(),
251  me = key.Member_End();
252  mi != me; ++mi)
253  {
254  if (mi->FunctionParameterSize())
255  continue;
256  if (!mi->IsPublic())
257  continue;
258  if (!mi->IsConst())
259  continue;
260  if (mi->TypeOf().ReturnType().Name() == "int")
261  handle.column(mi->Name().c_str(), TableEntry::INT);
262  else if (mi->TypeOf().ReturnType().Name() == "bool")
263  handle.column(mi->Name().c_str(), TableEntry::BOOL);
264  else if (mi->TypeOf().ReturnType().Name() == "double")
265  handle.column(mi->Name().c_str(), 5);
266  else if (mi->TypeOf().ReturnType().Name() == "float")
267  handle.column(mi->Name().c_str(), 3);
268  }
269  return m_tableFormats.find(keyType);
270 }
TableHandle table(const char *collection)
TableHandle & column(const char *formula, int precision, const char *name)
tuple handle
Definition: patZpeak.py:22
TableSpecs::iterator tableFormatsImpl(const Reflex::Type &key)
list key
Definition: combine.py:13
FWTableViewManager::TableSpecs::iterator FWTableViewManager::tableFormats ( const TClass &  key)

Helper function which uses TClass rather than Reflex::Type.

Otherwise identical to FWTableViewManager::tableFormats(const TClass &key).

Definition at line 278 of file FWTableViewManager.cc.

References tableFormats().

279 {
280  return tableFormats(Reflex::Type::ByName(key.GetName()));
281 }
list key
Definition: combine.py:13
TableSpecs::iterator tableFormats(const Reflex::Type &key)
FWTableViewManager::TableSpecs::iterator FWTableViewManager::tableFormatsImpl ( const Reflex::Type &  key)
private

Helper function to do recursive lookup of specialized table description for a given type key.

Definition at line 204 of file FWTableViewManager.cc.

References m_tableFormats, and run_regression::ret.

Referenced by tableFormats().

205 {
206  TableSpecs::iterator ret = m_tableFormats.find(key.Name(Reflex::SCOPED));
207  if (ret != m_tableFormats.end())
208  return ret;
209 
210  // if there is no exact match for the type, try the base classes
211  for (Reflex::Base_Iterator it = key.Base_Begin(); it != key.Base_End(); ++it)
212  {
213  ret = tableFormatsImpl(it->ToType());
214  if (ret != m_tableFormats.end())
215  return ret;
216  }
217 
218  return m_tableFormats.end();
219 }
TableSpecs::iterator tableFormatsImpl(const Reflex::Type &key)
list key
Definition: combine.py:13

Friends And Related Function Documentation

friend class FWTableView
friend

Definition at line 41 of file FWTableViewManager.h.

Referenced by buildView().

friend class FWTableViewTableManager
friend

Definition at line 42 of file FWTableViewManager.h.

Member Data Documentation

const std::string FWTableViewManager::kConfigColumns
static

Definition at line 81 of file FWTableViewManager.h.

const std::string FWTableViewManager::kConfigTypeNames = "typeNames"
static

Definition at line 80 of file FWTableViewManager.h.

Referenced by addToImpl(), and setFrom().

Items FWTableViewManager::m_items
protected

Definition at line 95 of file FWTableViewManager.h.

Referenced by destroyItem(), items(), newItem(), and removeAllItems().

TableSpecs FWTableViewManager::m_tableFormats
protected
Views FWTableViewManager::m_views
protected