-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
mitigate high CPU cost of HBHE hit position calculation in EgammaHcalIsolation #35955
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -118,52 +118,60 @@ EgammaHcalIsolation::EgammaHcalIsolation(InclusionRule extIncRule, | |
} | ||
} | ||
|
||
double EgammaHcalIsolation::goodHitEnergy(const GlobalPoint &pclu, | ||
double EgammaHcalIsolation::goodHitEnergy(float pcluEta, | ||
float pcluPhi, | ||
const HBHERecHit &hit, | ||
int depth, | ||
int ieta, | ||
int iphi, | ||
int include_or_exclude, | ||
double (*scale)(const double &)) const { | ||
const auto phit = caloGeometry_.getPosition(hit.detid()); | ||
|
||
if ((extIncRule_ == InclusionRule::withinConeAroundCluster and deltaR2(pclu, phit) > extRadius_) or | ||
(intIncRule_ == InclusionRule::withinConeAroundCluster and deltaR2(pclu, phit) < intRadius_)) | ||
return 0.; | ||
|
||
const HcalDetId hid(hit.detid()); | ||
const int hd = hid.depth(), he = hid.ieta(), hp = hid.iphi(); | ||
const int h1 = hd - 1; | ||
|
||
if ((hid.subdet() == HcalBarrel and (hd < 1 or hd > int(eThresHB_.size()))) or | ||
(hid.subdet() == HcalEndcap and (hd < 1 or hd > int(eThresHE_.size())))) | ||
edm::LogWarning("EgammaHcalIsolation") | ||
<< " hit in subdet " << hid.subdet() << " has an unaccounted for depth of " << hd << "!!"; | ||
|
||
if (include_or_exclude == -1 and (he != ieta or hp != iphi)) | ||
return 0.; | ||
|
||
if (include_or_exclude == 1 and (he == ieta and hp == iphi)) | ||
return 0.; | ||
|
||
if ((hid.subdet() == HcalBarrel and (hd < 1 or hd > int(eThresHB_.size()))) or | ||
(hid.subdet() == HcalEndcap and (hd < 1 or hd > int(eThresHE_.size())))) | ||
edm::LogWarning("EgammaHcalIsolation") | ||
<< " hit in subdet " << hid.subdet() << " has an unaccounted for depth of " << hd << "!!"; | ||
|
||
const bool right_depth = (depth == 0 or hd == depth); | ||
if (!right_depth) | ||
return 0.; | ||
|
||
const bool goodHBe = hid.subdet() == HcalBarrel and hit.energy() > eThresHB_[h1]; | ||
const bool goodHEe = hid.subdet() == HcalEndcap and hit.energy() > eThresHE_[h1]; | ||
if (!(goodHBe or goodHEe)) | ||
return 0.; | ||
|
||
const auto phit = caloGeometry_.getPosition(hit.detid()); | ||
const float phitEta = phit.eta(); | ||
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. use cashed eta in caloGeometry_ 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. please clarify the member method 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. RhoEtaPhi const& repPos() const { return m_rep; } 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. eventually through CaloGeometry::getGeometry if not in the same SubDetector 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. one could extend the CaloGeometry interface to support 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. ah, so the suggestion is for an extension to the geometry interface; I thought at first that this is something that exists already. IIRC, there is one rechit per cell in ECAL/HCAL 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. it exits already in CaloCellGeometry that is what CaloGeometry access. please have a look to the implementation in 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. here https://github.com/slava77/cmssw/blob/f33bdaa8be9c4aa4a3f336dbf23501b059a8988b/RecoEgamma/EgammaIsolationAlgos/src/EgammaHcalIsolation.cc#L188 |
||
|
||
if (extIncRule_ == InclusionRule::withinConeAroundCluster or intIncRule_ == InclusionRule::withinConeAroundCluster) { | ||
auto const dR2 = deltaR2(pcluEta, pcluPhi, phitEta, phit.phi()); | ||
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. use cashed phi in caloGeometry |
||
if ((extIncRule_ == InclusionRule::withinConeAroundCluster and dR2 > extRadius_) or | ||
(intIncRule_ == InclusionRule::withinConeAroundCluster and dR2 < intRadius_)) | ||
return 0.; | ||
} | ||
|
||
DetId did = hcalTopology_.idFront(hid); | ||
const uint32_t flag = hit.flags(); | ||
const uint32_t dbflag = hcalChStatus_.getValues(did)->getValue(); | ||
int severity = hcalSevLvlComputer_.getSeverityLevel(did, flag, dbflag); | ||
bool recovered = hcalSevLvlComputer_.recoveredRecHit(did, flag); | ||
|
||
const double het = hit.energy() * scaleToEt(phit.eta()); | ||
const bool goodHB = hid.subdet() == HcalBarrel and (severity <= maxSeverityHB_ or recovered) and | ||
hit.energy() > eThresHB_[h1] and het > etThresHB_[h1]; | ||
const bool goodHE = hid.subdet() == HcalEndcap and (severity <= maxSeverityHE_ or recovered) and | ||
hit.energy() > eThresHE_[h1] and het > etThresHE_[h1]; | ||
const double het = hit.energy() * scaleToEt(phitEta); | ||
const bool goodHB = goodHBe and (severity <= maxSeverityHB_ or recovered) and het > etThresHB_[h1]; | ||
const bool goodHE = goodHEe and (severity <= maxSeverityHE_ or recovered) and het > etThresHE_[h1]; | ||
|
||
if (goodHB or goodHE) | ||
return hit.energy() * scale(phit.eta()); | ||
return hit.energy() * scale(phitEta); | ||
|
||
return 0.; | ||
} | ||
|
@@ -175,8 +183,10 @@ double EgammaHcalIsolation::getHcalSum(const GlobalPoint &pclu, | |
int include_or_exclude, | ||
double (*scale)(const double &)) const { | ||
double sum = 0.; | ||
const float pcluEta = pclu.eta(); | ||
const float pcluPhi = pclu.phi(); | ||
for (const auto &hit : mhbhe_) | ||
sum += goodHitEnergy(pclu, hit, depth, ieta, iphi, include_or_exclude, scale); | ||
sum += goodHitEnergy(pcluEta, pcluPhi, hit, depth, ieta, iphi, include_or_exclude, scale); | ||
|
||
return sum; | ||
} |
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.
suggested change:
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.
Thanks. Testing.
PR soon.