Skip to content

Commit 7b27fdc

Browse files
committed
DRY PACK_CONFIGURABLES_TO_ARRAY
1 parent ebae3f3 commit 7b27fdc

1 file changed

Lines changed: 31 additions & 27 deletions

File tree

‎DPG/Tasks/TPC/treeCreatorPidTpcDiagnostics.cxx‎

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@
4343

4444
#include <TString.h>
4545

46+
#include <boost/preprocessor/cat.hpp>
47+
#include <boost/preprocessor/seq/for_each.hpp>
48+
4649
#include <array>
4750
#include <cmath>
4851
#include <cstdint>
@@ -53,16 +56,16 @@ using namespace o2::framework;
5356
using namespace o2::track;
5457
using namespace o2::dpg_tpcskimstablecreator;
5558

56-
#define DO_FOR_ALL_PARTICLES(MACRO) \
57-
MACRO(El, Electron) \
58-
MACRO(Mu, Muon) \
59-
MACRO(Pi, Pion) \
60-
MACRO(Ka, Kaon) \
61-
MACRO(Pr, Proton) \
62-
MACRO(De, Deuteron) \
63-
MACRO(Tr, Triton) \
64-
MACRO(He, Helium3) \
65-
MACRO(Al, Alpha)
59+
#define DO_FOR_ALL_PARTICLES(MACRO, ARG) \
60+
MACRO(El, Electron, ARG) \
61+
MACRO(Mu, Muon, ARG) \
62+
MACRO(Pi, Pion, ARG) \
63+
MACRO(Ka, Kaon, ARG) \
64+
MACRO(Pr, Proton, ARG) \
65+
MACRO(De, Deuteron, ARG) \
66+
MACRO(Tr, Triton, ARG) \
67+
MACRO(He, Helium3, ARG) \
68+
MACRO(Al, Alpha, ARG)
6669

6770
struct TreeCreatorPidTpcDiagnostics {
6871
Produces<o2::aod::PidTpcDiagnostics> rowPidTpcDiagnostics;
@@ -88,7 +91,7 @@ struct TreeCreatorPidTpcDiagnostics {
8891

8992
struct ParticleWiseCuts : ConfigurableGroup {
9093

91-
#define DECLARE_PARTICLE_WISE_CONFIGURABLES(ParticleNameShort, ParticleNameLong) \
94+
#define DECLARE_PARTICLE_WISE_CONFIGURABLES(ParticleNameShort, ParticleNameLong, Unused) \
9295
Configurable<float> cutTpcInnerParameterMin##ParticleNameLong{"cutTpcInnerParameterMin" #ParticleNameLong, 0.f, "Lower-value cut on tpcInnerParam for " #ParticleNameLong}; /* o2-linter: disable=name/configurable (Configurable defined in macro)*/ \
9396
Configurable<float> cutTpcInnerParameterMax##ParticleNameLong{"cutTpcInnerParameterMax" #ParticleNameLong, 999.f, "Upper-value cut on tpcInnerParam for " #ParticleNameLong}; /* o2-linter: disable=name/configurable (Configurable defined in macro)*/ \
9497
Configurable<float> cutExpSigmaMax##ParticleNameLong{"cutExpSigmaMax" #ParticleNameLong, 1e9f, "Upper-value cut on (positively-defined) expected sigma for " #ParticleNameLong}; /* o2-linter: disable=name/configurable (Configurable defined in macro)*/ \
@@ -98,24 +101,25 @@ struct TreeCreatorPidTpcDiagnostics {
98101
Configurable<float> cutDeDxDiffMax##ParticleNameLong{"cutDeDxDiffMax" #ParticleNameLong, 1e9f, "Upper-value cut on real - expected dE/dx difference for " #ParticleNameLong}; /* o2-linter: disable=name/configurable (Configurable defined in macro)*/ \
99102
Configurable<float> cutNSigmaTpcAbs##ParticleNameLong{"cutNSigmaTpcAbs" #ParticleNameLong, 999.f, "Cut on absolute value of nSigmaTpc for " #ParticleNameLong}; // o2-linter: disable=name/configurable (Configurable defined in macro)
100103

101-
DO_FOR_ALL_PARTICLES(DECLARE_PARTICLE_WISE_CONFIGURABLES)
104+
DO_FOR_ALL_PARTICLES(DECLARE_PARTICLE_WISE_CONFIGURABLES, _)
102105
#undef DECLARE_PARTICLE_WISE_CONFIGURABLES
103106
} particleWiseCuts;
104107

105-
#define PACK_CONFIGURABLES_TO_ARRAY(ParticleNameShort, ParticleNameLong) &particleWiseCuts.cutTpcInnerParameterMin##ParticleNameLong,
106-
std::array<Configurable<float>*, PID::Alpha + 1> cutTpcInnerParameterMin{
107-
DO_FOR_ALL_PARTICLES(PACK_CONFIGURABLES_TO_ARRAY)};
108-
#undef PACK_CONFIGURABLES_TO_ARRAY
108+
#define PARTICLE_WISE_CUT_NAMES \
109+
(cutTpcInnerParameterMin)(cutTpcInnerParameterMax)(cutNSigmaTpcAbs)
109110

110-
#define PACK_CONFIGURABLES_TO_ARRAY(ParticleNameShort, ParticleNameLong) &particleWiseCuts.cutTpcInnerParameterMax##ParticleNameLong,
111-
std::array<Configurable<float>*, PID::Alpha + 1> cutTpcInnerParameterMax{
112-
DO_FOR_ALL_PARTICLES(PACK_CONFIGURABLES_TO_ARRAY)};
113-
#undef PACK_CONFIGURABLES_TO_ARRAY
111+
#define MAKE_PARTICLE_CUT_POINTER(ShortName, LongName, CutName) \
112+
&particleWiseCuts.BOOST_PP_CAT(CutName, LongName),
113+
114+
#define PACK_CONFIGURABLES_TO_ARRAY(Unused1, Unused2, CutName) \
115+
std::array<Configurable<float>*, PID::Alpha + 1> CutName{ \
116+
DO_FOR_ALL_PARTICLES(MAKE_PARTICLE_CUT_POINTER, CutName)};
117+
118+
BOOST_PP_SEQ_FOR_EACH(PACK_CONFIGURABLES_TO_ARRAY, _, PARTICLE_WISE_CUT_NAMES)
114119

115-
#define PACK_CONFIGURABLES_TO_ARRAY(ParticleNameShort, ParticleNameLong) &particleWiseCuts.cutNSigmaTpcAbs##ParticleNameLong,
116-
std::array<Configurable<float>*, PID::Alpha + 1> cutNSigmaTpcAbs{
117-
DO_FOR_ALL_PARTICLES(PACK_CONFIGURABLES_TO_ARRAY)};
118120
#undef PACK_CONFIGURABLES_TO_ARRAY
121+
#undef MAKE_PARTICLE_CUT_POINTER
122+
#undef PARTICLE_WISE_CUT_NAMES
119123

120124
HistogramRegistry registry{"registry", {}};
121125

@@ -140,7 +144,7 @@ struct TreeCreatorPidTpcDiagnostics {
140144
int enabledProcesses{0};
141145

142146
switch (ParticleId) {
143-
#define INIT_PARTICLE(ParticleNameShort, ParticleNameLong) \
147+
#define INIT_PARTICLE(ParticleNameShort, ParticleNameLong, Unused) \
144148
case PID::ParticleNameLong: \
145149
if (!doprocess##ParticleNameLong && !doprocessFull##ParticleNameLong && !doprocessFullWithTOF##ParticleNameLong) { \
146150
return false; \
@@ -157,7 +161,7 @@ struct TreeCreatorPidTpcDiagnostics {
157161
LOG(info) << "Enabled TPC QA for " << #ParticleNameLong; \
158162
break;
159163

160-
DO_FOR_ALL_PARTICLES(INIT_PARTICLE)
164+
DO_FOR_ALL_PARTICLES(INIT_PARTICLE, _)
161165
#undef INIT_PARTICLE
162166
}
163167
if (enabledProcesses != 1) {
@@ -273,7 +277,7 @@ struct TreeCreatorPidTpcDiagnostics {
273277
}
274278
}
275279

276-
#define MAKE_PROCESS_FUNCTIONS(ParticleNameShort, ParticleNameLong) \
280+
#define MAKE_PROCESS_FUNCTIONS(ParticleNameShort, ParticleNameLong, Unused) \
277281
void process##ParticleNameLong(CollisionsExtra const& collisions, \
278282
soa::Join<TrackCandidates, aod::pidTPC##ParticleNameShort> const& tracks, \
279283
aod::BCsWithTimestamps const&) \
@@ -298,7 +302,7 @@ struct TreeCreatorPidTpcDiagnostics {
298302
} \
299303
PROCESS_SWITCH(TreeCreatorPidTpcDiagnostics, processFullWithTOF##ParticleNameLong, Form("Process for the %s hypothesis for full TPC PID QA with the TOF info added", #ParticleNameLong), false);
300304

301-
DO_FOR_ALL_PARTICLES(MAKE_PROCESS_FUNCTIONS)
305+
DO_FOR_ALL_PARTICLES(MAKE_PROCESS_FUNCTIONS, _)
302306
#undef MAKE_PROCESS_FUNCTIONS
303307
};
304308

0 commit comments

Comments
 (0)