Skip to content

Commit 79b47fa

Browse files
authored
[PWGEM,Photon] Clean up code base (#17485)
1 parent 658bf13 commit 79b47fa

73 files changed

Lines changed: 880 additions & 954 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.

PWGEM/PhotonMeson/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@ add_subdirectory(Core)
1414

1515
add_subdirectory(Tasks)
1616
add_subdirectory(TableProducer)
17+
18+
#add_subdirectory(Legacy)

PWGEM/PhotonMeson/Core/DalitzEECut.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include "PWGEM/Dilepton/Utils/PairUtilities.h"
2121

2222
#include <CommonConstants/PhysicsConstants.h>
23-
#include <Framework/ASoA.h>
2423
#include <Framework/Concepts.h>
2524

2625
#include <Math/Vector4D.h> // IWYU pragma: keep (do not replace with Math/Vector4Dfwd.h)

PWGEM/PhotonMeson/Core/EMCPhotonCut.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include <cstddef>
2424
#include <string>
2525

26-
std::array<std::string, static_cast<std::size_t>(EMCPhotonCut::EMCPhotonCuts::kNCuts)> EMCPhotonCut::mCutNames = {"Definition", "Energy", "NCell", "M02", "Timing", "TrackMatching", "SecTrackMatching", "Exotic"};
26+
const std::array<std::string, static_cast<std::size_t>(EMCPhotonCut::EMCPhotonCuts::kNCuts)> EMCPhotonCut::mCutNames = {"Definition", "Energy", "NCell", "M02", "Timing", "TrackMatching", "SecTrackMatching", "Exotic"};
2727

2828
void EMCPhotonCut::SetClusterizer(const std::string& clusterDefinitionString)
2929
{

PWGEM/PhotonMeson/Core/EMCPhotonCut.h

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#define PWGEM_PHOTONMESON_CORE_EMCPHOTONCUT_H_
1818

1919
#include "PWGEM/PhotonMeson/Core/EMBitFlags.h"
20+
#include "PWGEM/PhotonMeson/DataModel/EventTables.h" // IWYU pragma: keep
2021
#include "PWGEM/PhotonMeson/DataModel/gammaTables.h"
2122

2223
#include <CommonConstants/MathConstants.h>
@@ -29,6 +30,7 @@
2930

3031
#include <sys/types.h>
3132

33+
#include <array>
3234
#include <cmath>
3335
#include <concepts>
3436
#include <cstddef>
@@ -61,7 +63,7 @@ concept IsNonLinContainer = o2::soa::is_table<T> && requires(T t) {
6163
};
6264

6365
template <typename T>
64-
concept IsTrackIterator = o2::soa::is_iterator<T> && requires(T t) {
66+
concept IsFullTrackIterator = o2::soa::is_iterator<T> && !o2::soa::is_filtered_iterator<T> && requires(T t) {
6567
// Check that the *elements* of the container have the required methods:
6668
{ t.deltaEta() } -> std::same_as<float>;
6769
{ t.deltaPhi() } -> std::same_as<float>;
@@ -70,7 +72,7 @@ concept IsTrackIterator = o2::soa::is_iterator<T> && requires(T t) {
7072
};
7173

7274
template <typename T>
73-
concept IsTrackContainer = o2::soa::is_table<T> && requires(T t) {
75+
concept IsFullTrackContainer = o2::soa::is_table<T> && o2::soa::is_not_filtered_table<T> && requires(T t) {
7476
// Check that the *elements* of the container have the required methods:
7577
{ t.begin().deltaEta() } -> std::same_as<float>;
7678
{ t.begin().deltaPhi() } -> std::same_as<float>;
@@ -134,7 +136,7 @@ class EMCPhotonCut
134136
const std::string& getName() const { return name; }
135137
const std::string& getTitle() const { return title; }
136138

137-
static std::array<std::string, static_cast<std::size_t>(EMCPhotonCut::EMCPhotonCuts::kNCuts)> mCutNames;
139+
static const std::array<std::string, static_cast<std::size_t>(EMCPhotonCut::EMCPhotonCuts::kNCuts)> mCutNames;
138140

139141
static constexpr auto getClusterId(o2::soa::is_iterator auto const& t)
140142
{
@@ -198,26 +200,26 @@ class EMCPhotonCut
198200
/// \brief performs check if track is matched with given cluster
199201
/// \param cluster cluster to be checked
200202
/// \param emcmatchedtrack matched track iterator
201-
/// \param emcmatchedtrackEnd matched track end iterator
203+
/// \param nMatchedTracks number of matched tracks
202204
/// \param GetEtaCut lambda to get the eta cut value
203205
/// \param GetPhiCut lambda to get the phi cut value
204206
/// \param applyEoverP bool to check if E/p should be checked (for secondaries we do not check this!)
205-
bool checkTrackMatching(o2::soa::is_iterator auto const& cluster, IsTrackIterator auto& emcmatchedtrack, o2::soa::RowViewSentinel const emcmatchedtrackEnd, bool applyEoverP, auto GetEtaCut, auto GetPhiCut, o2::framework::HistogramRegistry* fRegistry = nullptr, TrackType trackType = TrackType::kPrimary) const
207+
bool checkTrackMatching(o2::soa::is_iterator auto const& cluster, IsFullTrackIterator auto& emcmatchedtrack, int64_t const nMatchedTracks, bool applyEoverP, auto GetEtaCut, auto GetPhiCut, o2::framework::HistogramRegistry* fRegistry = nullptr, TrackType trackType = TrackType::kPrimary) const
206208
{
207209
// advance to cluster
208-
while (emcmatchedtrack != emcmatchedtrackEnd && getClusterId(emcmatchedtrack) < cluster.globalIndex()) {
210+
while (emcmatchedtrack.globalIndex() < nMatchedTracks && getClusterId(emcmatchedtrack) < cluster.globalIndex()) {
209211
++emcmatchedtrack;
210212
}
211213
// all matched tracks have been checked
212-
if (emcmatchedtrack == emcmatchedtrackEnd) {
214+
if (emcmatchedtrack.globalIndex() >= nMatchedTracks) {
213215
return true;
214216
}
215217
// if all remaining tracks are beyond this cluster, it survives
216218
if (getClusterId(emcmatchedtrack) > cluster.globalIndex()) {
217219
return true;
218220
}
219221
// iterate over tracks belonging to this cluster
220-
while (emcmatchedtrack != emcmatchedtrackEnd && getClusterId(emcmatchedtrack) == cluster.globalIndex()) {
222+
while (emcmatchedtrack.globalIndex() < nMatchedTracks && getClusterId(emcmatchedtrack) == cluster.globalIndex()) {
221223
const auto dEta = emcmatchedtrack.deltaEta();
222224
const auto dPhi = emcmatchedtrack.deltaPhi();
223225
const auto fdEta = std::fabs(emcmatchedtrack.deltaEta());
@@ -286,18 +288,18 @@ class EMCPhotonCut
286288
/// \brief check if given clusters survives all cuts
287289
/// \param flags EMBitFlags where results will be stored
288290
/// \param cluster cluster table to check
289-
/// \param matchedTracks matched primary tracks table
290-
/// \param matchedSecondaries matched secondary tracks table
291+
/// \param matchedTracks matched primary tracks table. HAS TO BE FULL TABLE!
292+
/// \param matchedSecondaries matched secondary tracks table. HAS TO BE FULL TABLE!
291293
/// \param fRegistry o2::framework::HistogramRegistry pointer of the main task
292-
void AreSelectedRunning(EMBitFlags& flags, o2::soa::is_table auto const& clusters, IsTrackContainer auto const& emcmatchedtracks, IsTrackContainer auto const& secondaries, o2::framework::HistogramRegistry* fRegistry = nullptr) const
294+
void AreSelectedRunning(EMBitFlags& flags, o2::soa::is_table auto const& clusters, IsFullTrackContainer auto const& emcmatchedtracks, IsFullTrackContainer auto const& secondaries, o2::framework::HistogramRegistry* fRegistry = nullptr) const
293295
{
294296
if (clusters.size() <= 0) {
295297
return;
296298
}
297299
auto emcmatchedtrackIter = emcmatchedtracks.begin();
298-
auto emcmatchedtrackEnd = emcmatchedtracks.end();
300+
int64_t nMatchedTracks = emcmatchedtracks.size();
299301
auto secondaryIter = secondaries.begin();
300-
auto secondaryEnd = secondaries.end();
302+
int64_t nSecondaryTracks = secondaries.size();
301303
size_t iCluster = 0;
302304

303305
const bool doQA = mDoQA && fRegistry != nullptr;
@@ -309,7 +311,7 @@ class EMCPhotonCut
309311
if (doQA) {
310312
fillBeforeClusterHistogram(cluster, fRegistry);
311313
}
312-
if (!IsSelectedRunning(cluster, emcmatchedtrackIter, emcmatchedtrackEnd, secondaryIter, secondaryEnd, fRegistry)) {
314+
if (!IsSelectedRunning(cluster, emcmatchedtrackIter, nMatchedTracks, secondaryIter, nSecondaryTracks, fRegistry)) {
313315
flags.set(iCluster);
314316
} else if (doQA) {
315317
fillAfterClusterHistogram(cluster, fRegistry);
@@ -329,11 +331,11 @@ class EMCPhotonCut
329331
/// \brief check if given cluster survives all cuts
330332
/// \param cluster cluster to check
331333
/// \param emcmatchedtrackIter current iterator of matched primary tracks
332-
/// \param emcmatchedtrackEnd end iterator of matched primary tracks
334+
/// \param nMatchedTracks number of matched primary tracks
333335
/// \param secondaryIter current iterator of matched secondary tracks
334-
/// \param secondaryEnd end iterator of matched secondary tracks
336+
/// \param nSecondaryTracks number of matched secondary tracks
335337
/// \return true if cluster survives all cuts else false
336-
bool IsSelectedRunning(o2::soa::is_iterator auto const& cluster, IsTrackIterator auto& emcmatchedtrackIter, o2::soa::RowViewSentinel const emcmatchedtrackEnd, IsTrackIterator auto& secondaryIter, o2::soa::RowViewSentinel const secondaryEnd, o2::framework::HistogramRegistry* fRegistry = nullptr) const
338+
bool IsSelectedRunning(o2::soa::is_iterator auto const& cluster, IsFullTrackIterator auto& emcmatchedtrackIter, int64_t const nMatchedTracks, IsFullTrackIterator auto& secondaryIter, int64_t const nSecondaryTracks, o2::framework::HistogramRegistry* fRegistry = nullptr) const
337339
{
338340
const bool doQA = mDoQA && fRegistry != nullptr;
339341
if (!IsSelectedEMCalRunning(EMCPhotonCuts::kDefinition, cluster)) {
@@ -366,13 +368,13 @@ class EMCPhotonCut
366368
}
367369
return false;
368370
}
369-
if (mUseTM && (!IsSelectedEMCalRunning(EMCPhotonCuts::kTM, cluster, emcmatchedtrackIter, emcmatchedtrackEnd, fRegistry))) {
371+
if (mUseTM && (!IsSelectedEMCalRunning(EMCPhotonCuts::kTM, cluster, emcmatchedtrackIter, nMatchedTracks, fRegistry))) {
370372
if (doQA) {
371373
fRegistry->fill(HIST("QA/Cluster/hClusterQualityCuts"), static_cast<int>(EMCPhotonCuts::kTM) + 1, cluster.e());
372374
}
373375
return false;
374376
}
375-
if (mUseSecondaryTM && (!IsSelectedEMCalRunning(EMCPhotonCuts::kSecondaryTM, cluster, secondaryIter, secondaryEnd, fRegistry))) {
377+
if (mUseSecondaryTM && (!IsSelectedEMCalRunning(EMCPhotonCuts::kSecondaryTM, cluster, secondaryIter, nSecondaryTracks, fRegistry))) {
376378
if (doQA) {
377379
fRegistry->fill(HIST("QA/Cluster/hClusterQualityCuts"), static_cast<int>(EMCPhotonCuts::kSecondaryTM) + 1, cluster.e());
378380
}
@@ -437,16 +439,16 @@ class EMCPhotonCut
437439
/// \param cut enum of the cluster cut to check
438440
/// \param cluster cluster to check
439441
/// \param matchedTrackIter current iterator of matched primary or secondary tracks
440-
/// \param matchedTrackEnd end iterator of matched primary or secondary tracks
442+
/// \param nMatchedTracks number of matched primary or secondary tracks
441443
/// \return true if cluster survives cut else false
442-
bool IsSelectedEMCalRunning(const EMCPhotonCuts& cut, o2::soa::is_iterator auto const& cluster, IsTrackIterator auto& matchedTrackIter, o2::soa::RowViewSentinel const matchedTrackEnd, o2::framework::HistogramRegistry* fRegistry = nullptr) const
444+
bool IsSelectedEMCalRunning(const EMCPhotonCuts& cut, o2::soa::is_iterator auto const& cluster, IsFullTrackIterator auto& matchedTrackIter, int64_t const nMatchedTracks, o2::framework::HistogramRegistry* fRegistry = nullptr) const
443445
{
444446
switch (cut) {
445447
case EMCPhotonCuts::kTM:
446-
return checkTrackMatching(cluster, matchedTrackIter, matchedTrackEnd, true, [this](float pt) { return GetTrackMatchingEta(pt); }, [this](float pt) { return GetTrackMatchingPhi(pt); }, fRegistry, TrackType::kPrimary);
448+
return checkTrackMatching(cluster, matchedTrackIter, nMatchedTracks, true, [this](float pt) { return GetTrackMatchingEta(pt); }, [this](float pt) { return GetTrackMatchingPhi(pt); }, fRegistry, TrackType::kPrimary);
447449

448450
case EMCPhotonCuts::kSecondaryTM:
449-
return checkTrackMatching(cluster, matchedTrackIter, matchedTrackEnd, false, [this](float pt) { return GetSecTrackMatchingEta(pt); }, [this](float pt) { return GetSecTrackMatchingPhi(pt); }, fRegistry, TrackType::kSecondary);
451+
return checkTrackMatching(cluster, matchedTrackIter, nMatchedTracks, false, [this](float pt) { return GetSecTrackMatchingEta(pt); }, [this](float pt) { return GetSecTrackMatchingPhi(pt); }, fRegistry, TrackType::kSecondary);
450452

451453
default:
452454
return true;
@@ -518,7 +520,7 @@ class EMCPhotonCut
518520
return mMinTime <= cluster.time() && cluster.time() <= mMaxTime;
519521

520522
case EMCPhotonCuts::kTM: {
521-
if constexpr (IsTrackContainer<TMatchedTracks>) {
523+
if constexpr (IsFullTrackContainer<TMatchedTracks>) {
522524
for (const auto& emcmatchedtrack : emcmatchedtracks) {
523525
auto dEta = std::fabs(emcmatchedtrack.deltaEta());
524526
auto dPhi = std::fabs(emcmatchedtrack.deltaPhi());
@@ -551,7 +553,7 @@ class EMCPhotonCut
551553
return true; // when we don't have any tracks the cluster should always survive the TM cut!
552554
}
553555
case EMCPhotonCuts::kSecondaryTM: {
554-
if constexpr (IsTrackContainer<TMatchedTracks>) {
556+
if constexpr (IsFullTrackContainer<TMatchedTracks>) {
555557
for (const auto& emcmatchedtrack : emcmatchedtracks) {
556558
auto dEta = std::fabs(emcmatchedtrack.deltaEta());
557559
auto dPhi = std::fabs(emcmatchedtrack.deltaPhi());

PWGEM/PhotonMeson/Core/PHOSPhotonCut.cxx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,10 @@
1717

1818
#include <Framework/Logger.h>
1919

20-
#include <Rtypes.h>
20+
#include <array>
21+
#include <string>
2122

22-
ClassImp(PHOSPhotonCut);
23-
24-
const char* PHOSPhotonCut::mCutNames[static_cast<int>(PHOSPhotonCut::PHOSPhotonCuts::kNCuts)] = {"Energy", "Dispersion", "CPV"};
23+
const std::array<std::string, static_cast<int>(PHOSPhotonCut::PHOSPhotonCuts::kNCuts)> PHOSPhotonCut::mCutNames = {"Energy", "Dispersion", "CPV"};
2524

2625
void PHOSPhotonCut::SetEnergyRange(float min, float max)
2726
{

PWGEM/PhotonMeson/Core/PHOSPhotonCut.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@
1616
#ifndef PWGEM_PHOTONMESON_CORE_PHOSPHOTONCUT_H_
1717
#define PWGEM_PHOTONMESON_CORE_PHOSPHOTONCUT_H_
1818

19-
#include <Framework/ASoA.h>
2019
#include <Framework/Concepts.h>
2120

21+
#include <array>
22+
#include <cmath>
2223
#include <string>
2324

2425
class PHOSPhotonCut
@@ -34,10 +35,10 @@ class PHOSPhotonCut
3435
kNCuts
3536
};
3637

37-
const std::string getName() const { return name; }
38-
const std::string getTitle() const { return title; }
38+
[[nodiscard]] const std::string& getName() const { return name; }
39+
[[nodiscard]] const std::string& getTitle() const { return title; }
3940

40-
static const char* mCutNames[static_cast<int>(PHOSPhotonCuts::kNCuts)];
41+
static const std::array<std::string, static_cast<int>(PHOSPhotonCuts::kNCuts)> mCutNames;
4142

4243
// Temporary function to check if track passes selection criteria. To be replaced by framework filters.
4344
template <o2::soa::is_iterator Cluster>
@@ -55,10 +56,10 @@ class PHOSPhotonCut
5556
}
5657

5758
// only temporary solution to avoid noisy channels.
58-
if (-1.20 + 10.2 * sqrt(cluster.e()) < cluster.nCells()) {
59+
if (-1.20 + 10.2 * std::sqrt(cluster.e()) < cluster.nCells()) {
5960
return false;
6061
}
61-
if (cluster.nCells() < -3.04 + 3.14 * sqrt(cluster.e())) {
62+
if (cluster.nCells() < -3.04 + 3.14 * std::sqrt(cluster.e())) {
6263
return false;
6364
}
6465

@@ -81,8 +82,6 @@ class PHOSPhotonCut
8182
return cls.e() >= mMinEnergy && cls.e() <= mMaxEnergy;
8283

8384
case PHOSPhotonCuts::kDispersion:
84-
return true;
85-
8685
case PHOSPhotonCuts::kCPV:
8786
return true;
8887

PWGEM/PhotonMeson/Core/PairCut.cxx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717

1818
#include <Framework/Logger.h>
1919

20-
#include <Rtypes.h>
20+
#include <array>
21+
#include <cstddef>
22+
#include <string>
2123

22-
ClassImp(PairCut);
23-
24-
const char* PairCut::mCutNames[static_cast<int>(PairCut::PairCuts::kNCuts)] = {"Asym"};
24+
const std::array<std::string, static_cast<std::size_t>(PairCut::PairCuts::kNCuts)> PairCut::mCutNames = {"Asym"};
2525

2626
void PairCut::SetAsymRange(float min, float max)
2727
{

PWGEM/PhotonMeson/Core/PairCut.h

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
#ifndef PWGEM_PHOTONMESON_CORE_PAIRCUT_H_
1717
#define PWGEM_PHOTONMESON_CORE_PAIRCUT_H_
1818

19+
#include <array>
20+
#include <cmath>
21+
#include <cstddef>
1922
#include <string>
2023

2124
class PairCut
@@ -30,19 +33,15 @@ class PairCut
3033
kNCuts
3134
};
3235

33-
const std::string getName() const { return name; }
34-
const std::string getTitle() const { return title; }
36+
[[nodiscard]] const std::string& getName() const { return name; }
37+
[[nodiscard]] const std::string& getTitle() const { return title; }
3538

36-
static const char* mCutNames[static_cast<int>(PairCuts::kNCuts)];
39+
static const std::array<std::string, static_cast<std::size_t>(PairCuts::kNCuts)> mCutNames;
3740

3841
template <typename G1, typename G2>
3942
bool IsSelected(G1 const& g1, G2 const& g2) const
4043
{
41-
if (!IsSelectedPair(g1, g2, PairCuts::kAsym)) {
42-
return false;
43-
}
44-
45-
return true;
44+
return IsSelectedPair(g1, g2, PairCuts::kAsym);
4645
}
4746

4847
// template <typename U1, typename U2, typename G1, typename G2>
@@ -51,7 +50,7 @@ class PairCut
5150
{
5251
switch (cut) {
5352
case PairCuts::kAsym: {
54-
float asym = abs(g1.e() - g2.e()) / (g1.e() + g2.e());
53+
float asym = std::abs(g1.e() - g2.e()) / (g1.e() + g2.e());
5554
// float asym = abs(g1.p() - g2.p()) / (g1.p() + g2.p());
5655
return mMinAsym < asym && asym < mMaxAsym;
5756
}

0 commit comments

Comments
 (0)