CMS 3D CMS Logo

Classes | Public Member Functions | Protected Types | Protected Member Functions

CaloSubdetectorTopology Class Reference

#include <CaloSubdetectorTopology.h>

Inheritance diagram for CaloSubdetectorTopology:
CastorTopology GCC11_FINAL< T, TOPO > GCC11_FINAL< T, TOPO > GCC11_FINAL< T, TOPO > GCC11_FINAL< T, TOPO > GCC11_FINAL< T, TOPO > GCC11_FINAL< T, TOPO > HcalTopology ZdcTopology

List of all members.

Classes

struct  CellInfo

Public Member Functions

 CaloSubdetectorTopology ()
 standard constructor
virtual DetId denseId2detId (unsigned int) const
 return a linear packed id
virtual bool denseIdConsistent (int topoVer) const
 return whether this topology is consistent with the numbering in the given topology
virtual unsigned int detId2denseId (const DetId &) const
 return a linear packed id
virtual std::vector< DetIddown (const DetId &id) const =0
virtual std::vector< DetIdeast (const DetId &id) const =0
virtual std::vector< DetIdgetAllNeighbours (const DetId &id) const
virtual std::vector< DetIdgetNeighbours (const DetId &id, const CaloDirection &dir) const
virtual std::vector< DetIdgetWindow (const DetId &id, const int &northSouthSize, const int &eastWestSize) const
virtual DetId goDown (const DetId &id) const
virtual DetId goEast (const DetId &id) const
virtual DetId goNorth (const DetId &id) const
virtual DetId goSouth (const DetId &id) const
virtual DetId goUp (const DetId &id) const
virtual DetId goWest (const DetId &id) const
virtual unsigned int ncells () const
 return a count of valid cells (for dense indexing use)
virtual std::vector< DetIdnorth (const DetId &id) const =0
virtual std::vector< DetIdsouth (const DetId &id) const =0
virtual int topoVersion () const
 return a version which identifies the given topology
virtual std::vector< DetIdup (const DetId &id) const =0
virtual bool valid (const DetId &) const
 is this detid present in the Topology?
virtual std::vector< DetIdwest (const DetId &id) const =0
virtual ~CaloSubdetectorTopology ()
 virtual destructor

Protected Types

typedef std::pair< int, int > Coordinate

Protected Member Functions

Coordinate getNeighbourIndex (const Coordinate &coord, const CaloDirection &dir) const

Detailed Description

Date:
2012/12/18 09:38:07
Revision:
1.8
Author:
P.Meridiani INFN Roma1
J. Mans - Minnesota

Definition at line 21 of file CaloSubdetectorTopology.h.


Member Typedef Documentation

typedef std::pair<int,int> CaloSubdetectorTopology::Coordinate [protected]

Definition at line 118 of file CaloSubdetectorTopology.h.


Constructor & Destructor Documentation

CaloSubdetectorTopology::CaloSubdetectorTopology ( ) [inline]

standard constructor

Definition at line 24 of file CaloSubdetectorTopology.h.

{};
virtual CaloSubdetectorTopology::~CaloSubdetectorTopology ( ) [inline, virtual]

virtual destructor

Definition at line 26 of file CaloSubdetectorTopology.h.

{ }

Member Function Documentation

virtual DetId CaloSubdetectorTopology::denseId2detId ( unsigned int  ) const [inline, virtual]

return a linear packed id

Reimplemented in HcalTopology.

Definition at line 32 of file CaloSubdetectorTopology.h.

{ return DetId(0); }
virtual bool CaloSubdetectorTopology::denseIdConsistent ( int  topoVer) const [inline, virtual]

return whether this topology is consistent with the numbering in the given topology

Definition at line 38 of file CaloSubdetectorTopology.h.

References topoVersion().

Referenced by HcalCondObjectContainerBase::setTopo().

{ return topoVer==topoVersion(); }
virtual unsigned int CaloSubdetectorTopology::detId2denseId ( const DetId ) const [inline, virtual]

return a linear packed id

Reimplemented in HcalTopology.

Definition at line 30 of file CaloSubdetectorTopology.h.

{ return 0; }
virtual std::vector<DetId> CaloSubdetectorTopology::down ( const DetId id) const [pure virtual]
virtual std::vector<DetId> CaloSubdetectorTopology::east ( const DetId id) const [pure virtual]
virtual std::vector<DetId> CaloSubdetectorTopology::getAllNeighbours ( const DetId id) const [inline, virtual]

Get all the neighbors of the given cell

Definition at line 112 of file CaloSubdetectorTopology.h.

References getWindow().

Referenced by CaloTopology::getAllNeighbours().

    {
      return getWindow(id,3,3);
    }
Coordinate CaloSubdetectorTopology::getNeighbourIndex ( const Coordinate coord,
const CaloDirection dir 
) const [inline, protected]

Definition at line 138 of file CaloSubdetectorTopology.h.

References EAST, Exception, NORTH, SOUTH, and WEST.

Referenced by getWindow().

    {
      switch (dir)
        {
        case NORTH: return Coordinate(coord.first,coord.second + 1);
        case SOUTH: return Coordinate(coord.first,coord.second - 1);
          
        case EAST:  return Coordinate(coord.first + 1,coord.second);
        case WEST:  return Coordinate(coord.first - 1,coord.second);
          
        default:
          throw cms::Exception("getWindowError") << "Unsopported direction";
        }
    }
virtual std::vector<DetId> CaloSubdetectorTopology::getNeighbours ( const DetId id,
const CaloDirection dir 
) const [inline, virtual]

Get the neighbors of the given cell given direction

Definition at line 82 of file CaloSubdetectorTopology.h.

References EAST, east(), Exception, NONE, NORTH, north(), SOUTH, south(), west(), and WEST.

Referenced by CaloTopology::getNeighbours(), getWindow(), CaloGeometryHelper::simplemove(), spr::simpleMove(), PFRecHitProducerECAL::stdsimplemove(), and PFRecHitProducerHO::stdsimplemove().

    {
      std::vector<DetId> aNullVector;
      switch(dir)
        {
        case NONE:
          return aNullVector;
          break;
        case SOUTH:
          return south(id);
          break;
        case NORTH:
          return north(id);
          break;
        case EAST:
          return east(id);
          break;
        case WEST:
          return west(id);
          break;
        default:
          throw cms::Exception("getNeighboursError") << "Unsopported direction";
        }
      return aNullVector;
    }
std::vector< DetId > CaloSubdetectorTopology::getWindow ( const DetId id,
const int &  northSouthSize,
const int &  eastWestSize 
) const [virtual]

Get the neighbors of the given cell in a window of given size

Definition at line 4 of file CaloSubdetectorTopology.cc.

References EAST, Exception, getNeighbourIndex(), getNeighbours(), i, NORTH, SOUTH, and WEST.

Referenced by HLTAlCaMonPi0::analyze(), HLTAlCa::analyze(), DQMSourcePi0::analyze(), CaloGeometryHelper::buildNeighbourArray(), HLTEcalResonanceFilter::calcShowerShape(), PFRecHitProducerECAL::ecalNeighbArray(), HLTEcalResonanceFilter::filter(), getAllNeighbours(), BetaCalculatorECAL::getDetailedTrackLengthInXtals(), CaloTopology::getWindow(), PFRecHitProducerHO::hoNeighbArray(), EgammaHLTNxNClusterProducer::makeNxNClusters(), EcalDeadChannelRecoveryAlgos::MakeNxNMatrice(), PiZeroAnalyzer::makePizero(), pat::PATElectronProducer::produce(), HighPtTrackEcalDetIdProducer::produce(), InterestingTrackEcalDetIdProducer::produce(), InterestingDetIdCollectionProducer::produce(), InterestingEcalDetIdProducer::produce(), and SingleEleCalibSelector::select().

{
  
  std::vector<DetId> cellsInWindow;
  // check pivot
  if (id.null())
    return cellsInWindow;

  //
  DetId myTmpId(id);
  std::vector<std::pair<Coordinate,DetId> > fringe;
  fringe.push_back(std::pair<Coordinate,DetId>(Coordinate(0,0),myTmpId));
  
  int halfWestEast = eastWestSize/2 ;
  int halfNorthSouth = northSouthSize/2 ;

  std::vector<CellInfo> visited_cells;
  visited_cells.resize(northSouthSize * eastWestSize);
  
  while (fringe.size() > 0)
    {
      std::pair<Coordinate,DetId> cur = fringe.back();
      fringe.pop_back();
      
      // check all four neighbours
      const CaloDirection directions[4] = { NORTH, SOUTH, EAST, WEST };
      
      for (unsigned dirnum = 0; dirnum < 4; ++dirnum)
        {
          Coordinate neighbour = getNeighbourIndex(cur.first,directions[dirnum]);
          //If outside the window range
          if ( neighbour.first < -halfWestEast ||
               neighbour.first > halfWestEast ||
               neighbour.second < -halfNorthSouth ||
               neighbour.second > halfNorthSouth )
            continue;
          
          
          //Found integer index in the matrix
          unsigned int_index =  neighbour.first + halfWestEast +  
            eastWestSize * (neighbour.second + halfNorthSouth );
          assert(int_index < visited_cells.size());
          
          // check whether we have seen this neighbour already
          if (visited_cells[int_index].visited)
            // we have seen this one already
            continue;
              
          // a new cell, get the DetId of the neighbour, mark it
          // as visited and add it to the fringe
          visited_cells[int_index].visited = true;
          std::vector<DetId> neighbourCells = getNeighbours(cur.second,directions[dirnum]);

          if ( neighbourCells.size() == 1 )
            visited_cells[int_index].cell = neighbourCells[0];
          else if ( neighbourCells.size() == 0 )
            visited_cells[int_index].cell = DetId(0);
          else
            throw cms::Exception("getWindowError") << "Not supported subdetector for getWindow method";
          
          if (!visited_cells[int_index].cell.null())
            fringe.push_back(std::pair<Coordinate,DetId>(neighbour,visited_cells[int_index].cell));
                  
        } // loop over all possible directions
    } // while some cells are left on the fringe
  
  
  for (unsigned int i=0; i<visited_cells.size(); i++)
    if (!visited_cells[i].cell.null())
      cellsInWindow.push_back(visited_cells[i].cell);
  
  return cellsInWindow;
}
virtual DetId CaloSubdetectorTopology::goDown ( const DetId id) const [inline, virtual]

Reimplemented in GCC11_FINAL< T, TOPO >.

Definition at line 75 of file CaloSubdetectorTopology.h.

References down().

Referenced by GCC11_FINAL< T, TOPO >::down().

                                              {
    std::vector<DetId> ids = down(id);
    return ids.empty() ? DetId() : ids[0];    
  }
virtual DetId CaloSubdetectorTopology::goEast ( const DetId id) const [inline, virtual]

Reimplemented in GCC11_FINAL< T, TOPO >, GCC11_FINAL< T, TOPO >, GCC11_FINAL< T, TOPO >, GCC11_FINAL< T, TOPO >, and GCC11_FINAL< T, TOPO >.

Definition at line 55 of file CaloSubdetectorTopology.h.

References east().

Referenced by GCC11_FINAL< T, TOPO >::east().

                                              {
    std::vector<DetId> ids = east(id);
    return ids.empty() ? DetId() : ids[0];    
  }
virtual DetId CaloSubdetectorTopology::goNorth ( const DetId id) const [inline, virtual]

Reimplemented in GCC11_FINAL< T, TOPO >, GCC11_FINAL< T, TOPO >, GCC11_FINAL< T, TOPO >, GCC11_FINAL< T, TOPO >, and GCC11_FINAL< T, TOPO >.

Definition at line 63 of file CaloSubdetectorTopology.h.

References north().

Referenced by GCC11_FINAL< T, TOPO >::north().

                                               {
    std::vector<DetId> ids = north(id);
    return ids.empty() ? DetId() : ids[0];    
  }
virtual DetId CaloSubdetectorTopology::goSouth ( const DetId id) const [inline, virtual]

Reimplemented in GCC11_FINAL< T, TOPO >, GCC11_FINAL< T, TOPO >, GCC11_FINAL< T, TOPO >, GCC11_FINAL< T, TOPO >, and GCC11_FINAL< T, TOPO >.

Definition at line 67 of file CaloSubdetectorTopology.h.

References south().

Referenced by GCC11_FINAL< T, TOPO >::south().

                                               {
    std::vector<DetId> ids = south(id);
    return ids.empty() ? DetId() : ids[0];    
  }
virtual DetId CaloSubdetectorTopology::goUp ( const DetId id) const [inline, virtual]

Reimplemented in GCC11_FINAL< T, TOPO >.

Definition at line 71 of file CaloSubdetectorTopology.h.

References up().

Referenced by GCC11_FINAL< T, TOPO >::up().

                                            {
    std::vector<DetId> ids = up(id);
    return ids.empty() ? DetId() : ids[0];    
  }
virtual DetId CaloSubdetectorTopology::goWest ( const DetId id) const [inline, virtual]

Reimplemented in GCC11_FINAL< T, TOPO >, GCC11_FINAL< T, TOPO >, GCC11_FINAL< T, TOPO >, GCC11_FINAL< T, TOPO >, and GCC11_FINAL< T, TOPO >.

Definition at line 59 of file CaloSubdetectorTopology.h.

References west().

Referenced by GCC11_FINAL< T, TOPO >::west().

                                              {
    std::vector<DetId> ids = west(id);
    return ids.empty() ? DetId() : ids[0];    
  }
virtual unsigned int CaloSubdetectorTopology::ncells ( ) const [inline, virtual]

return a count of valid cells (for dense indexing use)

Reimplemented in HcalTopology.

Definition at line 34 of file CaloSubdetectorTopology.h.

Referenced by CastorTopology::ncells(), and ZdcTopology::ncells().

{ return 1; }
virtual std::vector<DetId> CaloSubdetectorTopology::north ( const DetId id) const [pure virtual]
virtual std::vector<DetId> CaloSubdetectorTopology::south ( const DetId id) const [pure virtual]
virtual int CaloSubdetectorTopology::topoVersion ( ) const [inline, virtual]

return a version which identifies the given topology

Reimplemented in HcalTopology.

Definition at line 36 of file CaloSubdetectorTopology.h.

Referenced by denseIdConsistent().

{ return 0; }
virtual std::vector<DetId> CaloSubdetectorTopology::up ( const DetId id) const [pure virtual]
virtual bool CaloSubdetectorTopology::valid ( const DetId ) const [inline, virtual]

is this detid present in the Topology?

Reimplemented in GCC11_FINAL< T, TOPO >, and HcalTopology.

Definition at line 28 of file CaloSubdetectorTopology.h.

Referenced by CaloTopology::valid().

{ return false; };
virtual std::vector<DetId> CaloSubdetectorTopology::west ( const DetId id) const [pure virtual]