New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PFRecHit navigator for HCAL with dense index #29049
Merged
cmsbuild
merged 23 commits into
cms-sw:master
from
hatakeyamak:PFRecHitNavigatorForHcalWithDenseId
Mar 9, 2020
Merged
Changes from 22 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
a7289f8
clean up config files for PF HBHE and HF rechit producers
hatakeyamak a80c85b
Adding a new navigator for HCAL that uses a cached list of neighbours
hatakeyamak 3864d1e
Move some of initilization from beginEvent/beginLuminosityBlock to be…
hatakeyamak b321e40
HLT customization for PFRecHitProducer (HBHE/HF) update
hatakeyamak 036dcc8
Cleanup
hatakeyamak 126664d
cleanup
hatakeyamak 6b156b8
Introduce PFHCALDenseIdNavigator
hatakeyamak b73f9f8
Cleanup of PRRecHit producer update for HCAL
hatakeyamak 82bfdb8
apply changes to HLT
hatakeyamak b5270e6
clean up config files for PF HBHE and HF rechit producers
hatakeyamak 84b782d
Adding a new navigator for HCAL that uses a cached list of neighbours
hatakeyamak 4852f88
Move some of initilization from beginEvent/beginLuminosityBlock to be…
hatakeyamak ee5700f
HLT customization for PFRecHitProducer (HBHE/HF) update
hatakeyamak 19c1fd4
Cleanup
hatakeyamak 271750e
cleanup
hatakeyamak 46f4383
Introduce PFHCALDenseIdNavigator
hatakeyamak 799c759
Cleanup of PRRecHit producer update for HCAL
hatakeyamak 03b78bc
apply changes to HLT
hatakeyamak 0c76452
cleanup
hatakeyamak 914772a
cleanup conflict
hatakeyamak 5f05257
clang-format
hatakeyamak 8c80609
cleanup customizeHLTforCMSSW
hatakeyamak 29da198
Use range-based for-loop. And, some clean-up
hatakeyamak File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
192 changes: 192 additions & 0 deletions
192
RecoParticleFlow/PFClusterProducer/interface/PFHCALDenseIdNavigator.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,192 @@ | ||
#ifndef RecoParticleFlow_PFClusterProducer_PFHCALDenseIdNavigator_h | ||
#define RecoParticleFlow_PFClusterProducer_PFHCALDenseIdNavigator_h | ||
|
||
#include "FWCore/Framework/interface/ESWatcher.h" | ||
|
||
#include "RecoParticleFlow/PFClusterProducer/interface/PFRecHitNavigatorBase.h" | ||
#include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h" | ||
#include "Geometry/CaloGeometry/interface/CaloGeometry.h" | ||
|
||
#include "RecoCaloTools/Navigation/interface/CaloNavigator.h" | ||
#include "DataFormats/EcalDetId/interface/EBDetId.h" | ||
#include "DataFormats/EcalDetId/interface/EEDetId.h" | ||
#include "DataFormats/EcalDetId/interface/ESDetId.h" | ||
#include "DataFormats/HcalDetId/interface/HcalDetId.h" | ||
|
||
#include "Geometry/CaloTopology/interface/EcalEndcapTopology.h" | ||
#include "Geometry/CaloTopology/interface/EcalBarrelTopology.h" | ||
#include "Geometry/CaloTopology/interface/EcalPreshowerTopology.h" | ||
#include "Geometry/CaloTopology/interface/HcalTopology.h" | ||
|
||
#include "Geometry/CaloTopology/interface/CaloTowerTopology.h" | ||
#include "DataFormats/CaloTowers/interface/CaloTowerDetId.h" | ||
|
||
template <typename DET, typename TOPO, bool ownsTopo = true> | ||
class PFHCALDenseIdNavigator : public PFRecHitNavigatorBase { | ||
public: | ||
~PFHCALDenseIdNavigator() override { | ||
if (!ownsTopo) { | ||
topology_.release(); | ||
} | ||
} | ||
|
||
PFHCALDenseIdNavigator(const edm::ParameterSet& iConfig) { | ||
vdetectorEnum_ = iConfig.getParameter<std::vector<int>>("detectorEnums"); | ||
} | ||
|
||
void init(const edm::EventSetup& iSetup) override { | ||
bool check = theRecNumberWatcher_.check(iSetup); | ||
if (!check) | ||
return; | ||
|
||
edm::ESHandle<HcalTopology> hcalTopology; | ||
iSetup.get<HcalRecNumberingRecord>().get(hcalTopology); | ||
topology_.release(); | ||
topology_.reset(hcalTopology.product()); | ||
|
||
// Fill a vector of valid denseid's | ||
edm::ESHandle<CaloGeometry> hGeom; | ||
iSetup.get<CaloGeometryRecord>().get(hGeom); | ||
const CaloGeometry& caloGeom = *hGeom; | ||
|
||
std::vector<DetId> vecHcal; | ||
std::vector<unsigned int> vDenseIdHcal; | ||
neighboursHcal_.clear(); | ||
for (unsigned i = 0; i < vdetectorEnum_.size(); ++i) { | ||
std::vector<DetId> vecDetIds(caloGeom.getValidDetIds(DetId::Hcal, vdetectorEnum_.at(i))); | ||
vecHcal.insert(vecHcal.end(), vecDetIds.begin(), vecDetIds.end()); | ||
} | ||
for (unsigned i = 0; i < vecHcal.size(); ++i) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A range based for loop could be more appropriate here |
||
vDenseIdHcal.push_back(topology_.get()->detId2denseId(vecHcal.at(i))); | ||
} | ||
std::sort(vDenseIdHcal.begin(), vDenseIdHcal.end()); | ||
|
||
// Fill a vector of cell neighbours | ||
denseIdHcalMax_ = *max_element(vDenseIdHcal.begin(), vDenseIdHcal.end()); | ||
denseIdHcalMin_ = *min_element(vDenseIdHcal.begin(), vDenseIdHcal.end()); | ||
neighboursHcal_.resize(denseIdHcalMax_ - denseIdHcalMin_ + 1); | ||
|
||
for (unsigned i = 0; i < vDenseIdHcal.size(); ++i) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A range based for loop could be more appropriate here |
||
DetId N(0); | ||
DetId E(0); | ||
DetId S(0); | ||
DetId W(0); | ||
DetId NW(0); | ||
DetId NE(0); | ||
DetId SW(0); | ||
DetId SE(0); | ||
std::vector<DetId> neighbours(9, DetId(0)); | ||
|
||
// the centre | ||
unsigned denseid_c = vDenseIdHcal.at(i); | ||
DetId detid_c = topology_.get()->denseId2detId(denseid_c); | ||
CaloNavigator<DET> navigator(detid_c, topology_.get()); | ||
|
||
// Using enum in Geometry/CaloTopology/interface/CaloDirection.h | ||
// Order: CENTER(NONE),SOUTH,SOUTHEAST,SOUTHWEST,EAST,WEST,NORTHEAST,NORTHWEST,NORTH | ||
neighbours.at(NONE) = detid_c; | ||
|
||
navigator.home(); | ||
N = navigator.north(); | ||
neighbours.at(NORTH) = N; | ||
if (N != DetId(0)) { | ||
NE = navigator.east(); | ||
} else { | ||
navigator.home(); | ||
E = navigator.east(); | ||
NE = navigator.north(); | ||
} | ||
neighbours.at(NORTHEAST) = NE; | ||
|
||
navigator.home(); | ||
S = navigator.south(); | ||
neighbours.at(SOUTH) = S; | ||
if (S != DetId(0)) { | ||
SW = navigator.west(); | ||
} else { | ||
navigator.home(); | ||
W = navigator.west(); | ||
SW = navigator.south(); | ||
} | ||
neighbours.at(SOUTHWEST) = SW; | ||
|
||
navigator.home(); | ||
E = navigator.east(); | ||
neighbours.at(EAST) = E; | ||
if (E != DetId(0)) { | ||
SE = navigator.south(); | ||
} else { | ||
navigator.home(); | ||
S = navigator.south(); | ||
SE = navigator.east(); | ||
} | ||
neighbours.at(SOUTHEAST) = SE; | ||
|
||
navigator.home(); | ||
W = navigator.west(); | ||
neighbours.at(WEST) = W; | ||
if (W != DetId(0)) { | ||
NW = navigator.north(); | ||
} else { | ||
navigator.home(); | ||
N = navigator.north(); | ||
NW = navigator.west(); | ||
} | ||
neighbours.at(NORTHWEST) = NW; | ||
|
||
unsigned index = getIdx(denseid_c); | ||
neighboursHcal_[index] = neighbours; | ||
} | ||
} | ||
|
||
void associateNeighbours(reco::PFRecHit& hit, | ||
std::unique_ptr<reco::PFRecHitCollection>& hits, | ||
edm::RefProd<reco::PFRecHitCollection>& refProd) override { | ||
DetId detid(hit.detId()); | ||
unsigned denseid = topology_.get()->detId2denseId(detid); | ||
|
||
std::vector<DetId> neighbours(9, DetId(0)); | ||
|
||
if (denseid < denseIdHcalMin_ || denseid > denseIdHcalMax_) { | ||
edm::LogWarning("PFRecHitHCALCachedNavigator") << " DenseId for this cell is out of the range." << std::endl; | ||
} else if (!validNeighbours(denseid)) { | ||
edm::LogWarning("PFRecHitHCALCachedNavigator") | ||
<< " DenseId for this cell does not have the neighbour information." << std::endl; | ||
} else { | ||
unsigned index = getIdx(denseid); | ||
neighbours = neighboursHcal_.at(index); | ||
} | ||
|
||
associateNeighbour(neighbours.at(NORTH), hit, hits, refProd, 0, 1, 0); // N | ||
associateNeighbour(neighbours.at(NORTHEAST), hit, hits, refProd, 1, 1, 0); // NE | ||
associateNeighbour(neighbours.at(SOUTH), hit, hits, refProd, 0, -1, 0); // S | ||
associateNeighbour(neighbours.at(SOUTHWEST), hit, hits, refProd, -1, -1, 0); // SW | ||
associateNeighbour(neighbours.at(EAST), hit, hits, refProd, 1, 0, 0); // E | ||
associateNeighbour(neighbours.at(SOUTHEAST), hit, hits, refProd, 1, -1, 0); // SE | ||
associateNeighbour(neighbours.at(WEST), hit, hits, refProd, -1, 0, 0); // W | ||
associateNeighbour(neighbours.at(NORTHWEST), hit, hits, refProd, -1, 1, 0); // NW | ||
} | ||
|
||
bool validNeighbours(const unsigned int denseid) const { | ||
bool ok = true; | ||
unsigned index = getIdx(denseid); | ||
if (neighboursHcal_.at(index).size() != 9) | ||
ok = false; // the neighbour vector size should be 3x3 | ||
return ok; | ||
} | ||
|
||
unsigned int getIdx(const unsigned int denseid) const { | ||
unsigned index = denseid - denseIdHcalMin_; | ||
return index; | ||
} | ||
|
||
protected: | ||
edm::ESWatcher<HcalRecNumberingRecord> theRecNumberWatcher_; | ||
std::unique_ptr<const TOPO> topology_; | ||
std::vector<int> vdetectorEnum_; | ||
std::vector<std::vector<DetId>> neighboursHcal_; | ||
unsigned int denseIdHcalMax_; | ||
unsigned int denseIdHcalMin_; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A range based for loop could be more appropriate here