-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
[HGCAL trigger] Fix percentile out of bound #28570
Conversation
The code-checks are being triggered in jenkins. |
+code-checks Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-28570/13062
|
A new Pull Request was created by @jbsauvan (Jean-Baptiste Sauvan) for master. It involves the following packages: L1Trigger/L1THGCal @cmsbuild, @rekovic, @benkrikler, @kpedro88 can you please review it and eventually sign? Thanks. cms-bot commands are listed here |
please test |
The tests are being triggered in jenkins. |
@@ -133,7 +133,7 @@ float HGCalShowerShape::percentileLayer(const l1t::HGCalMulticluster& c3d, | |||
} | |||
// Linear interpolation of percentile value | |||
double pt0 = (percentile > 0 ? layers[percentile - 1] : 0.); | |||
double pt1 = layers[percentile]; | |||
double pt1 = (percentile < layers.size() ? layers[percentile] : layers.back()); |
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.
Can layers.size() == 0
? If so then calling layers.back()
in that case reads off the end (and may cause a segmentation fault since it is likely to be reading memory location 0).
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.
The size of layers
is given by the number of HGCAL layers :
cmssw/L1Trigger/L1THGCal/src/backend/HGCalShowerShape.cc
Lines 111 to 112 in 04f9376
unsigned nlayers = triggerTools_.layers(ForwardSubdetector::ForwardEmpty); | |
std::vector<double> layers(nlayers, 0); |
where the trigger tools returns this:
cmssw/L1Trigger/L1THGCal/src/HGCalTriggerTools.cc
Lines 72 to 73 in 04f9376
case ForwardSubdetector::ForwardEmpty: | |
layers = totalLayers_; |
Which is computed from the HGCAL geometry:
cmssw/L1Trigger/L1THGCal/src/HGCalTriggerTools.cc
Lines 38 to 47 in 04f9376
eeLayers_ = geom_->eeTopology().dddConstants().layers(true); | |
fhLayers_ = geom_->fhTopology().dddConstants().layers(true); | |
if (geom_->isV9Geometry()) { | |
bhLayers_ = geom_->hscTopology().dddConstants().layers(true); | |
totalLayers_ = eeLayers_ + fhLayers_; | |
} else { | |
bhLayers_ = geom_->bhTopology().dddConstants()->getMaxDepth(1); | |
totalLayers_ = eeLayers_ + fhLayers_ + bhLayers_; | |
} | |
} |
So unless something really bad happens it shouldn't be 0
Comparison job queued. |
Comparison is ready Comparison Summary:
|
+upgrade |
+1 @rekovic please have a look |
merge |
PR description:
Fix out of bound in layer percentile interpolation. See issue #28566.
PR validation:
Ran on HGCAL V9 sample.
Tested extreme case where no trigger cell are selected in the computation, which gives 0 energy in all the layers.