CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Classes | Public Member Functions | Protected Types | Protected Member Functions
CaloSubdetectorTopology Class Referenceabstract

#include <CaloSubdetectorTopology.h>

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

Classes

struct  CellInfo
 

Public Member Functions

 CaloSubdetectorTopology ()
 standard constructor More...
 
virtual DetId denseId2detId (unsigned int) const
 return a linear packed id More...
 
virtual bool denseIdConsistent (int topoVer) const
 return whether this topology is consistent with the numbering in the given topology More...
 
virtual unsigned int detId2denseId (const DetId &) const
 return a linear packed id More...
 
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) More...
 
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 More...
 
virtual std::vector< DetIdup (const DetId &id) const =0
 
virtual bool valid (const DetId &) const
 is this detid present in the Topology? More...
 
virtual std::vector< DetIdwest (const DetId &id) const =0
 
virtual ~CaloSubdetectorTopology ()
 virtual destructor More...
 

Protected Types

typedef std::pair< int, int > Coordinate
 

Protected Member Functions

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

Detailed Description

Revision:
1.7
Author
P.Meridiani INFN Roma1
J. Mans - Minnesota

Definition at line 17 of file CaloSubdetectorTopology.h.

Member Typedef Documentation

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

Definition at line 108 of file CaloSubdetectorTopology.h.

Constructor & Destructor Documentation

CaloSubdetectorTopology::CaloSubdetectorTopology ( )
inline

standard constructor

Definition at line 20 of file CaloSubdetectorTopology.h.

20 {};
virtual CaloSubdetectorTopology::~CaloSubdetectorTopology ( )
inlinevirtual

virtual destructor

Definition at line 22 of file CaloSubdetectorTopology.h.

22 {}

Member Function Documentation

virtual DetId CaloSubdetectorTopology::denseId2detId ( unsigned int  ) const
inlinevirtual

return a linear packed id

Reimplemented in HcalTopology.

Definition at line 28 of file CaloSubdetectorTopology.h.

28 { return DetId(0); }
Definition: DetId.h:17
virtual bool CaloSubdetectorTopology::denseIdConsistent ( int  topoVer) const
inlinevirtual

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

Definition at line 34 of file CaloSubdetectorTopology.h.

References topoVersion().

Referenced by HcalCondObjectContainerBase::setTopo().

34 { return topoVer == topoVersion(); }
virtual int topoVersion() const
return a version which identifies the given topology
virtual unsigned int CaloSubdetectorTopology::detId2denseId ( const DetId ) const
inlinevirtual

return a linear packed id

Reimplemented in HGCalTopology, FastTimeTopology, and HcalTopology.

Definition at line 26 of file CaloSubdetectorTopology.h.

26 { 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
inlinevirtual

Get all the neighbors of the given cell

Definition at line 105 of file CaloSubdetectorTopology.h.

References getWindow().

Referenced by CaloTopology::getAllNeighbours().

105 { return getWindow(id, 3, 3); }
virtual std::vector< DetId > getWindow(const DetId &id, const int &northSouthSize, const int &eastWestSize) const
Coordinate CaloSubdetectorTopology::getNeighbourIndex ( const Coordinate coord,
const CaloDirection dir 
) const
inlineprotected

Definition at line 120 of file CaloSubdetectorTopology.h.

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

Referenced by getWindow().

120  {
121  switch (dir) {
122  case NORTH:
123  return Coordinate(coord.first, coord.second + 1);
124  case SOUTH:
125  return Coordinate(coord.first, coord.second - 1);
126 
127  case EAST:
128  return Coordinate(coord.first + 1, coord.second);
129  case WEST:
130  return Coordinate(coord.first - 1, coord.second);
131 
132  default:
133  throw cms::Exception("getWindowError") << "Unsopported direction";
134  }
135  }
std::pair< int, int > Coordinate
virtual std::vector<DetId> CaloSubdetectorTopology::getNeighbours ( const DetId id,
const CaloDirection dir 
) const
inlinevirtual

Get the neighbors of the given cell given direction

Definition at line 77 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(), and PFECALHashNavigator::stdsimplemove().

77  {
78  std::vector<DetId> aNullVector;
79  switch (dir) {
80  case NONE:
81  return aNullVector;
82  break;
83  case SOUTH:
84  return south(id);
85  break;
86  case NORTH:
87  return north(id);
88  break;
89  case EAST:
90  return east(id);
91  break;
92  case WEST:
93  return west(id);
94  break;
95  default:
96  throw cms::Exception("getNeighboursError") << "Unsopported direction";
97  }
98  return aNullVector;
99  }
virtual std::vector< DetId > west(const DetId &id) const =0
virtual std::vector< DetId > north(const DetId &id) const =0
virtual std::vector< DetId > south(const DetId &id) const =0
virtual std::vector< DetId > east(const DetId &id) const =0
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 cms::cuda::assert(), EAST, Exception, getNeighbourIndex(), getNeighbours(), NORTH, SOUTH, class-composition::visited, and WEST.

Referenced by DQMSourcePi0::analyze(), ElectronCalibrationUniv::analyze(), CaloGeometryHelper::buildNeighbourArray(), HLTEcalResonanceFilter::calcShowerShape(), HLTRegionalEcalResonanceFilter::calcShowerShape(), PFECALHashNavigator::ecalNeighbArray(), HLTEcalResonanceFilter::filter(), HLTRegionalEcalResonanceFilter::filter(), getAllNeighbours(), CaloTopology::getWindow(), PiZeroAnalyzer::makePizero(), InterestingEcalDetIdProducer::produce(), InterestingTrackEcalDetIdProducer::produce(), pat::PATPhotonProducer::produce(), InterestingDetIdFromSuperClusterProducer::produce(), InterestingDetIdCollectionProducer::produce(), and pat::PATElectronProducer::produce().

6  {
7  std::vector<DetId> cellsInWindow;
8  // check pivot
9  if (id.null())
10  return cellsInWindow;
11 
12  //
13  DetId myTmpId(id);
14  std::vector<std::pair<Coordinate, DetId> > fringe;
15  fringe.emplace_back(std::pair<Coordinate, DetId>(Coordinate(0, 0), myTmpId));
16 
17  int halfWestEast = eastWestSize / 2;
18  int halfNorthSouth = northSouthSize / 2;
19 
20  std::vector<CellInfo> visited_cells;
21  visited_cells.resize(northSouthSize * eastWestSize);
22 
23  while (!fringe.empty()) {
24  std::pair<Coordinate, DetId> cur = fringe.back();
25  fringe.pop_back();
26 
27  // check all four neighbours
28  const CaloDirection directions[4] = {NORTH, SOUTH, EAST, WEST};
29 
30  for (auto direction : directions) {
31  Coordinate neighbour = getNeighbourIndex(cur.first, direction);
32  //If outside the window range
33  if (neighbour.first < -halfWestEast || neighbour.first > halfWestEast || neighbour.second < -halfNorthSouth ||
34  neighbour.second > halfNorthSouth)
35  continue;
36 
37  //Found integer index in the matrix
38  unsigned int_index = neighbour.first + halfWestEast + eastWestSize * (neighbour.second + halfNorthSouth);
39  assert(int_index < visited_cells.size());
40 
41  // check whether we have seen this neighbour already
42  if (visited_cells[int_index].visited)
43  // we have seen this one already
44  continue;
45 
46  // a new cell, get the DetId of the neighbour, mark it
47  // as visited and add it to the fringe
48  visited_cells[int_index].visited = true;
49  std::vector<DetId> neighbourCells = getNeighbours(cur.second, direction);
50 
51  if (neighbourCells.size() == 1)
52  visited_cells[int_index].cell = neighbourCells[0];
53  else if (neighbourCells.empty())
54  visited_cells[int_index].cell = DetId(0);
55  else
56  throw cms::Exception("getWindowError") << "Not supported subdetector for getWindow method";
57 
58  if (!visited_cells[int_index].cell.null())
59  fringe.emplace_back(std::pair<Coordinate, DetId>(neighbour, visited_cells[int_index].cell));
60 
61  } // loop over all possible directions
62  } // while some cells are left on the fringe
63 
64  for (auto& visited_cell : visited_cells)
65  if (!visited_cell.cell.null())
66  cellsInWindow.emplace_back(visited_cell.cell);
67 
68  return cellsInWindow;
69 }
virtual std::vector< DetId > getNeighbours(const DetId &id, const CaloDirection &dir) const
assert(be >=bs)
Coordinate getNeighbourIndex(const Coordinate &coord, const CaloDirection &dir) const
Definition: DetId.h:17
CaloDirection
Codes the local directions in the cell lattice.
Definition: CaloDirection.h:9
std::pair< int, int > Coordinate
virtual DetId CaloSubdetectorTopology::goDown ( const DetId id) const
inlinevirtual

Reimplemented in EcalPreshowerTopology.

Definition at line 71 of file CaloSubdetectorTopology.h.

References down().

71  {
72  std::vector<DetId> ids = down(id);
73  return ids.empty() ? DetId() : ids[0];
74  }
Definition: DetId.h:17
virtual std::vector< DetId > down(const DetId &id) const =0
virtual DetId CaloSubdetectorTopology::goEast ( const DetId id) const
inlinevirtual

Reimplemented in EcalBarrelTopology, EcalEndcapTopology, HGCalTopology, EcalPreshowerTopology, FastTimeTopology, EcalBarrelHardcodedTopology, and EcalEndcapHardcodedTopology.

Definition at line 51 of file CaloSubdetectorTopology.h.

References east().

Referenced by offsetBy().

51  {
52  std::vector<DetId> ids = east(id);
53  return ids.empty() ? DetId() : ids[0];
54  }
Definition: DetId.h:17
virtual std::vector< DetId > east(const DetId &id) const =0
virtual DetId CaloSubdetectorTopology::goNorth ( const DetId id) const
inlinevirtual

Reimplemented in EcalBarrelTopology, EcalEndcapTopology, HGCalTopology, EcalPreshowerTopology, FastTimeTopology, EcalBarrelHardcodedTopology, and EcalEndcapHardcodedTopology.

Definition at line 59 of file CaloSubdetectorTopology.h.

References north().

Referenced by offsetBy().

59  {
60  std::vector<DetId> ids = north(id);
61  return ids.empty() ? DetId() : ids[0];
62  }
virtual std::vector< DetId > north(const DetId &id) const =0
Definition: DetId.h:17
virtual DetId CaloSubdetectorTopology::goSouth ( const DetId id) const
inlinevirtual

Reimplemented in EcalBarrelTopology, EcalEndcapTopology, HGCalTopology, EcalPreshowerTopology, FastTimeTopology, EcalBarrelHardcodedTopology, and EcalEndcapHardcodedTopology.

Definition at line 63 of file CaloSubdetectorTopology.h.

References south().

Referenced by offsetBy().

63  {
64  std::vector<DetId> ids = south(id);
65  return ids.empty() ? DetId() : ids[0];
66  }
Definition: DetId.h:17
virtual std::vector< DetId > south(const DetId &id) const =0
virtual DetId CaloSubdetectorTopology::goUp ( const DetId id) const
inlinevirtual

Reimplemented in EcalPreshowerTopology.

Definition at line 67 of file CaloSubdetectorTopology.h.

References up().

67  {
68  std::vector<DetId> ids = up(id);
69  return ids.empty() ? DetId() : ids[0];
70  }
Definition: DetId.h:17
virtual std::vector< DetId > up(const DetId &id) const =0
virtual DetId CaloSubdetectorTopology::goWest ( const DetId id) const
inlinevirtual

Reimplemented in EcalBarrelTopology, EcalEndcapTopology, HGCalTopology, EcalPreshowerTopology, FastTimeTopology, EcalBarrelHardcodedTopology, and EcalEndcapHardcodedTopology.

Definition at line 55 of file CaloSubdetectorTopology.h.

References west().

Referenced by offsetBy().

55  {
56  std::vector<DetId> ids = west(id);
57  return ids.empty() ? DetId() : ids[0];
58  }
virtual std::vector< DetId > west(const DetId &id) const =0
Definition: DetId.h:17
virtual unsigned int CaloSubdetectorTopology::ncells ( ) const
inlinevirtual

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

Reimplemented in HcalTopology.

Definition at line 30 of file CaloSubdetectorTopology.h.

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

30 { 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
inlinevirtual

return a version which identifies the given topology

Reimplemented in HcalTopology.

Definition at line 32 of file CaloSubdetectorTopology.h.

Referenced by denseIdConsistent().

32 { return 0; }
virtual std::vector<DetId> CaloSubdetectorTopology::up ( const DetId id) const
pure virtual
virtual bool CaloSubdetectorTopology::valid ( const DetId ) const
inlinevirtual

is this detid present in the Topology?

Reimplemented in HGCalTopology, FastTimeTopology, HcalTopology, and CaloTowerTopology.

Definition at line 24 of file CaloSubdetectorTopology.h.

Referenced by CaloTopology::valid().

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