CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

FWCaloTowerSliceSelector Class Reference

#include <Fireworks/Calo/interface/FWCaloTowerSliceSelector.h>

Inheritance diagram for FWCaloTowerSliceSelector:
FWFromSliceSelector

List of all members.

Public Member Functions

virtual void doSelect (const TEveCaloData::CellId_t &)
virtual void doUnselect (const TEveCaloData::CellId_t &)
 FWCaloTowerSliceSelector (TH2F *h, const FWEventItem *i)
virtual ~FWCaloTowerSliceSelector ()

Private Member Functions

bool matchCell (const TEveCaloData::CellId_t &iCell, const CaloTower &tower) const

Private Attributes

TH2F * m_hist

Detailed Description

Description: [one line class summary]

Usage: <usage>

Definition at line 31 of file FWCaloTowerSliceSelector.h.


Constructor & Destructor Documentation

FWCaloTowerSliceSelector::FWCaloTowerSliceSelector ( TH2F *  h,
const FWEventItem i 
)

Definition at line 26 of file FWCaloTowerSliceSelector.cc.

FWCaloTowerSliceSelector::~FWCaloTowerSliceSelector ( ) [virtual]

Definition at line 32 of file FWCaloTowerSliceSelector.cc.

{
}

Member Function Documentation

void FWCaloTowerSliceSelector::doSelect ( const TEveCaloData::CellId_t &  iCell) [virtual]

Reimplemented from FWFromSliceSelector.

Definition at line 84 of file FWCaloTowerSliceSelector.cc.

References edm::SortedCollection< T, SORT >::begin(), FWEventItem::changeManager(), edm::SortedCollection< T, SORT >::end(), FWEventItem::get(), getHLTprescales::index, FWFromSliceSelector::m_item, matchCell(), FWEventItem::modelInfo(), and FWEventItem::select().

{
   if (!m_item) return;

   const CaloTowerCollection* towers=0;
   m_item->get(towers);
   assert(0!=towers);
   int index = 0;

   FWChangeSentry sentry(*(m_item->changeManager()));
   for(CaloTowerCollection::const_iterator tower = towers->begin(); tower != towers->end(); ++tower,++index)
   {
      if (m_item->modelInfo(index).m_displayProperties.isVisible() && !m_item->modelInfo(index).isSelected())
      {
         if (matchCell(iCell, *tower))
         {
            m_item->select(index);
            break;
         }
      }
   }
}
void FWCaloTowerSliceSelector::doUnselect ( const TEveCaloData::CellId_t &  iCell) [virtual]

Reimplemented from FWFromSliceSelector.

Definition at line 108 of file FWCaloTowerSliceSelector.cc.

References edm::SortedCollection< T, SORT >::begin(), FWEventItem::changeManager(), edm::SortedCollection< T, SORT >::end(), FWEventItem::get(), getHLTprescales::index, FWFromSliceSelector::m_item, matchCell(), FWEventItem::modelInfo(), and FWEventItem::unselect().

{
   if (!m_item) return;
  
   //  std::cout <<"  doUnselect "<<std::endl;

   const CaloTowerCollection* towers=0;
   m_item->get(towers);
   assert(0!=towers);
   int index = 0;
   FWChangeSentry sentry(*(m_item->changeManager()));
   for(CaloTowerCollection::const_iterator tower = towers->begin(); tower != towers->end(); ++tower,++index)
   {
      if ( m_item->modelInfo(index).m_displayProperties.isVisible() &&
           m_item->modelInfo(index).isSelected()) {
         if (matchCell(iCell, *tower))
         {
            //  std::cout <<"  doUnselect "<<index<<std::endl;
            m_item->unselect(index);
            break;
         }
      }
   }
}
bool FWCaloTowerSliceSelector::matchCell ( const TEveCaloData::CellId_t &  iCell,
const CaloTower tower 
) const [private]

Definition at line 42 of file FWCaloTowerSliceSelector.cc.

References reco::LeafCandidate::eta(), ExpressReco_HICollisions_FallBack::etaBin, CaloTower::ietaAbs(), m_hist, match(), reco::LeafCandidate::phi(), and ExpressReco_HICollisions_FallBack::phiBin.

Referenced by doSelect(), and doUnselect().

{
   bool match = false;
   int idx = m_hist->FindBin(tower.eta(), tower.phi());
   int nBinsX = m_hist->GetXaxis()->GetNbins() + 2;

   int etaBin, phiBin, w, newPhiBin;
   m_hist->GetBinXYZ(idx, etaBin, phiBin, w);

   if (tower.ietaAbs() > 39)
   {
      newPhiBin =  ((phiBin + 1) / 4) * 4 - 1;
      if (newPhiBin <= 0) newPhiBin = 71;

      idx = etaBin + newPhiBin*nBinsX;
      match |= (idx == iCell.fTower);

      idx += nBinsX;
      match |= (idx == iCell.fTower);

      idx += nBinsX;
      if (newPhiBin == 71)
         idx = etaBin + 1*nBinsX;
      match |= (idx == iCell.fTower);

      idx += nBinsX;
      match |= (idx == iCell.fTower);
   } 
   else if (tower.ietaAbs() > 20)
   {
      newPhiBin =  ((phiBin  + 1) / 2) * 2 -1;
      idx = etaBin + newPhiBin*nBinsX;
      match = ( idx == iCell.fTower ||  idx + nBinsX == iCell.fTower);
   }
   else
   {
      match = ( idx == iCell.fTower);
   }
   return match;
}

Member Data Documentation

Definition at line 41 of file FWCaloTowerSliceSelector.h.

Referenced by matchCell().