Skip to content

Commit a6bd3b4

Browse files
committed
Outlier cut support for JCorran task
1 parent 1690c9e commit a6bd3b4

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

PWGCF/JCorran/Tasks/jflucAnalysisTask.cxx

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@
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>
2731

2832
// #include "CCDB/BasicCCDBManager.h"
2933

@@ -56,6 +60,7 @@ struct jflucAnalysisTask {
5660
O2_DEFINE_CONFIGURABLE(ptmax, float, 5.0, "Maximum pt for tracks");
5761
O2_DEFINE_CONFIGURABLE(cfgCentBinsForMC, int, 0, "0 = OFF and 1 = ON for data like multiplicity/centrality bins for MC process");
5862
O2_DEFINE_CONFIGURABLE(cfgMultCorrelationsMask, uint16_t, 0, "Selection bitmask for the multiplicity correlations. This should match the filter selection cfgEstimatorBitMask.")
63+
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")
5964

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

7277
HistogramRegistry registry{"registry"};
7378

79+
std::unique_ptr<TFormula> multCutFormula;
80+
std::array<uint, 4> multCutFormulaParamIndex;
81+
7482
void init(InitContext const&)
7583
{
7684
auto axisSpecMult = AxisSpec(axisMultiplicity);
@@ -98,6 +106,28 @@ struct jflucAnalysisTask {
98106
}
99107
if ((doprocessCFDerivedMultSet || doprocessCFDerivedMultSetCorrected) && cfgMultCorrelationsMask == 0)
100108
LOGF(fatal, "cfgMultCorrelationsMask can not be 0 when MultSet process functions are in use.");
109+
110+
if (!cfgMultCutFormula.value.empty()) {
111+
if (cfgMultCorrelationsMask == 0)
112+
LOGF(fatal, "cfgMultCorrelationsMask can not be 0 when outlier cuts are enabled.");
113+
multCutFormula = std::make_unique<TFormula>("multCutFormula", cfgMultCutFormula.value.c_str());
114+
std::fill_n(multCutFormulaParamIndex.begin(), std::size(multCutFormulaParamIndex), ~0u);
115+
std::array<std::string, 4> pars = {"cFT0C", "mFV0A", "mPV", "mGlob"}; // must correspond the order of MultiplicityEstimators
116+
for (uint i = 0, n = multCutFormula->GetNpar(); i < n; ++i) {
117+
auto m = std::find(pars.begin(), pars.end(), multCutFormula->GetParName(i));
118+
if (m == pars.end()) {
119+
120+
LOGF(warning, "Unknown parameter in cfgMultCutFormula: %s", multCutFormula->GetParName(i));
121+
continue;
122+
}
123+
if ((cfgMultCorrelationsMask.value & (1u << i)) == 0) {
124+
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.");
125+
} else {
126+
multCutFormulaParamIndex[std::distance(pars.begin(), m)] = i;
127+
LOGF(info, "Multiplicity cut parameter %s in use.", m->c_str());
128+
}
129+
}
130+
}
101131
}
102132

103133
template <class T>
@@ -138,6 +168,20 @@ struct jflucAnalysisTask {
138168
}
139169
}
140170

171+
template <class CollType>
172+
bool passOutlier(CollType const& collision)
173+
{
174+
if (cfgMultCutFormula.value.empty())
175+
return true;
176+
for (uint i = 0; i < 4; ++i) {
177+
if ((cfgMultCorrelationsMask.value & (1u << i)) == 0 || multCutFormulaParamIndex[i] == ~0u)
178+
continue;
179+
auto estIndex = std::popcount(cfgMultCorrelationsMask.value & ((1u << i) - 1));
180+
multCutFormula->SetParameter(multCutFormulaParamIndex[i], collision.multiplicities()[estIndex]);
181+
}
182+
return multCutFormula->Eval() > 0.0f;
183+
}
184+
141185
void processJDerived(aod::JCollision const& collision, soa::Filtered<aod::JTracks> const& tracks)
142186
{
143187
analyze(collision, tracks);
@@ -166,6 +210,8 @@ struct jflucAnalysisTask {
166210
{
167211
if (std::popcount(cfgMultCorrelationsMask.value) != static_cast<int>(collision.multiplicities().size()))
168212
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());
213+
if (!passOutlier(collision))
214+
return;
169215
analyze(collision, tracks);
170216
}
171217
PROCESS_SWITCH(jflucAnalysisTask, processCFDerivedMultSet, "Process CF derived data with multiplicity sets", false);
@@ -174,6 +220,8 @@ struct jflucAnalysisTask {
174220
{
175221
if (std::popcount(cfgMultCorrelationsMask.value) != static_cast<int>(collision.multiplicities().size()))
176222
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());
223+
if (!passOutlier(collision))
224+
return;
177225
analyze(collision, tracks);
178226
}
179227
PROCESS_SWITCH(jflucAnalysisTask, processCFDerivedMultSetCorrected, "Process CF derived data with corrections and multiplicity sets", false);

0 commit comments

Comments
 (0)