CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Attributes | Private Attributes
PFHCALDenseIdNavigator< DET, TOPO, ownsTopo > Class Template Reference

#include <PFHCALDenseIdNavigator.h>

Inheritance diagram for PFHCALDenseIdNavigator< DET, TOPO, ownsTopo >:
PFRecHitNavigatorBase

Public Member Functions

void associateNeighbours (reco::PFRecHit &hit, std::unique_ptr< reco::PFRecHitCollection > &hits, edm::RefProd< reco::PFRecHitCollection > &refProd) override
 
unsigned int getIdx (const unsigned int denseid) const
 
void init (const edm::EventSetup &iSetup) override
 
 PFHCALDenseIdNavigator (const edm::ParameterSet &iConfig, edm::ConsumesCollector &cc)
 
bool validNeighbours (const unsigned int denseid) const
 
 ~PFHCALDenseIdNavigator () override
 
- Public Member Functions inherited from PFRecHitNavigatorBase
 PFRecHitNavigatorBase ()=default
 
 PFRecHitNavigatorBase (const edm::ParameterSet &iConfig, edm::ConsumesCollector &cc)
 
virtual ~PFRecHitNavigatorBase ()=default
 

Protected Attributes

unsigned int denseIdHcalMax_
 
unsigned int denseIdHcalMin_
 
std::vector< std::vector< DetId > > neighboursHcal_
 
edm::ESWatcher< HcalRecNumberingRecordtheRecNumberWatcher_
 
std::unique_ptr< const TOPO > topology_
 
std::vector< int > vhcalEnum_
 

Private Attributes

edm::ESGetToken< CaloGeometry, CaloGeometryRecordgeomToken_
 
edm::ESGetToken< HcalTopology, HcalRecNumberingRecordhcalToken_
 

Additional Inherited Members

- Public Types inherited from PFRecHitNavigatorBase
typedef std::unordered_map< unsigned, unsigned > DetIdToHitIdx
 
- Protected Member Functions inherited from PFRecHitNavigatorBase
void associateNeighbour (const DetId &id, reco::PFRecHit &hit, std::unique_ptr< reco::PFRecHitCollection > &hits, edm::RefProd< reco::PFRecHitCollection > &refProd, short eta, short phi, short depth)
 

Detailed Description

template<typename DET, typename TOPO, bool ownsTopo = true>
class PFHCALDenseIdNavigator< DET, TOPO, ownsTopo >

Definition at line 26 of file PFHCALDenseIdNavigator.h.

Constructor & Destructor Documentation

◆ ~PFHCALDenseIdNavigator()

template<typename DET, typename TOPO, bool ownsTopo = true>
PFHCALDenseIdNavigator< DET, TOPO, ownsTopo >::~PFHCALDenseIdNavigator ( )
inlineoverride

Definition at line 28 of file PFHCALDenseIdNavigator.h.

28  {
29  if (!ownsTopo) {
30  topology_.release();
31  }
32  }

◆ PFHCALDenseIdNavigator()

template<typename DET, typename TOPO, bool ownsTopo = true>
PFHCALDenseIdNavigator< DET, TOPO, ownsTopo >::PFHCALDenseIdNavigator ( const edm::ParameterSet iConfig,
edm::ConsumesCollector cc 
)
inline

Definition at line 34 of file PFHCALDenseIdNavigator.h.

35  : vhcalEnum_(iConfig.getParameter<std::vector<int>>("hcalEnums")),

Member Function Documentation

◆ associateNeighbours()

template<typename DET, typename TOPO, bool ownsTopo = true>
void PFHCALDenseIdNavigator< DET, TOPO, ownsTopo >::associateNeighbours ( reco::PFRecHit hit,
std::unique_ptr< reco::PFRecHitCollection > &  hits,
edm::RefProd< reco::PFRecHitCollection > &  refProd 
)
inlineoverridevirtual

Implements PFRecHitNavigatorBase.

Definition at line 143 of file PFHCALDenseIdNavigator.h.

145  {
146  DetId detid(hit.detId());
147  unsigned denseid = topology_.get()->detId2denseId(detid);
148 
149  std::vector<DetId> neighbours(9, DetId(0));
150 
151  if (denseid < denseIdHcalMin_ || denseid > denseIdHcalMax_) {
152  edm::LogWarning("PFRecHitHCALCachedNavigator") << " DenseId for this cell is out of the range." << std::endl;
153  } else if (!validNeighbours(denseid)) {
154  edm::LogWarning("PFRecHitHCALCachedNavigator")
155  << " DenseId for this cell does not have the neighbour information." << std::endl;
156  } else {
157  unsigned index = getIdx(denseid);
158  neighbours = neighboursHcal_.at(index);
159  }
160 
161  associateNeighbour(neighbours.at(NORTH), hit, hits, refProd, 0, 1, 0); // N
162  associateNeighbour(neighbours.at(NORTHEAST), hit, hits, refProd, 1, 1, 0); // NE
163  associateNeighbour(neighbours.at(SOUTH), hit, hits, refProd, 0, -1, 0); // S
164  associateNeighbour(neighbours.at(SOUTHWEST), hit, hits, refProd, -1, -1, 0); // SW
165  associateNeighbour(neighbours.at(EAST), hit, hits, refProd, 1, 0, 0); // E
166  associateNeighbour(neighbours.at(SOUTHEAST), hit, hits, refProd, 1, -1, 0); // SE
167  associateNeighbour(neighbours.at(WEST), hit, hits, refProd, -1, 0, 0); // W
168  associateNeighbour(neighbours.at(NORTHWEST), hit, hits, refProd, -1, 1, 0); // NW
169  }

◆ getIdx()

template<typename DET, typename TOPO, bool ownsTopo = true>
unsigned int PFHCALDenseIdNavigator< DET, TOPO, ownsTopo >::getIdx ( const unsigned int  denseid) const
inline

◆ init()

template<typename DET, typename TOPO, bool ownsTopo = true>
void PFHCALDenseIdNavigator< DET, TOPO, ownsTopo >::init ( const edm::EventSetup iSetup)
inlineoverridevirtual

Implements PFRecHitNavigatorBase.

Definition at line 39 of file PFHCALDenseIdNavigator.h.

39  {
40  bool check = theRecNumberWatcher_.check(iSetup);
41  if (!check)
42  return;
43 
44  edm::ESHandle<HcalTopology> hcalTopology = iSetup.getHandle(hcalToken_);
45  topology_.release();
46  topology_.reset(hcalTopology.product());
47 
48  // Fill a vector of valid denseid's
50  const CaloGeometry& caloGeom = *hGeom;
51 
52  std::vector<DetId> vecHcal;
53  std::vector<unsigned int> vDenseIdHcal;
54  neighboursHcal_.clear();
55  for (auto hcalSubdet : vhcalEnum_) {
56  std::vector<DetId> vecDetIds(caloGeom.getValidDetIds(DetId::Hcal, hcalSubdet));
57  vecHcal.insert(vecHcal.end(), vecDetIds.begin(), vecDetIds.end());
58  }
59  vDenseIdHcal.reserve(vecHcal.size());
60  for (auto hDetId : vecHcal) {
61  vDenseIdHcal.push_back(topology_.get()->detId2denseId(hDetId));
62  }
63  std::sort(vDenseIdHcal.begin(), vDenseIdHcal.end());
64 
65  // Fill a vector of cell neighbours
66  denseIdHcalMax_ = *max_element(vDenseIdHcal.begin(), vDenseIdHcal.end());
67  denseIdHcalMin_ = *min_element(vDenseIdHcal.begin(), vDenseIdHcal.end());
69 
70  for (auto denseid : vDenseIdHcal) {
71  DetId N(0);
72  DetId E(0);
73  DetId S(0);
74  DetId W(0);
75  DetId NW(0);
76  DetId NE(0);
77  DetId SW(0);
78  DetId SE(0);
79  std::vector<DetId> neighbours(9, DetId(0));
80 
81  // the centre
82  unsigned denseid_c = denseid;
83  DetId detid_c = topology_.get()->denseId2detId(denseid_c);
84  CaloNavigator<DET> navigator(detid_c, topology_.get());
85 
86  // Using enum in Geometry/CaloTopology/interface/CaloDirection.h
87  // Order: CENTER(NONE),SOUTH,SOUTHEAST,SOUTHWEST,EAST,WEST,NORTHEAST,NORTHWEST,NORTH
88  neighbours.at(NONE) = detid_c;
89 
90  navigator.home();
91  N = navigator.north();
92  neighbours.at(NORTH) = N;
93  if (N != DetId(0)) {
94  NE = navigator.east();
95  } else {
96  navigator.home();
97  E = navigator.east();
98  NE = navigator.north();
99  }
100  neighbours.at(NORTHEAST) = NE;
101 
102  navigator.home();
103  S = navigator.south();
104  neighbours.at(SOUTH) = S;
105  if (S != DetId(0)) {
106  SW = navigator.west();
107  } else {
108  navigator.home();
109  W = navigator.west();
110  SW = navigator.south();
111  }
112  neighbours.at(SOUTHWEST) = SW;
113 
114  navigator.home();
115  E = navigator.east();
116  neighbours.at(EAST) = E;
117  if (E != DetId(0)) {
118  SE = navigator.south();
119  } else {
120  navigator.home();
121  S = navigator.south();
122  SE = navigator.east();
123  }
124  neighbours.at(SOUTHEAST) = SE;
125 
126  navigator.home();
127  W = navigator.west();
128  neighbours.at(WEST) = W;
129  if (W != DetId(0)) {
130  NW = navigator.north();
131  } else {
132  navigator.home();
133  N = navigator.north();
134  NW = navigator.west();
135  }
136  neighbours.at(NORTHWEST) = NW;
137 
138  unsigned index = getIdx(denseid_c);
139  neighboursHcal_[index] = neighbours;
140  }
141  }

◆ validNeighbours()

template<typename DET, typename TOPO, bool ownsTopo = true>
bool PFHCALDenseIdNavigator< DET, TOPO, ownsTopo >::validNeighbours ( const unsigned int  denseid) const
inline

Definition at line 171 of file PFHCALDenseIdNavigator.h.

171  {
172  bool ok = true;
173  unsigned index = getIdx(denseid);
174  if (neighboursHcal_.at(index).size() != 9)
175  ok = false; // the neighbour vector size should be 3x3
176  return ok;
177  }

Referenced by PFHCALDenseIdNavigator< HcalDetId, HcalTopology, false >::associateNeighbours().

Member Data Documentation

◆ denseIdHcalMax_

template<typename DET, typename TOPO, bool ownsTopo = true>
unsigned int PFHCALDenseIdNavigator< DET, TOPO, ownsTopo >::denseIdHcalMax_
protected

◆ denseIdHcalMin_

template<typename DET, typename TOPO, bool ownsTopo = true>
unsigned int PFHCALDenseIdNavigator< DET, TOPO, ownsTopo >::denseIdHcalMin_
protected

◆ geomToken_

template<typename DET, typename TOPO, bool ownsTopo = true>
edm::ESGetToken<CaloGeometry, CaloGeometryRecord> PFHCALDenseIdNavigator< DET, TOPO, ownsTopo >::geomToken_
private

◆ hcalToken_

template<typename DET, typename TOPO, bool ownsTopo = true>
edm::ESGetToken<HcalTopology, HcalRecNumberingRecord> PFHCALDenseIdNavigator< DET, TOPO, ownsTopo >::hcalToken_
private

◆ neighboursHcal_

template<typename DET, typename TOPO, bool ownsTopo = true>
std::vector<std::vector<DetId> > PFHCALDenseIdNavigator< DET, TOPO, ownsTopo >::neighboursHcal_
protected

◆ theRecNumberWatcher_

template<typename DET, typename TOPO, bool ownsTopo = true>
edm::ESWatcher<HcalRecNumberingRecord> PFHCALDenseIdNavigator< DET, TOPO, ownsTopo >::theRecNumberWatcher_
protected

◆ topology_

template<typename DET, typename TOPO, bool ownsTopo = true>
std::unique_ptr<const TOPO> PFHCALDenseIdNavigator< DET, TOPO, ownsTopo >::topology_
protected

◆ vhcalEnum_

template<typename DET, typename TOPO, bool ownsTopo = true>
std::vector<int> PFHCALDenseIdNavigator< DET, TOPO, ownsTopo >::vhcalEnum_
protected
edm::ESWatcher::check
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
PFRecHitNavigatorBase::associateNeighbour
void associateNeighbour(const DetId &id, reco::PFRecHit &hit, std::unique_ptr< reco::PFRecHitCollection > &hits, edm::RefProd< reco::PFRecHitCollection > &refProd, short eta, short phi, short depth)
Definition: PFRecHitNavigatorBase.h:40
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
HLT_FULL_cff.navigator
navigator
Definition: HLT_FULL_cff.py:13108
DetId::Hcal
Definition: DetId.h:28
PFHCALDenseIdNavigator::vhcalEnum_
std::vector< int > vhcalEnum_
Definition: PFHCALDenseIdNavigator.h:187
PFHCALDenseIdNavigator::validNeighbours
bool validNeighbours(const unsigned int denseid) const
Definition: PFHCALDenseIdNavigator.h:171
PFHCALDenseIdNavigator::denseIdHcalMin_
unsigned int denseIdHcalMin_
Definition: PFHCALDenseIdNavigator.h:190
convertSQLiteXML.ok
bool ok
Definition: convertSQLiteXML.py:98
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
PFHCALDenseIdNavigator::denseIdHcalMax_
unsigned int denseIdHcalMax_
Definition: PFHCALDenseIdNavigator.h:189
DetId
Definition: DetId.h:17
CaloGeometry
Definition: CaloGeometry.h:21
RPCNoise_example.check
check
Definition: RPCNoise_example.py:71
EAST
Definition: CaloDirection.h:14
NORTH
Definition: CaloDirection.h:18
SOUTHEAST
Definition: CaloDirection.h:12
edm::ESHandle< HcalTopology >
N
#define N
Definition: blowfish.cc:9
edm::Transition::BeginLuminosityBlock
S
double S(const TLorentzVector &, const TLorentzVector &)
Definition: Particle.cc:97
jetUpdater_cfi.sort
sort
Definition: jetUpdater_cfi.py:29
PFHCALDenseIdNavigator::getIdx
unsigned int getIdx(const unsigned int denseid) const
Definition: PFHCALDenseIdNavigator.h:179
SOUTHWEST
Definition: CaloDirection.h:13
edm::EventSetup::getHandle
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:155
PFHCALDenseIdNavigator::theRecNumberWatcher_
edm::ESWatcher< HcalRecNumberingRecord > theRecNumberWatcher_
Definition: PFHCALDenseIdNavigator.h:185
PFHCALDenseIdNavigator::topology_
std::unique_ptr< const TOPO > topology_
Definition: PFHCALDenseIdNavigator.h:186
PFHCALDenseIdNavigator::geomToken_
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > geomToken_
Definition: PFHCALDenseIdNavigator.h:194
cc
CaloNavigator
Definition: CaloNavigator.h:7
CaloGeometry::getValidDetIds
std::vector< DetId > getValidDetIds() const
Get the list of all valid detector ids.
Definition: CaloGeometry.cc:75
WEST
Definition: CaloDirection.h:15
NORTHWEST
Definition: CaloDirection.h:17
NONE
Definition: TkAlStyle.cc:47
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
S
Definition: CSCDBL1TPParametersExtended.h:16
PFHCALDenseIdNavigator::hcalToken_
edm::ESGetToken< HcalTopology, HcalRecNumberingRecord > hcalToken_
Definition: PFHCALDenseIdNavigator.h:193
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
SOUTH
Definition: CaloDirection.h:11
NORTHEAST
Definition: CaloDirection.h:16
PFHCALDenseIdNavigator::neighboursHcal_
std::vector< std::vector< DetId > > neighboursHcal_
Definition: PFHCALDenseIdNavigator.h:188
hit
Definition: SiStripHitEffFromCalibTree.cc:88