CMS 3D CMS Logo

FWFromTEveCaloDataSelector.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Calo
4 // Class : FWFromTEveCaloDataSelector
5 //
6 // Implementation:
7 // [Notes on implementation]
8 //
9 // Original Author: Chris Jones
10 // Created: Fri Oct 23 14:44:33 CDT 2009
11 //
12 
13 // system include files
14 #include <boost/bind.hpp>
15 #include <algorithm>
16 #include <cassert>
17 
18 // user include files
22 
23 //
24 // static data member definitions
25 //
26 
27 //
28 // constructors and destructor
29 //
30 FWFromTEveCaloDataSelector::FWFromTEveCaloDataSelector(TEveCaloData* iData) : m_data(iData), m_changeManager(nullptr) {
31  // reserve 3 , first slice is background
32  m_sliceSelectors.reserve(3);
33  m_sliceSelectors.push_back(new FWFromSliceSelector(nullptr));
34 }
35 
36 // FWFromTEveCaloDataSelector::FWFromTEveCaloDataSelector(const FWFromTEveCaloDataSelector& rhs)
37 // {
38 // // do actual copying here;
39 // }
40 
42  for (std::vector<FWFromSliceSelector*>::iterator i = m_sliceSelectors.begin(); i != m_sliceSelectors.end(); ++i) {
43  delete *i;
44  }
45  m_sliceSelectors.clear();
46 }
47 
48 //
49 // assignment operators
50 //
51 // const FWFromTEveCaloDataSelector& FWFromTEveCaloDataSelector::operator=(const FWFromTEveCaloDataSelector& rhs)
52 // {
53 // //An exception safe implementation is
54 // FWFromTEveCaloDataSelector temp(rhs);
55 // swap(rhs);
56 //
57 // return *this;
58 // }
59 
60 //
61 // member functions
62 //
64  assert(m_changeManager);
66  std::for_each(m_sliceSelectors.begin(), m_sliceSelectors.end(), boost::bind(&FWFromSliceSelector::clear, _1));
67  const TEveCaloData::vCellId_t& cellIds = m_data->GetCellsSelected();
68  for (TEveCaloData::vCellId_t::const_iterator it = cellIds.begin(), itEnd = cellIds.end(); it != itEnd; ++it) {
69  assert(it->fSlice < static_cast<int>(m_sliceSelectors.size()));
70  m_sliceSelectors[it->fSlice]->doSelect(*it);
71  }
72 }
73 
75  assert(m_changeManager);
76  //std::cout <<"FWFromTEveCaloDataSelector::doUnselect()"<<std::endl;
77 
79  const TEveCaloData::vCellId_t& cellIds = m_data->GetCellsSelected();
80  for (TEveCaloData::vCellId_t::const_iterator it = cellIds.begin(), itEnd = cellIds.end(); it != itEnd; ++it) {
81  assert(it->fSlice < static_cast<int>(m_sliceSelectors.size()));
82  m_sliceSelectors[it->fSlice]->doUnselect(*it);
83  }
84 }
85 
87  assert(iSlice > 0 && (iSlice <= static_cast<int>(m_sliceSelectors.size())));
88 
89  if (nullptr == m_changeManager) {
90  m_changeManager = iSelector->changeManager();
91  }
92 
93  if (iSlice == static_cast<int>(m_sliceSelectors.size())) {
94  m_sliceSelectors.push_back(iSelector);
95  } else {
96  assert(iSlice < static_cast<int>(m_sliceSelectors.size()));
97  m_sliceSelectors[iSlice] = iSelector;
98  }
99 }
100 
102 //
103 // const member functions
104 //
105 
106 //
107 // static member functions
108 //
#define nullptr
void addSliceSelector(int iSlice, FWFromSliceSelector *)
FWModelChangeManager * m_changeManager
FWModelChangeManager * changeManager() const
std::vector< FWFromSliceSelector * > m_sliceSelectors