CMS 3D CMS Logo

List of all members | Public Member Functions | Protected 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)
 
bool validNeighbours (const unsigned int denseid) const
 
 ~PFHCALDenseIdNavigator () override
 
- Public Member Functions inherited from PFRecHitNavigatorBase
 PFRecHitNavigatorBase ()=default
 
 PFRecHitNavigatorBase (const edm::ParameterSet &iConfig)
 
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_
 

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 25 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 27 of file PFHCALDenseIdNavigator.h.

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

◆ PFHCALDenseIdNavigator()

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

Definition at line 33 of file PFHCALDenseIdNavigator.h.

33  {
34  vhcalEnum_ = iConfig.getParameter<std::vector<int>>("hcalEnums");
35  }

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 142 of file PFHCALDenseIdNavigator.h.

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

◆ 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 37 of file PFHCALDenseIdNavigator.h.

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

◆ validNeighbours()

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

Definition at line 170 of file PFHCALDenseIdNavigator.h.

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

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

◆ 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:52
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:41
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
HLT_FULL_cff.navigator
navigator
Definition: HLT_FULL_cff.py:13192
CaloGeometryRecord
Definition: CaloGeometryRecord.h:30
DetId::Hcal
Definition: DetId.h:28
PFHCALDenseIdNavigator::vhcalEnum_
std::vector< int > vhcalEnum_
Definition: PFHCALDenseIdNavigator.h:186
PFHCALDenseIdNavigator::validNeighbours
bool validNeighbours(const unsigned int denseid) const
Definition: PFHCALDenseIdNavigator.h:170
PFHCALDenseIdNavigator::denseIdHcalMin_
unsigned int denseIdHcalMin_
Definition: PFHCALDenseIdNavigator.h:189
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:188
DetId
Definition: DetId.h:17
CaloGeometry
Definition: CaloGeometry.h:21
RPCNoise_example.check
check
Definition: RPCNoise_example.py:71
edm::EventSetup::get
T get() const
Definition: EventSetup.h:80
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
HcalRecNumberingRecord
Definition: HcalRecNumberingRecord.h:23
S
double S(const TLorentzVector &, const TLorentzVector &)
Definition: Particle.cc:97
PFHCALDenseIdNavigator::getIdx
unsigned int getIdx(const unsigned int denseid) const
Definition: PFHCALDenseIdNavigator.h:178
SOUTHWEST
Definition: CaloDirection.h:13
PFHCALDenseIdNavigator::theRecNumberWatcher_
edm::ESWatcher< HcalRecNumberingRecord > theRecNumberWatcher_
Definition: PFHCALDenseIdNavigator.h:184
PFHCALDenseIdNavigator::topology_
std::unique_ptr< const TOPO > topology_
Definition: PFHCALDenseIdNavigator.h:185
get
#define get
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
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:187
hit
Definition: SiStripHitEffFromCalibTree.cc:88