File indexing completed on 2024-04-06 12:11:29
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #include <algorithm>
0015 #include <cassert>
0016 #include <functional>
0017
0018
0019 #include "Fireworks/Calo/interface/FWFromTEveCaloDataSelector.h"
0020 #include "Fireworks/Core/interface/FWModelChangeManager.h"
0021 #include "Fireworks/Core/interface/FWEventItem.h"
0022
0023
0024
0025
0026
0027
0028
0029
0030 FWFromTEveCaloDataSelector::FWFromTEveCaloDataSelector(TEveCaloData* iData) : m_data(iData), m_changeManager(nullptr) {
0031
0032 m_sliceSelectors.reserve(3);
0033 m_sliceSelectors.push_back(new FWFromSliceSelector(nullptr));
0034 }
0035
0036
0037
0038
0039
0040
0041 FWFromTEveCaloDataSelector::~FWFromTEveCaloDataSelector() {
0042 for (std::vector<FWFromSliceSelector*>::iterator i = m_sliceSelectors.begin(); i != m_sliceSelectors.end(); ++i) {
0043 delete *i;
0044 }
0045 m_sliceSelectors.clear();
0046 }
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063 void FWFromTEveCaloDataSelector::doSelect() {
0064 assert(m_changeManager);
0065 FWChangeSentry sentry(*m_changeManager);
0066 std::for_each(
0067 m_sliceSelectors.begin(), m_sliceSelectors.end(), std::bind(&FWFromSliceSelector::clear, std::placeholders::_1));
0068 const TEveCaloData::vCellId_t& cellIds = m_data->GetCellsSelected();
0069 for (TEveCaloData::vCellId_t::const_iterator it = cellIds.begin(), itEnd = cellIds.end(); it != itEnd; ++it) {
0070 assert(it->fSlice < static_cast<int>(m_sliceSelectors.size()));
0071 m_sliceSelectors[it->fSlice]->doSelect(*it);
0072 }
0073 }
0074
0075 void FWFromTEveCaloDataSelector::doUnselect() {
0076 assert(m_changeManager);
0077
0078
0079 FWChangeSentry sentry(*m_changeManager);
0080 const TEveCaloData::vCellId_t& cellIds = m_data->GetCellsSelected();
0081 for (TEveCaloData::vCellId_t::const_iterator it = cellIds.begin(), itEnd = cellIds.end(); it != itEnd; ++it) {
0082 assert(it->fSlice < static_cast<int>(m_sliceSelectors.size()));
0083 m_sliceSelectors[it->fSlice]->doUnselect(*it);
0084 }
0085 }
0086
0087 void FWFromTEveCaloDataSelector::addSliceSelector(int iSlice, FWFromSliceSelector* iSelector) {
0088 assert(iSlice > 0 && (iSlice <= static_cast<int>(m_sliceSelectors.size())));
0089
0090 if (nullptr == m_changeManager) {
0091 m_changeManager = iSelector->changeManager();
0092 }
0093
0094 if (iSlice == static_cast<int>(m_sliceSelectors.size())) {
0095 m_sliceSelectors.push_back(iSelector);
0096 } else {
0097 assert(iSlice < static_cast<int>(m_sliceSelectors.size()));
0098 m_sliceSelectors[iSlice] = iSelector;
0099 }
0100 }
0101
0102 void FWFromTEveCaloDataSelector::resetSliceSelector(int iSlice) { m_sliceSelectors[iSlice]->reset(); }
0103
0104
0105
0106
0107
0108
0109