CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FWEveViewManager.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Core
4 // Class : FWEveViewManager
5 //
6 // Implementation:
7 // [Notes on implementation]
8 //
9 // Original Author: Chris Jones, Alja Mrak-Tadel
10 // Created: Thu Mar 18 14:11:32 CET 2010
11 //
12 
13 // system include files
14 
15 #include <boost/bind.hpp>
16 
17 
18 // user include files
19 #include "TEveManager.h"
20 #include "TEveSelection.h"
21 #include "TEveScene.h"
22 #include "TEveViewer.h"
23 #include "TEveCalo.h"
24 #include "TEveGedEditor.h"
25 #include "TGListTree.h"
26 #include "TGeoManager.h"
27 #include "TExMap.h"
28 #include "TEnv.h"
29 
38 
39 // PB
46 
47 // viewes
55 
58 
59 class FWViewContext;
60 
61 // sentry class block TEveSelection signals when call TEveSelection::Remove/AddElement and
62 // when process its callbacks
64 public:
66  {
67  m_blocked = gEve->GetSelection()->BlockSignals(true);
68  }
70  {
71  gEve->GetSelection()->BlockSignals(m_blocked);
72  }
73 private:
74  bool m_blocked;
75 };
76 
77 //
78 //
79 // constants, enums and typedefs
80 //
81 //
82 // constructors and destructor
83 //
86 {
87 
88  // builders
89  std::set<std::string> builders;
90 
91  std::vector<edmplugin::PluginInfo> available = FWProxyBuilderFactory::get()->available();
92  std::transform(available.begin(),
93  available.end(),
94  std::inserter(builders,builders.begin()),
95  boost::bind(&edmplugin::PluginInfo::name_,_1));
96 
99  std::transform(available.begin(),
100  available.end(),
101  std::inserter(builders,builders.begin()),
102  boost::bind(&edmplugin::PluginInfo::name_,_1));
103  }
104 
105 
106  for(std::set<std::string>::iterator it = builders.begin(), itEnd=builders.end();
107  it!=itEnd;
108  ++it) {
109  std::string::size_type first = it->find_first_of('@')+1;
110  std::string purpose = it->substr(first,it->find_last_of('@')-first);
111 
112  first = it->find_last_of('@')+1;
113  std::string view_str = it->substr(first,it->find_last_of('#')-first);
114  int viewTypes = atoi(view_str.c_str());
115  std::string fullName = *it;
116  m_typeToBuilder[purpose].push_back(BuilderInfo(*it, viewTypes));
117  }
118 
120 
121  // view construction called via GUI mng
122  FWGUIManager::ViewBuildFunctor f = boost::bind(&FWEveViewManager::buildView, this, _1, _2);
123  for (int i = 0; i < FWViewType::kTypeSize; i++)
124  {
126  continue;
128  }
129 
130  // signal
131  gEve->GetHighlight()->SetPickToSelect(TEveSelection::kPS_Master);
132  TEveSelection* eveSelection = gEve->GetSelection();
133  eveSelection->SetPickToSelect(TEveSelection::kPS_Master);
134  eveSelection->Connect("SelectionAdded(TEveElement*)","FWEveViewManager",this,"selectionAdded(TEveElement*)");
135  eveSelection->Connect("SelectionRepeated(TEveElement*)","FWEveViewManager",this,"selectionAdded(TEveElement*)");
136  eveSelection->Connect("SelectionRemoved(TEveElement*)","FWEveViewManager",this,"selectionRemoved(TEveElement*)");
137  eveSelection->Connect("SelectionCleared()","FWEveViewManager",this,"selectionCleared()");
138 
139  gEve->GetHighlight()->Connect("SelectionAdded(TEveElement*)","FWEveViewManager",this,"highlightAdded(TEveElement*)");
140  gEve->GetHighlight()->Connect("SelectionRepeated(TEveElement*)","FWEveViewManager",this,"highlightAdded(TEveElement*)");
141 
142  TGeoManager::SetVerboseLevel(0);
143 }
144 
146 {
147 }
148 
149 //
150 // member functions
151 //
152 
153 //______________________________________________________________________________
154 
160 void
161 addElements(const FWEventItem *item, FWEveView *view,
162  int viewType, TEveElementList* product)
163 {
164  if (FWViewType::isProjected(viewType))
165  {
166  FWRPZView* rpzView = dynamic_cast<FWRPZView*>(view);
167  assert(rpzView);
168  rpzView->importElements(product, item->layer(), rpzView->eventScene());
169  }
170  else
171  {
172  view->eventScene()->AddElement(product);
173  }
174 }
175 
190 void
192 {
193  TypeToBuilder::iterator itFind = m_typeToBuilder.find(iItem->purpose());
194 
195  if (itFind == m_typeToBuilder.end())
196  return;
197 
198  std::vector<BuilderInfo>& blist = itFind->second;
199 
200  std::string bType; bool bIsSimple;
201  for (size_t bii = 0, bie = blist.size(); bii != bie; ++bii)
202  {
203  // 1.
204  BuilderInfo &info = blist[bii];
205  info.classType(bType, bIsSimple);
206  if (bIsSimple)
207  {
208  unsigned int distance=1;
209  edm::TypeWithDict modelType( *(iItem->modelType()->GetTypeInfo()));
210  if (!FWSimpleRepresentationChecker::inheritsFrom(modelType, bType,distance))
211  {
212  // printf("PB does not matche itemType (%s) !!! EDproduct %s %s\n", info.m_name.c_str(), iItem->modelType()->GetTypeInfo()->name(), bType.c_str() );
213  continue;
214  }
215  }
216  else {
217  std::string itype = iItem->type()->GetTypeInfo()->name();
218  if (itype != bType) {
219  // printf("PB does not match modeType (%s)!!! EDproduct %s %s\n", info.m_name.c_str(), itype.c_str(), bType.c_str() );
220  continue;
221  }
222  }
223 
224  std::string builderName = info.m_name;
225  int builderViewBit = info.m_viewBit;
226 
227  FWProxyBuilderBase* builder = 0;
228  try
229  {
230  builder = FWProxyBuilderFactory::get()->create(builderName);
231 
232  }
233  catch (std::exception& exc)
234  {
235  fwLog(fwlog::kWarning) << "FWEveViewManager::newItem ignoring the following exception (probably edmplugincache mismatch):"
236  << std::endl << exc.what();
237  }
238  if (!builder)
239  continue;
240 
241  // 2.
242  // printf("FWEveViewManager::makeProxyBuilderFor NEW builder %s \n", builderName.c_str());
243 
244  boost::shared_ptr<FWProxyBuilderBase> pB(builder);
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*)0));
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, 0);
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].push_back(pB);
296  } // loop views
297 }
298 
299 //______________________________________________________________________________
300 FWViewBase*
301 FWEveViewManager::buildView(TEveWindowSlot* iParent, const std::string& viewName)
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  boost::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(boost::shared_ptr<FWEveView> (view));
342  return finishViewCreate(m_views[type].back());
343 }
344 
345 FWEveView*
346 FWEveViewManager::finishViewCreate(boost::shared_ptr<FWEveView> view)
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 }
427 
428 void
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 }
473 
474 //______________________________________________________________________________
475 
476 void
478 {
479  gEve->DisableRedraw();
480 }
481 
482 void
484 {
485  gEve->EnableRedraw();
486 }
487 
489 void
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 }
524 
530 void
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 }
563 
566 void
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 }
597 
598 void
600 {
603 
604 }
605 
606 void
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 }
621 
622 void
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  (*i)->setBackgroundColor(colorManager().background());
629  }
630 }
631 
632 //______________________________________________________________________________
633 void
635 {
636  // Prevent registration of redraw timer, full redraw is done in
637  // FWEveViewManager::eventEnd().
638  gEve->EnforceTimerActive(kTRUE);
639  gEve->DisableRedraw();
640 
642 
643  for (int t = 0 ; t < FWViewType::kTypeSize; ++t)
644  {
645  for(EveViewVec_it i = m_views[t].begin(); i != m_views[t].end(); ++i)
646  (*i)->eventBegin();
647  }
648 }
649 
650 void
652 {
653  for (int t = 0 ; t < FWViewType::kTypeSize; ++t)
654  {
655  for(EveViewVec_it i = m_views[t].begin(); i != m_views[t].end(); ++i)
656  (*i)->eventEnd();
657  }
658 
659  // What follows is a copy of TEveManager::DoRedraw3D() with the difference that
660  // we have full control over execution of GL view rendering. In particular:
661  // - optionally delay buffer swapping so they can all be swapped together;
662  // - we could render into FBO once and then use this to be put on screen
663  // and saved into an image file.
664 
665  {
666  TEveElement::List_t scenes;
667  Long64_t key, value;
668  TExMapIter stamped_elements(gEve->PtrToStampedElements());
669  while (stamped_elements.Next(key, value))
670  {
671  TEveElement *el = reinterpret_cast<TEveElement*>(key);
672  if (el->GetChangeBits() & TEveElement::kCBVisibility)
673  {
674  el->CollectSceneParents(scenes);
675  }
676  }
677  gEve->ScenesChanged(scenes);
678  }
679 
680  // Process changes in scenes.
681  gEve->GetScenes()->ProcessSceneChanges(kFALSE, gEve->PtrToStampedElements());
682 
683  // To synchronize buffer swapping set swap_on_render to false.
684  // Note that this costs 25-40% extra time with 4 views, depending on V-sync settings.
685  // Tested with NVIDIA 343.22.
686  const bool swap_on_render = !s_syncAllViews;
687 
688  // Loop over viewers, swap buffers if swap_on_render is true.
689  for (int t = 0 ; t < FWViewType::kTypeSize; ++t)
690  {
691  for(EveViewVec_it i = m_views[t].begin(); i != m_views[t].end(); ++i)
692  (*i)->fwViewerGL()->DrawHiLod(swap_on_render);
693  }
694 
695  // Swap buffers if they were not swapped before.
696  if ( ! swap_on_render)
697  {
698  for (int t = 0 ; t < FWViewType::kTypeSize; ++t)
699  {
700  for(EveViewVec_it i = m_views[t].begin(); i != m_views[t].end(); ++i)
701  (*i)->fwViewerGL()->JustSwap();
702  }
703  }
704 
705  gEve->GetViewers()->RepaintChangedViewers(kFALSE, kFALSE);
706 
707  {
708  Long64_t key, value;
709  TExMapIter stamped_elements(gEve->PtrToStampedElements());
710  while (stamped_elements.Next(key, value))
711  {
712  TEveElement *el = reinterpret_cast<TEveElement*>(key);
713  if (gEve->GetEditor()->GetModel() == el->GetEditorObject("FWEveViewManager::eventEnd"))
714  gEve->EditElement(el);
715  TEveGedEditor::ElementChanged(el);
716 
717  el->ClearStamps();
718  }
719  }
720  gEve->PtrToStampedElements()->Delete();
721 
722  gEve->GetListTree()->ClearViewPort(); // Fix this when several list-trees can be added.
723 
724  gEve->EnableRedraw();
725  gEve->EnforceTimerActive(kFALSE);
726 }
727 
728 //______________________________________________________________________________
729 
732 FWFromEveSelectorBase *getSelector(TEveElement *iElement)
733 {
734  if (!iElement)
735  return 0;
736 
737  //std::cout <<" non null"<<std::endl;
738  void* userData = iElement->GetUserData();
739  //std::cout <<" user data "<<userData<<std::endl;
740  if (!userData)
741  return 0;
742 
743  //std::cout <<" have userData"<<std::endl;
744  //std::cout <<" calo"<<std::endl;
746  return reinterpret_cast<FWFromEveSelectorBase*> (userData);
747 }
748 
749 void
750 FWEveViewManager::selectionAdded(TEveElement* iElement)
751 {
752  FWFromEveSelectorBase* selector = getSelector(iElement);
753  if (selector)
754  selector->doSelect();
755 }
756 
757 void
759 {
760  FWFromEveSelectorBase* selector = getSelector(iElement);
761  if (selector)
762  selector->doUnselect();
763 }
764 
765 void
767 {
769 }
770 
771 
772 //
773 // const member functions
774 //
775 
778 {
779  // needed for add collection GUI
780  FWTypeToRepresentations returnValue;
781  const static std::string kFullFrameWorkPBExtension = "FullFramework";
782  for(TypeToBuilder::const_iterator it = m_typeToBuilder.begin(), itEnd = m_typeToBuilder.end();
783  it != itEnd;
784  ++it)
785  {
786  std::vector<BuilderInfo> blist = it->second;
787  for (size_t bii = 0, bie = blist.size(); bii != bie; ++bii)
788  {
789  BuilderInfo &info = blist[bii];
790 
791  if (context().getHidePFBuilders()) {
792  const static std::string pfExt = "PF ";
793  if (std::string::npos != info.m_name.find(pfExt))
794  continue;
795  }
796 
797  unsigned int bitPackedViews = info.m_viewBit;
798  bool representsSubPart = (info.m_name.substr(info.m_name.find_first_of('@')-1, 1)=="!");
799  size_t extp = info.m_name.rfind(kFullFrameWorkPBExtension);
800  bool FFOnly = (extp != std::string::npos);
801 
803  bool isSimple;
804  info.classType(name, isSimple);
805  if(isSimple)
806  {
807  returnValue.add(boost::shared_ptr<FWRepresentationCheckerBase>(new FWSimpleRepresentationChecker(name, it->first,bitPackedViews,representsSubPart, FFOnly)) );
808  }
809  else
810  {
811  returnValue.add(boost::shared_ptr<FWRepresentationCheckerBase>(new FWEDProductRepresentationChecker(name, it->first,bitPackedViews,representsSubPart, FFOnly)) );
812  }
813  }
814  }
815  return returnValue;
816 }
817 
818 
820 bool
822 {
823  for (int t = 0; t < FWViewType::kTypeSize; ++t)
824  {
825  if ((bit & (1 << t)) && m_views[t].size())
826  return true;
827  }
828  // printf("have %d view for bit %d \n", haveView, bit);
829  return false;
830 }
831 
832 
833 void
835 {
836  const std::string kSimple("simple#");
837  simple = (m_name.substr(0,kSimple.size()) == kSimple);
838  if (simple)
839  {
840  typeName = m_name.substr(kSimple.size(), m_name.find_first_of('@')-kSimple.size()-1);
841  }
842  else
843  {
844  typeName = m_name.substr(0, m_name.find_first_of('@')-1);
845  }
846 }
847 
848 /*
849 AMT: temporary workaround for using TEveCaloDataHist instead of
850 TEveCaloDataVec.
851 
852  */
853 
854 #include "TH2F.h"
855 #include "TAxis.h"
856 #include "TEveCaloData.h"
857 
858 void
859 FWEveViewManager::highlightAdded(TEveElement* iElement)
860 {
861 
862  bool blocked = gEve->GetHighlight()->BlockSignals(true);
863 
864 
865  if (iElement == context().getCaloData())
866  {
867  TEveCaloData::vCellId_t& hlist = context().getCaloData()->GetCellsHighlighted();
868  std::set<TEveCaloData::CellId_t> hset;
869 
870  int etaBin, phiBin, w, newPhiBin, tower;
871  TH2F* hist = context().getCaloData()->GetHist(0);
872  TAxis* etaAxis = hist->GetXaxis();
873  int nBinsX = etaAxis->GetNbins() + 2;
874 
875  for (TEveCaloData::vCellId_i i = hlist.begin(); i != hlist.end(); ++i)
876  {
877  hist->GetBinXYZ((*i).fTower, etaBin, phiBin, w);
878  if (TMath::Abs(etaAxis->GetBinCenter(etaBin)) > 4.71475)
879  {
880  newPhiBin = ((phiBin + 1) / 4) * 4 - 1;
881  if (newPhiBin <= 0) newPhiBin = 71;
882 
883  tower = etaBin + newPhiBin*nBinsX;
884  hset.insert(TEveCaloData::CellId_t( tower, (*i).fSlice, (*i).fFraction));
885  tower += nBinsX;
886  hset.insert(TEveCaloData::CellId_t(tower, (*i).fSlice, (*i).fFraction));
887  tower += nBinsX;
888 
889  if (newPhiBin == 71)
890  tower = etaBin + 1*nBinsX;
891 
892  hset.insert(TEveCaloData::CellId_t(tower, (*i).fSlice, (*i).fFraction));
893  tower += nBinsX;
894  hset.insert(TEveCaloData::CellId_t(tower, (*i).fSlice, (*i).fFraction));
895  }
896  else if (TMath::Abs(etaAxis->GetBinCenter(etaBin)) > 1.747650)
897  {
898  newPhiBin = ((phiBin + 1)/2)*2 - 1;
899  tower = etaBin + newPhiBin*nBinsX;
900  hset.insert(TEveCaloData::CellId_t( tower, (*i).fSlice, (*i).fFraction));
901  tower += nBinsX;
902  hset.insert(TEveCaloData::CellId_t(tower, (*i).fSlice, (*i).fFraction));
903  }
904  else
905  {
906  hset.insert(*i);
907  }
908  }
909 
910  // edit calo data list
911  hlist.clear();
912  for(std::set<TEveCaloData::CellId_t>::iterator it = hset.begin(); it != hset.end(); ++it)
913  {
914  hlist.push_back(*it);
915  }
916  context().getCaloData()->CellSelectionChanged();
917 
918  }
919 
920  gEve->GetHighlight()->BlockSignals(blocked);
921 }
const CategoryToInfos & categoryToInfos() const
Definition: PluginManager.h:82
FWEveView * finishViewCreate(boost::shared_ptr< FWEveView >)
type
Definition: HCALResponse.h:21
int i
Definition: DBlmapReader.cc:9
static const TGPicture * info(bool iBackgroundIsBlack)
Color_t background() const
const fireworks::Context & context() const
TEveScene * eventScene()
Definition: FWEveView.h:82
virtual void modelChangesDone()
virtual void doUnselect()=0
const double w
Definition: UKUtility.cc:23
FWTypeToRepresentations supportedTypesAndRepresentations() const
virtual bool willHandleInteraction() const
virtual bool havePerViewProduct(FWViewType::EType) const
FWColorManager * colorManager() const
Definition: Context.h:65
assert(m_qm.get())
void selectionAdded(TEveElement *)
void itemChanged(const FWEventItem *)
virtual void colorsChanged()
FWItemChangeSignal goingToBeDestroyed_
Definition: FWEventItem.h:217
TypeToBuilder m_typeToBuilder
FWColorManager & colorManager() const
uint16_t size_type
boost::function2< FWViewBase *, TEveWindowSlot *, const std::string & > ViewBuildFunctor
Definition: FWGUIManager.h:99
static bool s_syncAllViews
const FWEventItem * item() const
void add(boost::shared_ptr< FWRepresentationCheckerBase > iChecker)
std::list< Particle > List_t
Definition: Particle.h:141
int layer() const
Definition: FWEventItem.cc:457
FWEveViewManager(FWGUIManager *)
void registerViewBuilder(const std::string &iName, ViewBuildFunctor &iBuilder)
FWFromEveSelectorBase * getSelector(TEveElement *iElement)
static bool isProjected(int)
Definition: FWViewType.cc:128
T x() const
Cartesian x coordinate.
static bool inheritsFrom(const edm::TypeWithDict &iChild, const std::string &iParentTypeName, unsigned int &distance)
virtual void setContext(const fireworks::Context *x)
virtual void newItem(const FWEventItem *)
std::set< FWModelId > FWModelIds
std::vector< boost::shared_ptr< FWEveView > >::iterator EveViewVec_it
virtual void setItem(const FWEventItem *iItem)
void resetMaxEtAndEnergy() const
Definition: Context.cc:192
const TClass * type() const
Definition: FWEventItem.cc:506
FWItemChangeSignal itemChanged_
Definition: FWEventItem.h:201
T Abs(T a)
Definition: MathUtil.h:49
bool haveViewForBit(int) const
void addElements(const FWEventItem *item, FWEveView *view, int viewType, TEveElementList *product)
bool getHidePFBuilders() const
Definition: Context.h:91
virtual void setContext(const fireworks::Context *)
double f[11][100]
void selectionRemoved(TEveElement *)
void highlightAdded(TEveElement *)
void importElements(TEveElement *iProjectableChild, float layer, TEveElement *iProjectedParent=0)
Definition: FWRPZView.cc:298
TEveCaloDataHist * getCaloData() const
Definition: Context.h:80
void modelChanges(const FWModelIds &iIds)
void beingDestroyed(const FWViewBase *)
std::map< int, BuilderVec > m_builders
FWSelectionManager * selectionManager() const
Definition: Context.h:57
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
FWViewBase * buildView(TEveWindowSlot *iParent, const std::string &type)
virtual void doSelect()=0
void setHaveWindow(bool iFlag)
string fullName
std::map< const FWEventItem *, FWInteractionList * > m_interactionLists
virtual void modelChangesComing()
#define fwLog(_level_)
Definition: fwLog.h:50
FWViewContext * viewContext()
Definition: FWEveView.h:86
FWViewEnergyScale * getEnergyScale() const
Definition: CmsShowCommon.h:67
virtual void eventEnd()
virtual ~FWEveViewManager()
std::vector< boost::shared_ptr< FWProxyBuilderBase > > BuilderVec
CmsShowCommon * commonPrefs() const
Definition: Context.cc:179
BuilderVec::iterator BuilderVec_it
FWModelChangeSignal changed_
Definition: FWEventItem.h:198
sigc::signal< void > parameterChanged_
#define begin
Definition: vmac.h:30
static const std::string & idToName(int)
Definition: FWViewType.cc:89
const TClass * modelType() const
Definition: FWEventItem.cc:561
std::string name_
Definition: PluginInfo.h:29
TEveElement * ownedProducts()
Definition: FWEveView.h:85
static Bool_t setColorSetViewer(TGLViewer *, Color_t)
virtual void removeItem(const FWEventItem *)
bool getHaveWindow() const
virtual void eventBegin()
TEveElementList * createProduct(FWViewType::EType, const FWViewContext *)
const std::string & purpose() const
Definition: FWEventItem.cc:512
static PluginManager * get()
void classType(std::string &, bool &) const
tuple size
Write out results.
virtual void setContext(const fireworks::Context &x)
Definition: FWEveView.cc:271
T get(const Candidate &c)
Definition: component.h:55
void itemChanged(const FWEventItem *)
void modelChanges(const FWModelIds &)
std::vector< std::vector< boost::shared_ptr< FWEveView > > > m_views
virtual void setInteractionList(FWInteractionList *, const std::string &)
FWViewType::EType typeId() const
Definition: FWViewBase.h:41