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 20 of file CaloSubdetectorTopology.h.

Member Typedef Documentation

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

Definition at line 117 of file CaloSubdetectorTopology.h.

Constructor & Destructor Documentation

CaloSubdetectorTopology::CaloSubdetectorTopology ( )
inline

standard constructor

Definition at line 23 of file CaloSubdetectorTopology.h.

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

virtual destructor

Definition at line 25 of file CaloSubdetectorTopology.h.

25 { }

Member Function Documentation

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

return a linear packed id

Reimplemented in HcalTopology.

Definition at line 31 of file CaloSubdetectorTopology.h.

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

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

Definition at line 37 of file CaloSubdetectorTopology.h.

References down(), east(), north(), south(), topoVersion(), up(), and west().

Referenced by HcalCondObjectContainerBase::setTopo().

37 { 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 29 of file CaloSubdetectorTopology.h.

29 { 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 111 of file CaloSubdetectorTopology.h.

References getWindow().

Referenced by CaloTopology::getAllNeighbours().

112  {
113  return getWindow(id,3,3);
114  }
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 137 of file CaloSubdetectorTopology.h.

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

Referenced by getWindow().

138  {
139  switch (dir)
140  {
141  case NORTH: return Coordinate(coord.first,coord.second + 1);
142  case SOUTH: return Coordinate(coord.first,coord.second - 1);
143 
144  case EAST: return Coordinate(coord.first + 1,coord.second);
145  case WEST: return Coordinate(coord.first - 1,coord.second);
146 
147  default:
148  throw cms::Exception("getWindowError") << "Unsopported direction";
149  }
150  }
std::pair< int, int > Coordinate
dbl *** dir
Definition: mlp_gen.cc:35
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 81 of file CaloSubdetectorTopology.h.

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

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

82  {
83  std::vector<DetId> aNullVector;
84  switch(dir)
85  {
86  case NONE:
87  return aNullVector;
88  break;
89  case SOUTH:
90  return south(id);
91  break;
92  case NORTH:
93  return north(id);
94  break;
95  case EAST:
96  return east(id);
97  break;
98  case WEST:
99  return west(id);
100  break;
101  default:
102  throw cms::Exception("getNeighboursError") << "Unsopported direction";
103  }
104  return aNullVector;
105  }
virtual std::vector< DetId > north(const DetId &id) const =0
virtual std::vector< DetId > east(const DetId &id) const =0
virtual std::vector< DetId > west(const DetId &id) const =0
dbl *** dir
Definition: mlp_gen.cc:35
virtual std::vector< DetId > south(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 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(), BetaCalculatorECAL::getDetailedTrackLengthInXtals(), getNeighbours(), CaloTopology::getWindow(), ReducedEGProducer::linkCaloClusters(), EcalDeadChannelRecoveryNN< EEDetId >::makeNxNMatrice_RelDC(), EcalDeadChannelRecoveryNN< EBDetId >::makeNxNMatrice_RelDC(), EcalDeadChannelRecoveryNN< DetIdT >::makeNxNMatrice_RelMC(), PiZeroAnalyzer::makePizero(), InterestingEcalDetIdProducer::produce(), InterestingDetIdFromSuperClusterProducer::produce(), InterestingDetIdCollectionProducer::produce(), InterestingTrackEcalDetIdProducer::produce(), pat::PATPhotonProducer::produce(), pat::PATElectronProducer::produce(), HighPtTrackEcalDetIdProducer::produce(), and SingleEleCalibSelector::select().

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

Reimplemented in EcalPreshowerTopology.

Definition at line 74 of file CaloSubdetectorTopology.h.

References down(), and photons_cff::ids.

74  {
75  std::vector<DetId> ids = down(id);
76  return ids.empty() ? DetId() : ids[0];
77  }
virtual std::vector< DetId > down(const DetId &id) const =0
Definition: DetId.h:18
virtual DetId CaloSubdetectorTopology::goEast ( const DetId id) const
inlinevirtual

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

Definition at line 54 of file CaloSubdetectorTopology.h.

References east(), and photons_cff::ids.

54  {
55  std::vector<DetId> ids = east(id);
56  return ids.empty() ? DetId() : ids[0];
57  }
virtual std::vector< DetId > east(const DetId &id) const =0
Definition: DetId.h:18
virtual DetId CaloSubdetectorTopology::goNorth ( const DetId id) const
inlinevirtual

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

Definition at line 62 of file CaloSubdetectorTopology.h.

References photons_cff::ids, and north().

62  {
63  std::vector<DetId> ids = north(id);
64  return ids.empty() ? DetId() : ids[0];
65  }
virtual std::vector< DetId > north(const DetId &id) const =0
Definition: DetId.h:18
virtual DetId CaloSubdetectorTopology::goSouth ( const DetId id) const
inlinevirtual

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

Definition at line 66 of file CaloSubdetectorTopology.h.

References photons_cff::ids, and south().

66  {
67  std::vector<DetId> ids = south(id);
68  return ids.empty() ? DetId() : ids[0];
69  }
Definition: DetId.h:18
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 70 of file CaloSubdetectorTopology.h.

References photons_cff::ids, and up().

70  {
71  std::vector<DetId> ids = up(id);
72  return ids.empty() ? DetId() : ids[0];
73  }
virtual std::vector< DetId > up(const DetId &id) const =0
Definition: DetId.h:18
virtual DetId CaloSubdetectorTopology::goWest ( const DetId id) const
inlinevirtual

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

Definition at line 58 of file CaloSubdetectorTopology.h.

References photons_cff::ids, and west().

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

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

Reimplemented in HcalTopology.

Definition at line 33 of file CaloSubdetectorTopology.h.

Referenced by ZdcTopology::ncells(), CastorTopology::ncells(), and CaloGeometryDBEP< T, U >::produceAligned().

33 { 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 35 of file CaloSubdetectorTopology.h.

Referenced by denseIdConsistent().

35 { 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 27 of file CaloSubdetectorTopology.h.

Referenced by CaloTopology::valid().

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