Skip to content

Commit 5fe973c

Browse files
authored
[DPG] treeCreatorPidTpcDiagnostics: reduce output tree size (#18241)
1 parent cde9f2a commit 5fe973c

1 file changed

Lines changed: 62 additions & 36 deletions

File tree

‎DPG/Tasks/TPC/treeCreatorPidTpcDiagnostics.cxx‎

Lines changed: 62 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,12 @@
4141
#include <Framework/runDataProcessing.h>
4242
#include <ReconstructionDataFormats/PID.h>
4343

44+
#include <TRandom3.h>
4445
#include <TString.h>
4546

47+
#include <boost/preprocessor/cat.hpp>
48+
#include <boost/preprocessor/seq/for_each.hpp>
49+
4650
#include <array>
4751
#include <cmath>
4852
#include <cstdint>
@@ -53,16 +57,16 @@ using namespace o2::framework;
5357
using namespace o2::track;
5458
using namespace o2::dpg_tpcskimstablecreator;
5559

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)
60+
#define DO_FOR_ALL_PARTICLES(MACRO, ARG) \
61+
MACRO(El, Electron, ARG) \
62+
MACRO(Mu, Muon, ARG) \
63+
MACRO(Pi, Pion, ARG) \
64+
MACRO(Ka, Kaon, ARG) \
65+
MACRO(Pr, Proton, ARG) \
66+
MACRO(De, Deuteron, ARG) \
67+
MACRO(Tr, Triton, ARG) \
68+
MACRO(He, Helium3, ARG) \
69+
MACRO(Al, Alpha, ARG)
6670

6771
struct TreeCreatorPidTpcDiagnostics {
6872
Produces<o2::aod::PidTpcDiagnostics> rowPidTpcDiagnostics;
@@ -86,28 +90,38 @@ struct TreeCreatorPidTpcDiagnostics {
8690
Configurable<bool> treatLimitedAcceptanceAsBad{"treatLimitedAcceptanceAsBad", false, "reject all events where the detectors relevant for the specified Runlist are flagged as LimitedAcceptance"};
8791
Configurable<bool> requireGoodRct{"requireGoodRct", false, "require good detector flag in run condtion table"};
8892

89-
#define DECLARE_PARTICLE_WISE_CONFIGURABLES(ParticleNameShort, ParticleNameLong) \
90-
Configurable<float> cutTpcInnerParameterMin##ParticleNameLong{"cutTpcInnerParameterMin" #ParticleNameLong, 0.f, "Lower-value cut on tpcInnerParam for " #ParticleNameLong}; /* o2-linter: disable=name/configurable (Configurable defined in macro)*/ \
91-
Configurable<float> cutTpcInnerParameterMax##ParticleNameLong{"cutTpcInnerParameterMax" #ParticleNameLong, 999.f, "Upper-value cut on tpcInnerParam for " #ParticleNameLong}; /* o2-linter: disable=name/configurable (Configurable defined in macro)*/ \
92-
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)
93+
struct ParticleWiseCfgs : ConfigurableGroup {
94+
95+
#define DECLARE_PARTICLE_WISE_CONFIGURABLES(Unused1, ParticleNameLong, Unused2) \
96+
Configurable<float> cutTpcInnerParameterMin##ParticleNameLong{"cutTpcInnerParameterMin" #ParticleNameLong, 0.f, "Lower-value cut on tpcInnerParam for " #ParticleNameLong}; /* o2-linter: disable=name/configurable (Configurable defined in macro)*/ \
97+
Configurable<float> cutTpcInnerParameterMax##ParticleNameLong{"cutTpcInnerParameterMax" #ParticleNameLong, 999.f, "Upper-value cut on tpcInnerParam for " #ParticleNameLong}; /* o2-linter: disable=name/configurable (Configurable defined in macro)*/ \
98+
Configurable<float> cutExpSigmaMax##ParticleNameLong{"cutExpSigmaMax" #ParticleNameLong, 1e9f, "Upper-value cut on expected sigma for " #ParticleNameLong}; /* o2-linter: disable=name/configurable (Configurable defined in macro)*/ \
99+
Configurable<float> cutDeDxExpectedMin##ParticleNameLong{"cutDeDxExpectedMin" #ParticleNameLong, -1e9f, "Lower-value cut on expected dE/dx for " #ParticleNameLong}; /* o2-linter: disable=name/configurable (Configurable defined in macro)*/ \
100+
Configurable<float> cutDeDxExpectedMax##ParticleNameLong{"cutDeDxExpectedMax" #ParticleNameLong, 1e9f, "Upper-value cut on expected dE/dx for " #ParticleNameLong}; /* o2-linter: disable=name/configurable (Configurable defined in macro)*/ \
101+
Configurable<float> cutDeDxDiffMin##ParticleNameLong{"cutDeDxDiffMin" #ParticleNameLong, -1e9f, "Lower-value cut on real - expected dE/dx difference for " #ParticleNameLong}; /* o2-linter: disable=name/configurable (Configurable defined in macro)*/ \
102+
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)*/ \
103+
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)*/ \
104+
Configurable<float> downsampleFactor##ParticleNameLong{"downsampleFactor" #ParticleNameLong, 1.f, "Downsampling factor for " #ParticleNameLong}; // o2-linter: disable=name/configurable (Configurable defined in macro)
93105

94-
DO_FOR_ALL_PARTICLES(DECLARE_PARTICLE_WISE_CONFIGURABLES)
106+
DO_FOR_ALL_PARTICLES(DECLARE_PARTICLE_WISE_CONFIGURABLES, _)
95107
#undef DECLARE_PARTICLE_WISE_CONFIGURABLES
108+
} particleWiseCfgs;
96109

97-
#define PACK_CONFIGURABLES_TO_ARRAY(ParticleNameShort, ParticleNameLong) &cutTpcInnerParameterMin##ParticleNameLong,
98-
std::array<Configurable<float>*, PID::Alpha + 1> cutTpcInnerParameterMin{
99-
DO_FOR_ALL_PARTICLES(PACK_CONFIGURABLES_TO_ARRAY)};
100-
#undef PACK_CONFIGURABLES_TO_ARRAY
110+
#define PARTICLE_WISE_CFG_NAMES \
111+
(cutTpcInnerParameterMin)(cutTpcInnerParameterMax)(cutExpSigmaMax)(cutDeDxExpectedMin)(cutDeDxExpectedMax)(cutDeDxDiffMin)(cutDeDxDiffMax)(cutNSigmaTpcAbs)(downsampleFactor)
101112

102-
#define PACK_CONFIGURABLES_TO_ARRAY(ParticleNameShort, ParticleNameLong) &cutTpcInnerParameterMax##ParticleNameLong,
103-
std::array<Configurable<float>*, PID::Alpha + 1> cutTpcInnerParameterMax{
104-
DO_FOR_ALL_PARTICLES(PACK_CONFIGURABLES_TO_ARRAY)};
105-
#undef PACK_CONFIGURABLES_TO_ARRAY
113+
#define MAKE_PARTICLE_CUT_POINTER(Unused, ParticleNameLong, CfgName) \
114+
&particleWiseCfgs.BOOST_PP_CAT(CfgName, ParticleNameLong),
115+
116+
#define PACK_CONFIGURABLES_TO_ARRAY(Unused1, Unused2, CfgName) \
117+
std::array<Configurable<float>*, PID::Alpha + 1> CfgName{ \
118+
DO_FOR_ALL_PARTICLES(MAKE_PARTICLE_CUT_POINTER, CfgName)};
119+
120+
BOOST_PP_SEQ_FOR_EACH(PACK_CONFIGURABLES_TO_ARRAY, _, PARTICLE_WISE_CFG_NAMES)
106121

107-
#define PACK_CONFIGURABLES_TO_ARRAY(ParticleNameShort, ParticleNameLong) &cutNSigmaTpcAbs##ParticleNameLong,
108-
std::array<Configurable<float>*, PID::Alpha + 1> cutNSigmaTpcAbs{
109-
DO_FOR_ALL_PARTICLES(PACK_CONFIGURABLES_TO_ARRAY)};
110122
#undef PACK_CONFIGURABLES_TO_ARRAY
123+
#undef MAKE_PARTICLE_CUT_POINTER
124+
#undef PARTICLE_WISE_CFG_NAMES
111125

112126
HistogramRegistry registry{"registry", {}};
113127

@@ -117,6 +131,8 @@ struct TreeCreatorPidTpcDiagnostics {
117131

118132
o2::aod::rctsel::RCTFlagsChecker rctChecker;
119133

134+
TRandom3 mRnd;
135+
120136
using CollisionsExtra = soa::Join<aod::Collisions, aod::Mults, aod::EvSels>;
121137
using TrackCandidates = soa::Join<aod::Tracks, aod::TracksExtra, aod::TrackSelection>;
122138

@@ -132,7 +148,7 @@ struct TreeCreatorPidTpcDiagnostics {
132148
int enabledProcesses{0};
133149

134150
switch (ParticleId) {
135-
#define INIT_PARTICLE(ParticleNameShort, ParticleNameLong) \
151+
#define INIT_PARTICLE(Unused1, ParticleNameLong, Unused2) \
136152
case PID::ParticleNameLong: \
137153
if (!doprocess##ParticleNameLong && !doprocessFull##ParticleNameLong && !doprocessFullWithTOF##ParticleNameLong) { \
138154
return false; \
@@ -149,7 +165,7 @@ struct TreeCreatorPidTpcDiagnostics {
149165
LOG(info) << "Enabled TPC QA for " << #ParticleNameLong; \
150166
break;
151167

152-
DO_FOR_ALL_PARTICLES(INIT_PARTICLE)
168+
DO_FOR_ALL_PARTICLES(INIT_PARTICLE, _)
153169
#undef INIT_PARTICLE
154170
}
155171
if (enabledProcesses != 1) {
@@ -212,6 +228,10 @@ struct TreeCreatorPidTpcDiagnostics {
212228
const auto tracksFromCollision = tracks.sliceBy(perCollisionTracks, static_cast<int>(collision.globalIndex()));
213229

214230
for (const auto& track : tracksFromCollision) {
231+
if (*downsampleFactor.at(ParticleId) < 1.f && mRnd.Uniform(1) > *downsampleFactor.at(ParticleId)) {
232+
continue;
233+
}
234+
215235
bool isGoodTrack = isTrackSelected(track, trackSelection);
216236
isGoodTrack &= (!requireGlobalTrack || track.isGlobalTrack());
217237
isGoodTrack &= (!requireIts || track.hasITS());
@@ -233,10 +253,6 @@ struct TreeCreatorPidTpcDiagnostics {
233253
isGoodTrack &= (tpcInnerParam <= *cutTpcInnerParameterMax.at(ParticleId));
234254
isGoodTrack &= (std::fabs(nSigmaTpc) <= *cutNSigmaTpcAbs.at(ParticleId));
235255

236-
if (!isGoodTrack) {
237-
continue;
238-
}
239-
240256
float dedxDiff{UndefValueFloat};
241257
float dedxExpected{UndefValueFloat};
242258
float expSigma{UndefValueFloat};
@@ -245,6 +261,16 @@ struct TreeCreatorPidTpcDiagnostics {
245261
dedxDiff = o2::aod::pidutils::tpcExpSignalDiff<ParticleId>(track);
246262
dedxExpected = track.tpcSignal() - dedxDiff;
247263
expSigma = o2::aod::pidutils::tpcExpSigma<ParticleId>(track);
264+
265+
isGoodTrack &= (expSigma <= *cutExpSigmaMax.at(ParticleId));
266+
isGoodTrack &= (dedxExpected >= *cutDeDxExpectedMin.at(ParticleId));
267+
isGoodTrack &= (dedxExpected <= *cutDeDxExpectedMax.at(ParticleId));
268+
isGoodTrack &= (dedxDiff >= *cutDeDxDiffMin.at(ParticleId));
269+
isGoodTrack &= (dedxDiff <= *cutDeDxDiffMax.at(ParticleId));
270+
}
271+
272+
if (!isGoodTrack) {
273+
continue;
248274
}
249275

250276
float nSigmaTof{UndefValueFloat};
@@ -265,7 +291,7 @@ struct TreeCreatorPidTpcDiagnostics {
265291
}
266292
}
267293

268-
#define MAKE_PROCESS_FUNCTIONS(ParticleNameShort, ParticleNameLong) \
294+
#define MAKE_PROCESS_FUNCTIONS(ParticleNameShort, ParticleNameLong, Unused) \
269295
void process##ParticleNameLong(CollisionsExtra const& collisions, \
270296
soa::Join<TrackCandidates, aod::pidTPC##ParticleNameShort> const& tracks, \
271297
aod::BCsWithTimestamps const&) \
@@ -290,12 +316,12 @@ struct TreeCreatorPidTpcDiagnostics {
290316
} \
291317
PROCESS_SWITCH(TreeCreatorPidTpcDiagnostics, processFullWithTOF##ParticleNameLong, Form("Process for the %s hypothesis for full TPC PID QA with the TOF info added", #ParticleNameLong), false);
292318

293-
DO_FOR_ALL_PARTICLES(MAKE_PROCESS_FUNCTIONS)
319+
DO_FOR_ALL_PARTICLES(MAKE_PROCESS_FUNCTIONS, _)
294320
#undef MAKE_PROCESS_FUNCTIONS
295321
};
296322

297-
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
323+
WorkflowSpec defineDataProcessing(ConfigContext const& context)
298324
{
299-
return WorkflowSpec{adaptAnalysisTask<TreeCreatorPidTpcDiagnostics>(cfgc)};
325+
return WorkflowSpec{adaptAnalysisTask<TreeCreatorPidTpcDiagnostics>(context)};
300326
}
301327
#undef DO_FOR_ALL_PARTICLES

0 commit comments

Comments
 (0)