Skip to content

Commit d348a17

Browse files
committed
Merge remote-tracking branch 'upstream/master' into ds-jet-mc-efficiency
2 parents cb617b3 + f86101a commit d348a17

433 files changed

Lines changed: 53651 additions & 26442 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.clang-tidy

Lines changed: 142 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,144 @@
1+
---
2+
Checks:
3+
# - clang-analyzer-* # enabled by default
4+
# - clang-diagnostic-* # enabled by default
5+
- -clang-diagnostic-unknown-pragmas
6+
- bugprone-*
7+
- -bugprone-assert-side-effect
8+
- -bugprone-bad-signal-to-kill-thread
9+
- -bugprone-bitwise-pointer-cast
10+
- -bugprone-bool-pointer-implicit-conversion
11+
- -bugprone-compare-pointer-to-member-virtual-function
12+
- -bugprone-crtp-constructor-accessibility
13+
- -bugprone-easily-swappable-parameters # Too sensitive
14+
- -bugprone-forwarding-reference-overload
15+
- -bugprone-implicit-widening-of-multiplication-result # Specific cases irrelevant in this repo
16+
- -bugprone-lambda-function-name
17+
- -bugprone-no-escape
18+
- -bugprone-posix-return
19+
- -bugprone-signal-handler
20+
- -bugprone-signed-char-misuse # Specific use cases. Probably very rare.
21+
- -bugprone-spuriously-wake-up-functions
22+
- -bugprone-suspicious-stringview-data-usage # Probably harmless in this repo
23+
- -bugprone-unused-raii
24+
- cppcoreguidelines-avoid-const-or-ref-data-members
25+
- cppcoreguidelines-avoid-goto
26+
- cppcoreguidelines-avoid-non-const-global-variables
27+
- cppcoreguidelines-init-variables
28+
- cppcoreguidelines-macro-usage
29+
- cppcoreguidelines-misleading-capture-default-by-value
30+
- cppcoreguidelines-missing-std-forward
31+
- cppcoreguidelines-prefer-member-initializer
32+
- cppcoreguidelines-pro-bounds-array-to-pointer-decay
33+
- cppcoreguidelines-pro-type-const-cast
34+
- cppcoreguidelines-pro-type-cstyle-cast
35+
- cppcoreguidelines-pro-type-member-init
36+
- cppcoreguidelines-pro-type-reinterpret-cast
37+
- cppcoreguidelines-pro-type-static-cast-downcast
38+
- cppcoreguidelines-pro-type-union-access
39+
- cppcoreguidelines-rvalue-reference-param-not-moved
40+
- cppcoreguidelines-slicing
41+
- cppcoreguidelines-virtual-class-destructor
42+
- google-default-arguments
43+
# - google-explicit-constructor # triggered for O2 columns
44+
- google-global-names-in-headers
45+
# - misc-const-correctness # to be checked
46+
- misc-header-include-cycle
47+
- misc-include-cleaner
48+
- misc-misplaced-const
49+
- misc-redundant-expression
50+
- misc-unconventional-assign-operator
51+
- misc-unused-alias-decls
52+
- misc-unused-parameters
53+
- misc-unused-using-decls
54+
- modernize-avoid-bind
55+
- modernize-avoid-c-arrays
56+
- modernize-concat-nested-namespaces
57+
- modernize-deprecated-headers
58+
- modernize-make-shared
59+
- modernize-make-unique
60+
- modernize-redundant-void-arg
61+
- modernize-return-braced-init-list
62+
- modernize-use-auto
63+
- modernize-use-default-member-init
64+
- modernize-use-designated-initializers
65+
- modernize-use-equals-default
66+
- modernize-use-equals-delete
67+
- modernize-use-nodiscard
68+
- modernize-use-nullptr
69+
- modernize-use-override
70+
- modernize-use-starts-ends-with
71+
- performance-for-range-copy
72+
- performance-implicit-conversion-in-loop
73+
- performance-inefficient-algorithm
74+
- performance-inefficient-string-concatenation
75+
- performance-inefficient-vector-operation
76+
- performance-move-const-arg
77+
- performance-no-automatic-move
78+
- performance-trivially-destructible
79+
- performance-type-promotion-in-math-fn
80+
- performance-unnecessary-copy-initialization
81+
- performance-unnecessary-value-param # slow
82+
- readability-avoid-unconditional-preprocessor-if
83+
- readability-braces-around-statements
84+
- readability-const-return-type
85+
- readability-container-contains
86+
- readability-container-data-pointer
87+
- readability-container-size-empty
88+
- readability-delete-null-pointer
89+
- readability-duplicate-include
90+
- readability-else-after-return
91+
- readability-enum-initial-value
92+
- readability-implicit-bool-conversion
93+
- readability-inconsistent-declaration-parameter-name
94+
- readability-misplaced-array-index
95+
- readability-non-const-parameter
96+
- readability-redundant-access-specifiers
97+
- readability-redundant-casting
98+
- readability-redundant-control-flow
99+
- readability-redundant-declaration
100+
- readability-redundant-member-init
101+
- readability-redundant-preprocessor
102+
- readability-redundant-string-cstr
103+
- readability-redundant-string-init
104+
- readability-reference-to-constructed-temporary
105+
- readability-simplify-boolean-expr
106+
- readability-static-definition-in-anonymous-namespace
107+
- readability-string-compare
108+
- readability-suspicious-call-argument
109+
# Select which of the enabled checks should be reported as errors instead of warnings.
110+
WarningsAsErrors: >-
111+
*,
112+
-readability-braces-around-statements,
113+
-readability-suspicious-call-argument,
1114
CheckOptions:
115+
modernize-avoid-c-arrays.AllowStringArrays: true
116+
# Common tolerated conversions
117+
bugprone-narrowing-conversions.WarnOnFloatingPointNarrowingConversion: false
118+
bugprone-narrowing-conversions.WarnOnIntegerNarrowingConversion: false
119+
bugprone-narrowing-conversions.WarnOnIntegerToFloatingPointNarrowingConversion: false
120+
readability-implicit-bool-conversion.AllowLogicalOperatorConversion: true
121+
readability-implicit-bool-conversion.AllowPointerConditions: true
122+
# Some data model structs are missing some special functions by design.
123+
cppcoreguidelines-special-member-functions.AllowMissingMoveFunctions: true
2124
# Naming conventions
3-
- { key: readability-identifier-naming.ClassCase, value: CamelCase }
4-
- { key: readability-identifier-naming.ClassMemberPrefix, value: m }
5-
- { key: readability-identifier-naming.ConceptCase, value: CamelCase }
6-
- { key: readability-identifier-naming.ConstexprVariableCase, value: CamelCase }
7-
- { key: readability-identifier-naming.EnumCase, value: CamelCase }
8-
- { key: readability-identifier-naming.EnumConstantCase, value: CamelCase }
9-
- { key: readability-identifier-naming.EnumConstantIgnoredRegexp, value: "^k?[A-Z][a-zA-Z0-9_]*$" } # Allow "k" prefix and non-trailing underscores in PDG names.
10-
- { key: readability-identifier-naming.FunctionCase, value: camelBack }
11-
- { key: readability-identifier-naming.MacroDefinitionCase, value: UPPER_CASE }
12-
- { key: readability-identifier-naming.MacroDefinitionIgnoredRegexp, value: "^[A-Z][A-Z0-9_]*_$" } # Allow the trailing underscore in header guards.
13-
- { key: readability-identifier-naming.MemberCase, value: camelBack }
14-
- { key: readability-identifier-naming.NamespaceCase, value: lower_case }
15-
- { key: readability-identifier-naming.ParameterCase, value: camelBack }
16-
- { key: readability-identifier-naming.StructCase, value: CamelCase }
17-
- { key: readability-identifier-naming.TemplateParameterCase, value: CamelCase }
18-
- { key: readability-identifier-naming.TypeAliasCase, value: CamelCase }
19-
- { key: readability-identifier-naming.TypedefCase, value: CamelCase }
20-
- { key: readability-identifier-naming.TypeTemplateParameterCase, value: CamelCase }
21-
- { key: readability-identifier-naming.VariableCase, value: camelBack }
125+
readability-identifier-naming.ClassCase: CamelCase
126+
readability-identifier-naming.ClassMemberPrefix: m
127+
readability-identifier-naming.ConceptCase: CamelCase
128+
readability-identifier-naming.ConstexprVariableCase: CamelCase
129+
readability-identifier-naming.EnumCase: CamelCase
130+
readability-identifier-naming.EnumConstantCase: CamelCase
131+
readability-identifier-naming.EnumConstantIgnoredRegexp: "^k?[A-Z][a-zA-Z0-9_]*$" # Allow "k" prefix and non-trailing underscores in PDG names.
132+
readability-identifier-naming.FunctionCase: camelBack
133+
readability-identifier-naming.MacroDefinitionCase: UPPER_CASE
134+
readability-identifier-naming.MacroDefinitionIgnoredRegexp: "^[A-Z][A-Z0-9_]*_$" # Allow the trailing underscore in header guards.
135+
readability-identifier-naming.MemberCase: camelBack
136+
readability-identifier-naming.NamespaceCase: lower_case
137+
readability-identifier-naming.ParameterCase: camelBack
138+
readability-identifier-naming.StructCase: CamelCase
139+
readability-identifier-naming.TemplateParameterCase: CamelCase
140+
readability-identifier-naming.TypeAliasCase: CamelCase
141+
readability-identifier-naming.TypedefCase: CamelCase
142+
readability-identifier-naming.TypeTemplateParameterCase: CamelCase
143+
readability-identifier-naming.VariableCase: camelBack
144+
...

.github/workflows/mega-linter.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
steps:
2424
# Git Checkout
2525
- name: Checkout Code
26-
uses: actions/checkout@v6
26+
uses: actions/checkout@v7
2727
with:
2828
# Checkout the HEAD of the PR instead of the merge commit.
2929
ref: ${{ github.event.pull_request.head.sha }}
@@ -32,13 +32,14 @@ jobs:
3232
fetch-depth: 0
3333
# So we can use secrets.ALIBUILD_GITHUB_TOKEN to push later.
3434
persist-credentials: false
35+
allow-unsafe-pr-checkout: true # needed for pull_request_target
3536

3637
# MegaLinter
3738
- name: MegaLinter
3839
id: ml
3940
# You can override MegaLinter flavor used to have faster performances
4041
# More info at https://megalinter.io/flavors/
41-
uses: oxsecurity/megalinter@v9.5.0
42+
uses: oxsecurity/megalinter@v9.6.0
4243
env:
4344
# All available variables are described in documentation:
4445
# https://megalinter.io/configuration/

.github/workflows/o2-linter.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,11 @@ jobs:
3030
echo BRANCH_HEAD="$branch_head" >> "$GITHUB_ENV"
3131
echo BRANCH_BASE="$branch_base" >> "$GITHUB_ENV"
3232
- name: Checkout Code
33-
uses: actions/checkout@v6
33+
uses: actions/checkout@v7
3434
with:
3535
ref: ${{ env.BRANCH_HEAD }}
3636
fetch-depth: 0 # needed to get the full history
37+
allow-unsafe-pr-checkout: true # needed for pull_request_target
3738
- name: Run tests
3839
id: linter
3940
run: |

.mega-linter.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,6 @@ PYTHON_RUFF_CONFIG_FILE: pyproject.toml
4242
CPP_CPPLINT_FILE_EXTENSIONS: [".C", ".c", ".c++", ".cc", ".cl", ".cpp", ".cu", ".cuh", ".cxx", ".cxx.in", ".h", ".h++", ".hh", ".h.in", ".hpp", ".hxx", ".inc", ".inl", ".macro"]
4343
CPP_CLANG_FORMAT_FILE_EXTENSIONS: [".C", ".c", ".c++", ".cc", ".cl", ".cpp", ".cu", ".cuh", ".cxx", ".cxx.in", ".h", ".h++", ".hh", ".h.in", ".hpp", ".hxx", ".inc", ".inl", ".macro"]
4444
CPP_CPPCHECK_FILE_EXTENSIONS: [".C", ".c", ".c++", ".cc", ".cl", ".cpp", ".cu", ".cuh", ".cxx", ".cxx.in", ".h", ".h++", ".hh", ".h.in", ".hpp", ".hxx", ".inc", ".inl", ".macro"]
45-
CPP_CPPCHECK_ARGUMENTS: --language=c++ --std=c++20 --check-level=exhaustive --suppressions-list=cppcheck_config
45+
CPP_CPPCHECK_ARGUMENTS: --language=c++ --std=c++20 --enable=style --check-level=exhaustive --suppressions-list=cppcheck_suppressions --inline-suppr --force
4646
REPOSITORY_GITLEAKS_PR_COMMITS_SCAN: true
4747
ACTION_ZIZMOR_UNSECURED_ENV_VARIABLES: [GITHUB_TOKEN]

ALICE3/Core/OTFParticle.h

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <array>
2424
#include <bitset>
2525
#include <cmath>
26+
#include <cstddef>
2627
#include <cstdint>
2728
#include <span>
2829

@@ -58,6 +59,9 @@ class OTFParticle
5859
if (particle.has_mothers()) {
5960
mIndicesMother = {particle.mothersIds().front(), particle.mothersIds().back()};
6061
}
62+
if (particle.has_daughters()) {
63+
mIndicesDaughter = {particle.daughtersIds().front(), particle.daughtersIds().back()};
64+
}
6165
if constexpr (requires { particle.decayerBits(); }) {
6266
mBits = particle.decayerBits();
6367
} else {
@@ -88,6 +92,14 @@ class OTFParticle
8892
mPz = pz;
8993
mE = e;
9094
}
95+
void setIndexOffset(const std::size_t offset)
96+
{
97+
static constexpr int NotFound = -1;
98+
mIndicesMother[0] = (mIndicesMother[0] >= 0) ? mIndicesMother[0] + static_cast<int>(offset) : NotFound;
99+
mIndicesMother[1] = (mIndicesMother[1] >= 0) ? mIndicesMother[1] + static_cast<int>(offset) : NotFound;
100+
mIndicesDaughter[0] = (mIndicesDaughter[0] >= 0) ? mIndicesDaughter[0] + static_cast<int>(offset) : NotFound;
101+
mIndicesDaughter[1] = (mIndicesDaughter[1] >= 0) ? mIndicesDaughter[1] + static_cast<int>(offset) : NotFound;
102+
}
91103

92104
// Getters
93105
int pdgCode() const { return mPdgCode; }
@@ -147,8 +159,8 @@ class OTFParticle
147159
std::span<const int> getMotherSpan() const { return hasMothers() ? std::span<const int>(mIndicesMother.data(), 2) : std::span<const int>(); }
148160

149161
// Checks
150-
bool hasDaughters() const { return (mIndicesDaughter[0] > 0); }
151-
bool hasMothers() const { return (mIndicesMother[0] > 0); }
162+
bool hasDaughters() const { return (mIndicesDaughter[0] >= 0); }
163+
bool hasMothers() const { return (mIndicesMother[0] >= 0); }
152164
bool hasNaN() const
153165
{
154166
return std::isnan(mPx) || std::isnan(mPy) || std::isnan(mPz) || std::isnan(mE) ||
@@ -171,7 +183,7 @@ class OTFParticle
171183

172184
private:
173185
int mPdgCode{}, mGlobalIndex{-1};
174-
int mCollisionId{};
186+
int mCollisionId{-1};
175187
float mVx{}, mVy{}, mVz{}, mVt{};
176188
float mPx{}, mPy{}, mPz{}, mE{};
177189
bool mIsAlive{}, mIsFromMcParticles{false};

ALICE3/Core/TrackUtilities.cxx

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@
2929
#include <vector>
3030

3131
void o2::upgrade::convertTLorentzVectorToO2Track(const int charge,
32-
const TLorentzVector particle,
33-
const std::vector<double> productionVertex,
32+
const TLorentzVector& particle,
33+
const std::vector<double>& productionVertex,
3434
o2::track::TrackParCov& o2track)
3535
{
36-
std::array<float, 5> params;
36+
std::array<float, 5> params = {0.};
3737
std::array<float, 15> covm = {0.};
38-
float s, c, x;
38+
float s{}, c{}, x{};
3939
o2::math_utils::sincos(static_cast<float>(particle.Phi()), s, c);
4040
o2::math_utils::rotateZInv(static_cast<float>(productionVertex[0]), static_cast<float>(productionVertex[1]), x, params[0], s, c);
4141
params[1] = static_cast<float>(productionVertex[2]);
@@ -48,29 +48,27 @@ void o2::upgrade::convertTLorentzVectorToO2Track(const int charge,
4848
new (&o2track)(o2::track::TrackParCov)(x, particle.Phi(), params, covm);
4949
}
5050

51-
float o2::upgrade::computeParticleVelocity(float momentum, float mass)
51+
float o2::upgrade::computeParticleVelocity(const float momentum, const float mass)
5252
{
5353
const float a = momentum / mass;
5454
// uses light speed in cm/ps so output is in those units
5555
return o2::constants::physics::LightSpeedCm2PS * a / std::sqrt((1.f + a * a));
5656
}
5757

58-
float o2::upgrade::computeTrackLength(o2::track::TrackParCov track, float radius, float magneticField)
58+
float o2::upgrade::computeTrackLength(const o2::track::TrackParCov& track, const float radius, const float magneticField)
5959
{
6060
// don't make use of the track parametrization
6161
float length = -100;
6262

6363
o2::math_utils::CircleXYf_t trcCircle;
64-
float sna, csa;
64+
float sna{}, csa{};
6565
track.getCircleParams(magneticField, trcCircle, sna, csa);
6666

6767
// distance between circle centers (one circle is at origin -> easy)
6868
const float centerDistance = std::hypot(trcCircle.xC, trcCircle.yC);
6969

7070
// condition of circles touching - if not satisfied returned length will be -100
7171
if (centerDistance < trcCircle.rC + radius && centerDistance > std::fabs(trcCircle.rC - radius)) {
72-
length = 0.0f;
73-
7472
// base radical direction
7573
const float ux = trcCircle.xC / centerDistance;
7674
const float uy = trcCircle.yC / centerDistance;
@@ -87,17 +85,17 @@ float o2::upgrade::computeTrackLength(o2::track::TrackParCov track, float radius
8785
(centerDistance + trcCircle.rC + radius));
8886

8987
// possible intercept points of track and TOF layer in 2D plane
90-
const float point1[2] = {radical * ux + displace * vx, radical * uy + displace * vy};
91-
const float point2[2] = {radical * ux - displace * vx, radical * uy - displace * vy};
88+
const std::array<float, 2> point1 = {radical * ux + displace * vx, radical * uy + displace * vy};
89+
const std::array<float, 2> point2 = {radical * ux - displace * vx, radical * uy - displace * vy};
9290

9391
// decide on correct intercept point
94-
std::array<float, 3> mom;
92+
std::array<float, 3> mom{};
9593
track.getPxPyPzGlo(mom);
9694
const float scalarProduct1 = point1[0] * mom[0] + point1[1] * mom[1];
9795
const float scalarProduct2 = point2[0] * mom[0] + point2[1] * mom[1];
9896

9997
// get start point
100-
std::array<float, 3> startPoint;
98+
std::array<float, 3> startPoint{};
10199
track.getXYZGlo(startPoint);
102100

103101
float cosAngle = -1000, modulus = -1000;

ALICE3/Core/TrackUtilities.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ namespace o2::upgrade
3636
/// \param productionVertex where the particle was produced
3737
/// \param o2track the address of the resulting TrackParCov
3838
void convertTLorentzVectorToO2Track(const int charge,
39-
const TLorentzVector particle,
40-
const std::vector<double> productionVertex,
39+
const TLorentzVector& particle,
40+
const std::vector<double>& productionVertex,
4141
o2::track::TrackParCov& o2track);
4242

4343
/// Function to convert a TLorentzVector into a perfect Track
@@ -47,9 +47,9 @@ void convertTLorentzVectorToO2Track(const int charge,
4747
/// \param o2track the address of the resulting TrackParCov
4848
/// \param pdg the pdg service
4949
template <typename PdgService>
50-
void convertTLorentzVectorToO2Track(int pdgCode,
51-
TLorentzVector particle,
52-
std::vector<double> productionVertex,
50+
void convertTLorentzVectorToO2Track(const int pdgCode,
51+
const TLorentzVector& particle,
52+
const std::vector<double>& productionVertex,
5353
o2::track::TrackParCov& o2track,
5454
const PdgService& pdg)
5555
{
@@ -80,7 +80,7 @@ void convertOTFParticleToO2Track(const OTFParticle& particle,
8080
/// \param o2track the address of the resulting TrackParCov
8181
/// \param pdg the pdg service
8282
template <typename McParticleType, typename PdgService>
83-
void convertMCParticleToO2Track(McParticleType& particle,
83+
void convertMCParticleToO2Track(const McParticleType& particle,
8484
o2::track::TrackParCov& o2track,
8585
const PdgService& pdg)
8686
{
@@ -94,7 +94,7 @@ void convertMCParticleToO2Track(McParticleType& particle,
9494
/// \param o2track the address of the resulting TrackParCov
9595
/// \param pdg the pdg service
9696
template <typename McParticleType, typename PdgService>
97-
o2::track::TrackParCov convertMCParticleToO2Track(McParticleType& particle,
97+
o2::track::TrackParCov convertMCParticleToO2Track(const McParticleType& particle,
9898
const PdgService& pdg)
9999
{
100100
o2::track::TrackParCov o2track;
@@ -105,13 +105,13 @@ o2::track::TrackParCov convertMCParticleToO2Track(McParticleType& particle,
105105
/// returns velocity in centimeters per picoseconds
106106
/// \param momentum the momentum of the track
107107
/// \param mass the mass of the particle
108-
float computeParticleVelocity(float momentum, float mass);
108+
float computeParticleVelocity(const float momentum, const float mass);
109109

110110
/// function to calculate track length of this track up to a certain radius
111111
/// \param track the input track (TrackParCov)
112112
/// \param radius the radius of the layer you're calculating the length to
113113
/// \param magneticField the magnetic field to use when propagating
114-
float computeTrackLength(o2::track::TrackParCov track, float radius, float magneticField);
114+
float computeTrackLength(const o2::track::TrackParCov& track, const float radius, const float magneticField);
115115

116116
} // namespace o2::upgrade
117117

0 commit comments

Comments
 (0)