CMS 3D CMS Logo

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

List of all members.

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

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

:FWViewManagerBase()
{
   FWGUIManager::ViewBuildFunctor f;
   f=boost::bind(&FWTableViewManager::buildView,
                 this, _1, _2);
   iGUIMgr->registerViewBuilder(FWViewType::idToName(FWViewType::kTable), f);

   // ---------- for some object types, we have default table contents ----------
   table("reco::GenParticle").
   column("pT", 1, "pt").
   column("eta", 3).
   column("phi", 3).
   column("status", TableEntry::INT).
   column("pdgId", TableEntry::INT);

   table("reco::Muon").
   column("q", TableEntry::INT, "charge").
   column("pT", 1, "pt").
   column("global", TableEntry::BOOL, "isGlobalMuon").
   column("tracker", TableEntry::BOOL, "isTrackerMuon").
   column("SA", TableEntry::BOOL, "isStandAloneMuon").
   column("calo", TableEntry::BOOL, "isCaloMuon").
   column("tr pt", 1, "track().pt()").
   column("eta", 3).
   column("phi", 3).
   column("matches", TableEntry::INT, "numberOfMatches('SegmentArbitration')").
   column("d0", 3, "track().d0()").
   column("d0 / d0Err", 3, "track().d0() / track().d0Error()");

   table("reco::GsfElectron").
   column("q", TableEntry::INT, "charge").
   column("pT", 1, "pt").
   column("eta", 3).
   column("phi", 3).
   column("E/p", 3, "eSuperClusterOverP").
   column("H/E", 3, "hadronicOverEm").
   column("fbrem", 3, "(trackMomentumAtVtx().R() - trackMomentumOut().R()) / trackMomentumAtVtx().R()").
   column("dei", 3, "deltaEtaSuperClusterTrackAtVtx()").
   column("dpi", 3, "deltaPhiSuperClusterTrackAtVtx()");

   table("reco::Photon").
   column("pT", 1, "pt").
   column("eta", 3).
   column("phi", 3).
   column("H/E", 3, "hadronicOverEm");

   table("reco::CaloJet").
   column("pT", 1, "pt").
   column("eta", 3).
   column("phi", 3).
   column("ECAL", 1, "p4().E() * emEnergyFraction()").
   column("HCAL", 1, "p4().E() * energyFractionHadronic()").
   column("emf", 3, "emEnergyFraction()");

   table("reco::Jet").
   column("pT", 1, "pt").
   column("eta", 3).
   column("phi", 3);

   table("reco::MET").
   column("et", 1).
   column("phi", 3).
   column("sumEt", 1).
   column("mEtSig", 3);

   table("reco::Track").
   column("q", TableEntry::INT, "charge").
   column("pT", 1, "pt").
   column("eta", 3).
   column("phi", 3).
   column("d0", 5).
   column("d0Err", 5, "d0Error").
   column("dz", 5).
   column("dzErr", 5, "dzError").
   column("vx", 5).
   column("vy", 5).
   column("vz", 5).
   column("pixel hits", TableEntry::INT, "hitPattern().numberOfValidPixelHits()").
   column("strip hits", TableEntry::INT, "hitPattern().numberOfValidStripHits()").
   column("chi2", 3).
   column("ndof", TableEntry::INT);

   table("reco::Vertex").
   column("x", 5).
   column("xError", 5).
   column("y", 5).
   column("yError", 5).
   column("z", 5).
   column("zError", 5).
   column("tracks", TableEntry::INT, "tracksSize").
   column("chi2", 3).
   column("ndof", 3);

   table("CaloTower").
   column("emEt", 1).
   column("hadEt", 1).
   column("et", 1, "Et").
   column("eta", 3).
   column("phi", 3);
   
   table("CaloRecHit").
   column("id", TableEntry::INT,"detid.rawId").
   column("energy",3).
   column("time",3).
   column("flags",TableEntry::INT,"flags");
}
FWTableViewManager::~FWTableViewManager ( ) [virtual]

Definition at line 153 of file FWTableViewManager.cc.

{
}
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.

{
   // if there are views, it's the job of the first view to store
   // the configuration (this is to avoid ordering problems in the
   // case of multiple views)
   if (!m_views.empty())
      return;
   // if there are no views, then it's up to us to store the column
   // formats.  This is done in addToImpl, which can be called by
   // FWTableView as well
   addToImpl(iTo);
}
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().

{
   FWConfiguration typeNames(1);
   char prec[100];

   for (TableSpecs::const_iterator 
        iType = m_tableFormats.begin(),
        iType_end = m_tableFormats.end();
        iType != iType_end; ++iType) 
   {
      const std::string &typeName = iType->first;
      typeNames.addValue(typeName);
      FWConfiguration columns(1);
      const TableEntries &entries = iType->second;
      for (size_t ei = 0, ee = entries.size(); ei != ee; ++ei)
      {
         const TableEntry &entry = entries[ei];
         columns.addValue(entry.name);
         columns.addValue(entry.expression);
         columns.addValue((snprintf(prec, 100, "%d", entry.precision), prec));
      }
      iTo.addKeyValue(typeName, columns);
   }
   iTo.addKeyValue(kConfigTypeNames, typeNames);
}
void FWTableViewManager::beingDestroyed ( const FWViewBase iView) [private]

Definition at line 296 of file FWTableViewManager.cc.

References m_views.

Referenced by buildView().

{
   for(Views::iterator it = m_views.begin(), itEnd = m_views.end();
       it != itEnd;
       ++it) 
   {
      if(it->get() == iView) 
      {
         m_views.erase(it);
         return;
      }
   }
}
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().

{
   TEveManager::TRedrawDisabler disableRedraw(gEve);
   boost::shared_ptr<FWTableView> view(new FWTableView(iParent, this));
   view->setBackgroundColor(colorManager().background());
   m_views.push_back(view);
   view->beingDestroyed_.connect(boost::bind(&FWTableViewManager::beingDestroyed,
                                             this, _1));
   return view.get();
}
void FWTableViewManager::colorsChanged ( ) [protected, virtual]

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.

{
   for(size_t i = 0, e = m_views.size(); i != e; ++i)
      m_views[i].get()->resetColors(colorManager());
}
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().

{
   for(size_t i = 0, e = m_views.size(); i != e; ++i)
      m_views[i].get()->dataChanged();
}
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().

{
   // remove the item from the list
   // FIXME: why doesn't it use erase?? Boh...
   for (size_t i = 0, e = m_items.size(); i != e; ++i)
   {
      if (m_items[i] != iItem)
         continue;
      m_items[i] = 0;
   }

   notifyViews();
}
const Items& FWTableViewManager::items ( ) const [inline]
void FWTableViewManager::modelChangesComing ( ) [protected, virtual]

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

Implements FWViewManagerBase.

Definition at line 363 of file FWTableViewManager.cc.

{
   gEve->DisableRedraw();
}
void FWTableViewManager::modelChangesDone ( ) [protected, virtual]

Implements FWViewManagerBase.

Definition at line 369 of file FWTableViewManager.cc.

References dataChanged().

{
   gEve->EnableRedraw();
   // tell the views to update their item lists
   // FIXME: doesn't this need to call updateItems as well
   // and hence notifyViews would be more appropriate?? Boh...
   dataChanged();
}
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().

{
   m_items.push_back(iItem);
   iItem->goingToBeDestroyed_.connect(boost::bind(&FWTableViewManager::destroyItem,
                                                  this, _1));
   notifyViews();
}
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().

{
   for(size_t i = 0, e = m_views.size(); i != e; ++i)
   { 
      FWTableView *view = m_views[i].get();
      view->updateItems();
      view->dataChanged();
   } 
}
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().

{
   m_items.clear();
   notifyViews();
}
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().

{
   try
   {
      const FWConfiguration *typeNames = iFrom.valueForKey(kConfigTypeNames);
      if (typeNames == 0)
      {
         fwLog(fwlog::kWarning) << "no table column configuration stored, using defaults\n";
         return;
      }
            
      //NOTE: FWTableViewTableManagers hold pointers into m_tableFormats so if we
      // clear it those pointers would be invalid
      // instead we will just clear the lists and fill them with their new values
      //m_tableFormats.clear();
      for (FWConfiguration::StringValuesIt 
           iType = typeNames->stringValues()->begin(),
           iTypeEnd = typeNames->stringValues()->end(); 
           iType != iTypeEnd; ++iType) 
      {
         //std::cout << "reading type " << *iType << std::endl;
         const FWConfiguration *columns = iFrom.valueForKey(*iType);
         assert(columns != 0);
         TableHandle handle = table(iType->c_str());
         for (FWConfiguration::StringValuesIt 
              it = columns->stringValues()->begin(),
              itEnd = columns->stringValues()->end(); 
              it != itEnd; ++it) 
         {
            const std::string &name = *it++;
            const std::string &expr = *it++;
            int prec = atoi(it->c_str());
            handle.column(name.c_str(), prec, expr.c_str());
         }
      }
   } 
   catch (...) 
   {
      // No info about types in the configuration; this is not an
      // error, it merely means that the types are handled by the
      // first FWTableView.
   }
}
FWTypeToRepresentations FWTableViewManager::supportedTypesAndRepresentations ( ) const [virtual]

Implements FWViewManagerBase.

Definition at line 394 of file FWTableViewManager.cc.

{
   FWTypeToRepresentations returnValue;
   return returnValue;
}
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().

{
   TableHandle handle(name, m_tableFormats);
   return handle;
}
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().

{
   std::string keyType = key.Name(Reflex::SCOPED);

   TableSpecs::iterator ret = m_tableFormats.find(keyType);

   if (ret != m_tableFormats.end())
      return ret;
   
   ret = tableFormatsImpl(key); // recursive search for base classes

   if (ret != m_tableFormats.end()) 
      return ret;

   TableHandle handle = table(keyType.c_str());
   for (Reflex::Member_Iterator mi = key.Member_Begin(),
                                      me = key.Member_End();
        mi != me; ++mi)
   {
      if (mi->FunctionParameterSize())
         continue;
      if (!mi->IsPublic())
         continue;
      if (!mi->IsConst())
         continue;
      if (mi->TypeOf().ReturnType().Name() == "int")
         handle.column(mi->Name().c_str(), TableEntry::INT);
      else if (mi->TypeOf().ReturnType().Name() == "bool")
         handle.column(mi->Name().c_str(), TableEntry::BOOL);
      else if (mi->TypeOf().ReturnType().Name() == "double")
         handle.column(mi->Name().c_str(), 5);
      else if (mi->TypeOf().ReturnType().Name() == "float")
         handle.column(mi->Name().c_str(), 3);
   }
   return m_tableFormats.find(keyType);
}
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().

{
   return tableFormats(Reflex::Type::ByName(key.GetName()));
}
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().

{
   TableSpecs::iterator ret = m_tableFormats.find(key.Name(Reflex::SCOPED));
   if (ret != m_tableFormats.end())
      return ret;

   // if there is no exact match for the type, try the base classes
   for (Reflex::Base_Iterator it = key.Base_Begin(); it != key.Base_End(); ++it) 
   {
      ret = tableFormatsImpl(it->ToType());
      if (ret != m_tableFormats.end()) 
         return ret;
   }

   return m_tableFormats.end();
}

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

Definition at line 95 of file FWTableViewManager.h.

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