CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/Fireworks/Calo/src/FWFromTEveCaloDataSelector.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     Calo
00004 // Class  :     FWFromTEveCaloDataSelector
00005 // 
00006 // Implementation:
00007 //     [Notes on implementation]
00008 //
00009 // Original Author:  Chris Jones
00010 //         Created:  Fri Oct 23 14:44:33 CDT 2009
00011 // $Id: FWFromTEveCaloDataSelector.cc,v 1.13 2012/09/20 20:09:10 eulisse Exp $
00012 //
00013 
00014 // system include files
00015 #include <boost/bind.hpp>
00016 #include <algorithm>
00017 #include <cassert>
00018 
00019 // user include files
00020 #include "Fireworks/Calo/src/FWFromTEveCaloDataSelector.h"
00021 #include "Fireworks/Core/interface/FWModelChangeManager.h"
00022 #include "Fireworks/Core/interface/FWEventItem.h"
00023 
00024 
00025 //
00026 // static data member definitions
00027 //
00028 
00029 //
00030 // constructors and destructor
00031 //
00032 FWFromTEveCaloDataSelector::FWFromTEveCaloDataSelector(TEveCaloData* iData):
00033 m_data(iData),
00034 m_changeManager(0)
00035 {                       
00036    // reserve 3 , first slice is background
00037    m_sliceSelectors.reserve(3);
00038    m_sliceSelectors.push_back(new FWFromSliceSelector(0));
00039 }
00040 
00041 // FWFromTEveCaloDataSelector::FWFromTEveCaloDataSelector(const FWFromTEveCaloDataSelector& rhs)
00042 // {
00043 //    // do actual copying here;
00044 // }
00045 
00046 FWFromTEveCaloDataSelector::~FWFromTEveCaloDataSelector()
00047 {
00048    for (std::vector<FWFromSliceSelector*>::iterator i = m_sliceSelectors.begin(); i != m_sliceSelectors.end(); ++i)
00049    {
00050       delete *i;
00051    }
00052    m_sliceSelectors.clear();
00053 }
00054 
00055 //
00056 // assignment operators
00057 //
00058 // const FWFromTEveCaloDataSelector& FWFromTEveCaloDataSelector::operator=(const FWFromTEveCaloDataSelector& rhs)
00059 // {
00060 //   //An exception safe implementation is
00061 //   FWFromTEveCaloDataSelector temp(rhs);
00062 //   swap(rhs);
00063 //
00064 //   return *this;
00065 // }
00066 
00067 //
00068 // member functions
00069 //
00070 void 
00071 FWFromTEveCaloDataSelector::doSelect()
00072 {
00073    assert(m_changeManager);
00074    FWChangeSentry sentry(*m_changeManager);
00075    std::for_each(m_sliceSelectors.begin(),
00076                  m_sliceSelectors.end(),
00077                  boost::bind(&FWFromSliceSelector::clear,_1));
00078    const TEveCaloData::vCellId_t& cellIds = m_data->GetCellsSelected();
00079    for(TEveCaloData::vCellId_t::const_iterator it = cellIds.begin(),itEnd=cellIds.end();
00080        it != itEnd;
00081        ++it) {
00082       assert(it->fSlice < static_cast<int>(m_sliceSelectors.size()));
00083       m_sliceSelectors[it->fSlice]->doSelect(*it);
00084    }
00085 }
00086 
00087 void 
00088 FWFromTEveCaloDataSelector::doUnselect()
00089 {
00090    assert(m_changeManager);
00091    //std::cout <<"FWFromTEveCaloDataSelector::doUnselect()"<<std::endl;
00092    
00093    FWChangeSentry sentry(*m_changeManager);
00094    const TEveCaloData::vCellId_t& cellIds = m_data->GetCellsSelected();
00095    for(TEveCaloData::vCellId_t::const_iterator it = cellIds.begin(),itEnd=cellIds.end();
00096        it != itEnd;
00097        ++it) {
00098       assert(it->fSlice < static_cast<int>(m_sliceSelectors.size()));
00099       m_sliceSelectors[it->fSlice]->doUnselect(*it);
00100    }
00101 }
00102 
00103 void 
00104 FWFromTEveCaloDataSelector::addSliceSelector(int iSlice, FWFromSliceSelector* iSelector)
00105 {
00106    assert(iSlice>0 && (iSlice <= static_cast<int>(m_sliceSelectors.size())));
00107 
00108    if(0==m_changeManager) {
00109       m_changeManager = iSelector->changeManager();
00110    }
00111 
00112    if(iSlice ==static_cast<int>(m_sliceSelectors.size())) {
00113       m_sliceSelectors.push_back(iSelector);
00114    } else {
00115       assert(iSlice<static_cast<int>(m_sliceSelectors.size()));
00116       m_sliceSelectors[iSlice]=iSelector;
00117    }
00118 }
00119 
00120 void 
00121 FWFromTEveCaloDataSelector::resetSliceSelector(int iSlice)
00122 {
00123    m_sliceSelectors[iSlice]->reset();
00124 }
00125 //
00126 // const member functions
00127 //
00128 
00129 //
00130 // static member functions
00131 //