Skip to content

Commit 5bf4516

Browse files
committed
Fix: apply fixes from clang-tidy and cppcheck
1 parent ebe3f7a commit 5bf4516

20 files changed

+83
-53
lines changed

PWGCF/Femto/Core/cascadeHistManager.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ template <const char* cascadePrefix,
168168
class CascadeHistManager
169169
{
170170
public:
171-
/// Destructor
171+
CascadeHistManager() = default;
172172
virtual ~CascadeHistManager() = default;
173173
/// Initializes histograms for the task
174174
/// \param registry Histogram registry to be passed
@@ -257,7 +257,7 @@ class CascadeHistManager
257257
}
258258

259259
private:
260-
o2::framework::HistogramRegistry* mHistogramRegistry;
260+
o2::framework::HistogramRegistry* mHistogramRegistry = nullptr;
261261

262262
trackhistmanager::TrackHistManager<bachelorPrefix, mode> mBachelorManager;
263263
trackhistmanager::TrackHistManager<posDauPrefix, mode> mPosDauManager;

PWGCF/Femto/Core/closePairRejection.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,13 @@
1919
#include "PWGCF/Femto/Core/femtoUtils.h"
2020
#include "PWGCF/Femto/Core/histManager.h"
2121

22+
#include "Framework/Configurable.h"
2223
#include "Framework/HistogramRegistry.h"
24+
#include "Framework/HistogramSpec.h"
2325

2426
#include <array>
27+
#include <cmath>
28+
#include <cstddef>
2529
#include <map>
2630
#include <numeric>
2731
#include <string>

PWGCF/Femto/Core/collisionBuilder.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@
2020
#include "PWGCF/Femto/Core/dataTypes.h"
2121
#include "PWGCF/Femto/Core/femtoUtils.h"
2222
#include "PWGCF/Femto/Core/modes.h"
23+
#include "PWGCF/Femto/Core/selectionContainer.h"
2324
#include "PWGCF/Femto/DataModel/FemtoTables.h"
2425

2526
#include "Common/CCDB/EventSelectionParams.h"
27+
#include "Common/CCDB/RCTSelectionFlags.h"
2628
#include "EventFiltering/Zorro.h"
2729

2830
#include "DataFormatsParameters/GRPMagField.h"
@@ -33,6 +35,8 @@
3335

3436
#include <algorithm>
3537
#include <cmath>
38+
#include <cstddef>
39+
#include <cstdint>
3640
#include <string>
3741
#include <unordered_map>
3842
#include <vector>

PWGCF/Femto/Core/collisionHistManager.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ template <modes::Mode mode>
125125
class CollisionHistManager
126126
{
127127
public:
128-
/// Destructor
128+
CollisionHistManager() = default;
129129
virtual ~CollisionHistManager() = default;
130130
/// Initializes histograms for the task
131131
/// \param registry Histogram registry to be passed
@@ -181,7 +181,7 @@ class CollisionHistManager
181181
}
182182

183183
private:
184-
o2::framework::HistogramRegistry* mHistogramRegistry;
184+
o2::framework::HistogramRegistry* mHistogramRegistry = nullptr;
185185
}; // namespace femtounitedcolhistmanager
186186
}; // namespace colhistmanager
187187
}; // namespace o2::analysis::femto

PWGCF/Femto/Core/histManager.h

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -37,45 +37,41 @@ struct HistInfo {
3737
template <typename EnumType, typename ArrayType>
3838
constexpr o2::framework::HistType GetHistType(EnumType variable, const ArrayType& array)
3939
{
40-
for (const auto& entry : array) {
41-
if (entry.hist == variable) {
42-
return entry.histtype;
43-
}
44-
}
45-
return o2::framework::kUndefinedHist;
40+
const auto it = std::find_if(array.begin(), array.end(), [=](const auto& entry) {
41+
return entry.hist == variable;
42+
});
43+
44+
return it != array.end() ? it->histtype : o2::framework::kUndefinedHist;
4645
}
4746

4847
template <typename EnumType, typename ArrayType>
4948
constexpr std::string_view GetHistName(EnumType variable, const ArrayType& array)
5049
{
51-
for (const auto& entry : array) {
52-
if (entry.hist == variable) {
53-
return entry.histname;
54-
}
55-
}
56-
return ""; // Return an empty string or a default name if not found
50+
auto it = std::find_if(array.begin(), array.end(), [=](const auto& entry) {
51+
return entry.hist == variable;
52+
});
53+
54+
return (it != array.end()) ? it->histname : std::string_view{};
5755
}
5856

5957
template <typename EnumType, typename ArrayType>
60-
constexpr std::string GetHistNamev2(EnumType variable, const ArrayType& array)
58+
std::string GetHistNamev2(EnumType variable, const ArrayType& array)
6159
{
62-
for (const auto& entry : array) {
63-
if (entry.hist == variable) {
64-
return std::string(entry.histname);
65-
}
66-
}
67-
return std::string(""); // Return an empty string or a default name if not found
60+
auto it = std::find_if(array.begin(), array.end(), [=](const auto& entry) {
61+
return entry.hist == variable;
62+
});
63+
64+
return (it != array.end()) ? std::string(it->histname) : std::string{};
6865
}
6966

7067
template <typename EnumType, typename ArrayType>
7168
constexpr const char* GetHistDesc(EnumType variable, const ArrayType& array)
7269
{
73-
for (const auto& entry : array) {
74-
if (entry.hist == variable) {
75-
return entry.histdesc.data();
76-
}
77-
}
78-
return ""; // Return an empty string or a default description if not found
70+
auto it = std::find_if(array.begin(), array.end(), [=](const auto& entry) {
71+
return entry.hist == variable;
72+
});
73+
74+
return it != array.end() ? it->histdesc.data() : "";
7975
}
8076
} // namespace histmanager
8177
} // namespace o2::analysis::femto

PWGCF/Femto/Core/kinkBuilder.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include <array>
3838
#include <cmath>
3939
#include <cstdint>
40+
#include <numeric>
4041
#include <string>
4142
#include <unordered_map>
4243
#include <vector>

PWGCF/Femto/Core/kinkHistManager.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ template <const char* kinkPrefix,
166166
class KinkHistManager
167167
{
168168
public:
169-
/// Destructor
169+
KinkHistManager() = default;
170170
virtual ~KinkHistManager() = default;
171171

172172
/// Initializes histograms for the task
@@ -280,7 +280,7 @@ class KinkHistManager
280280
}
281281

282282
private:
283-
o2::framework::HistogramRegistry* mHistogramRegistry;
283+
o2::framework::HistogramRegistry* mHistogramRegistry = nullptr;
284284
trackhistmanager::TrackHistManager<chaDauPrefix, mode> mChaDauManager;
285285
};
286286
}; // namespace kinkhistmanager

PWGCF/Femto/Core/pairBuilder.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,12 @@
3030
#include "PWGCF/Femto/DataModel/FemtoTables.h"
3131

3232
#include "Framework/HistogramRegistry.h"
33+
#include "Framework/HistogramSpec.h"
3334

35+
#include "fairlogger/Logger.h"
36+
37+
#include <chrono>
38+
#include <cstdint>
3439
#include <map>
3540
#include <random>
3641
#include <vector>

PWGCF/Femto/Core/pairHistManager.h

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,22 @@
1616
#ifndef PWGCF_FEMTO_CORE_PAIRHISTMANAGER_H_
1717
#define PWGCF_FEMTO_CORE_PAIRHISTMANAGER_H_
1818

19-
#include "PWGCF/Femto/Core/closePairRejection.h"
20-
#include "PWGCF/Femto/Core/collisionHistManager.h"
2119
#include "PWGCF/Femto/Core/femtoUtils.h"
2220
#include "PWGCF/Femto/Core/histManager.h"
2321
#include "PWGCF/Femto/Core/modes.h"
24-
#include "PWGCF/Femto/Core/pairCleaner.h"
25-
#include "PWGCF/Femto/Core/trackHistManager.h"
26-
#include "PWGCF/Femto/DataModel/FemtoTables.h"
2722

2823
#include "Framework/Configurable.h"
29-
#include "Framework/GroupedCombinations.h"
3024
#include "Framework/HistogramRegistry.h"
25+
#include "Framework/HistogramSpec.h"
3126

32-
#include "Math/Boost.h"
33-
#include "Math/Vector4D.h"
34-
#include "TMath.h"
27+
#include <Math/GenVector/Boost.h>
28+
#include <Math/Vector4D.h>
3529

3630
#include <array>
31+
#include <cmath>
3732
#include <map>
38-
#include <random>
3933
#include <string>
34+
#include <string_view>
4035
#include <vector>
4136

4237
namespace o2::analysis::femto
@@ -221,7 +216,7 @@ class PairHistManager
221216
}
222217

223218
private:
224-
o2::framework::HistogramRegistry* mHistogramRegistry;
219+
o2::framework::HistogramRegistry* mHistogramRegistry = nullptr;
225220
float mMass1 = 0.f;
226221
float mMass2 = 0.f;
227222
float mAbsCharge1 = 1.f;

PWGCF/Femto/Core/pairProcessHelpers.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#include "PWGCF/Femto/DataModel/FemtoTables.h"
2020

21+
#include "CommonConstants/MathConstants.h"
2122
#include "Framework/ASoAHelpers.h"
2223

2324
#include <random>

0 commit comments

Comments
 (0)