CMS 3D CMS Logo

FWCaloDataProxyBuilderBase.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Calo
4 // Class : FWCaloDataProxyBuilderBase
5 //
6 // Implementation:
7 // [Notes on implementation]
8 //
9 // Original Author:
10 // Created: Mon May 31 15:09:39 CEST 2010
11 //
12 
13 // system include files
14 
15 #include <cmath>
16 
17 // user includes
18 #include "TEveCaloData.h"
19 #include "TEveCalo.h"
20 #include "TH2F.h"
21 #include "TEveManager.h"
22 #include "TEveSelection.h"
23 
26 
29 
31 
32 //
33 // constants, enums and typedefs
34 //
35 
36 //
37 // static data member definitions
38 //
39 
40 //
41 // constructors and destructor
42 //
44 
45 // FWCaloDataProxyBuilderBase::FWCaloDataProxyBuilderBase(const FWCaloDataProxyBuilderBase& rhs)
46 // {
47 // // do actual copying here;
48 // }
49 
51 
52 //
53 // assignment operators
54 //
55 // const FWCaloDataProxyBuilderBase& FWCaloDataProxyBuilderBase::operator=(const FWCaloDataProxyBuilderBase& rhs)
56 // {
57 // //An exception safe implementation is
58 // FWCaloDataProxyBuilderBase temp(rhs);
59 // swap(rhs);
60 //
61 // return *this;
62 // }
63 
64 //
65 // member functions
66 //
67 
68 void FWCaloDataProxyBuilderBase::build(const FWEventItem* iItem, TEveElementList*, const FWViewContext*) {
69  setCaloData(iItem->context());
70 
72  fillCaloData();
73 
74  m_caloData->SetSliceColor(m_sliceIndex, item()->defaultDisplayProperties().color());
75  m_caloData->SetSliceTransparency(m_sliceIndex, item()->defaultDisplayProperties().transparency());
76  m_caloData->DataChanged();
77  m_caloData->CellSelectionChanged();
78 }
79 
80 //______________________________________________________________________________
81 
83  if (m_caloData && item()) {
85  fillCaloData();
86 
87  TEveCaloData::vCellId_t& selected = m_caloData->GetCellsSelected();
88  if (!selected.empty()) {
89  if (0 == m_caloData->GetSelectedLevel()) {
90  gEve->GetSelection()->AddElement(m_caloData);
91  }
92  } else {
93  if (1 == m_caloData->GetSelectedLevel() || 2 == m_caloData->GetSelectedLevel()) {
94  gEve->GetSelection()->RemoveElement(m_caloData);
95  }
96  }
97 
98  m_caloData->SetSliceColor(m_sliceIndex, item()->defaultDisplayProperties().color());
99  m_caloData->SetSliceTransparency(m_sliceIndex, item()->defaultDisplayProperties().transparency());
100  m_caloData->DataChanged();
101  m_caloData->CellSelectionChanged();
102  }
103 }
104 //______________________________________________________________________________
105 
108  if (m_caloData) {
110  FWFromTEveCaloDataSelector* sel = reinterpret_cast<FWFromTEveCaloDataSelector*>(m_caloData->GetUserData());
112  m_caloData->DataChanged();
113  }
114 }
115 
117  //find all selected cell ids which are not from this FWEventItem and preserve only them
118  // do this by moving them to the end of the list and then clearing only the end of the list
119  // this avoids needing any additional memory
120 
121  TEveCaloData::vCellId_t& selected = m_caloData->GetCellsSelected();
122 
123  TEveCaloData::vCellId_t::iterator itEnd = selected.end();
124  for (TEveCaloData::vCellId_t::iterator it = selected.begin(); it != itEnd; ++it) {
125  if (it->fSlice == m_sliceIndex) {
126  //we have found one we want to get rid of, so we swap it with the
127  // one closest to the end which is not of this slice
128  do {
129  TEveCaloData::vCellId_t::iterator itLast = itEnd - 1;
130  itEnd = itLast;
131  } while (itEnd != it && itEnd->fSlice == m_sliceIndex);
132 
133  if (itEnd != it) {
134  std::swap(*it, *itEnd);
135  } else {
136  //shouldn't go on since advancing 'it' will put us past itEnd
137  break;
138  }
139  //std::cout <<"keeping "<<it->fTower<<" "<<it->fSlice<<std::endl;
140  }
141  }
142  selected.erase(itEnd, selected.end());
143 
144  // reset higlight
145  m_caloData->GetCellsHighlighted().clear();
146 }
virtual void itemBeingDestroyed(const FWEventItem *)
#define nullptr
const FWEventItem * item() const
std::set< FWModelId > FWModelIds
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
void itemBeingDestroyed(const FWEventItem *) override
const fireworks::Context & context() const
Definition: FWEventItem.h:121
virtual bool assertCaloDataSlice()=0
virtual void setCaloData(const fireworks::Context &)=0
void modelChanges(const FWModelIds &, Product *) override
virtual void fillCaloData()=0