Skip to content

Commit 4cd832c

Browse files
authored
[PWGCF] Outlier cut support for JCorran task (#13181)
1 parent 64b8ebe commit 4cd832c

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

PWGCF/JCorran/Tasks/jflucAnalysisTask.cxx

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@
2323
#include "Framework/RunningWorkflowInfo.h"
2424
#include "ReconstructionDataFormats/V0.h"
2525

26+
#include <TFormula.h>
27+
28+
#include <array>
2629
#include <deque>
30+
#include <memory>
31+
#include <string>
2732

2833
// #include "CCDB/BasicCCDBManager.h"
2934

@@ -56,6 +61,7 @@ struct jflucAnalysisTask {
5661
O2_DEFINE_CONFIGURABLE(ptmax, float, 5.0, "Maximum pt for tracks");
5762
O2_DEFINE_CONFIGURABLE(cfgCentBinsForMC, int, 0, "0 = OFF and 1 = ON for data like multiplicity/centrality bins for MC process");
5863
O2_DEFINE_CONFIGURABLE(cfgMultCorrelationsMask, uint16_t, 0, "Selection bitmask for the multiplicity correlations. This should match the filter selection cfgEstimatorBitMask.")
64+
O2_DEFINE_CONFIGURABLE(cfgMultCutFormula, std::string, "", "Multiplicity correlations cut formula. A result greater than zero results in accepted event. Parameters: [cFT0C] FT0C centrality, [mFV0A] V0A multiplicity, [mGlob] global track multiplicity, [mPV] PV track multiplicity")
5965

6066
ConfigurableAxis axisMultiplicity{"axisMultiplicity", {VARIABLE_WIDTH, 0, 5, 10, 20, 30, 40, 50, 100.1}, "multiplicity / centrality axis for histograms"};
6167
ConfigurableAxis phiAxis{"axisPhi", {50, 0.0, o2::constants::math::TwoPI}, "phi axis for histograms"};
@@ -71,6 +77,9 @@ struct jflucAnalysisTask {
7177

7278
HistogramRegistry registry{"registry"};
7379

80+
std::unique_ptr<TFormula> multCutFormula;
81+
std::array<uint, 4> multCutFormulaParamIndex;
82+
7483
void init(InitContext const&)
7584
{
7685
auto axisSpecMult = AxisSpec(axisMultiplicity);
@@ -98,6 +107,28 @@ struct jflucAnalysisTask {
98107
}
99108
if ((doprocessCFDerivedMultSet || doprocessCFDerivedMultSetCorrected) && cfgMultCorrelationsMask == 0)
100109
LOGF(fatal, "cfgMultCorrelationsMask can not be 0 when MultSet process functions are in use.");
110+
111+
if (!cfgMultCutFormula.value.empty()) {
112+
if (cfgMultCorrelationsMask == 0)
113+
LOGF(fatal, "cfgMultCorrelationsMask can not be 0 when outlier cuts are enabled.");
114+
multCutFormula = std::make_unique<TFormula>("multCutFormula", cfgMultCutFormula.value.c_str());
115+
std::fill_n(multCutFormulaParamIndex.begin(), std::size(multCutFormulaParamIndex), ~0u);
116+
std::array<std::string, 4> pars = {"cFT0C", "mFV0A", "mPV", "mGlob"}; // must correspond the order of MultiplicityEstimators
117+
for (uint i = 0, n = multCutFormula->GetNpar(); i < n; ++i) {
118+
auto m = std::find(pars.begin(), pars.end(), multCutFormula->GetParName(i));
119+
if (m == pars.end()) {
120+
121+
LOGF(warning, "Unknown parameter in cfgMultCutFormula: %s", multCutFormula->GetParName(i));
122+
continue;
123+
}
124+
if ((cfgMultCorrelationsMask.value & (1u << i)) == 0) {
125+
LOGF(warning, "The centrality/multiplicity estimator %s is not available to be used in cfgMultCutFormula. Ensure cfgMultCorrelationsMask is correct and matches the CFMultSets in derived data.");
126+
} else {
127+
multCutFormulaParamIndex[std::distance(pars.begin(), m)] = i;
128+
LOGF(info, "Multiplicity cut parameter %s in use.", m->c_str());
129+
}
130+
}
131+
}
101132
}
102133

103134
template <class T>
@@ -138,6 +169,20 @@ struct jflucAnalysisTask {
138169
}
139170
}
140171

172+
template <class CollType>
173+
bool passOutlier(CollType const& collision)
174+
{
175+
if (cfgMultCutFormula.value.empty())
176+
return true;
177+
for (uint i = 0; i < 4; ++i) {
178+
if ((cfgMultCorrelationsMask.value & (1u << i)) == 0 || multCutFormulaParamIndex[i] == ~0u)
179+
continue;
180+
auto estIndex = std::popcount(cfgMultCorrelationsMask.value & ((1u << i) - 1));
181+
multCutFormula->SetParameter(multCutFormulaParamIndex[i], collision.multiplicities()[estIndex]);
182+
}
183+
return multCutFormula->Eval() > 0.0f;
184+
}
185+
141186
void processJDerived(aod::JCollision const& collision, soa::Filtered<aod::JTracks> const& tracks)
142187
{
143188
analyze(collision, tracks);
@@ -166,6 +211,8 @@ struct jflucAnalysisTask {
166211
{
167212
if (std::popcount(cfgMultCorrelationsMask.value) != static_cast<int>(collision.multiplicities().size()))
168213
LOGF(fatal, "Multiplicity selections (cfgMultCorrelationsMask = 0x%x) do not match the size of the table column (%ld). The histogram filling relies on the preservation of order.", cfgMultCorrelationsMask.value, collision.multiplicities().size());
214+
if (!passOutlier(collision))
215+
return;
169216
analyze(collision, tracks);
170217
}
171218
PROCESS_SWITCH(jflucAnalysisTask, processCFDerivedMultSet, "Process CF derived data with multiplicity sets", false);
@@ -174,6 +221,8 @@ struct jflucAnalysisTask {
174221
{
175222
if (std::popcount(cfgMultCorrelationsMask.value) != static_cast<int>(collision.multiplicities().size()))
176223
LOGF(fatal, "Multiplicity selections (cfgMultCorrelationsMask = 0x%x) do not match the size of the table column (%ld). The histogram filling relies on the preservation of order.", cfgMultCorrelationsMask.value, collision.multiplicities().size());
224+
if (!passOutlier(collision))
225+
return;
177226
analyze(collision, tracks);
178227
}
179228
PROCESS_SWITCH(jflucAnalysisTask, processCFDerivedMultSetCorrected, "Process CF derived data with corrections and multiplicity sets", false);

0 commit comments

Comments
 (0)