Skip to content

Commit e19059a

Browse files
authored
[PWGEM] PhotonMeson: specify template parameter with concept if possible (#14755)
1 parent c627da0 commit e19059a

File tree

7 files changed

+42
-37
lines changed

7 files changed

+42
-37
lines changed

PWGEM/PhotonMeson/TableProducer/bcWiseClusterSkimmer.cxx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ struct bcWiseClusterSkimmer {
145145
}
146146

147147
/// \brief Process EMCAL clusters (either ambigous or unique)
148-
template <typename Clusters>
148+
template <o2::soa::is_table Clusters>
149149
void processClusters(Clusters const& clusters, const int bcID)
150150
{
151151
for (const auto& cluster : clusters) {
@@ -161,7 +161,7 @@ struct bcWiseClusterSkimmer {
161161
}
162162
}
163163

164-
template <typename Clusters>
164+
template <o2::soa::is_table Clusters>
165165
void processClusterMCInfo(Clusters const& clusters, const int bcID, aod::McParticles const& mcParticles)
166166
{
167167
for (const auto& cluster : clusters) {
@@ -298,8 +298,8 @@ struct bcWiseClusterSkimmer {
298298
collisionTable(bcTable.lastIndex(), convertForStorage<int16_t>(collision.posZ(), kZVtx));
299299
}
300300

301-
template <typename TMCParticle, typename TMCParticles>
302-
bool isGammaGammaDecay(TMCParticle mcParticle, TMCParticles mcParticles)
301+
template <o2::soa::is_iterator TMCParticle, o2::soa::is_table TMCParticles>
302+
bool isGammaGammaDecay(TMCParticle const& mcParticle, TMCParticles const& mcParticles)
303303
{
304304
auto daughtersIds = mcParticle.daughtersIds();
305305
if (daughtersIds.size() != 2)
@@ -311,8 +311,8 @@ struct bcWiseClusterSkimmer {
311311
return true;
312312
}
313313

314-
template <typename TMCParticle, typename TMCParticles>
315-
bool isAccepted(TMCParticle mcParticle, TMCParticles mcParticles)
314+
template <o2::soa::is_iterator TMCParticle, o2::soa::is_table TMCParticles>
315+
bool isAccepted(TMCParticle const& mcParticle, TMCParticles const& mcParticles)
316316
{
317317
auto daughtersIds = mcParticle.daughtersIds();
318318
if (daughtersIds.size() != 2)

PWGEM/PhotonMeson/Utils/EventHistograms.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ inline void addEventHistograms(o2::framework::HistogramRegistry* fRegistry)
7979
fRegistry->addClone("Event/before/", "Event/after/");
8080
}
8181

82-
template <const int ev_id, typename TCollision>
82+
template <const int ev_id, o2::soa::is_iterator TCollision>
8383
void fillEventInfo(o2::framework::HistogramRegistry* fRegistry, TCollision const& collision, float weight = 1.)
8484
{
8585
const float maxZ = 10.f;

PWGEM/PhotonMeson/Utils/HNMUtilities.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ inline int getSMNumber(float eta, float phi)
139139
}
140140

141141
/// \brief Store photons from EMC clusters and V0s in a vector and possibly add a eta and phi offset for alignment of EMCal clusters
142-
template <typename C, typename V>
142+
template <o2::soa::is_table C, o2::soa::is_table V>
143143
void storeGammasInVector(C clusters, V v0s, std::vector<Photon>& vPhotons, std::array<float, 20> EMCEtaShift, std::array<float, 20> EMCPhiShift)
144144
{
145145
vPhotons.clear();

PWGEM/PhotonMeson/Utils/MCUtilities.h

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

19+
#include <Framework/ASoA.h>
20+
1921
#include <TPDGCode.h>
2022

2123
#include <algorithm>
@@ -26,7 +28,7 @@
2628
//_______________________________________________________________________
2729
namespace o2::aod::pwgem::photonmeson::utils::mcutil
2830
{
29-
template <typename TTrack>
31+
template <o2::soa::is_iterator TTrack>
3032
bool IsPhysicalPrimary(TTrack const& mctrack)
3133
{
3234
// This is to check mctrack is ALICE physical primary.
@@ -37,7 +39,7 @@ bool IsPhysicalPrimary(TTrack const& mctrack)
3739
}
3840
}
3941
//_______________________________________________________________________
40-
template <typename TCollision, typename T, typename TMCs>
42+
template <o2::soa::is_iterator TCollision, o2::soa::is_iterator T, o2::soa::is_table TMCs>
4143
int IsFromWD(TCollision const&, T const& mctrack, TMCs const& mcTracks)
4244
{
4345
// is this particle from weak decay?
@@ -69,7 +71,7 @@ int IsFromWD(TCollision const&, T const& mctrack, TMCs const& mcTracks)
6971
return -1;
7072
}
7173
//_______________________________________________________________________
72-
template <typename T, typename TMCs>
74+
template <o2::soa::is_iterator T, o2::soa::is_table TMCs>
7375
int IsXFromY(T const& mctrack, TMCs const& mcTracks, const int pdgX, const int pdgY)
7476
{
7577
// is photon from pi0? returns index of mother photon
@@ -91,7 +93,7 @@ int IsXFromY(T const& mctrack, TMCs const& mcTracks, const int pdgX, const int p
9193
//_______________________________________________________________________
9294
// Go up the decay chain of a mcparticle looking for a mother with the given pdg codes, if found return this mothers daughter
9395
// E.g. Find the gamma that was created in a pi0 or eta decay
94-
template <typename T, typename TMCs, typename TTargetPDGs>
96+
template <o2::soa::is_iterator T, o2::soa::is_table TMCs, typename TTargetPDGs>
9597
int FindMotherInChain(T const& mcparticle, TMCs const& mcparticles, TTargetPDGs const& motherpdgs, const int Depth = 50) // o2-linter: disable=pdg/explicit-code (false positive)
9698
{
9799
if (!mcparticle.has_mothers() || Depth < 1) {
@@ -107,7 +109,7 @@ int FindMotherInChain(T const& mcparticle, TMCs const& mcparticles, TTargetPDGs
107109
}
108110
}
109111
//_______________________________________________________________________
110-
template <typename T, typename TMCs>
112+
template <o2::soa::is_iterator T, o2::soa::is_table TMCs>
111113
int IsEleFromPC(T const& mctrack, TMCs const& mcTracks)
112114
{
113115
// is election from photon conversion? returns index of mother photon
@@ -130,7 +132,7 @@ int IsEleFromPC(T const& mctrack, TMCs const& mcTracks)
130132
return -1;
131133
}
132134
//_______________________________________________________________________
133-
template <typename TMCParticle, typename TMCParticles, typename TTargetPDGs>
135+
template <o2::soa::is_iterator TMCParticle, o2::soa::is_table TMCParticles, typename TTargetPDGs>
134136
bool IsInAcceptanceNonDerived(TMCParticle const& mcparticle, TMCParticles const& mcparticles, TTargetPDGs target_pdgs, const float ymin, const float ymax, const float phimin, const float phimax)
135137
{
136138
// contents in vector of daughter ID is different.
@@ -181,7 +183,7 @@ bool IsInAcceptanceNonDerived(TMCParticle const& mcparticle, TMCParticles const&
181183
return true;
182184
}
183185
//_______________________________________________________________________
184-
template <typename TMCParticle, typename TMCParticles, typename TTargetPDGs>
186+
template <o2::soa::is_iterator TMCParticle, o2::soa::is_table TMCParticles, typename TTargetPDGs>
185187
bool IsInAcceptance(TMCParticle const& mcparticle, TMCParticles const& mcparticles, TTargetPDGs target_pdgs, const float ymin, const float ymax, const float phimin, const float phimax)
186188
{
187189
if (mcparticle.y() < ymin || ymax < mcparticle.y()) {
@@ -229,7 +231,7 @@ bool IsInAcceptance(TMCParticle const& mcparticle, TMCParticles const& mcparticl
229231
return true;
230232
}
231233
//_______________________________________________________________________
232-
template <typename TMCPhoton, typename TMCParticles>
234+
template <o2::soa::is_iterator TMCPhoton, o2::soa::is_table TMCParticles>
233235
bool IsConversionPointInAcceptance(TMCPhoton const& mcphoton, const float max_r_gen, const float max_eta_gen, const float margin_z_mc, TMCParticles const& mcparticles)
234236
{
235237
if (std::abs(mcphoton.pdgCode()) != kGamma) {
@@ -264,8 +266,8 @@ bool IsConversionPointInAcceptance(TMCPhoton const& mcphoton, const float max_r_
264266
return true;
265267
}
266268
//_______________________________________________________________________
267-
template <typename TMCParticle, typename TMCParticles>
268-
bool isGammaGammaDecay(TMCParticle mcParticle, TMCParticles mcParticles)
269+
template <o2::soa::is_iterator TMCParticle, o2::soa::is_table TMCParticles>
270+
bool isGammaGammaDecay(TMCParticle const& mcParticle, TMCParticles const& mcParticles)
269271
{
270272
auto daughtersIds = mcParticle.daughtersIds();
271273
if (daughtersIds.size() != 2) { // o2-linter: disable=magic-number (2 is not that magic in this context)

PWGEM/PhotonMeson/Utils/NMHistograms.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ inline void addNMHistograms(o2::framework::HistogramRegistry* fRegistry, bool is
7676
}
7777
}
7878

79-
template <typename TDiphoton, typename TMCParitlce, typename TMCParticles, typename TMCCollisions>
79+
template <typename TDiphoton, o2::soa::is_iterator TMCParitlce, o2::soa::is_table TMCParticles, o2::soa::is_table TMCCollisions>
8080
void fillTruePairInfo(o2::framework::HistogramRegistry* fRegistry, TDiphoton const& v12, TMCParitlce const& mcparticle, TMCParticles const& mcparticles, TMCCollisions const&, const TF1* f1fd_k0s_to_pi0 = nullptr, float eventWeight = 1.f)
8181
{
8282
int pdg = std::abs(mcparticle.pdgCode());

PWGEM/PhotonMeson/Utils/PairUtilities.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515
#ifndef PWGEM_PHOTONMESON_UTILS_PAIRUTILITIES_H_
1616
#define PWGEM_PHOTONMESON_UTILS_PAIRUTILITIES_H_
1717

18-
#include "Common/Core/RecoDecay.h"
18+
#include <Common/Core/RecoDecay.h>
1919

2020
#include <CommonConstants/MathConstants.h>
21+
#include <Framework/ASoA.h>
2122

2223
#include <cmath>
2324

@@ -47,7 +48,7 @@ enum PairType {
4748
kNpair,
4849
};
4950

50-
template <typename U1, typename U2, typename TG1, typename TG2, typename TCut1, typename TCut2>
51+
template <typename U1, typename U2, o2::soa::is_iterator TG1, o2::soa::is_iterator TG2, typename TCut1, typename TCut2>
5152
bool IsSelectedPair(TG1 const& g1, TG2 const& g2, TCut1 const& cut1, TCut2 const& cut2)
5253
{
5354
bool is_g1_selected = false;
@@ -57,7 +58,7 @@ bool IsSelectedPair(TG1 const& g1, TG2 const& g2, TCut1 const& cut1, TCut2 const
5758
return (is_g1_selected && is_g2_selected);
5859
}
5960

60-
template <typename TV0Leg, typename TCluster>
61+
template <o2::soa::is_iterator TV0Leg, o2::soa::is_iterator TCluster>
6162
bool DoesV0LegMatchWithCluster(TV0Leg const& v0leg, TCluster const& cluster, const float max_deta, const float max_dphi, const float max_Ep_width)
6263
{
6364
float deta = v0leg.eta() - cluster.eta();

PWGEM/PhotonMeson/Utils/TrackSelection.h

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

19+
#include <Framework/ASoA.h>
20+
1921
#include <TPDGCode.h>
2022

2123
#include <cmath>
@@ -30,7 +32,7 @@ namespace o2::pwgem::photonmeson
3032
* @param track track
3133
* @return true if has both
3234
*/
33-
template <typename TTrack>
35+
template <o2::soa::is_iterator TTrack>
3436
inline bool isITSTPCTrack(TTrack const& track)
3537
{
3638
return track.hasITS() && track.hasTPC();
@@ -43,7 +45,7 @@ inline bool isITSTPCTrack(TTrack const& track)
4345
* @param track track
4446
* @return true if has both
4547
*/
46-
template <typename TTrack>
48+
template <o2::soa::is_iterator TTrack>
4749
inline bool isTPCTRDTrack(TTrack const& track)
4850
{
4951
return !track.hasITS() && track.hasTPC() && track.hasTRD() && !track.hasTOF();
@@ -56,7 +58,7 @@ inline bool isTPCTRDTrack(TTrack const& track)
5658
* @param track track
5759
* @return true if has all
5860
*/
59-
template <typename TTrack>
61+
template <o2::soa::is_iterator TTrack>
6062
inline bool isITSTPCTRDTrack(TTrack const& track)
6163
{
6264
return track.hasITS() && track.hasTPC() && track.hasTRD() && !track.hasTOF();
@@ -68,7 +70,7 @@ inline bool isITSTPCTRDTrack(TTrack const& track)
6870
* @param track track
6971
* @return true if has both
7072
*/
71-
template <typename TTrack>
73+
template <o2::soa::is_iterator TTrack>
7274
inline bool isTPCTOFTrack(TTrack const& track)
7375
{
7476
return !track.hasITS() && track.hasTPC() && !track.hasTRD() && track.hasTOF();
@@ -80,7 +82,7 @@ inline bool isTPCTOFTrack(TTrack const& track)
8082
* @param track track
8183
* @return true if has all
8284
*/
83-
template <typename TTrack>
85+
template <o2::soa::is_iterator TTrack>
8486
inline bool isTPCTRDTOFTrack(TTrack const& track)
8587
{
8688
return !track.hasITS() && track.hasTPC() && track.hasTRD() && track.hasTOF();
@@ -92,7 +94,7 @@ inline bool isTPCTRDTOFTrack(TTrack const& track)
9294
* @param track track
9395
* @return true if has all
9496
*/
95-
template <typename TTrack>
97+
template <o2::soa::is_iterator TTrack>
9698
inline bool isITSTPCTRDTOFTrack(TTrack const& track)
9799
{
98100
return track.hasITS() && track.hasTPC() && track.hasTRD() && track.hasTOF();
@@ -105,7 +107,7 @@ inline bool isITSTPCTRDTOFTrack(TTrack const& track)
105107
* @param track track
106108
* @return true if tracks is TPC-only
107109
*/
108-
template <typename TTrack>
110+
template <o2::soa::is_iterator TTrack>
109111
inline bool isTPConlyTrack(TTrack const& track)
110112
{
111113
return !track.hasITS() && track.hasTPC() && !track.hasTRD() && !track.hasTOF();
@@ -118,7 +120,7 @@ inline bool isTPConlyTrack(TTrack const& track)
118120
* @param track track
119121
* @return true if tracks is ITS-only
120122
*/
121-
template <typename TTrack>
123+
template <o2::soa::is_iterator TTrack>
122124
inline bool isITSonlyTrack(TTrack const& track)
123125
{
124126
return track.hasITS() && !track.hasTPC() && !track.hasTRD() && !track.hasTOF();
@@ -132,7 +134,7 @@ inline bool isITSonlyTrack(TTrack const& track)
132134
* @param track1 track from daughter 1
133135
* @return true if V0 pairs are ITSTPC-tracks
134136
*/
135-
template <typename TTrack>
137+
template <o2::soa::is_iterator TTrack>
136138
inline bool isITSTPC_ITSTPC(TTrack const& track0, TTrack const& track1)
137139
{
138140
return isITSTPCTrack(track0) && isITSTPCTrack(track1);
@@ -146,7 +148,7 @@ inline bool isITSTPC_ITSTPC(TTrack const& track0, TTrack const& track1)
146148
* @param track1 track from daughter 1
147149
* @return true if one is TPC-only and the other ITSTPC
148150
*/
149-
template <typename TTrack>
151+
template <o2::soa::is_iterator TTrack>
150152
inline bool isITSTPC_TPConly(TTrack const& track0, TTrack const& track1)
151153
{
152154
return (isITSTPCTrack(track0) && isTPConlyTrack(track1)) || (isITSTPCTrack(track1) && isTPConlyTrack(track0));
@@ -160,7 +162,7 @@ inline bool isITSTPC_TPConly(TTrack const& track0, TTrack const& track1)
160162
* @param track1 track from daughter 1
161163
* @return true if one is ITS-only and the other ITSTPC
162164
*/
163-
template <typename TTrack>
165+
template <o2::soa::is_iterator TTrack>
164166
inline bool isITSTPC_ITSonly(TTrack const& track0, TTrack const& track1)
165167
{
166168
return (isITSTPCTrack(track0) && isITSonlyTrack(track1)) || (isITSTPCTrack(track1) && isITSonlyTrack(track0));
@@ -174,7 +176,7 @@ inline bool isITSTPC_ITSonly(TTrack const& track0, TTrack const& track1)
174176
* @param track1 track from daughter 1
175177
* @return true if both are TPC-only tracks
176178
*/
177-
template <typename TTrack>
179+
template <o2::soa::is_iterator TTrack>
178180
inline bool isTPConly_TPConly(TTrack const& track0, TTrack const& track1)
179181
{
180182
return isTPConlyTrack(track0) && isTPConlyTrack(track1);
@@ -188,7 +190,7 @@ inline bool isTPConly_TPConly(TTrack const& track0, TTrack const& track1)
188190
* @param track1 track from daughter 1
189191
* @return true if both are ITS-only tracks
190192
*/
191-
template <typename TTrack>
193+
template <o2::soa::is_iterator TTrack>
192194
inline bool isITSonly_ITSonly(TTrack const& track0, TTrack const& track1)
193195
{
194196
return isITSonlyTrack(track0) && isITSonlyTrack(track1);
@@ -202,7 +204,7 @@ inline bool isITSonly_ITSonly(TTrack const& track0, TTrack const& track1)
202204
* @param track1 track from daughter 1
203205
* @return true if either one is ITS-only while the other one is TPC-only
204206
*/
205-
template <typename TTrack>
207+
template <o2::soa::is_iterator TTrack>
206208
inline bool isTPConly_ITSonly(TTrack const& track0, TTrack const& track1)
207209
{
208210
return (isTPConlyTrack(track0) && isITSonlyTrack(track1)) || (isTPConlyTrack(track1) && isITSonlyTrack(track0));
@@ -215,7 +217,7 @@ inline bool isTPConly_ITSonly(TTrack const& track0, TTrack const& track1)
215217
* @param mc2 MCParticle 1
216218
* @return true if the mother particle is the expected type and the same for both
217219
*/
218-
template <PDG_t motherType, typename T>
220+
template <PDG_t motherType, o2::soa::is_iterator T>
219221
inline bool checkMCParticles(T const& mc1, T const& mc2)
220222
{
221223
if (std::abs(mc1.pdgCode()) != kElectron || std::abs(mc2.pdgCode()) != kElectron) {

0 commit comments

Comments
 (0)