CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 <algorithm>
15 #include <cassert>
16 #include <functional>
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 //
66  std::for_each(
67  m_sliceSelectors.begin(), m_sliceSelectors.end(), std::bind(&FWFromSliceSelector::clear, std::placeholders::_1));
68  const TEveCaloData::vCellId_t& cellIds = m_data->GetCellsSelected();
69  for (TEveCaloData::vCellId_t::const_iterator it = cellIds.begin(), itEnd = cellIds.end(); it != itEnd; ++it) {
70  assert(it->fSlice < static_cast<int>(m_sliceSelectors.size()));
71  m_sliceSelectors[it->fSlice]->doSelect(*it);
72  }
73 }
74 
77  //std::cout <<"FWFromTEveCaloDataSelector::doUnselect()"<<std::endl;
78 
80  const TEveCaloData::vCellId_t& cellIds = m_data->GetCellsSelected();
81  for (TEveCaloData::vCellId_t::const_iterator it = cellIds.begin(), itEnd = cellIds.end(); it != itEnd; ++it) {
82  assert(it->fSlice < static_cast<int>(m_sliceSelectors.size()));
83  m_sliceSelectors[it->fSlice]->doUnselect(*it);
84  }
85 }
86 
88  assert(iSlice > 0 && (iSlice <= static_cast<int>(m_sliceSelectors.size())));
89 
90  if (nullptr == m_changeManager) {
91  m_changeManager = iSelector->changeManager();
92  }
93 
94  if (iSlice == static_cast<int>(m_sliceSelectors.size())) {
95  m_sliceSelectors.push_back(iSelector);
96  } else {
97  assert(iSlice < static_cast<int>(m_sliceSelectors.size()));
98  m_sliceSelectors[iSlice] = iSelector;
99  }
100 }
101 
103 //
104 // const member functions
105 //
106 
107 //
108 // static member functions
109 //
assert(be >=bs)
void addSliceSelector(int iSlice, FWFromSliceSelector *)
FWModelChangeManager * m_changeManager
FWModelChangeManager * changeManager() const
std::vector< FWFromSliceSelector * > m_sliceSelectors