#include <Geometry/CaloTopology/interface/CaloSubdetectorTopology.h>
Public Member Functions | |
CaloSubdetectorTopology () | |
standard constructor | |
virtual std::vector< DetId > | down (const DetId &id) const =0 |
Get the neighbors of the given cell in down direction (inward). | |
virtual std::vector< DetId > | east (const DetId &id) const =0 |
Get the neighbors of the given cell in east direction. | |
virtual std::vector< DetId > | getAllNeighbours (const DetId &id) const |
Get all the neighbors of the given cell. | |
virtual std::vector< DetId > | getNeighbours (const DetId &id, const CaloDirection &dir) const |
Get the neighbors of the given cell given direction. | |
virtual std::vector< DetId > | getWindow (const DetId &id, const int &northSouthSize, const int &eastWestSize) const |
Get the neighbors of the given cell in a window of given size. | |
virtual std::vector< DetId > | north (const DetId &id) const =0 |
Get the neighbors of the given cell in north direction. | |
virtual std::vector< DetId > | south (const DetId &id) const =0 |
Get the neighbors of the given cell in south direction. | |
virtual std::vector< DetId > | up (const DetId &id) const =0 |
Get the neighbors of the given cell in up direction (outward). | |
virtual bool | valid (const DetId &id) const |
is this detid present in the Topology? | |
virtual std::vector< DetId > | west (const DetId &id) const =0 |
Get the neighbors of the given cell in west direction. | |
virtual | ~CaloSubdetectorTopology () |
virtual destructor | |
Protected Types | |
typedef std::pair< int, int > | Coordinate |
Protected Member Functions | |
Coordinate | getNeighbourIndex (const Coordinate &coord, const CaloDirection &dir) const |
Classes | |
struct | CellInfo |
Definition at line 18 of file CaloSubdetectorTopology.h.
typedef std::pair<int,int> CaloSubdetectorTopology::Coordinate [protected] |
Definition at line 74 of file CaloSubdetectorTopology.h.
CaloSubdetectorTopology::CaloSubdetectorTopology | ( | ) | [inline] |
virtual CaloSubdetectorTopology::~CaloSubdetectorTopology | ( | ) | [inline, virtual] |
Get the neighbors of the given cell in down direction (inward).
Implemented in CaloTowerTopology, EcalBarrelHardcodedTopology, EcalBarrelTopology, EcalEndcapTopology, EcalPreshowerTopology, HcalTopology, CastorTopology, and ZdcTopology.
Referenced by CaloNavigator< EBDetId >::down(), and CaloTopology::down().
Get the neighbors of the given cell in east direction.
Implemented in CaloTowerTopology, EcalBarrelHardcodedTopology, EcalBarrelTopology, EcalEndcapTopology, EcalPreshowerTopology, HcalTopology, CastorTopology, and ZdcTopology.
Referenced by CaloTopology::east(), CaloNavigator< EBDetId >::east(), and getNeighbours().
virtual std::vector<DetId> CaloSubdetectorTopology::getAllNeighbours | ( | const DetId & | id | ) | const [inline, virtual] |
Get all the neighbors of the given cell.
Definition at line 68 of file CaloSubdetectorTopology.h.
References getWindow().
Referenced by CaloTopology::getAllNeighbours().
00069 { 00070 return getWindow(id,3,3); 00071 }
Coordinate CaloSubdetectorTopology::getNeighbourIndex | ( | const Coordinate & | coord, | |
const CaloDirection & | dir | |||
) | const [inline, protected] |
Definition at line 94 of file CaloSubdetectorTopology.h.
References EAST, Exception, NORTH, SOUTH, and WEST.
Referenced by getWindow().
00095 { 00096 switch (dir) 00097 { 00098 case NORTH: return Coordinate(coord.first,coord.second + 1); 00099 case SOUTH: return Coordinate(coord.first,coord.second - 1); 00100 00101 case EAST: return Coordinate(coord.first + 1,coord.second); 00102 case WEST: return Coordinate(coord.first - 1,coord.second); 00103 00104 default: 00105 throw cms::Exception("getWindowError") << "Unsopported direction"; 00106 } 00107 }
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(), and PFRecHitProducerECAL::stdsimplemove().
00040 { 00041 std::vector<DetId> aNullVector; 00042 switch(dir) 00043 { 00044 case NONE: 00045 return aNullVector; 00046 break; 00047 case SOUTH: 00048 return south(id); 00049 break; 00050 case NORTH: 00051 return north(id); 00052 break; 00053 case EAST: 00054 return east(id); 00055 break; 00056 case WEST: 00057 return west(id); 00058 break; 00059 default: 00060 throw cms::Exception("getNeighboursError") << "Unsopported direction"; 00061 } 00062 }
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 ElectronCalibrationUniv::analyze(), DQMHLTSourcePi0::analyze(), DQMSourcePi0::analyze(), CaloGeometryHelper::buildNeighbourArray(), PFRecHitProducerECAL::ecalNeighbArray(), HLTPi0RecHitsFilter::filter(), getAllNeighbours(), CaloTopology::getWindow(), EcalDeadChannelRecoveryAlgos::MakeNxNMatrice(), PhotonAnalyzer::makePizero(), InterestingDetIdCollectionProducer::produce(), and SingleEleCalibSelector::select().
00005 { 00006 00007 std::vector<DetId> cellsInWindow; 00008 // check pivot 00009 if (id.null()) 00010 return cellsInWindow; 00011 00012 // 00013 DetId myTmpId(id); 00014 std::vector<std::pair<Coordinate,DetId> > fringe; 00015 fringe.push_back(std::pair<Coordinate,DetId>(Coordinate(0,0),myTmpId)); 00016 00017 int halfWestEast = eastWestSize/2 ; 00018 int halfNorthSouth = northSouthSize/2 ; 00019 00020 std::vector<CellInfo> visited_cells; 00021 visited_cells.resize(northSouthSize * eastWestSize); 00022 00023 while (fringe.size() > 0) 00024 { 00025 std::pair<Coordinate,DetId> cur = fringe.back(); 00026 fringe.pop_back(); 00027 00028 // check all four neighbours 00029 const CaloDirection directions[4] = { NORTH, SOUTH, EAST, WEST }; 00030 00031 for (unsigned dirnum = 0; dirnum < 4; ++dirnum) 00032 { 00033 Coordinate neighbour = getNeighbourIndex(cur.first,directions[dirnum]); 00034 //If outside the window range 00035 if ( neighbour.first < -halfWestEast || 00036 neighbour.first > halfWestEast || 00037 neighbour.second < -halfNorthSouth || 00038 neighbour.second > halfNorthSouth ) 00039 continue; 00040 00041 00042 //Found integer index in the matrix 00043 unsigned int_index = neighbour.first + halfWestEast + 00044 eastWestSize * (neighbour.second + halfNorthSouth ); 00045 assert(int_index < visited_cells.size()); 00046 00047 // check whether we have seen this neighbour already 00048 if (visited_cells[int_index].visited) 00049 // we have seen this one already 00050 continue; 00051 00052 // a new cell, get the DetId of the neighbour, mark it 00053 // as visited and add it to the fringe 00054 visited_cells[int_index].visited = true; 00055 std::vector<DetId> neighbourCells = getNeighbours(cur.second,directions[dirnum]); 00056 00057 if ( neighbourCells.size() == 1 ) 00058 visited_cells[int_index].cell = neighbourCells[0]; 00059 else if ( neighbourCells.size() == 0 ) 00060 visited_cells[int_index].cell = DetId(0); 00061 else 00062 throw cms::Exception("getWindowError") << "Not supported subdetector for getWindow method"; 00063 00064 if (!visited_cells[int_index].cell.null()) 00065 fringe.push_back(std::pair<Coordinate,DetId>(neighbour,visited_cells[int_index].cell)); 00066 00067 } // loop over all possible directions 00068 } // while some cells are left on the fringe 00069 00070 00071 for (unsigned int i=0; i<visited_cells.size(); i++) 00072 if (!visited_cells[i].cell.null()) 00073 cellsInWindow.push_back(visited_cells[i].cell); 00074 00075 return cellsInWindow; 00076 }
Get the neighbors of the given cell in north direction.
Implemented in CaloTowerTopology, EcalBarrelHardcodedTopology, EcalBarrelTopology, EcalEndcapTopology, EcalPreshowerTopology, HcalTopology, CastorTopology, and ZdcTopology.
Referenced by getNeighbours(), PFRecHitProducerHCAL::getNorth(), CaloTopology::north(), and CaloNavigator< EBDetId >::north().
Get the neighbors of the given cell in south direction.
Implemented in CaloTowerTopology, EcalBarrelHardcodedTopology, EcalBarrelTopology, EcalEndcapTopology, EcalPreshowerTopology, HcalTopology, CastorTopology, and ZdcTopology.
Referenced by getNeighbours(), PFRecHitProducerHCAL::getSouth(), CaloTopology::south(), and CaloNavigator< EBDetId >::south().
Get the neighbors of the given cell in up direction (outward).
Implemented in CaloTowerTopology, EcalBarrelHardcodedTopology, EcalBarrelTopology, EcalEndcapTopology, EcalPreshowerTopology, HcalTopology, CastorTopology, and ZdcTopology.
Referenced by CaloNavigator< EBDetId >::up(), and CaloTopology::up().
is this detid present in the Topology?
Reimplemented in CaloTowerTopology.
Definition at line 25 of file CaloSubdetectorTopology.h.
Referenced by CaloTopology::valid().
Get the neighbors of the given cell in west direction.
Implemented in CaloTowerTopology, EcalBarrelHardcodedTopology, EcalBarrelTopology, EcalEndcapTopology, EcalPreshowerTopology, HcalTopology, CastorTopology, and ZdcTopology.
Referenced by getNeighbours(), CaloNavigator< EBDetId >::west(), and CaloTopology::west().