CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 // $Id: FWFromTEveCaloDataSelector.cc,v 1.13 2012/09/20 20:09:10 eulisse Exp $
12 //
13 
14 // system include files
15 #include <boost/bind.hpp>
16 #include <algorithm>
17 #include <cassert>
18 
19 // user include files
23 
24 
25 //
26 // static data member definitions
27 //
28 
29 //
30 // constructors and destructor
31 //
33 m_data(iData),
34 m_changeManager(0)
35 {
36  // reserve 3 , first slice is background
37  m_sliceSelectors.reserve(3);
38  m_sliceSelectors.push_back(new FWFromSliceSelector(0));
39 }
40 
41 // FWFromTEveCaloDataSelector::FWFromTEveCaloDataSelector(const FWFromTEveCaloDataSelector& rhs)
42 // {
43 // // do actual copying here;
44 // }
45 
47 {
48  for (std::vector<FWFromSliceSelector*>::iterator i = m_sliceSelectors.begin(); i != m_sliceSelectors.end(); ++i)
49  {
50  delete *i;
51  }
52  m_sliceSelectors.clear();
53 }
54 
55 //
56 // assignment operators
57 //
58 // const FWFromTEveCaloDataSelector& FWFromTEveCaloDataSelector::operator=(const FWFromTEveCaloDataSelector& rhs)
59 // {
60 // //An exception safe implementation is
61 // FWFromTEveCaloDataSelector temp(rhs);
62 // swap(rhs);
63 //
64 // return *this;
65 // }
66 
67 //
68 // member functions
69 //
70 void
72 {
73  assert(m_changeManager);
75  std::for_each(m_sliceSelectors.begin(),
76  m_sliceSelectors.end(),
77  boost::bind(&FWFromSliceSelector::clear,_1));
78  const TEveCaloData::vCellId_t& cellIds = m_data->GetCellsSelected();
79  for(TEveCaloData::vCellId_t::const_iterator it = cellIds.begin(),itEnd=cellIds.end();
80  it != itEnd;
81  ++it) {
82  assert(it->fSlice < static_cast<int>(m_sliceSelectors.size()));
83  m_sliceSelectors[it->fSlice]->doSelect(*it);
84  }
85 }
86 
87 void
89 {
90  assert(m_changeManager);
91  //std::cout <<"FWFromTEveCaloDataSelector::doUnselect()"<<std::endl;
92 
94  const TEveCaloData::vCellId_t& cellIds = m_data->GetCellsSelected();
95  for(TEveCaloData::vCellId_t::const_iterator it = cellIds.begin(),itEnd=cellIds.end();
96  it != itEnd;
97  ++it) {
98  assert(it->fSlice < static_cast<int>(m_sliceSelectors.size()));
99  m_sliceSelectors[it->fSlice]->doUnselect(*it);
100  }
101 }
102 
103 void
105 {
106  assert(iSlice>0 && (iSlice <= static_cast<int>(m_sliceSelectors.size())));
107 
108  if(0==m_changeManager) {
109  m_changeManager = iSelector->changeManager();
110  }
111 
112  if(iSlice ==static_cast<int>(m_sliceSelectors.size())) {
113  m_sliceSelectors.push_back(iSelector);
114  } else {
115  assert(iSlice<static_cast<int>(m_sliceSelectors.size()));
116  m_sliceSelectors[iSlice]=iSelector;
117  }
118 }
119 
120 void
122 {
123  m_sliceSelectors[iSlice]->reset();
124 }
125 //
126 // const member functions
127 //
128 
129 //
130 // static member functions
131 //
int i
Definition: DBlmapReader.cc:9
void addSliceSelector(int iSlice, FWFromSliceSelector *)
FWModelChangeManager * m_changeManager
FWModelChangeManager * changeManager() const
std::vector< FWFromSliceSelector * > m_sliceSelectors