CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/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.12 2010/06/07 17:54:00 amraktad Exp $
00012 //
00013 
00014 // system include files
00015 #include <boost/bind.hpp>
00016 #include <algorithm>
00017 
00018 // user include files
00019 #include "Fireworks/Calo/src/FWFromTEveCaloDataSelector.h"
00020 #include "Fireworks/Core/interface/FWModelChangeManager.h"
00021 #include "Fireworks/Core/interface/FWEventItem.h"
00022 
00023 
00024 //
00025 // static data member definitions
00026 //
00027 
00028 //
00029 // constructors and destructor
00030 //
00031 FWFromTEveCaloDataSelector::FWFromTEveCaloDataSelector(TEveCaloData* iData):
00032 m_data(iData),
00033 m_changeManager(0)
00034 {                       
00035    // reserve 3 , first slice is background
00036    m_sliceSelectors.reserve(3);
00037    m_sliceSelectors.push_back(new FWFromSliceSelector(0));
00038 }
00039 
00040 // FWFromTEveCaloDataSelector::FWFromTEveCaloDataSelector(const FWFromTEveCaloDataSelector& rhs)
00041 // {
00042 //    // do actual copying here;
00043 // }
00044 
00045 FWFromTEveCaloDataSelector::~FWFromTEveCaloDataSelector()
00046 {
00047    for (std::vector<FWFromSliceSelector*>::iterator i = m_sliceSelectors.begin(); i != m_sliceSelectors.end(); ++i)
00048    {
00049       delete *i;
00050    }
00051    m_sliceSelectors.clear();
00052 }
00053 
00054 //
00055 // assignment operators
00056 //
00057 // const FWFromTEveCaloDataSelector& FWFromTEveCaloDataSelector::operator=(const FWFromTEveCaloDataSelector& rhs)
00058 // {
00059 //   //An exception safe implementation is
00060 //   FWFromTEveCaloDataSelector temp(rhs);
00061 //   swap(rhs);
00062 //
00063 //   return *this;
00064 // }
00065 
00066 //
00067 // member functions
00068 //
00069 void 
00070 FWFromTEveCaloDataSelector::doSelect()
00071 {
00072    assert(m_changeManager);
00073    FWChangeSentry sentry(*m_changeManager);
00074    std::for_each(m_sliceSelectors.begin(),
00075                  m_sliceSelectors.end(),
00076                  boost::bind(&FWFromSliceSelector::clear,_1));
00077    const TEveCaloData::vCellId_t& cellIds = m_data->GetCellsSelected();
00078    for(TEveCaloData::vCellId_t::const_iterator it = cellIds.begin(),itEnd=cellIds.end();
00079        it != itEnd;
00080        ++it) {
00081       assert(it->fSlice < static_cast<int>(m_sliceSelectors.size()));
00082       m_sliceSelectors[it->fSlice]->doSelect(*it);
00083    }
00084 }
00085 
00086 void 
00087 FWFromTEveCaloDataSelector::doUnselect()
00088 {
00089    assert(m_changeManager);
00090    //std::cout <<"FWFromTEveCaloDataSelector::doUnselect()"<<std::endl;
00091    
00092    FWChangeSentry sentry(*m_changeManager);
00093    const TEveCaloData::vCellId_t& cellIds = m_data->GetCellsSelected();
00094    for(TEveCaloData::vCellId_t::const_iterator it = cellIds.begin(),itEnd=cellIds.end();
00095        it != itEnd;
00096        ++it) {
00097       assert(it->fSlice < static_cast<int>(m_sliceSelectors.size()));
00098       m_sliceSelectors[it->fSlice]->doUnselect(*it);
00099    }
00100 }
00101 
00102 void 
00103 FWFromTEveCaloDataSelector::addSliceSelector(int iSlice, FWFromSliceSelector* iSelector)
00104 {
00105    assert(iSlice>0 && (iSlice <= static_cast<int>(m_sliceSelectors.size())));
00106 
00107    if(0==m_changeManager) {
00108       m_changeManager = iSelector->changeManager();
00109    }
00110 
00111    if(iSlice ==static_cast<int>(m_sliceSelectors.size())) {
00112       m_sliceSelectors.push_back(iSelector);
00113    } else {
00114       assert(iSlice<static_cast<int>(m_sliceSelectors.size()));
00115       m_sliceSelectors[iSlice]=iSelector;
00116    }
00117 }
00118 
00119 void 
00120 FWFromTEveCaloDataSelector::resetSliceSelector(int iSlice)
00121 {
00122    m_sliceSelectors[iSlice]->reset();
00123 }
00124 //
00125 // const member functions
00126 //
00127 
00128 //
00129 // static member functions
00130 //