test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 <math.h>
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 //
34 // constants, enums and typedefs
35 //
36 
37 //
38 // static data member definitions
39 //
40 
41 //
42 // constructors and destructor
43 //
45  m_caloData(0),
46  m_sliceIndex(-1)
47 {
48 }
49 
50 // FWCaloDataProxyBuilderBase::FWCaloDataProxyBuilderBase(const FWCaloDataProxyBuilderBase& rhs)
51 // {
52 // // do actual copying here;
53 // }
54 
56 {
57 }
58 
59 //
60 // assignment operators
61 //
62 // const FWCaloDataProxyBuilderBase& FWCaloDataProxyBuilderBase::operator=(const FWCaloDataProxyBuilderBase& rhs)
63 // {
64 // //An exception safe implementation is
65 // FWCaloDataProxyBuilderBase temp(rhs);
66 // swap(rhs);
67 //
68 // return *this;
69 // }
70 
71 //
72 // member functions
73 //
74 
75 void
77  TEveElementList*, const FWViewContext*)
78 {
79  setCaloData(iItem->context());
80 
82  fillCaloData();
83 
84  m_caloData->SetSliceColor(m_sliceIndex,item()->defaultDisplayProperties().color());
85  m_caloData->SetSliceTransparency(m_sliceIndex,item()->defaultDisplayProperties().transparency());
86  m_caloData->DataChanged();
87  m_caloData->CellSelectionChanged();
88 }
89 
90 //______________________________________________________________________________
91 
92 void
94 {
95  if(m_caloData && item())
96  {
98  fillCaloData();
99 
100  TEveCaloData::vCellId_t& selected = m_caloData->GetCellsSelected();
101  if(!selected.empty()) {
102  if(0==m_caloData->GetSelectedLevel()) {
103  gEve->GetSelection()->AddElement(m_caloData);
104  }
105  } else {
106  if(1==m_caloData->GetSelectedLevel()||2==m_caloData->GetSelectedLevel()) {
107  gEve->GetSelection()->RemoveElement(m_caloData);
108  }
109  }
110 
111  m_caloData->SetSliceColor(m_sliceIndex,item()->defaultDisplayProperties().color());
112  m_caloData->SetSliceTransparency(m_sliceIndex,item()->defaultDisplayProperties().transparency());
113  m_caloData->DataChanged();
114  m_caloData->CellSelectionChanged();
115  }
116 }
117 //______________________________________________________________________________
118 
119 void
121 {
123  if (m_caloData)
124  {
126  FWFromTEveCaloDataSelector* sel = reinterpret_cast<FWFromTEveCaloDataSelector*>(m_caloData->GetUserData());
128  m_caloData->DataChanged();
129  }
130 }
131 
132 
133 
134 void
136 {
137  //find all selected cell ids which are not from this FWEventItem and preserve only them
138  // do this by moving them to the end of the list and then clearing only the end of the list
139  // this avoids needing any additional memory
140 
141  TEveCaloData::vCellId_t& selected = m_caloData->GetCellsSelected();
142 
143  TEveCaloData::vCellId_t::iterator itEnd = selected.end();
144  for(TEveCaloData::vCellId_t::iterator it = selected.begin();
145  it != itEnd;
146  ++it) {
147  if(it->fSlice ==m_sliceIndex) {
148  //we have found one we want to get rid of, so we swap it with the
149  // one closest to the end which is not of this slice
150  do {
151  TEveCaloData::vCellId_t::iterator itLast = itEnd-1;
152  itEnd = itLast;
153  } while (itEnd != it && itEnd->fSlice==m_sliceIndex);
154 
155  if(itEnd != it) {
156  std::swap(*it,*itEnd);
157  } else {
158  //shouldn't go on since advancing 'it' will put us past itEnd
159  break;
160  }
161  //std::cout <<"keeping "<<it->fTower<<" "<<it->fSlice<<std::endl;
162  }
163  }
164  selected.erase(itEnd,selected.end());
165 
166 
167  // reset higlight
168  m_caloData->GetCellsHighlighted().clear();
169 }
virtual void itemBeingDestroyed(const FWEventItem *)
const FWEventItem * item() const
std::set< FWModelId > FWModelIds
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
const fireworks::Context & context() const
Definition: FWEventItem.h:128
virtual bool assertCaloDataSlice()=0
virtual void setCaloData(const fireworks::Context &)=0
virtual void modelChanges(const FWModelIds &, Product *)
virtual void itemBeingDestroyed(const FWEventItem *)
virtual void fillCaloData()=0