CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 HcalTopology ZdcTopology

Classes

struct  CellInfo
 

Public Member Functions

 CaloSubdetectorTopology ()
 standard constructor 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 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 &id) 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

Date:
2006/09/07 09:43:39
Revision:
1.2
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.

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

virtual destructor

Definition at line 23 of file CaloSubdetectorTopology.h.

23 { }

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
inlinevirtual

Get all the neighbors of the given cell

Definition at line 69 of file CaloSubdetectorTopology.h.

References getWindow().

Referenced by CaloTopology::getAllNeighbours().

70  {
71  return getWindow(id,3,3);
72  }
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 95 of file CaloSubdetectorTopology.h.

References EAST, edm::hlt::Exception, NORTH, SOUTH, and WEST.

Referenced by getWindow().

96  {
97  switch (dir)
98  {
99  case NORTH: return Coordinate(coord.first,coord.second + 1);
100  case SOUTH: return Coordinate(coord.first,coord.second - 1);
101 
102  case EAST: return Coordinate(coord.first + 1,coord.second);
103  case WEST: return Coordinate(coord.first - 1,coord.second);
104 
105  default:
106  throw cms::Exception("getWindowError") << "Unsopported direction";
107  }
108  }
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 39 of file CaloSubdetectorTopology.h.

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

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

40  {
41  std::vector<DetId> aNullVector;
42  switch(dir)
43  {
44  case NONE:
45  return aNullVector;
46  break;
47  case SOUTH:
48  return south(id);
49  break;
50  case NORTH:
51  return north(id);
52  break;
53  case EAST:
54  return east(id);
55  break;
56  case WEST:
57  return west(id);
58  break;
59  default:
60  throw cms::Exception("getNeighboursError") << "Unsopported direction";
61  }
62  return aNullVector;
63  }
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
dbl *** dir
Definition: mlp_gen.cc:35
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 EAST, edm::hlt::Exception, getNeighbourIndex(), getNeighbours(), i, NORTH, SOUTH, and WEST.

Referenced by HLTAlCaMonPi0::analyze(), DQMSourcePi0::analyze(), HLTAlCa::analyze(), CaloGeometryHelper::buildNeighbourArray(), HLTEcalResonanceFilter::calcShowerShape(), PFRecHitProducerECAL::ecalNeighbArray(), HLTEcalResonanceFilter::filter(), HLTPi0RecHitsFilter::filter(), getAllNeighbours(), BetaCalculatorECAL::getDetailedTrackLengthInXtals(), CaloTopology::getWindow(), EgammaHLTNxNClusterProducer::makeNxNClusters(), EcalDeadChannelRecoveryAlgos::MakeNxNMatrice(), PiZeroAnalyzer::makePizero(), InterestingEcalDetIdProducer::produce(), InterestingDetIdCollectionProducer::produce(), InterestingTrackEcalDetIdProducer::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.push_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.size() > 0)
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 (unsigned dirnum = 0; dirnum < 4; ++dirnum)
32  {
33  Coordinate neighbour = getNeighbourIndex(cur.first,directions[dirnum]);
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,directions[dirnum]);
56 
57  if ( neighbourCells.size() == 1 )
58  visited_cells[int_index].cell = neighbourCells[0];
59  else if ( neighbourCells.size() == 0 )
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.push_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 (unsigned int i=0; i<visited_cells.size(); i++)
72  if (!visited_cells[i].cell.null())
73  cellsInWindow.push_back(visited_cells[i].cell);
74 
75  return cellsInWindow;
76 }
int i
Definition: DBlmapReader.cc:9
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:20
CaloDirection
Codes the local directions in the cell lattice.
Definition: CaloDirection.h:9
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 id) const
inlinevirtual

is this detid present in the Topology?

Reimplemented in CaloTowerTopology.

Definition at line 25 of file CaloSubdetectorTopology.h.

Referenced by CaloTopology::valid().

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