CMS 3D CMS Logo

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

CaloSubdetectorTopology Class Reference

#include <CaloSubdetectorTopology.h>

Inheritance diagram for CaloSubdetectorTopology:
CaloTowerTopology CastorTopology EcalBarrelHardcodedTopology EcalBarrelTopology EcalEndcapHardcodedTopology EcalEndcapTopology EcalPreshowerTopology HcalTopology ZdcTopology

List of all members.

Classes

struct  CellInfo

Public Member Functions

 CaloSubdetectorTopology ()
 standard constructor
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 std::vector< DetIdnorth (const DetId &id) const =0
virtual std::vector< DetIdsouth (const DetId &id) const =0
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:
2011/09/27 09:11:27
Revision:
1.4
Author:
P.Meridiani INFN Roma1
J. Mans - Minnesota

Definition at line 18 of file CaloSubdetectorTopology.h.


Member Typedef Documentation

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

Definition at line 75 of file CaloSubdetectorTopology.h.


Constructor & Destructor Documentation

CaloSubdetectorTopology::CaloSubdetectorTopology ( ) [inline]

standard constructor

Definition at line 21 of file CaloSubdetectorTopology.h.

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

virtual destructor

Definition at line 23 of file CaloSubdetectorTopology.h.

{ }

Member Function Documentation

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 69 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 95 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 39 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(), 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 std::vector<DetId> CaloSubdetectorTopology::north ( const DetId id) const [pure virtual]
virtual std::vector<DetId> CaloSubdetectorTopology::south ( const DetId id) const [pure virtual]
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 CaloTowerTopology.

Definition at line 25 of file CaloSubdetectorTopology.h.

Referenced by CaloTopology::valid().

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