CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes
FWEveViewManager Class Reference

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

Inheritance diagram for FWEveViewManager:
FWViewManagerBase

Classes

struct  BuilderInfo
 

Public Member Functions

void eventBegin () override
 
void eventEnd () override
 
 FWEveViewManager (FWGUIManager *)
 
void highlightAdded (TEveElement *)
 
void newItem (const FWEventItem *) override
 
virtual void removeItem (const FWEventItem *)
 
void selectionAdded (TEveElement *)
 
void selectionCleared ()
 
void selectionRemoved (TEveElement *)
 
void setContext (const fireworks::Context *) override
 
FWTypeToRepresentations supportedTypesAndRepresentations () const override
 
 ~FWEveViewManager () override
 
- Public Member Functions inherited from FWViewManagerBase
void colorsChangedSlot ()
 
const fireworks::Contextcontext () const
 
void modelChangesComingSlot ()
 
void modelChangesDoneSlot ()
 
void setChangeManager (FWModelChangeManager *iCM)
 
void setColorManager (FWColorManager *iCM)
 
virtual ~FWViewManagerBase ()
 

Static Public Member Functions

static void syncAllViews ()
 

Protected Member Functions

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

Private Types

typedef std::vector< std::shared_ptr< FWProxyBuilderBase > > BuilderVec
 
typedef BuilderVec::iterator BuilderVec_it
 
typedef std::vector< std::shared_ptr< FWEveView > >::iterator EveViewVec_it
 
typedef std::map< std::string, std::vector< BuilderInfo > > TypeToBuilder
 

Private Member Functions

void beingDestroyed (const FWViewBase *)
 
FWViewBasebuildView (TEveWindowSlot *iParent, const std::string &type)
 
void eventCenterChanged ()
 
FWEveViewfinishViewCreate (std::shared_ptr< FWEveView >)
 
 FWEveViewManager (const FWEveViewManager &)=delete
 
void globalEnergyScaleChanged ()
 
bool haveViewForBit (int) const
 
void itemChanged (const FWEventItem *)
 
void modelChanges (const FWModelIds &iIds)
 
const FWEveViewManageroperator= (const FWEveViewManager &)=delete
 

Private Attributes

std::map< int, BuilderVecm_builders
 
std::map< const FWEventItem *, FWInteractionList * > m_interactionLists
 
TypeToBuilder m_typeToBuilder
 
std::vector< std::vector< std::shared_ptr< FWEveView > > > m_views
 

Static Private Attributes

static bool s_syncAllViews = false
 

Detailed Description

Description: [one line class summary]

Usage: <usage>

Definition at line 44 of file FWEveViewManager.h.

Member Typedef Documentation

typedef std::vector<std::shared_ptr<FWProxyBuilderBase> > FWEveViewManager::BuilderVec
private

Definition at line 104 of file FWEveViewManager.h.

typedef BuilderVec::iterator FWEveViewManager::BuilderVec_it
private

Definition at line 105 of file FWEveViewManager.h.

typedef std::vector<std::shared_ptr<FWEveView > >::iterator FWEveViewManager::EveViewVec_it
private

Definition at line 106 of file FWEveViewManager.h.

typedef std::map<std::string, std::vector<BuilderInfo> > FWEveViewManager::TypeToBuilder
private

Definition at line 103 of file FWEveViewManager.h.

Constructor & Destructor Documentation

FWEveViewManager::FWEveViewManager ( FWGUIManager iGUIMgr)

Definition at line 85 of file FWEveViewManager.cc.

References PFRecoTauChargedHadronProducer_cff::builders, buildView(), taus_updatedMVAIds_cff::category, edmplugin::PluginManager::categoryToInfos(), f, plotBeamSpotDB::first, reco::get(), edmplugin::PluginManager::get(), mps_fire::i, FWViewType::idToName(), FWViewType::kTable, FWViewType::kTableHLT, FWViewType::kTableL1, FWViewType::kTypeSize, m_typeToBuilder, m_views, edmplugin::PluginInfo::name_, hgcalPlots::purpose, FWGUIManager::registerViewBuilder(), AlCaHLTBitMon_QueryRunRegistry::string, and create_public_lumi_plots::transform.

Referenced by FWEveViewManager::BuilderInfo::BuilderInfo(), and syncAllViews().

85  :
87 {
88 
89  // builders
90  std::set<std::string> builders;
91 
92  std::vector<edmplugin::PluginInfo> available = FWProxyBuilderFactory::get()->available();
93  std::transform(available.begin(),
94  available.end(),
95  std::inserter(builders,builders.begin()),
96  boost::bind(&edmplugin::PluginInfo::name_,_1));
97 
100  std::transform(available.begin(),
101  available.end(),
102  std::inserter(builders,builders.begin()),
103  boost::bind(&edmplugin::PluginInfo::name_,_1));
104  }
105 
106 
107  for(std::set<std::string>::iterator it = builders.begin(), itEnd=builders.end();
108  it!=itEnd;
109  ++it) {
110  std::string::size_type first = it->find_first_of('@')+1;
111  std::string purpose = it->substr(first,it->find_last_of('@')-first);
112 
113  first = it->find_last_of('@')+1;
114  std::string view_str = it->substr(first,it->find_last_of('#')-first);
115  int viewTypes = atoi(view_str.c_str());
116  std::string fullName = *it;
117  m_typeToBuilder[purpose].push_back(BuilderInfo(*it, viewTypes));
118  }
119 
121 
122  // view construction called via GUI mng
123  FWGUIManager::ViewBuildFunctor f = boost::bind(&FWEveViewManager::buildView, this, _1, _2);
124  for (int i = 0; i < FWViewType::kTypeSize; i++)
125  {
127  continue;
129  }
130 
131  // signal
132  gEve->GetHighlight()->SetPickToSelect(TEveSelection::kPS_Master);
133  TEveSelection* eveSelection = gEve->GetSelection();
134  eveSelection->SetPickToSelect(TEveSelection::kPS_Master);
135  eveSelection->Connect("SelectionAdded(TEveElement*)","FWEveViewManager",this,"selectionAdded(TEveElement*)");
136  eveSelection->Connect("SelectionRepeated(TEveElement*)","FWEveViewManager",this,"selectionAdded(TEveElement*)");
137  eveSelection->Connect("SelectionRemoved(TEveElement*)","FWEveViewManager",this,"selectionRemoved(TEveElement*)");
138  eveSelection->Connect("SelectionCleared()","FWEveViewManager",this,"selectionCleared()");
139 
140  gEve->GetHighlight()->Connect("SelectionAdded(TEveElement*)","FWEveViewManager",this,"highlightAdded(TEveElement*)");
141  gEve->GetHighlight()->Connect("SelectionRepeated(TEveElement*)","FWEveViewManager",this,"highlightAdded(TEveElement*)");
142 
143  TGeoManager::SetVerboseLevel(0);
144 }
const CategoryToInfos & categoryToInfos() const
Definition: PluginManager.h:83
TypeToBuilder m_typeToBuilder
uint16_t size_type
boost::function2< FWViewBase *, TEveWindowSlot *, const std::string & > ViewBuildFunctor
Definition: FWGUIManager.h:98
void registerViewBuilder(const std::string &iName, ViewBuildFunctor &iBuilder)
std::vector< std::vector< std::shared_ptr< FWEveView > > > m_views
double f[11][100]
FWViewBase * buildView(TEveWindowSlot *iParent, const std::string &type)
static const std::string & idToName(int)
Definition: FWViewType.cc:89
std::string name_
Definition: PluginInfo.h:29
static PluginManager * get()
T get(const Candidate &c)
Definition: component.h:55
FWEveViewManager::~FWEveViewManager ( )
override

Definition at line 146 of file FWEveViewManager.cc.

Referenced by FWEveViewManager::BuilderInfo::BuilderInfo().

147 {
148 }
FWEveViewManager::FWEveViewManager ( const FWEveViewManager )
privatedelete

Member Function Documentation

void FWEveViewManager::beingDestroyed ( const FWViewBase vb)
private

Definition at line 429 of file FWEveViewManager.cc.

References begin, haveViewForBit(), mps_fire::i, m_builders, m_views, FWViewBase::typeId(), and FWEveView::viewContext().

Referenced by finishViewCreate(), and syncAllViews().

430 {
431  FWEveView* view = (FWEveView*) vb;
432  int typeId = view->typeId();
433 
434  int viewerBit = 1 << typeId;
435  int nviews = m_views[typeId].size();
436  for ( std::map<int, BuilderVec>::iterator i = m_builders.begin(); i!= m_builders.end(); ++i)
437  {
438  int builderBit = i->first;
439  if (viewerBit == (builderBit & viewerBit)) // check only in case if connected
440  {
441  BuilderVec& bv = i->second;
442 
443  // remove view-owned product
444  if (viewerBit == (builderBit & viewerBit))
445  {
446  for(BuilderVec_it bIt = bv.begin(); bIt != bv.end(); ++bIt)
447  (*bIt)->removePerViewProduct(view->typeId(), view->viewContext());
448  }
449 
450  // and setup proxy builders have-a-window flag
451  if (nviews == 1)
452  {
453  if (!haveViewForBit(builderBit))
454  {
455  if (viewerBit == (builderBit & viewerBit))
456  {
457  for(BuilderVec_it bIt = bv.begin(); bIt != bv.end(); ++bIt)
458  (*bIt)->setHaveWindow(false);
459  }
460  }
461  }
462  }
463  }
464 
465 
466  for(EveViewVec_it i= m_views[typeId].begin(); i != m_views[typeId].end(); ++i) {
467  if(i->get() == vb) {
468  m_views[typeId].erase(i);
469  break;
470  }
471  }
472 }
bool haveViewForBit(int) const
std::vector< std::vector< std::shared_ptr< FWEveView > > > m_views
std::map< int, BuilderVec > m_builders
std::vector< std::shared_ptr< FWEveView > >::iterator EveViewVec_it
FWViewContext * viewContext()
Definition: FWEveView.h:86
BuilderVec::iterator BuilderVec_it
#define begin
Definition: vmac.h:32
std::vector< std::shared_ptr< FWProxyBuilderBase > > BuilderVec
FWViewType::EType typeId() const
Definition: FWViewBase.h:43
FWViewBase * FWEveViewManager::buildView ( TEveWindowSlot *  iParent,
const std::string &  type 
)
private

Definition at line 301 of file FWEveViewManager.cc.

References finishViewCreate(), mps_fire::i, FWViewType::idToName(), FWViewType::k3D, FWViewType::kGlimpse, FWViewType::kISpy, FWViewType::kLego, FWViewType::kLegoHF, FWViewType::kLegoPFECAL, FWViewType::kRhoPhi, FWViewType::kRhoPhiPF, FWViewType::kRhoZ, FWViewType::kTypeSize, and m_views.

Referenced by FWEveViewManager(), and syncAllViews().

302 {
304  for (int i = 0; i < FWViewType::kTypeSize; ++i)
305  {
306  if (viewName == FWViewType::idToName(i))
307  {
308  type = FWViewType::EType(i);
309  break;
310  }
311  }
312 
313  std::shared_ptr<FWEveView> view;
314  switch(type)
315  {
316  case FWViewType::k3D:
317  view.reset(new FW3DView(iParent, type));
318  break;
319  case FWViewType::kISpy:
320  view.reset(new FWISpyView(iParent, type));
321  break;
322  case FWViewType::kRhoPhi:
323  case FWViewType::kRhoZ:
325  view.reset(new FWRPZView(iParent, type));
326  break;
327  case FWViewType::kLego:
329  view.reset(new FWEveLegoView(iParent, type));
330  break;
331  case FWViewType::kLegoHF:
332  view.reset(new FWHFView(iParent, type));
333  break;
335  view.reset(new FWGlimpseView(iParent, type));
336  break;
337  default:
338  break;
339  }
340 
341  m_views[type].push_back(std::shared_ptr<FWEveView> (view));
342  return finishViewCreate(m_views[type].back());
343 }
type
Definition: HCALResponse.h:21
FWEveView * finishViewCreate(std::shared_ptr< FWEveView >)
std::vector< std::vector< std::shared_ptr< FWEveView > > > m_views
static const std::string & idToName(int)
Definition: FWViewType.cc:89
void FWEveViewManager::colorsChanged ( )
overrideprotectedvirtual

Implements FWViewManagerBase.

Definition at line 636 of file FWEveViewManager.cc.

References begin, FWViewManagerBase::colorManager(), mps_fire::i, FWViewType::kTypeSize, m_views, and protons_cff::t.

Referenced by syncAllViews().

637 {
638  for (int t = 0 ; t < FWViewType::kTypeSize; ++t)
639  {
640  for(EveViewVec_it i = m_views[t].begin(); i != m_views[t].end(); ++i)
641  (*i)->setBackgroundColor(colorManager().background());
642  }
643 }
FWColorManager & colorManager() const
std::vector< std::vector< std::shared_ptr< FWEveView > > > m_views
std::vector< std::shared_ptr< FWEveView > >::iterator EveViewVec_it
#define begin
Definition: vmac.h:32
void FWEveViewManager::eventBegin ( )
overridevirtual

Reimplemented from FWViewManagerBase.

Definition at line 647 of file FWEveViewManager.cc.

References begin, FWViewManagerBase::context(), mps_fire::i, FWViewType::kTypeSize, m_views, fireworks::Context::resetMaxEtAndEnergy(), and protons_cff::t.

Referenced by FWEveViewManager::BuilderInfo::BuilderInfo().

648 {
649  // Prevent registration of redraw timer, full redraw is done in
650  // FWEveViewManager::eventEnd().
651  gEve->EnforceTimerActive(kTRUE);
652  gEve->DisableRedraw();
653 
655 
656  for (int t = 0 ; t < FWViewType::kTypeSize; ++t)
657  {
658  for(EveViewVec_it i = m_views[t].begin(); i != m_views[t].end(); ++i)
659  (*i)->eventBegin();
660  }
661 }
const fireworks::Context & context() const
void resetMaxEtAndEnergy() const
Definition: Context.cc:190
std::vector< std::vector< std::shared_ptr< FWEveView > > > m_views
std::vector< std::shared_ptr< FWEveView > >::iterator EveViewVec_it
#define begin
Definition: vmac.h:32
void FWEveViewManager::eventCenterChanged ( )
private

Definition at line 623 of file FWEveViewManager.cc.

References begin, mps_fire::i, FWViewType::kTypeSize, m_views, and protons_cff::t.

Referenced by setContext(), and syncAllViews().

624 {
625  for (int t = 0 ; t < FWViewType::kTypeSize; ++t)
626  {
627  for(EveViewVec_it i = m_views[t].begin(); i != m_views[t].end(); ++i)
628  {
629  (*i)->setupEventCenter();
630  }
631  }
632 
633 }
std::vector< std::vector< std::shared_ptr< FWEveView > > > m_views
std::vector< std::shared_ptr< FWEveView > >::iterator EveViewVec_it
#define begin
Definition: vmac.h:32
void FWEveViewManager::eventEnd ( )
overridevirtual

Reimplemented from FWViewManagerBase.

Definition at line 664 of file FWEveViewManager.cc.

References begin, mps_fire::i, crabWrapper::key, FWViewType::kTypeSize, m_views, s_syncAllViews, protons_cff::t, and relativeConstraints::value.

Referenced by FWEveViewManager::BuilderInfo::BuilderInfo().

665 {
666  for (int t = 0 ; t < FWViewType::kTypeSize; ++t)
667  {
668  for(EveViewVec_it i = m_views[t].begin(); i != m_views[t].end(); ++i)
669  (*i)->eventEnd();
670  }
671 
672  // What follows is a copy of TEveManager::DoRedraw3D() with the difference that
673  // we have full control over execution of GL view rendering. In particular:
674  // - optionally delay buffer swapping so they can all be swapped together;
675  // - we could render into FBO once and then use this to be put on screen
676  // and saved into an image file.
677 
678  {
679  TEveElement::List_t scenes;
680  Long64_t key, value;
681  TExMapIter stamped_elements(gEve->PtrToStampedElements());
682  while (stamped_elements.Next(key, value))
683  {
684  TEveElement *el = reinterpret_cast<TEveElement*>(key);
685  if (el->GetChangeBits() & TEveElement::kCBVisibility)
686  {
687  el->CollectSceneParents(scenes);
688  }
689  }
690  gEve->ScenesChanged(scenes);
691  }
692 
693  // Process changes in scenes.
694  gEve->GetScenes()->ProcessSceneChanges(kFALSE, gEve->PtrToStampedElements());
695 
696  // To synchronize buffer swapping set swap_on_render to false.
697  // Note that this costs 25-40% extra time with 4 views, depending on V-sync settings.
698  // Tested with NVIDIA 343.22.
699  const bool swap_on_render = !s_syncAllViews;
700 
701  // Loop over viewers, swap buffers if swap_on_render is true.
702  for (int t = 0 ; t < FWViewType::kTypeSize; ++t)
703  {
704  for(EveViewVec_it i = m_views[t].begin(); i != m_views[t].end(); ++i)
705  (*i)->fwViewerGL()->DrawHiLod(swap_on_render);
706  }
707 
708  // Swap buffers if they were not swapped before.
709  if ( ! swap_on_render)
710  {
711  for (int t = 0 ; t < FWViewType::kTypeSize; ++t)
712  {
713  for(EveViewVec_it i = m_views[t].begin(); i != m_views[t].end(); ++i)
714  (*i)->fwViewerGL()->JustSwap();
715  }
716  }
717 
718  gEve->GetViewers()->RepaintChangedViewers(kFALSE, kFALSE);
719 
720  {
721  Long64_t key, value;
722  TExMapIter stamped_elements(gEve->PtrToStampedElements());
723  while (stamped_elements.Next(key, value))
724  {
725  TEveElement *el = reinterpret_cast<TEveElement*>(key);
726  if (gEve->GetEditor()->GetModel() == el->GetEditorObject("FWEveViewManager::eventEnd"))
727  gEve->EditElement(el);
728  TEveGedEditor::ElementChanged(el);
729 
730  el->ClearStamps();
731  }
732  }
733  gEve->PtrToStampedElements()->Delete();
734 
735  gEve->GetListTree()->ClearViewPort(); // Fix this when several list-trees can be added.
736 
737  gEve->EnableRedraw();
738  gEve->EnforceTimerActive(kFALSE);
739 }
static bool s_syncAllViews
std::list< Particle > List_t
Definition: Particle.h:141
std::vector< std::vector< std::shared_ptr< FWEveView > > > m_views
std::vector< std::shared_ptr< FWEveView > >::iterator EveViewVec_it
#define begin
Definition: vmac.h:32
FWEveView * FWEveViewManager::finishViewCreate ( std::shared_ptr< FWEveView view)
private

Definition at line 346 of file FWEveViewManager.cc.

References FWColorManager::background(), beingDestroyed(), fireworks::Context::colorManager(), FWViewManagerBase::context(), FWEveView::eventScene(), mps_fire::i, FWRPZView::importElements(), m_builders, m_views, FWEveView::ownedProducts(), FWColorManager::setColorSetViewer(), and FWEveView::setContext().

Referenced by buildView(), and syncAllViews().

347 {
348  // printf("new view %s added \n", view->typeName().c_str());
349  gEve->DisableRedraw();
350 
351  // set geometry and calo data
352  view->setContext(context());
353 
355 
356  // set proxies have a window falg
357  int viewerBit = 1 << view->typeId();
358  if (m_views[view->typeId()].size() == 1)
359  {
360  for ( std::map<int, BuilderVec>::iterator i = m_builders.begin(); i!= m_builders.end(); ++i)
361  {
362  int builderViewBit = i->first;
363  BuilderVec& bv = i->second;
364  if (viewerBit == (builderViewBit & viewerBit))
365  {
366  for(BuilderVec_it bIt = bv.begin(); bIt != bv.end(); ++bIt)
367  {
368  (*bIt)->setHaveWindow(true);
369  }
370  }
371  }
372  }
373 
374  FWRPZView* rpzView = dynamic_cast<FWRPZView*>(view.get());
375  for ( std::map<int, BuilderVec>::iterator i = m_builders.begin(); i!= m_builders.end(); ++i)
376  {
377  int builderViewBit = i->first;
378  BuilderVec& bv = i->second;
379  if (viewerBit == (builderViewBit & viewerBit))
380  {
381  for(BuilderVec_it bIt = bv.begin(); bIt != bv.end(); ++bIt)
382  {
383  // it is ok to call create even for shared productsm since
384  // builder map key garanties that
385  TEveElementList* product = (*bIt)->createProduct(view->typeId(), view->viewContext());
386 
387  if ((*bIt)->havePerViewProduct((FWViewType::EType)view->typeId()))
388  {
389  // view owned
390  (*bIt)->build();
391  if (rpzView)
392  {
393  rpzView->importElements(product, (*bIt)->item()->layer(), rpzView->ownedProducts());
394  }
395  else
396  {
397  view->ownedProducts()->AddElement(product);
398  }
399  }
400  else
401  {
402  // shared
403  if (rpzView)
404  {
405  rpzView->importElements(product, (*bIt)->item()->layer(), rpzView->eventScene());
406  }
407  else
408  {
409  view->eventScene()->AddElement(product);
410  }
411 
412  }
413  }
414  }
415  }
416 
417  view->beingDestroyed_.connect(boost::bind(&FWEveViewManager::beingDestroyed,this,_1));
418 
419  view->setupEnergyScale(); // notify PB for energy scale
420 
421  gEve->EnableRedraw();
422  view->viewerGL()->UpdateScene();
423  gEve->Redraw3D();
424 
425  return view.get();
426 }
Color_t background() const
const fireworks::Context & context() const
TEveScene * eventScene()
Definition: FWEveView.h:82
FWColorManager * colorManager() const
Definition: Context.h:65
std::vector< std::vector< std::shared_ptr< FWEveView > > > m_views
void beingDestroyed(const FWViewBase *)
std::map< int, BuilderVec > m_builders
void importElements(TEveElement *iProjectableChild, float layer, TEveElement *iProjectedParent=nullptr)
Definition: FWRPZView.cc:316
BuilderVec::iterator BuilderVec_it
std::vector< std::shared_ptr< FWProxyBuilderBase > > BuilderVec
TEveElement * ownedProducts()
Definition: FWEveView.h:85
static Bool_t setColorSetViewer(TGLViewer *, Color_t)
void FWEveViewManager::globalEnergyScaleChanged ( )
private

Definition at line 607 of file FWEveViewManager.cc.

References begin, mps_fire::i, FWViewType::kTypeSize, m_views, and protons_cff::t.

Referenced by setContext(), and syncAllViews().

608 {
609  for (int t = 0 ; t < FWViewType::kTypeSize; ++t)
610  {
611  for(EveViewVec_it i = m_views[t].begin(); i != m_views[t].end(); ++i)
612  {
613  if ((*i)->isEnergyScaleGlobal())
614  {
615  (*i)->setupEnergyScale();
616  }
617  }
618 
619  }
620 }
std::vector< std::vector< std::shared_ptr< FWEveView > > > m_views
std::vector< std::shared_ptr< FWEveView > >::iterator EveViewVec_it
#define begin
Definition: vmac.h:32
bool FWEveViewManager::haveViewForBit ( int  bit) const
private

Checks whether any of the views

Definition at line 834 of file FWEveViewManager.cc.

References relativeConstraints::empty, FWViewType::kTypeSize, m_views, and protons_cff::t.

Referenced by beingDestroyed(), newItem(), and syncAllViews().

835 {
836  for (int t = 0; t < FWViewType::kTypeSize; ++t)
837  {
838  if ((bit & (1 << t)) && !m_views[t].empty())
839  return true;
840  }
841  // printf("have %d view for bit %d \n", haveView, bit);
842  return false;
843 }
std::vector< std::vector< std::shared_ptr< FWEveView > > > m_views
void FWEveViewManager::highlightAdded ( TEveElement *  iElement)

Definition at line 872 of file FWEveViewManager.cc.

References Abs(), FWViewManagerBase::context(), conversionPostprocessing_cfi::etaBin, fireworks::Context::getCaloData(), create_public_lumi_plots::hist, mps_fire::i, conversionPostprocessing_cfi::phiBin, and w.

Referenced by FWEveViewManager::BuilderInfo::BuilderInfo().

873 {
874 
875  bool blocked = gEve->GetHighlight()->BlockSignals(true);
876 
877 
878  if (iElement == context().getCaloData())
879  {
880  TEveCaloData::vCellId_t& hlist = context().getCaloData()->GetCellsHighlighted();
881  std::set<TEveCaloData::CellId_t> hset;
882 
883  int etaBin, phiBin, w, newPhiBin, tower;
884  TH2F* hist = context().getCaloData()->GetHist(0);
885  TAxis* etaAxis = hist->GetXaxis();
886  int nBinsX = etaAxis->GetNbins() + 2;
887 
888  for (TEveCaloData::vCellId_i i = hlist.begin(); i != hlist.end(); ++i)
889  {
890  hist->GetBinXYZ((*i).fTower, etaBin, phiBin, w);
891  if (TMath::Abs(etaAxis->GetBinCenter(etaBin)) > 4.71475)
892  {
893  newPhiBin = ((phiBin + 1) / 4) * 4 - 1;
894  if (newPhiBin <= 0) newPhiBin = 71;
895 
896  tower = etaBin + newPhiBin*nBinsX;
897  hset.insert(TEveCaloData::CellId_t( tower, (*i).fSlice, (*i).fFraction));
898  tower += nBinsX;
899  hset.insert(TEveCaloData::CellId_t(tower, (*i).fSlice, (*i).fFraction));
900  tower += nBinsX;
901 
902  if (newPhiBin == 71)
903  tower = etaBin + 1*nBinsX;
904 
905  hset.insert(TEveCaloData::CellId_t(tower, (*i).fSlice, (*i).fFraction));
906  tower += nBinsX;
907  hset.insert(TEveCaloData::CellId_t(tower, (*i).fSlice, (*i).fFraction));
908  }
909  else if (TMath::Abs(etaAxis->GetBinCenter(etaBin)) > 1.747650)
910  {
911  newPhiBin = ((phiBin + 1)/2)*2 - 1;
912  tower = etaBin + newPhiBin*nBinsX;
913  hset.insert(TEveCaloData::CellId_t( tower, (*i).fSlice, (*i).fFraction));
914  tower += nBinsX;
915  hset.insert(TEveCaloData::CellId_t(tower, (*i).fSlice, (*i).fFraction));
916  }
917  else
918  {
919  hset.insert(*i);
920  }
921  }
922 
923  // edit calo data list
924  hlist.clear();
925  for(std::set<TEveCaloData::CellId_t>::iterator it = hset.begin(); it != hset.end(); ++it)
926  {
927  hlist.push_back(*it);
928  }
929  context().getCaloData()->CellSelectionChanged();
930 
931  }
932 
933  gEve->GetHighlight()->BlockSignals(blocked);
934 }
const fireworks::Context & context() const
const double w
Definition: UKUtility.cc:23
T Abs(T a)
Definition: MathUtil.h:49
TEveCaloDataHist * getCaloData() const
Definition: Context.h:80
void FWEveViewManager::itemChanged ( const FWEventItem item)
private

Callback of itemChanged_ signal. Iterate over all the builders for all the views and call itemChanged for any of the builders. If any of the builder also has at least one view, also update the interaction list.

Definition at line 531 of file FWEveViewManager.cc.

References FWProxyBuilderBase::getHaveWindow(), mps_fire::i, FWProxyBuilderBase::item(), FWProxyBuilderBase::itemChanged(), m_builders, and m_interactionLists.

Referenced by newItem(), and syncAllViews().

532 {
533  if (!item)
534  return;
535 
536  bool itemHaveWindow = false;
537 
538  for (std::map<int, BuilderVec>::iterator i = m_builders.begin();
539  i != m_builders.end(); ++i)
540  {
541  for(size_t bi = 0, be = i->second.size(); bi != be; ++bi)
542  {
543  FWProxyBuilderBase *builder = i->second[bi].get();
544 
545  if (builder->item() != item)
546  continue;
547 
548  builder->itemChanged(item);
549  itemHaveWindow |= builder->getHaveWindow();
550  }
551  }
552 
553  if (!itemHaveWindow)
554  return;
555 
556  std::map<const FWEventItem*, FWInteractionList*>::iterator it = m_interactionLists.find(item);
557  if (it != m_interactionLists.end())
558  {
559  if (!it->second->empty())
560  it->second->itemChanged();
561  }
562 }
const FWEventItem * item() const
std::map< int, BuilderVec > m_builders
std::map< const FWEventItem *, FWInteractionList * > m_interactionLists
bool getHaveWindow() const
void itemChanged(const FWEventItem *)
void FWEveViewManager::modelChanges ( const FWModelIds iIds)
private

Callback of event item changed_ signal.

Definition at line 490 of file FWEveViewManager.cc.

References FWProxyBuilderBase::getHaveWindow(), mps_fire::i, FWProxyBuilderBase::item(), m_builders, m_interactionLists, and FWProxyBuilderBase::modelChanges().

Referenced by newItem(), and syncAllViews().

491 {
492  FWModelId id = *(iIds.begin());
493  const FWEventItem* item = id.item();
494 
495  // in standard case new elements can be build in case of change of visibility
496  // and in non-standard case (e.g. calo towers) PB's modelChages handles all changes
497  bool itemHaveWindow = false;
498  for (std::map<int, BuilderVec>::iterator i = m_builders.begin();
499  i != m_builders.end(); ++i)
500  {
501  for (size_t bi = 0, be = i->second.size(); bi != be; ++bi)
502  {
503  FWProxyBuilderBase *builder = i->second[bi].get();
504  if (builder->getHaveWindow() && builder->item() == item)
505  {
506  builder->modelChanges(iIds);
507  itemHaveWindow = true;
508  }
509  }
510  }
511 
512  if (!itemHaveWindow)
513  return;
514 
516 
517  std::map<const FWEventItem*, FWInteractionList*>::iterator it = m_interactionLists.find(item);
518  if (it != m_interactionLists.end())
519  {
520  if (!it->second->empty())
521  it->second->modelChanges(iIds);
522  }
523 }
const FWEventItem * item() const
std::map< int, BuilderVec > m_builders
std::map< const FWEventItem *, FWInteractionList * > m_interactionLists
bool getHaveWindow() const
void modelChanges(const FWModelIds &)
void FWEveViewManager::modelChangesComing ( )
overrideprotectedvirtual

called when models have changed and so the display must be updated

Implements FWViewManagerBase.

Definition at line 477 of file FWEveViewManager.cc.

Referenced by syncAllViews().

478 {
479  gEve->DisableRedraw();
480 }
void FWEveViewManager::modelChangesDone ( )
overrideprotectedvirtual

Implements FWViewManagerBase.

Definition at line 483 of file FWEveViewManager.cc.

Referenced by syncAllViews().

484 {
485  gEve->EnableRedraw();
486 }
void FWEveViewManager::newItem ( const FWEventItem iItem)
overridevirtual

This is invoked when a new item is created by the FWEventItemsManager. The workflow is the following

  1. First we check if we have a builder info for the given purpose of the item. We return simply if we don't.
  2. We iterate over all the proxy builder registered for the given purpose and create a new one for this given item.
  3. Interaction lists are set up in case the proxy builder does not handle interaction by itself.
  4. We then iterate on the various supported views and add elements to them, making sure that we handle the case in which those elements are not unique among all the views.

Implements FWViewManagerBase.

Definition at line 192 of file FWEveViewManager.cc.

References addElements(), FWEventItem::changed_, FWEveViewManager::BuilderInfo::classType(), SoftLeptonByDistance_cfi::distance, MillePedeFileConverter_cfg::e, cppFunctionSkipper::exception, fwLog, reco::get(), FWEventItem::goingToBeDestroyed_, haveViewForBit(), mps_fire::i, info(), FWSimpleRepresentationChecker::inheritsFrom(), itemChanged(), FWEventItem::itemChanged_, FWViewType::kTypeSize, fwlog::kWarning, m_builders, m_interactionLists, FWEveViewManager::BuilderInfo::m_name, m_typeToBuilder, FWEveViewManager::BuilderInfo::m_viewBit, m_views, modelChanges(), FWEventItem::modelType(), eostools::move(), FWEventItem::purpose(), removeItem(), findQualityFiles::size, AlCaHLTBitMon_QueryRunRegistry::string, protons_cff::t, FWEventItem::type(), and FWEveView::viewContext().

Referenced by FWEveViewManager::BuilderInfo::BuilderInfo().

193 {
194  TypeToBuilder::iterator itFind = m_typeToBuilder.find(iItem->purpose());
195 
196  if (itFind == m_typeToBuilder.end())
197  return;
198 
199  std::vector<BuilderInfo>& blist = itFind->second;
200 
201  std::string bType; bool bIsSimple;
202  for (size_t bii = 0, bie = blist.size(); bii != bie; ++bii)
203  {
204  // 1.
205  BuilderInfo &info = blist[bii];
206  info.classType(bType, bIsSimple);
207  if (bIsSimple)
208  {
209  unsigned int distance=1;
210  edm::TypeWithDict modelType( *(iItem->modelType()->GetTypeInfo()));
211  if (!FWSimpleRepresentationChecker::inheritsFrom(modelType, bType,distance))
212  {
213  // printf("PB does not matche itemType (%s) !!! EDproduct %s %s\n", info.m_name.c_str(), iItem->modelType()->GetTypeInfo()->name(), bType.c_str() );
214  continue;
215  }
216  }
217  else {
218  std::string itype = iItem->type()->GetTypeInfo()->name();
219  if (itype != bType) {
220  // printf("PB does not match modeType (%s)!!! EDproduct %s %s\n", info.m_name.c_str(), itype.c_str(), bType.c_str() );
221  continue;
222  }
223  }
224 
225  std::string builderName = info.m_name;
226  int builderViewBit = info.m_viewBit;
227 
228  std::shared_ptr<FWProxyBuilderBase> builder;
229  try
230  {
231  builder = std::shared_ptr<FWProxyBuilderBase>{FWProxyBuilderFactory::get()->create(builderName)};
232 
233  }
234  catch (std::exception& exc)
235  {
236  fwLog(fwlog::kWarning) << "FWEveViewManager::newItem ignoring the following exception (probably edmplugincache mismatch):"
237  << std::endl << exc.what();
238  }
239  if (!builder)
240  continue;
241 
242  // 2.
243  // printf("FWEveViewManager::makeProxyBuilderFor NEW builder %s \n", builderName.c_str());
244 
245  builder->setItem(iItem);
246  iItem->changed_.connect(boost::bind(&FWEveViewManager::modelChanges,this,_1));
247  iItem->goingToBeDestroyed_.connect(boost::bind(&FWEveViewManager::removeItem,this,_1));
248  iItem->itemChanged_.connect(boost::bind(&FWEveViewManager::itemChanged,this,_1));
249 
250  // 3.
251  // This calud be opaque to the user. I would pass a reference to the m_interactionLists to
252  // FWProxyBuilderBase::setInteractionList and handle different case differently.
253  if (builder->willHandleInteraction() == false)
254  {
255  typedef std::map<const FWEventItem*, FWInteractionList*>::iterator Iterator;
256  std::pair<Iterator, bool> t = m_interactionLists.insert(std::make_pair(iItem,
257  (FWInteractionList*)nullptr));
258 
259  if (t.second == true)
260  t.first->second = new FWInteractionList(iItem);
261  // printf(">>> builder %s add list %p \n", iItem->name().c_str(), il); fflush(stdout);
262  builder->setInteractionList(t.first->second, iItem->purpose());
263  }
264 
265  builder->setHaveWindow(haveViewForBit(builderViewBit));
266 
267  // 4.
268  for (size_t viewType = 0; viewType < FWViewType::kTypeSize; ++viewType)
269  {
270  if (((1 << viewType) & builderViewBit) == 0)
271  continue;
272 
274 
275  // printf("%s builder %s supportsd view %s \n", iItem->name().c_str(), builderName.c_str(), FWViewType::idToName(viewType).c_str());
276  if (builder->havePerViewProduct((FWViewType::EType) viewType))
277  {
278  for (size_t i = 0, e = m_views[viewType].size(); i != e; ++i)
279  {
280  FWEveView *view = m_views[viewType][i].get();
281  TEveElementList* product = builder->createProduct(type,
282  view->viewContext());
283  addElements(iItem, view, viewType, product);
284  }
285  }
286  else
287  {
288  TEveElementList* product = builder->createProduct(type, nullptr);
289 
290  for (size_t i = 0, e = m_views[viewType].size(); i != e; ++i)
291  addElements(iItem, m_views[viewType][i].get(), viewType, product);
292  }
293  }
294 
295  m_builders[builderViewBit].emplace_back(std::move(builder));
296  } // loop views
297 }
size
Write out results.
type
Definition: HCALResponse.h:21
static const TGPicture * info(bool iBackgroundIsBlack)
void itemChanged(const FWEventItem *)
FWItemChangeSignal goingToBeDestroyed_
Definition: FWEventItem.h:218
TypeToBuilder m_typeToBuilder
TGeoIterator Iterator
static bool inheritsFrom(const edm::TypeWithDict &iChild, const std::string &iParentTypeName, unsigned int &distance)
const TClass * type() const
Definition: FWEventItem.cc:511
FWItemChangeSignal itemChanged_
Definition: FWEventItem.h:202
bool haveViewForBit(int) const
void addElements(const FWEventItem *item, FWEveView *view, int viewType, TEveElementList *product)
std::vector< std::vector< std::shared_ptr< FWEveView > > > m_views
void modelChanges(const FWModelIds &iIds)
std::map< int, BuilderVec > m_builders
std::map< const FWEventItem *, FWInteractionList * > m_interactionLists
#define fwLog(_level_)
Definition: fwLog.h:50
FWViewContext * viewContext()
Definition: FWEveView.h:86
FWModelChangeSignal changed_
Definition: FWEventItem.h:199
const TClass * modelType() const
Definition: FWEventItem.cc:566
virtual void removeItem(const FWEventItem *)
const std::string & purpose() const
Definition: FWEventItem.cc:517
def move(src, dest)
Definition: eostools.py:511
T get(const Candidate &c)
Definition: component.h:55
const FWEveViewManager& FWEveViewManager::operator= ( const FWEveViewManager )
privatedelete

Referenced by syncAllViews().

void FWEveViewManager::removeItem ( const FWEventItem item)
virtual

Remove an item from the given view.

Definition at line 567 of file FWEveViewManager.cc.

References mps_fire::i, m_builders, and m_interactionLists.

Referenced by FWEveViewManager::BuilderInfo::BuilderInfo(), and newItem().

568 {
570 
571  std::map<const FWEventItem*, FWInteractionList*>::iterator it = m_interactionLists.find(item);
572  if (it != m_interactionLists.end())
573  {
574  delete it->second;
575  m_interactionLists.erase(it);
576  }
577 
578  for (std::map<int, BuilderVec>::iterator i = m_builders.begin();
579  i != m_builders.end(); ++i)
580  {
581  BuilderVec_it bIt = i->second.begin();
582  while( bIt != i->second.end() )
583  {
584  if ((*bIt)->item() == item)
585  {
586  // TODO caching of proxy builders
587  (*bIt)->itemBeingDestroyed(item);
588  bIt = i->second.erase(bIt);
589  }
590  else
591  {
592  ++bIt;
593  }
594  }
595  }
596 }
std::map< int, BuilderVec > m_builders
std::map< const FWEventItem *, FWInteractionList * > m_interactionLists
BuilderVec::iterator BuilderVec_it
void FWEveViewManager::selectionAdded ( TEveElement *  iElement)

Definition at line 763 of file FWEveViewManager.cc.

References FWFromEveSelectorBase::doSelect(), and getSelector().

Referenced by FWEveViewManager::BuilderInfo::BuilderInfo().

764 {
765  FWFromEveSelectorBase* selector = getSelector(iElement);
766  if (selector)
767  selector->doSelect();
768 }
FWFromEveSelectorBase * getSelector(TEveElement *iElement)
virtual void doSelect()=0
void FWEveViewManager::selectionCleared ( )

Definition at line 779 of file FWEveViewManager.cc.

References FWSelectionManager::clearSelection(), FWViewManagerBase::context(), and fireworks::Context::selectionManager().

Referenced by FWEveViewManager::BuilderInfo::BuilderInfo().

780 {
782 }
const fireworks::Context & context() const
FWSelectionManager * selectionManager() const
Definition: Context.h:57
void FWEveViewManager::selectionRemoved ( TEveElement *  iElement)

Definition at line 771 of file FWEveViewManager.cc.

References FWFromEveSelectorBase::doUnselect(), and getSelector().

Referenced by FWEveViewManager::BuilderInfo::BuilderInfo().

772 {
773  FWFromEveSelectorBase* selector = getSelector(iElement);
774  if (selector)
775  selector->doUnselect();
776 }
virtual void doUnselect()=0
FWFromEveSelectorBase * getSelector(TEveElement *iElement)
void FWEveViewManager::setContext ( const fireworks::Context x)
overridevirtual

Reimplemented from FWViewManagerBase.

Definition at line 599 of file FWEveViewManager.cc.

References fireworks::Context::commonPrefs(), eventCenterChanged(), CmsShowCommon::eventCenterChanged_, CmsShowCommon::getEnergyScale(), globalEnergyScaleChanged(), FWViewEnergyScale::parameterChanged_, and FWViewManagerBase::setContext().

Referenced by FWEveViewManager::BuilderInfo::BuilderInfo().

600 {
603  x->commonPrefs()->eventCenterChanged_.connect(boost::bind(&FWEveViewManager::eventCenterChanged,this));
604 }
sigc::signal< void, const CmsShowCommon * > eventCenterChanged_
Definition: CmsShowCommon.h:88
virtual void setContext(const fireworks::Context *x)
FWViewEnergyScale * getEnergyScale() const
Definition: CmsShowCommon.h:72
CmsShowCommon * commonPrefs() const
Definition: Context.cc:177
sigc::signal< void > parameterChanged_
FWTypeToRepresentations FWEveViewManager::supportedTypesAndRepresentations ( ) const
overridevirtual

Implements FWViewManagerBase.

Definition at line 790 of file FWEveViewManager.cc.

References FWTypeToRepresentations::add(), FWEveViewManager::BuilderInfo::classType(), FWViewManagerBase::context(), fireworks::Context::getHidePFBuilders(), info(), FWEveViewManager::BuilderInfo::m_name, m_typeToBuilder, FWEveViewManager::BuilderInfo::m_viewBit, dataset::name, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by FWEveViewManager::BuilderInfo::BuilderInfo().

791 {
792  // needed for add collection GUI
793  FWTypeToRepresentations returnValue;
794  const static std::string kFullFrameWorkPBExtension = "FullFramework";
795  for(TypeToBuilder::const_iterator it = m_typeToBuilder.begin(), itEnd = m_typeToBuilder.end();
796  it != itEnd;
797  ++it)
798  {
799  std::vector<BuilderInfo> blist = it->second;
800  for (size_t bii = 0, bie = blist.size(); bii != bie; ++bii)
801  {
802  BuilderInfo &info = blist[bii];
803 
804  if (context().getHidePFBuilders()) {
805  const static std::string pfExt = "PF ";
806  if (std::string::npos != info.m_name.find(pfExt))
807  continue;
808  }
809 
810  unsigned int bitPackedViews = info.m_viewBit;
811  bool representsSubPart = (info.m_name.substr(info.m_name.find_first_of('@')-1, 1)=="!");
812  size_t extp = info.m_name.rfind(kFullFrameWorkPBExtension);
813  bool FFOnly = (extp != std::string::npos);
814 
816  bool isSimple;
817  info.classType(name, isSimple);
818  if(isSimple)
819  {
820  returnValue.add(std::make_shared<FWSimpleRepresentationChecker>(name, it->first,bitPackedViews,representsSubPart, FFOnly) );
821  }
822  else
823  {
824  returnValue.add(std::make_shared<FWEDProductRepresentationChecker>(name, it->first,bitPackedViews,representsSubPart, FFOnly) );
825  }
826  }
827  }
828  return returnValue;
829 }
static const TGPicture * info(bool iBackgroundIsBlack)
const fireworks::Context & context() const
TypeToBuilder m_typeToBuilder
void add(std::shared_ptr< FWRepresentationCheckerBase > iChecker)
bool getHidePFBuilders() const
Definition: Context.h:91
static void FWEveViewManager::syncAllViews ( )
inlinestatic

Member Data Documentation

std::map<int, BuilderVec> FWEveViewManager::m_builders
private
std::map<const FWEventItem*,FWInteractionList*> FWEveViewManager::m_interactionLists
private

Definition at line 116 of file FWEveViewManager.h.

Referenced by itemChanged(), modelChanges(), newItem(), and removeItem().

TypeToBuilder FWEveViewManager::m_typeToBuilder
private

Definition at line 108 of file FWEveViewManager.h.

Referenced by FWEveViewManager(), newItem(), and supportedTypesAndRepresentations().

std::vector< std::vector<std::shared_ptr<FWEveView> > > FWEveViewManager::m_views
private
bool FWEveViewManager::s_syncAllViews = false
staticprivate

Definition at line 110 of file FWEveViewManager.h.

Referenced by eventEnd(), and syncAllViews().