CMS 3D CMS Logo

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

◆ Coordinate

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

Definition at line 108 of file CaloSubdetectorTopology.h.

Constructor & Destructor Documentation

◆ CaloSubdetectorTopology()

CaloSubdetectorTopology::CaloSubdetectorTopology ( )
inline

standard constructor

Definition at line 20 of file CaloSubdetectorTopology.h.

20 {};

◆ ~CaloSubdetectorTopology()

virtual CaloSubdetectorTopology::~CaloSubdetectorTopology ( )
inlinevirtual

virtual destructor

Definition at line 22 of file CaloSubdetectorTopology.h.

22 {}

Member Function Documentation

◆ denseId2detId()

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); }

◆ denseIdConsistent()

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.

34 { return topoVer == topoVersion(); }

References topoVersion().

Referenced by HcalCondObjectContainerBase::setTopo().

◆ detId2denseId()

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; }

◆ down()

virtual std::vector<DetId> CaloSubdetectorTopology::down ( const DetId id) const
pure virtual

◆ east()

virtual std::vector<DetId> CaloSubdetectorTopology::east ( const DetId id) const
pure virtual

◆ getAllNeighbours()

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.

105 { return getWindow(id, 3, 3); }

References getWindow().

Referenced by CaloTopology::getAllNeighbours().

◆ getNeighbourIndex()

Coordinate CaloSubdetectorTopology::getNeighbourIndex ( const Coordinate coord,
const CaloDirection dir 
) const
inlineprotected

Definition at line 120 of file CaloSubdetectorTopology.h.

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  }

References DeadROC_duringRun::dir, EAST, Exception, NORTH, SOUTH, and WEST.

Referenced by getWindow().

◆ getNeighbours()

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.

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  }

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

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

◆ getWindow()

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.

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 }

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(), ReducedEGProducer::linkCaloClusters(), PiZeroAnalyzer::makePizero(), InterestingEcalDetIdProducer::produce(), InterestingTrackEcalDetIdProducer::produce(), pat::PATElectronProducer::produce(), pat::PATPhotonProducer::produce(), InterestingDetIdFromSuperClusterProducer::produce(), InterestingDetIdCollectionProducer::produce(), and SingleEleCalibSelector::select().

◆ goDown()

virtual DetId CaloSubdetectorTopology::goDown ( const DetId id) const
inlinevirtual

Reimplemented in EcalPreshowerTopology.

Definition at line 71 of file CaloSubdetectorTopology.h.

71  {
72  std::vector<DetId> ids = down(id);
73  return ids.empty() ? DetId() : ids[0];
74  }

References down().

◆ goEast()

virtual DetId CaloSubdetectorTopology::goEast ( const DetId id) const
inlinevirtual

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

Definition at line 51 of file CaloSubdetectorTopology.h.

51  {
52  std::vector<DetId> ids = east(id);
53  return ids.empty() ? DetId() : ids[0];
54  }

References east().

Referenced by offsetBy().

◆ goNorth()

virtual DetId CaloSubdetectorTopology::goNorth ( const DetId id) const
inlinevirtual

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

Definition at line 59 of file CaloSubdetectorTopology.h.

59  {
60  std::vector<DetId> ids = north(id);
61  return ids.empty() ? DetId() : ids[0];
62  }

References north().

Referenced by offsetBy().

◆ goSouth()

virtual DetId CaloSubdetectorTopology::goSouth ( const DetId id) const
inlinevirtual

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

Definition at line 63 of file CaloSubdetectorTopology.h.

63  {
64  std::vector<DetId> ids = south(id);
65  return ids.empty() ? DetId() : ids[0];
66  }

References south().

Referenced by offsetBy().

◆ goUp()

virtual DetId CaloSubdetectorTopology::goUp ( const DetId id) const
inlinevirtual

Reimplemented in EcalPreshowerTopology.

Definition at line 67 of file CaloSubdetectorTopology.h.

67  {
68  std::vector<DetId> ids = up(id);
69  return ids.empty() ? DetId() : ids[0];
70  }

References up().

◆ goWest()

virtual DetId CaloSubdetectorTopology::goWest ( const DetId id) const
inlinevirtual

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

Definition at line 55 of file CaloSubdetectorTopology.h.

55  {
56  std::vector<DetId> ids = west(id);
57  return ids.empty() ? DetId() : ids[0];
58  }

References west().

Referenced by offsetBy().

◆ ncells()

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.

30 { return 1; }

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

◆ north()

virtual std::vector<DetId> CaloSubdetectorTopology::north ( const DetId id) const
pure virtual

◆ south()

virtual std::vector<DetId> CaloSubdetectorTopology::south ( const DetId id) const
pure virtual

◆ topoVersion()

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.

32 { return 0; }

Referenced by denseIdConsistent().

◆ up()

virtual std::vector<DetId> CaloSubdetectorTopology::up ( const DetId id) const
pure virtual

◆ valid()

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.

24 { return false; };

◆ west()

virtual std::vector<DetId> CaloSubdetectorTopology::west ( const DetId id) const
pure virtual
CaloDirection
CaloDirection
Codes the local directions in the cell lattice.
Definition: CaloDirection.h:9
CaloSubdetectorTopology::east
virtual std::vector< DetId > east(const DetId &id) const =0
cms::cuda::assert
assert(be >=bs)
CaloSubdetectorTopology::west
virtual std::vector< DetId > west(const DetId &id) const =0
DetId
Definition: DetId.h:17
directions
directions
Definition: DeviationsFromFileSensor2D.cc:15
EAST
Definition: CaloDirection.h:14
NORTH
Definition: CaloDirection.h:18
class-composition.visited
visited
Definition: class-composition.py:74
CaloSubdetectorTopology::getNeighbours
virtual std::vector< DetId > getNeighbours(const DetId &id, const CaloDirection &dir) const
Definition: CaloSubdetectorTopology.h:77
CaloSubdetectorTopology::getNeighbourIndex
Coordinate getNeighbourIndex(const Coordinate &coord, const CaloDirection &dir) const
Definition: CaloSubdetectorTopology.h:120
CaloSubdetectorTopology::south
virtual std::vector< DetId > south(const DetId &id) const =0
CaloSubdetectorTopology::north
virtual std::vector< DetId > north(const DetId &id) const =0
CaloSubdetectorTopology::getWindow
virtual std::vector< DetId > getWindow(const DetId &id, const int &northSouthSize, const int &eastWestSize) const
Definition: CaloSubdetectorTopology.cc:4
WEST
Definition: CaloDirection.h:15
Exception
Definition: hltDiff.cc:245
CaloSubdetectorTopology::topoVersion
virtual int topoVersion() const
return a version which identifies the given topology
Definition: CaloSubdetectorTopology.h:32
CaloSubdetectorTopology::up
virtual std::vector< DetId > up(const DetId &id) const =0
NONE
Definition: TkAlStyle.cc:47
CaloSubdetectorTopology::Coordinate
std::pair< int, int > Coordinate
Definition: CaloSubdetectorTopology.h:108
SOUTH
Definition: CaloDirection.h:11
CaloSubdetectorTopology::down
virtual std::vector< DetId > down(const DetId &id) const =0
DeadROC_duringRun.dir
dir
Definition: DeadROC_duringRun.py:23