Skip to content

[PWGDQ] Change type of cut lists to AnalysisCut* - #18715

Open
axti98 wants to merge 4 commits into
AliceO2Group:masterfrom
axti98:FixReinterpretCast
Open

axti98 wants to merge 4 commits into
AliceO2Group:masterfrom
axti98:FixReinterpretCast

Conversation

@axti98

@axti98 axti98 commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

In the original implementation, the track, muon, and hadron cut lists in several tasks were of the type std::vector<AnalysisCompositeCut*>, which made it necessary to cast the return values of type AnalysisCut* to AnalysisCompositeCut*.

Earlier, this cast was done with reinterpret_cast. This introduced undefined behaviour when the pointer-to-cast was of the type AnalysisCut* and accessed later in the code. It was changed to dynamic_cast, which, however, returned a nullptr in the case of recieving an AnalysisCut*, which leads to the workflow to fail when these nullptr were accessed.

However, since AnalysisCompositeCut is inheriting from AnalysisCut, the cast is generally not necessary and can be removed. The corresponding fTrackCuts, fMuonCuts, and fHadronCuts vectors are now of type std::vector<AnalysisCut*> and can now directly store both types. The function IsSelected() is virtual and thus overwritten by the the inheriting class, which preserves the intended behaviour. This similarly holds for the GetName() function, which is inherited from TNamed.

@github-actions github-actions Bot added the pwgdq label Nov 12, 2026
@github-actions

Copy link
Copy Markdown

O2 linter results: ❌ 0 errors, ⚠️ 1257 warnings, 🔕 0 disabled

@vkucera

vkucera commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator

@axti98 Thanks!

@alibuild

Copy link
Copy Markdown
Collaborator

Error while checking build/O2Physics/code-check for ee224a7 at 2026-11-12 19:26:

## sw/BUILD/O2Physics-code-check-latest/log
--
========== List of issues found ==========
++ echo 'To reproduce the results below locally, run: '\''aliBuild build O2Physics-code-check -e ALIBUILD_BASE_HASH=upstream/master'\''.'
To reproduce the results below locally, run: 'aliBuild build O2Physics-code-check -e ALIBUILD_BASE_HASH=upstream/master'.
++ echo 'To apply all automatic fixes, add the '\''-e O2PHYSICS_CHECKER_FIX=1'\'' option.'
To apply all automatic fixes, add the '-e O2PHYSICS_CHECKER_FIX=1' option.
++ echo 'See the documentation for more details at: <https://aliceo2group.github.io/analysis-framework/docs/tools/#running-with-o2physics-code-check>.'
See the documentation for more details at: <https://aliceo2group.github.io/analysis-framework/docs/tools/#running-with-o2physics-code-check>.
++ echo 'Found 1 errors and 67 warnings.'
Found 1 errors and 67 warnings.
++ [[ 1 -gt 0 ]]
++ cat /sw/BUILD/4640fd946a689a556232e7c44344b3f05593f6a8/O2Physics-code-check/errors.txt
PWGDQ/Tasks/dqEfficiency_withAssoc_direct.cxx:3497:15: error: loop variable is copied but only used as const reference; consider making it a const reference [performance-for-range-copy,-warnings-as-errors]
++ [[ 67 -gt 0 ]]
++ cat /sw/BUILD/4640fd946a689a556232e7c44344b3f05593f6a8/O2Physics-code-check/warnings.txt
PWGDQ/Tasks/dqEfficiency_withAssoc_direct.cxx:3237:8: warning: constructor does not initialize these fields: fCCDB [cppcoreguidelines-pro-type-member-init]
PWGDQ/Tasks/dqEfficiency_withAssoc_direct.cxx:3281:36: warning: initializer for member 'fDileptonCut' is redundant [readability-redundant-member-init]
PWGDQ/Tasks/dqEfficiency_withAssoc_direct.cxx:3314:9: warning: do not use 'else' after 'return' [readability-else-after-return]
PWGDQ/Tasks/dqEfficiency_withAssoc_direct.cxx:3334:34: warning: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay]
PWGDQ/Tasks/dqEfficiency_withAssoc_direct.cxx:3334:63: warning: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay]
PWGDQ/Tasks/dqEfficiency_withAssoc_direct.cxx:3457:7: warning: use auto when initializing with a template cast to avoid duplicating the type name [modernize-use-auto]
PWGDQ/Tasks/dqEfficiency_withAssoc_direct.cxx:3494:5: warning: use auto when initializing with a cast to avoid duplicating the type name [modernize-use-auto]
PWGDQ/Tasks/dqEfficiency_withAssoc_direct.cxx:3526:55: warning: statement should be inside braces [readability-braces-around-statements]
PWGDQ/Tasks/dqEfficiency_withAssoc_direct.cxx:3617:26: warning: statement should be inside braces [readability-braces-around-statements]
PWGDQ/Tasks/dqEfficiency_withAssoc_direct.cxx:3619:25: warning: statement should be inside braces [readability-braces-around-statements]
PWGDQ/Tasks/dqEnergyCorrelator_direct.cxx:89:8: warning: constructor does not initialize these fields: fCCDB [cppcoreguidelines-pro-type-member-init]
PWGDQ/Tasks/dqEnergyCorrelator_direct.cxx:394:34: warning: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay]
PWGDQ/Tasks/dqEnergyCorrelator_direct.cxx:394:63: warning: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay]
PWGDQ/Tasks/dqEnergyCorrelator_direct.cxx:502:5: warning: use auto when initializing with a template cast to avoid duplicating the type name [modernize-use-auto]
PWGDQ/Tasks/dqEnergyCorrelator_direct.cxx:519:15: warning: statement should be inside braces [readability-braces-around-statements]
PWGDQ/Tasks/dqEnergyCorrelator_direct.cxx:561:83: warning: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay]
PWGDQ/Tasks/dqEnergyCorrelator_direct.cxx:600:147: warning: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay]
PWGDQ/Tasks/dqEnergyCorrelator_direct.cxx:602:133: warning: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay]
PWGDQ/Tasks/dqEnergyCorrelator_direct.cxx:604:135: warning: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay]
PWGDQ/Tasks/dqEnergyCorrelator_direct.cxx:609:32: warning: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay]
PWGDQ/Tasks/dqEnergyCorrelator_direct.cxx:616:11: warning: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay]
PWGDQ/Tasks/dqEnergyCorrelator_direct.cxx:621:184: warning: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay]
PWGDQ/Tasks/dqEnergyCorrelator_direct.cxx:624:186: warning: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay]
PWGDQ/Tasks/dqEnergyCorrelator_direct.cxx:639:5: warning: use auto when initializing with a cast to avoid duplicating the type name [modernize-use-auto]
PWGDQ/Tasks/dqEnergyCorrelator_direct.cxx:652:101: warning: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay]
PWGDQ/Tasks/dqEnergyCorrelator_direct.cxx:655:61: warning: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay]
PWGDQ/Tasks/dqEnergyCorrelator_direct.cxx:658:104: warning: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay]
PWGDQ/Tasks/dqEnergyCorrelator_direct.cxx:663:63: warning: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay]
PWGDQ/Tasks/dqEnergyCorrelator_direct.cxx:666:106: warning: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay]
PWGDQ/Tasks/dqEnergyCorrelator_direct.cxx:670:63: warning: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay]
PWGDQ/Tasks/dqEnergyCorrelator_direct.cxx:673:106: warning: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay]
PWGDQ/Tasks/dqEnergyCorrelator_direct.cxx:687:28: warning: statement should be inside braces [readability-braces-around-statements]
PWGDQ/Tasks/dqEnergyCorrelator_direct.cxx:697:49: warning: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay]
[0 more errors; see full log]

Full log here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

3 participants