1 #ifndef RecoParticleFlow_PFClusterProducer_PFHCALDenseIdNavigator_h 2 #define RecoParticleFlow_PFClusterProducer_PFHCALDenseIdNavigator_h 25 template <
typename DET,
typename TOPO,
bool ownsTopo = true>
53 std::vector<DetId> vecHcal;
54 std::vector<unsigned int> vDenseIdHcal;
58 vecHcal.insert(vecHcal.end(), vecDetIds.begin(), vecDetIds.end());
60 vDenseIdHcal.reserve(vecHcal.size());
61 for (
auto hDetId : vecHcal) {
62 vDenseIdHcal.push_back(
topology_.get()->detId2denseId(hDetId));
64 std::sort(vDenseIdHcal.begin(), vDenseIdHcal.end());
67 denseIdHcalMax_ = *max_element(vDenseIdHcal.begin(), vDenseIdHcal.end());
68 denseIdHcalMin_ = *min_element(vDenseIdHcal.begin(), vDenseIdHcal.end());
71 for (
auto denseid : vDenseIdHcal) {
72 std::vector<DetId> neighbours(9,
DetId(0));
75 unsigned denseid_c = denseid;
81 neighbours.at(
NONE) = detid_c;
109 for (
auto denseid : vDenseIdHcal) {
117 edm::LogWarning(
"PFHCALDenseIdNavigator") <<
"The vector for neighbour information has an invalid length";
120 std::vector<DetId> neighbours(9,
DetId(0));
123 edm::LogWarning(
"PFHCALDenseIdNavigator") <<
"The vector for neighbour information is not found";
131 for (
auto neighbour : neighbours) {
133 if (neighbour ==
DetId(0))
136 std::vector<DetId> neighboursOfNeighbour(9,
DetId(0));
137 std::unordered_set<unsigned int> listOfNeighboursOfNeighbour;
138 unsigned denseidNeighbour =
topology_.get()->detId2denseId(neighbour);
142 <<
"This neighbour does not have a valid neighbour information (another subdetector?). Ignore: " 143 <<
detid.det() <<
" " << hid.
ieta() <<
" " << hid.
iphi() <<
" " << hid.
depth() <<
" " << neighbour.det()
144 <<
" " << hidn.
ieta() <<
" " << hidn.
iphi() <<
" " << hidn.
depth();
154 for (
auto neighbourOfNeighbour : neighboursOfNeighbour) {
155 if (neighbourOfNeighbour ==
DetId(0))
157 unsigned denseidNeighbourOfNeighbour =
topology_.get()->detId2denseId(neighbourOfNeighbour);
160 listOfNeighboursOfNeighbour.insert(denseidNeighbourOfNeighbour);
164 if (listOfNeighboursOfNeighbour.find(denseid) == listOfNeighboursOfNeighbour.end()) {
167 <<
"This neighbour does not have the original channel as its neighbour. Ignore: " <<
detid.det() <<
" " 168 << hid.
ieta() <<
" " << hid.
iphi() <<
" " << hid.
depth() <<
" " << neighbour.det() <<
" " << hidn.
ieta()
169 <<
" " << hidn.
iphi() <<
" " << hidn.
depth();
180 for (
auto denseid : vDenseIdHcal) {
181 std::vector<DetId> neighbours(9,
DetId(0));
184 unsigned denseid_c = denseid;
251 if (direction == 4) {
265 if (direction == 5) {
279 if (direction == 6) {
293 if (direction == 7) {
312 std::unique_ptr<reco::PFRecHitCollection>&
hits,
318 std::vector<DetId> neighbours(9,
DetId(0));
322 <<
" DenseId for this cell is out of the expected range." << std::endl;
325 <<
" DenseId for this cell does not have the neighbour information. " << hid.ieta() <<
" " << hid.iphi()
326 <<
" " << hid.depth() <<
" " << hid.subdetId();
353 const unsigned int getIdx(
const unsigned int denseid)
const {
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)
const bool checkSameSubDet(const DetId detId, const DetId detId2)
uint32_t cc[maxCellsPerHit]
void associateNeighbours(reco::PFRecHit &hit, std::unique_ptr< reco::PFRecHitCollection > &hits, edm::RefProd< reco::PFRecHitCollection > &refProd) override
void backwardCompatibilityCheck(const std::vector< unsigned int > vDenseIdHcal)
static constexpr uint32_t kHcalZsideMask2
std::unique_ptr< const TOPO > topology_
edm::ESWatcher< HcalRecNumberingRecord > theRecNumberWatcher_
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > geomToken_
T const * product() const
Particle flow rechit (rechit + geometry and topology information). See clustering algorithm in PFClus...
constexpr int ieta() const
get the cell ieta
static constexpr int getZside(const DetId detId)
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
void printNeighbourInfo(const std::vector< unsigned int > vDenseIdHcal)
unsigned int denseIdHcalMax_
std::vector< std::vector< DetId > > neighboursHcal_
Log< level::Warning, true > LogPrint
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
edm::ESGetToken< HcalTopology, HcalRecNumberingRecord > hcalToken_
PFHCALDenseIdNavigator(const edm::ParameterSet &iConfig, edm::ConsumesCollector &cc)
~PFHCALDenseIdNavigator() override
std::vector< DetId > getValidDetIds() const
Get the list of all valid detector ids.
bool check(const edm::EventSetup &iSetup)
const uint32_t getNeighbourDetId(const DetId detId, const uint32_t direction)
void init(const edm::EventSetup &iSetup) override
std::vector< int > vhcalEnum_
const bool validNeighbours(const unsigned int denseid) const
unsigned int denseIdHcalMin_
Log< level::Warning, false > LogWarning
const unsigned int getIdx(const unsigned int denseid) const
constexpr int iphi() const
get the cell iphi
constexpr int depth() const
get the tower depth