CMS 3D CMS Logo

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 <functional>
16 
17 // user include files
18 #include "TEveManager.h"
19 #include "TEveSelection.h"
20 #include "TEveScene.h"
21 #include "TEveViewer.h"
22 #include "TEveCalo.h"
23 #include "TEveGedEditor.h"
24 #include "TGListTree.h"
25 #include "TGeoManager.h"
26 #include "TExMap.h"
27 #include "TEnv.h"
28 
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:
65  EveSelectionSentry() { m_blocked = gEve->GetSelection()->BlockSignals(true); }
66  ~EveSelectionSentry() { gEve->GetSelection()->BlockSignals(m_blocked); }
67 
68 private:
69  bool m_blocked;
70 };
71 
72 //
73 //
74 // constants, enums and typedefs
75 //
76 //
77 // constructors and destructor
78 //
80  // builders
81  std::set<std::string> builders;
82 
83  std::vector<edmplugin::PluginInfo> available = FWProxyBuilderFactory::get()->available();
84  std::transform(available.begin(),
85  available.end(),
86  std::inserter(builders, builders.begin()),
87  std::bind(&edmplugin::PluginInfo::name_, std::placeholders::_1));
88 
91  available =
93  std::transform(available.begin(),
94  available.end(),
95  std::inserter(builders, builders.begin()),
96  std::bind(&edmplugin::PluginInfo::name_, std::placeholders::_1));
97  }
98 
99  for (std::set<std::string>::iterator it = builders.begin(), itEnd = builders.end(); it != itEnd; ++it) {
100  std::string::size_type first = it->find_first_of('@') + 1;
101  std::string purpose = it->substr(first, it->find_last_of('@') - first);
102 
103  first = it->find_last_of('@') + 1;
104  std::string view_str = it->substr(first, it->find_last_of('#') - first);
105  int viewTypes = atoi(view_str.c_str());
106  std::string fullName = *it;
107  m_typeToBuilder[purpose].push_back(BuilderInfo(*it, viewTypes));
108  }
109 
111 
112  // view construction called via GUI mng
114  std::bind(&FWEveViewManager::buildView, this, std::placeholders::_1, std::placeholders::_2);
115  for (int i = 0; i < FWViewType::kTypeSize; i++) {
117  continue;
119  }
120 
121  // signal
122  gEve->GetHighlight()->SetPickToSelect(TEveSelection::kPS_Master);
123  TEveSelection* eveSelection = gEve->GetSelection();
124  eveSelection->SetPickToSelect(TEveSelection::kPS_Master);
125  eveSelection->Connect("SelectionAdded(TEveElement*)", "FWEveViewManager", this, "selectionAdded(TEveElement*)");
126  eveSelection->Connect("SelectionRepeated(TEveElement*)", "FWEveViewManager", this, "selectionAdded(TEveElement*)");
127  eveSelection->Connect("SelectionRemoved(TEveElement*)", "FWEveViewManager", this, "selectionRemoved(TEveElement*)");
128  eveSelection->Connect("SelectionCleared()", "FWEveViewManager", this, "selectionCleared()");
129 
130  gEve->GetHighlight()->Connect(
131  "SelectionAdded(TEveElement*)", "FWEveViewManager", this, "highlightAdded(TEveElement*)");
132  gEve->GetHighlight()->Connect(
133  "SelectionRepeated(TEveElement*)", "FWEveViewManager", this, "highlightAdded(TEveElement*)");
134 
135  TGeoManager::SetVerboseLevel(0);
136 }
137 
139 
140 //
141 // member functions
142 //
143 
144 //______________________________________________________________________________
145 
151 void addElements(const FWEventItem* item, FWEveView* view, int viewType, TEveElementList* product) {
152  if (FWViewType::isProjected(viewType)) {
153  FWRPZView* rpzView = dynamic_cast<FWRPZView*>(view);
154  assert(rpzView);
155  rpzView->importElements(product, item->layer(), rpzView->eventScene());
156  } else {
157  view->eventScene()->AddElement(product);
158  }
159 }
160 
176  TypeToBuilder::iterator itFind = m_typeToBuilder.find(iItem->purpose());
177 
178  if (itFind == m_typeToBuilder.end())
179  return;
180 
181  std::vector<BuilderInfo>& blist = itFind->second;
182 
183  std::string bType;
184  bool bIsSimple;
185  for (size_t bii = 0, bie = blist.size(); bii != bie; ++bii) {
186  // 1.
187  BuilderInfo& info = blist[bii];
188  info.classType(bType, bIsSimple);
189  if (bIsSimple) {
190  unsigned int distance = 1;
191  edm::TypeWithDict modelType(*(iItem->modelType()->GetTypeInfo()));
192  if (!FWSimpleRepresentationChecker::inheritsFrom(modelType, bType, distance)) {
193  // printf("PB does not matche itemType (%s) !!! EDproduct %s %s\n", info.m_name.c_str(), iItem->modelType()->GetTypeInfo()->name(), bType.c_str() );
194  continue;
195  }
196  } else {
197  std::string itype = iItem->type()->GetTypeInfo()->name();
198  if (itype != bType) {
199  // printf("PB does not match modeType (%s)!!! EDproduct %s %s\n", info.m_name.c_str(), itype.c_str(), bType.c_str() );
200  continue;
201  }
202  }
203 
204  std::string builderName = info.m_name;
205  int builderViewBit = info.m_viewBit;
206 
207  std::shared_ptr<FWProxyBuilderBase> builder;
208  try {
209  builder = std::shared_ptr<FWProxyBuilderBase>{FWProxyBuilderFactory::get()->create(builderName)};
210 
211  } catch (std::exception& exc) {
213  << "FWEveViewManager::newItem ignoring the following exception (probably edmplugincache mismatch):"
214  << std::endl
215  << exc.what();
216  }
217  if (!builder)
218  continue;
219 
220  // 2.
221  // printf("FWEveViewManager::makeProxyBuilderFor NEW builder %s \n", builderName.c_str());
222 
223  builder->setItem(iItem);
224  iItem->changed_.connect(std::bind(&FWEveViewManager::modelChanges, this, std::placeholders::_1));
225  iItem->goingToBeDestroyed_.connect(std::bind(&FWEveViewManager::removeItem, this, std::placeholders::_1));
226  iItem->itemChanged_.connect(std::bind(&FWEveViewManager::itemChanged, this, std::placeholders::_1));
227 
228  // 3.
229  // This calud be opaque to the user. I would pass a reference to the m_interactionLists to
230  // FWProxyBuilderBase::setInteractionList and handle different case differently.
231  if (builder->willHandleInteraction() == false) {
232  typedef std::map<const FWEventItem*, FWInteractionList*>::iterator Iterator;
233  std::pair<Iterator, bool> t = m_interactionLists.insert(std::make_pair(iItem, (FWInteractionList*)nullptr));
234 
235  if (t.second == true)
236  t.first->second = new FWInteractionList(iItem);
237  // printf(">>> builder %s add list %p \n", iItem->name().c_str(), il); fflush(stdout);
238  builder->setInteractionList(t.first->second, iItem->purpose());
239  }
240 
241  builder->setHaveWindow(haveViewForBit(builderViewBit));
242 
243  // 4.
244  for (size_t viewType = 0; viewType < FWViewType::kTypeSize; ++viewType) {
245  if (((1 << viewType) & builderViewBit) == 0)
246  continue;
247 
249 
250  // printf("%s builder %s supportsd view %s \n", iItem->name().c_str(), builderName.c_str(), FWViewType::idToName(viewType).c_str());
251  if (builder->havePerViewProduct((FWViewType::EType)viewType)) {
252  for (size_t i = 0, e = m_views[viewType].size(); i != e; ++i) {
253  FWEveView* view = m_views[viewType][i].get();
254  TEveElementList* product = builder->createProduct(type, view->viewContext());
255  addElements(iItem, view, viewType, product);
256  }
257  } else {
258  TEveElementList* product = builder->createProduct(type, nullptr);
259 
260  for (size_t i = 0, e = m_views[viewType].size(); i != e; ++i)
261  addElements(iItem, m_views[viewType][i].get(), viewType, product);
262  }
263  }
264 
265  m_builders[builderViewBit].emplace_back(std::move(builder));
266  } // loop views
267 }
268 
269 //______________________________________________________________________________
270 FWViewBase* FWEveViewManager::buildView(TEveWindowSlot* iParent, const std::string& viewName) {
272  for (int i = 0; i < FWViewType::kTypeSize; ++i) {
273  if (viewName == FWViewType::idToName(i)) {
275  break;
276  }
277  }
278 
279  std::shared_ptr<FWEveView> view;
280  switch (type) {
281  case FWViewType::k3D:
282  view.reset(new FW3DView(iParent, type));
283  break;
284  case FWViewType::kISpy:
285  view.reset(new FWISpyView(iParent, type));
286  break;
287  case FWViewType::kRhoPhi:
288  case FWViewType::kRhoZ:
290  view.reset(new FWRPZView(iParent, type));
291  break;
292  case FWViewType::kLego:
294  view.reset(new FWEveLegoView(iParent, type));
295  break;
296  case FWViewType::kLegoHF:
297  view.reset(new FWHFView(iParent, type));
298  break;
300  view.reset(new FWGlimpseView(iParent, type));
301  break;
302  default:
303  break;
304  }
305 
306  m_views[type].push_back(std::shared_ptr<FWEveView>(view));
307  return finishViewCreate(m_views[type].back());
308 }
309 
310 FWEveView* FWEveViewManager::finishViewCreate(std::shared_ptr<FWEveView> view) {
311  // printf("new view %s added \n", view->typeName().c_str());
312  gEve->DisableRedraw();
313 
314  // set geometry and calo data
315  view->setContext(context());
316 
318 
319  // set proxies have a window falg
320  int viewerBit = 1 << view->typeId();
321  if (m_views[view->typeId()].size() == 1) {
322  for (std::map<int, BuilderVec>::iterator i = m_builders.begin(); i != m_builders.end(); ++i) {
323  int builderViewBit = i->first;
324  BuilderVec& bv = i->second;
325  if (viewerBit == (builderViewBit & viewerBit)) {
326  for (BuilderVec_it bIt = bv.begin(); bIt != bv.end(); ++bIt) {
327  (*bIt)->setHaveWindow(true);
328  }
329  }
330  }
331  }
332 
333  FWRPZView* rpzView = dynamic_cast<FWRPZView*>(view.get());
334  for (std::map<int, BuilderVec>::iterator i = m_builders.begin(); i != m_builders.end(); ++i) {
335  int builderViewBit = i->first;
336  BuilderVec& bv = i->second;
337  if (viewerBit == (builderViewBit & viewerBit)) {
338  for (BuilderVec_it bIt = bv.begin(); bIt != bv.end(); ++bIt) {
339  // it is ok to call create even for shared productsm since
340  // builder map key garanties that
341  TEveElementList* product = (*bIt)->createProduct(view->typeId(), view->viewContext());
342 
343  if ((*bIt)->havePerViewProduct((FWViewType::EType)view->typeId())) {
344  // view owned
345  (*bIt)->build();
346  if (rpzView) {
347  rpzView->importElements(product, (*bIt)->item()->layer(), rpzView->ownedProducts());
348  } else {
349  view->ownedProducts()->AddElement(product);
350  }
351  } else {
352  // shared
353  if (rpzView) {
354  rpzView->importElements(product, (*bIt)->item()->layer(), rpzView->eventScene());
355  } else {
356  view->eventScene()->AddElement(product);
357  }
358  }
359  }
360  }
361  }
362 
363  view->beingDestroyed_.connect(std::bind(&FWEveViewManager::beingDestroyed, this, std::placeholders::_1));
364 
365  view->setupEnergyScale(); // notify PB for energy scale
366 
367  gEve->EnableRedraw();
368  view->viewerGL()->UpdateScene();
369  gEve->Redraw3D();
370 
371  return view.get();
372 }
373 
375  FWEveView* view = (FWEveView*)vb;
376  int typeId = view->typeId();
377 
378  int viewerBit = 1 << typeId;
379  int nviews = m_views[typeId].size();
380  for (std::map<int, BuilderVec>::iterator i = m_builders.begin(); i != m_builders.end(); ++i) {
381  int builderBit = i->first;
382  if (viewerBit == (builderBit & viewerBit)) // check only in case if connected
383  {
384  BuilderVec& bv = i->second;
385 
386  // remove view-owned product
387  if (viewerBit == (builderBit & viewerBit)) {
388  for (BuilderVec_it bIt = bv.begin(); bIt != bv.end(); ++bIt)
389  (*bIt)->removePerViewProduct(view->typeId(), view->viewContext());
390  }
391 
392  // and setup proxy builders have-a-window flag
393  if (nviews == 1) {
394  if (!haveViewForBit(builderBit)) {
395  if (viewerBit == (builderBit & viewerBit)) {
396  for (BuilderVec_it bIt = bv.begin(); bIt != bv.end(); ++bIt)
397  (*bIt)->setHaveWindow(false);
398  }
399  }
400  }
401  }
402  }
403 
404  for (EveViewVec_it i = m_views[typeId].begin(); i != m_views[typeId].end(); ++i) {
405  if (i->get() == vb) {
406  m_views[typeId].erase(i);
407  break;
408  }
409  }
410 }
411 
412 //______________________________________________________________________________
413 
414 void FWEveViewManager::modelChangesComing() { gEve->DisableRedraw(); }
415 
416 void FWEveViewManager::modelChangesDone() { gEve->EnableRedraw(); }
417 
420  FWModelId id = *(iIds.begin());
421  const FWEventItem* item = id.item();
422 
423  // in standard case new elements can be build in case of change of visibility
424  // and in non-standard case (e.g. calo towers) PB's modelChages handles all changes
425  bool itemHaveWindow = false;
426  for (std::map<int, BuilderVec>::iterator i = m_builders.begin(); i != m_builders.end(); ++i) {
427  for (size_t bi = 0, be = i->second.size(); bi != be; ++bi) {
428  FWProxyBuilderBase* builder = i->second[bi].get();
429  if (builder->getHaveWindow() && builder->item() == item) {
430  builder->modelChanges(iIds);
431  itemHaveWindow = true;
432  }
433  }
434  }
435 
436  if (!itemHaveWindow)
437  return;
438 
440 
441  std::map<const FWEventItem*, FWInteractionList*>::iterator it = m_interactionLists.find(item);
442  if (it != m_interactionLists.end()) {
443  if (!it->second->empty())
444  it->second->modelChanges(iIds);
445  }
446 }
447 
454  if (!item)
455  return;
456 
457  bool itemHaveWindow = false;
458 
459  for (std::map<int, BuilderVec>::iterator i = m_builders.begin(); i != m_builders.end(); ++i) {
460  for (size_t bi = 0, be = i->second.size(); bi != be; ++bi) {
461  FWProxyBuilderBase* builder = i->second[bi].get();
462 
463  if (builder->item() != item)
464  continue;
465 
466  builder->itemChanged(item);
467  itemHaveWindow |= builder->getHaveWindow();
468  }
469  }
470 
471  if (!itemHaveWindow)
472  return;
473 
474  std::map<const FWEventItem*, FWInteractionList*>::iterator it = m_interactionLists.find(item);
475  if (it != m_interactionLists.end()) {
476  if (!it->second->empty())
477  it->second->itemChanged();
478  }
479 }
480 
485 
486  std::map<const FWEventItem*, FWInteractionList*>::iterator it = m_interactionLists.find(item);
487  if (it != m_interactionLists.end()) {
488  delete it->second;
489  m_interactionLists.erase(it);
490  }
491 
492  for (std::map<int, BuilderVec>::iterator i = m_builders.begin(); i != m_builders.end(); ++i) {
493  BuilderVec_it bIt = i->second.begin();
494  while (bIt != i->second.end()) {
495  if ((*bIt)->item() == item) {
496  // TODO caching of proxy builders
497  (*bIt)->itemBeingDestroyed(item);
498  bIt = i->second.erase(bIt);
499  } else {
500  ++bIt;
501  }
502  }
503  }
504 }
505 
508  x->commonPrefs()->getEnergyScale()->parameterChanged_.connect(
510  x->commonPrefs()->eventCenterChanged_.connect(std::bind(&FWEveViewManager::eventCenterChanged, this));
511 }
512 
514  for (int t = 0; t < FWViewType::kTypeSize; ++t) {
515  for (EveViewVec_it i = m_views[t].begin(); i != m_views[t].end(); ++i) {
516  if ((*i)->isEnergyScaleGlobal()) {
517  (*i)->setupEnergyScale();
518  }
519  }
520  }
521 }
522 
524  for (int t = 0; t < FWViewType::kTypeSize; ++t) {
525  for (EveViewVec_it i = m_views[t].begin(); i != m_views[t].end(); ++i) {
526  (*i)->setupEventCenter();
527  }
528  }
529 }
530 
532  for (int t = 0; t < FWViewType::kTypeSize; ++t) {
533  for (EveViewVec_it i = m_views[t].begin(); i != m_views[t].end(); ++i)
534  (*i)->setBackgroundColor(colorManager().background());
535  }
536 }
537 
538 //______________________________________________________________________________
540  // Prevent registration of redraw timer, full redraw is done in
541  // FWEveViewManager::eventEnd().
542  gEve->EnforceTimerActive(kTRUE);
543  gEve->DisableRedraw();
544 
546 
547  for (int t = 0; t < FWViewType::kTypeSize; ++t) {
548  for (EveViewVec_it i = m_views[t].begin(); i != m_views[t].end(); ++i)
549  (*i)->eventBegin();
550  }
551 }
552 
554  for (int t = 0; t < FWViewType::kTypeSize; ++t) {
555  for (EveViewVec_it i = m_views[t].begin(); i != m_views[t].end(); ++i)
556  (*i)->eventEnd();
557  }
558 
559  // What follows is a copy of TEveManager::DoRedraw3D() with the difference that
560  // we have full control over execution of GL view rendering. In particular:
561  // - optionally delay buffer swapping so they can all be swapped together;
562  // - we could render into FBO once and then use this to be put on screen
563  // and saved into an image file.
564 
565  {
566  TEveElement::List_t scenes;
567  Long64_t key, value;
568  TExMapIter stamped_elements(gEve->PtrToStampedElements());
569  while (stamped_elements.Next(key, value)) {
570  TEveElement* el = reinterpret_cast<TEveElement*>(key);
571  if (el->GetChangeBits() & TEveElement::kCBVisibility) {
572  el->CollectSceneParents(scenes);
573  }
574  }
575  gEve->ScenesChanged(scenes);
576  }
577 
578  // Process changes in scenes.
579  gEve->GetScenes()->ProcessSceneChanges(kFALSE, gEve->PtrToStampedElements());
580 
581  // To synchronize buffer swapping set swap_on_render to false.
582  // Note that this costs 25-40% extra time with 4 views, depending on V-sync settings.
583  // Tested with NVIDIA 343.22.
584  const bool swap_on_render = !s_syncAllViews;
585 
586  // Loop over viewers, swap buffers if swap_on_render is true.
587  for (int t = 0; t < FWViewType::kTypeSize; ++t) {
588  for (EveViewVec_it i = m_views[t].begin(); i != m_views[t].end(); ++i)
589  (*i)->fwViewerGL()->DrawHiLod(swap_on_render);
590  }
591 
592  // Swap buffers if they were not swapped before.
593  if (!swap_on_render) {
594  for (int t = 0; t < FWViewType::kTypeSize; ++t) {
595  for (EveViewVec_it i = m_views[t].begin(); i != m_views[t].end(); ++i)
596  (*i)->fwViewerGL()->JustSwap();
597  }
598  }
599 
600  gEve->GetViewers()->RepaintChangedViewers(kFALSE, kFALSE);
601 
602  {
603  Long64_t key, value;
604  TExMapIter stamped_elements(gEve->PtrToStampedElements());
605  while (stamped_elements.Next(key, value)) {
606  TEveElement* el = reinterpret_cast<TEveElement*>(key);
607  if (gEve->GetEditor()->GetModel() == el->GetEditorObject("FWEveViewManager::eventEnd"))
608  gEve->EditElement(el);
609  TEveGedEditor::ElementChanged(el);
610 
611  el->ClearStamps();
612  }
613  }
614  gEve->PtrToStampedElements()->Delete();
615 
616  gEve->GetListTree()->ClearViewPort(); // Fix this when several list-trees can be added.
617 
618  gEve->EnableRedraw();
619  gEve->EnforceTimerActive(kFALSE);
620 }
621 
622 //______________________________________________________________________________
623 
626 FWFromEveSelectorBase* getSelector(TEveElement* iElement) {
627  if (!iElement)
628  return nullptr;
629 
630  //std::cout <<" non null"<<std::endl;
631  void* userData = iElement->GetUserData();
632  //std::cout <<" user data "<<userData<<std::endl;
633  if (!userData)
634  return nullptr;
635 
636  //std::cout <<" have userData"<<std::endl;
637  //std::cout <<" calo"<<std::endl;
639  return reinterpret_cast<FWFromEveSelectorBase*>(userData);
640 }
641 
642 void FWEveViewManager::selectionAdded(TEveElement* iElement) {
643  FWFromEveSelectorBase* selector = getSelector(iElement);
644  if (selector)
645  selector->doSelect();
646 }
647 
648 void FWEveViewManager::selectionRemoved(TEveElement* iElement) {
649  FWFromEveSelectorBase* selector = getSelector(iElement);
650  if (selector)
651  selector->doUnselect();
652 }
653 
655 
656 //
657 // const member functions
658 //
659 
661  // needed for add collection GUI
662  FWTypeToRepresentations returnValue;
663  const static std::string kFullFrameWorkPBExtension = "FullFramework";
664  for (TypeToBuilder::const_iterator it = m_typeToBuilder.begin(), itEnd = m_typeToBuilder.end(); it != itEnd; ++it) {
665  std::vector<BuilderInfo> blist = it->second;
666  for (size_t bii = 0, bie = blist.size(); bii != bie; ++bii) {
667  BuilderInfo& info = blist[bii];
668 
669  if (context().getHidePFBuilders()) {
670  const static std::string pfExt = "PF ";
671  if (std::string::npos != info.m_name.find(pfExt))
672  continue;
673  }
674 
675  unsigned int bitPackedViews = info.m_viewBit;
676  bool representsSubPart = (info.m_name.substr(info.m_name.find_first_of('@') - 1, 1) == "!");
677  size_t extp = info.m_name.rfind(kFullFrameWorkPBExtension);
678  bool FFOnly = (extp != std::string::npos);
679 
681  bool isSimple;
682  info.classType(name, isSimple);
683  if (isSimple) {
684  returnValue.add(std::make_shared<FWSimpleRepresentationChecker>(
685  name, it->first, bitPackedViews, representsSubPart, FFOnly));
686  } else {
687  returnValue.add(std::make_shared<FWEDProductRepresentationChecker>(
688  name, it->first, bitPackedViews, representsSubPart, FFOnly));
689  }
690  }
691  }
692  return returnValue;
693 }
694 
696 bool FWEveViewManager::haveViewForBit(int bit) const {
697  for (int t = 0; t < FWViewType::kTypeSize; ++t) {
698  if ((bit & (1 << t)) && !m_views[t].empty())
699  return true;
700  }
701  // printf("have %d view for bit %d \n", haveView, bit);
702  return false;
703 }
704 
706  const std::string kSimple("simple#");
707  simple = (m_name.substr(0, kSimple.size()) == kSimple);
708  if (simple) {
709  typeName = m_name.substr(kSimple.size(), m_name.find_first_of('@') - kSimple.size() - 1);
710  } else {
711  typeName = m_name.substr(0, m_name.find_first_of('@') - 1);
712  }
713 }
714 
715 /*
716 AMT: temporary workaround for using TEveCaloDataHist instead of
717 TEveCaloDataVec.
718 
719  */
720 
721 #include "TH2F.h"
722 #include "TAxis.h"
723 #include "TEveCaloData.h"
724 
725 void FWEveViewManager::highlightAdded(TEveElement* iElement) {
726  bool blocked = gEve->GetHighlight()->BlockSignals(true);
727 
728  if (iElement == context().getCaloData()) {
729  TEveCaloData::vCellId_t& hlist = context().getCaloData()->GetCellsHighlighted();
730  std::set<TEveCaloData::CellId_t> hset;
731 
732  int etaBin, phiBin, w, newPhiBin, tower;
733  TH2F* hist = context().getCaloData()->GetHist(0);
734  TAxis* etaAxis = hist->GetXaxis();
735  int nBinsX = etaAxis->GetNbins() + 2;
736 
737  for (TEveCaloData::vCellId_i i = hlist.begin(); i != hlist.end(); ++i) {
738  hist->GetBinXYZ((*i).fTower, etaBin, phiBin, w);
739  if (TMath::Abs(etaAxis->GetBinCenter(etaBin)) > 4.71475) {
740  newPhiBin = ((phiBin + 1) / 4) * 4 - 1;
741  if (newPhiBin <= 0)
742  newPhiBin = 71;
743 
744  tower = etaBin + newPhiBin * nBinsX;
745  hset.insert(TEveCaloData::CellId_t(tower, (*i).fSlice, (*i).fFraction));
746  tower += nBinsX;
747  hset.insert(TEveCaloData::CellId_t(tower, (*i).fSlice, (*i).fFraction));
748  tower += nBinsX;
749 
750  if (newPhiBin == 71)
751  tower = etaBin + 1 * nBinsX;
752 
753  hset.insert(TEveCaloData::CellId_t(tower, (*i).fSlice, (*i).fFraction));
754  tower += nBinsX;
755  hset.insert(TEveCaloData::CellId_t(tower, (*i).fSlice, (*i).fFraction));
756  } else if (TMath::Abs(etaAxis->GetBinCenter(etaBin)) > 1.747650) {
757  newPhiBin = ((phiBin + 1) / 2) * 2 - 1;
758  tower = etaBin + newPhiBin * nBinsX;
759  hset.insert(TEveCaloData::CellId_t(tower, (*i).fSlice, (*i).fFraction));
760  tower += nBinsX;
761  hset.insert(TEveCaloData::CellId_t(tower, (*i).fSlice, (*i).fFraction));
762  } else {
763  hset.insert(*i);
764  }
765  }
766 
767  // edit calo data list
768  hlist.clear();
769  for (std::set<TEveCaloData::CellId_t>::iterator it = hset.begin(); it != hset.end(); ++it) {
770  hlist.push_back(*it);
771  }
772  context().getCaloData()->CellSelectionChanged();
773  }
774 
775  gEve->GetHighlight()->BlockSignals(blocked);
776 }
const CategoryToInfos & categoryToInfos() const
Definition: PluginManager.h:82
size
Write out results.
FWSelectionManager * selectionManager() const
Definition: Context.h:54
std::vector< std::vector< std::shared_ptr< FWEveView > > > m_views
static const TGPicture * info(bool iBackgroundIsBlack)
TEveScene * eventScene()
Definition: FWEveView.h:79
void resetMaxEtAndEnergy() const
Definition: Context.cc:167
virtual void doUnselect()=0
std::vector< std::shared_ptr< FWEveView > >::iterator EveViewVec_it
void eventBegin() override
T w() const
FWColorManager & colorManager() const
void selectionAdded(TEveElement *)
void itemChanged(const FWEventItem *)
bool haveViewForBit(int) const
FWItemChangeSignal goingToBeDestroyed_
Definition: FWEventItem.h:197
void newItem(const FWEventItem *) override
TypeToBuilder m_typeToBuilder
Color_t background() const
TEveCaloDataHist * getCaloData() const
Definition: Context.h:69
assert(be >=bs)
uint16_t size_type
static bool s_syncAllViews
void add(std::shared_ptr< FWRepresentationCheckerBase > iChecker)
TGeoIterator Iterator
FWEveViewManager(FWGUIManager *)
void registerViewBuilder(const std::string &iName, ViewBuildFunctor &iBuilder)
bool getHidePFBuilders() const
Definition: Context.h:80
FWFromEveSelectorBase * getSelector(TEveElement *iElement)
static bool isProjected(int)
Definition: FWViewType.cc:100
const TClass * modelType() const
Definition: FWEventItem.cc:464
static bool inheritsFrom(const edm::TypeWithDict &iChild, const std::string &iParentTypeName, unsigned int &distance)
FWEveView * finishViewCreate(std::shared_ptr< FWEveView >)
~FWEveViewManager() override
virtual void setContext(const fireworks::Context *x)
std::set< FWModelId > FWModelIds
bool getHaveWindow() const
FWItemChangeSignal itemChanged_
Definition: FWEventItem.h:181
void addElements(const FWEventItem *item, FWEveView *view, int viewType, TEveElementList *product)
double f[11][100]
void selectionRemoved(TEveElement *)
void highlightAdded(TEveElement *)
void modelChanges(const FWModelIds &iIds)
void beingDestroyed(const FWViewBase *)
Definition: value.py:1
std::map< int, BuilderVec > m_builders
std::function< FWViewBase *(TEveWindowSlot *, const std::string &)> ViewBuildFunctor
Definition: FWGUIManager.h:98
FWViewBase * buildView(TEveWindowSlot *iParent, const std::string &type)
void setContext(const fireworks::Context *) override
__shared__ Hist hist
virtual void doSelect()=0
void classType(std::string &, bool &) const
#define fwLog(_level_)
Definition: fwLog.h:45
FWViewContext * viewContext()
Definition: FWEveView.h:83
const TClass * type() const
Definition: FWEventItem.cc:437
void colorsChanged() override
std::map< const FWEventItem *, FWInteractionList * > m_interactionLists
void importElements(TEveElement *iProjectableChild, float layer, TEveElement *iProjectedParent=nullptr)
Definition: FWRPZView.cc:285
BuilderVec::iterator BuilderVec_it
FWModelChangeSignal changed_
Definition: FWEventItem.h:178
std::vector< std::shared_ptr< FWProxyBuilderBase > > BuilderVec
static const std::string & idToName(int)
Definition: FWViewType.cc:72
std::string name_
Definition: PluginInfo.h:29
TEveElement * ownedProducts()
Definition: FWEveView.h:82
static Bool_t setColorSetViewer(TGLViewer *, Color_t)
float x
virtual void removeItem(const FWEventItem *)
const std::string & purpose() const
Definition: FWEventItem.cc:439
FWTypeToRepresentations supportedTypesAndRepresentations() const override
void eventEnd() override
#define get
FWViewType::EType typeId() const
Definition: FWViewBase.h:42
void modelChangesDone() override
static PluginManager * get()
const FWEventItem * item() const
void modelChangesComing() override
virtual void setContext(const fireworks::Context &x)
Definition: FWEveView.cc:227
def move(src, dest)
Definition: eostools.py:511
void itemChanged(const FWEventItem *)
FWColorManager * colorManager() const
Definition: Context.h:58
const fireworks::Context & context() const
void modelChanges(const FWModelIds &)
unsigned transform(const HcalDetId &id, unsigned transformCode)