Skip to content

Conversation

@nucleosynthesis
Copy link
Contributor

@nucleosynthesis nucleosynthesis commented Nov 5, 2025

Avoid error with silent clipping (make it explicit) when setting POI values in scan for upper limits.

Summary by CodeRabbit

  • Bug Fixes
    • Parameter values are now clamped to valid bounds during evaluation, preventing out-of-range assignments and related unexpected behavior.
  • Tests
    • Test suite updated to capture and compare command output against a reference file, improving output verification.

Avoid error with silent clipping (make it explicit) when setting POI values in scan for upper limits.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 5, 2025

Walkthrough

Clamp POI input values to the parameter's min/max before assignment in HybridNew::eval; update test CMake to redirect combine command output to a reference file for the LHC-limits test.

Changes

Cohort / File(s) Summary
Parameter bounds clamping
src/HybridNew.cc
In eval, clamp rIn->getVal() to [r->getMin(), r->getMax()] before setting the POI value; added comment noting the underflow case should not occur.
Test output redirection
test/CMakeLists.txt
Replaced commented checkout/output handling with an active CHECKOUT OUTPUT and added ALL_COMBINE_COMMANDS entry to redirect combine stdout to references/LHC-limits.out.

Sequence Diagram(s)

sequenceDiagram
    participant Caller as Evaluation driver
    participant Hybrid as HybridNew::eval
    participant POI as POI parameter (r)

    rect rgb(235,245,255)
    Caller->>Hybrid: provide rIn (value)
    Hybrid->>POI: getMin(), getMax()
    note right of Hybrid: clamp value to [min,max]
    Hybrid->>POI: setVal(clamped_value)
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Small, localized logic change in src/HybridNew.cc (verify clamp semantics).
  • Minor CMake test change (verify test output redirection and reference file path).

Possibly related PRs

Poem

🐰 I nibble values, trim each hop,

From min to max I gently stop,
No out-of-bounds shall cross my lawn,
Tests now log where outputs dawn,
A tidy hop — then on we yawn.

Pre-merge checks and finishing touches

✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add value clamping for RooRealVar parameters' accurately reflects the main change in src/HybridNew.cc, which adds clamping of POI parameter values to their bounds. However, the PR also modifies test/CMakeLists.txt to re-enable test output comparison, which is not mentioned in the title.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch nucleosynthesis-patch-1

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ea6127a and c3cf686.

📒 Files selected for processing (1)
  • test/CMakeLists.txt (1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: guitargeek
Repo: cms-analysis/HiggsAnalysis-CombinedLimit PR: 1163
File: test/CMakeLists.txt:270-277
Timestamp: 2025-11-05T10:16:10.017Z
Learning: In PR #1163, the file test/references/LHC-Higgs-coupling-models-text2workspace.out was present and correctly included in the repository, despite an earlier incorrect comment flagging it as missing.
📚 Learning: 2025-11-05T10:16:10.017Z
Learnt from: guitargeek
Repo: cms-analysis/HiggsAnalysis-CombinedLimit PR: 1163
File: test/CMakeLists.txt:270-277
Timestamp: 2025-11-05T10:16:10.017Z
Learning: In PR #1163, the file test/references/LHC-Higgs-coupling-models-text2workspace.out was present and correctly included in the repository, despite an earlier incorrect comment flagging it as missing.

Applied to files:

  • test/CMakeLists.txt
📚 Learning: 2025-11-05T10:12:07.843Z
Learnt from: guitargeek
Repo: cms-analysis/HiggsAnalysis-CombinedLimit PR: 1163
File: test/CMakeLists.txt:279-287
Timestamp: 2025-11-05T10:12:07.843Z
Learning: In PR #1163, the file test/references/hzz4l-significance.out was present and correctly included in the repository, despite an earlier incorrect comment flagging it as missing.

Applied to files:

  • test/CMakeLists.txt
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
  • GitHub Check: dev3/latest - ROOT LCG master
  • GitHub Check: precheckin
  • GitHub Check: LCG_108 - ROOT 6.36.02
  • GitHub Check: CMSSW_14_0_0_pre1 - ROOT 6.26.11
  • GitHub Check: LCG_102 - ROOT 6.26.04
  • GitHub Check: CMSSW_14_1_0_pre4 - ROOT 6.30.07
  • GitHub Check: CMSSW_11_3_4 - ROOT 6.22.09
  • GitHub Check: LCG_106 - ROOT 6.32.02
  • GitHub Check: Compile (py3.10, root6.26.4)
  • GitHub Check: Compile (py3.10, root6.32.2)
  • GitHub Check: Compile (py3.12, root6.34.4)
🔇 Additional comments (1)
test/CMakeLists.txt (1)

289-297: Re-enable LHC-limits test output comparison as requested.

The changes correctly re-enable output comparison for the LHC-limits test by uncommenting the CHECKOUT OUTPUT and set_property directives. The structure aligns with the established pattern used in similar tests like hzz4l-significance (lines 279–287) and LHC-Higgs-coupling-models-text2workspace (lines 270–277). The required reference file test/references/LHC-limits.out exists and contains valid combine output.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/HybridNew.cc (1)

716-718: Consider adding logging when clamping occurs for better observability.

The clamping logic is correct, but it operates silently. Since the PR aims to prevent "unexpected silent clipping," consider adding log messages when values are clamped. Additionally, line 717's comment states "this should never be the case"—if this condition truly shouldn't occur, consider adding a warning or assertion to catch unexpected behavior during development.

Apply this diff to add logging:

-		if ( rIn->getVal() > r->getMax() ) r->setVal(r->getMax());
-		else if ( rIn->getVal() < r->getMin() ) r->setVal(r->getMin()); // this should never be the case
-		else r->setVal(rIn->getVal());
+		if ( rIn->getVal() > r->getMax() ) {
+			if (verbose > 0) CombineLogger::instance().log("HybridNew.cc",__LINE__,std::string(Form("Clamping %s from %g to max %g", rIn->GetName(), rIn->getVal(), r->getMax())),__func__);
+			r->setVal(r->getMax());
+		}
+		else if ( rIn->getVal() < r->getMin() ) {
+			CombineLogger::instance().log("HybridNew.cc",__LINE__,std::string(Form("[WARNING] Unexpected: clamping %s from %g to min %g (this should not happen)", rIn->GetName(), rIn->getVal(), r->getMin())),__func__);
+			r->setVal(r->getMin());
+		}
+		else r->setVal(rIn->getVal());
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b5e528b and ea6127a.

📒 Files selected for processing (1)
  • src/HybridNew.cc (1 hunks)

@guitargeek
Copy link
Collaborator

Hi, thanks a lot! Would you mind also enabling the comparison with the reference file for the test that was failing before with ROOT master?

It's just commenting these 4 lines back in and removing the TODO:
https://github.com/cms-analysis/HiggsAnalysis-CombinedLimit/blob/main/test/CMakeLists.txt#L294

@nucleosynthesis
Copy link
Contributor Author

Sure, just pushed that too

@anigamova anigamova merged commit 723a5ee into main Nov 6, 2025
14 of 15 checks passed
@nucleosynthesis nucleosynthesis deleted the nucleosynthesis-patch-1 branch November 6, 2025 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants