Skip to content

Commit f8c1c17

Browse files
nmallick19alibuild
andauthored
[PWGCF] process MultSet and track selection bit check added (#15180)
Co-authored-by: ALICE Action Bot <alibuild@cern.ch>
1 parent 55af72c commit f8c1c17

File tree

1 file changed

+72
-6
lines changed

1 file changed

+72
-6
lines changed

PWGCF/JCorran/Tasks/flowJSPCAnalysis.cxx

Lines changed: 72 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,19 @@
88
// In applying this license CERN does not waive the privileges and immunities
99
// granted to it by virtue of its status as an Intergovernmental Organization
1010
// or submit itself to any jurisdiction.
11-
12-
// \brief Task for the calculation of SPC with filtered data.
13-
// \author Maxim Virta (maxim.virta@cern.ch), Cindy Mordasini (cindy.mordasini@cern.ch)
11+
///
12+
/// \file flowJSPCAnalysis.cxx
13+
/// \brief Task for the calculation of SPC with filtered data.
14+
/// \author Maxim Virta (maxim.virta@cern.ch), Cindy Mordasini (cindy.mordasini@cern.ch), Neelkamal Mallick (neelkamal.mallick@cern.ch)
1415

1516
// Standard headers.
17+
#include <TFormula.h>
18+
#include <TRandom3.h>
19+
1620
#include <chrono>
21+
#include <memory>
1722
#include <string>
1823
#include <vector>
19-
#include <TRandom3.h>
2024

2125
// O2 headers. //
2226
// The first two are mandatory.
@@ -46,6 +50,8 @@ using namespace o2;
4650
using namespace o2::framework;
4751
using namespace o2::framework::expressions;
4852

53+
#define O2_DEFINE_CONFIGURABLE(NAME, TYPE, DEFAULT, HELP) Configurable<TYPE> NAME{#NAME, DEFAULT, HELP};
54+
4955
using MyCollisions = soa::Join<aod::Collisions, aod::EvSels, aod::Mults,
5056
aod::FT0sCorrected, aod::CentFT0Ms,
5157
aod::CentFT0As, aod::CentFT0Cs, aod::CentFV0As,
@@ -61,6 +67,8 @@ struct flowJSPCAnalysis {
6167
using HasWeightNUA = decltype(std::declval<T&>().weightNUA());
6268
template <class T>
6369
using HasWeightEff = decltype(std::declval<T&>().weightEff());
70+
template <class T>
71+
using HasTrackType = decltype(std::declval<T&>().trackType());
6472

6573
HistogramRegistry qaHistRegistry{"qaHistRegistry", {}, OutputObjHandlingPolicy::AnalysisObject, true, true};
6674
FlowJHistManager histManager;
@@ -84,12 +92,20 @@ struct flowJSPCAnalysis {
8492
Configurable<int> cfgMultMin{"cfgMultMin", 10, "Minimum number of particles required for the event to have."};
8593
} cfgEventCuts;
8694

95+
O2_DEFINE_CONFIGURABLE(cfgTrackBitMask, uint16_t, 0, "Track selection bitmask to use as defined in the filterCorrelations.cxx task");
96+
O2_DEFINE_CONFIGURABLE(cfgMultCorrelationsMask, uint16_t, 0, "Selection bitmask for the multiplicity correlations. This should match the filter selection cfgEstimatorBitMask.")
97+
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, [cFT0M] FT0M centrality")
98+
8799
// // Filters to be applied to the received data.
88100
// // The analysis assumes the data has been subjected to a QA of its selection,
89101
// // and thus only the final distributions of the data for analysis are saved.
90102
Filter collFilter = (nabs(aod::collision::posZ) < cfgEventCuts.cfgZvtxMax);
103+
91104
Filter trackFilter = (aod::track::pt > cfgTrackCuts.cfgPtMin) && (aod::track::pt < cfgTrackCuts.cfgPtMax) && (nabs(aod::track::eta) < cfgTrackCuts.cfgEtaMax);
92-
Filter cftrackFilter = (aod::cftrack::pt > cfgTrackCuts.cfgPtMin) && (aod::cftrack::pt < cfgTrackCuts.cfgPtMax); // eta cuts done by jfluc
105+
Filter cftrackFilter = (nabs(aod::cftrack::eta) < cfgTrackCuts.cfgEtaMax) && (aod::cftrack::pt > cfgTrackCuts.cfgPtMin) && (aod::cftrack::pt < cfgTrackCuts.cfgPtMax) && ncheckbit(aod::track::trackType, as<uint8_t>(cfgTrackBitMask));
106+
107+
std::unique_ptr<TFormula> multCutFormula;
108+
std::array<uint, aod::cfmultset::NMultiplicityEstimators> multCutFormulaParamIndex;
93109

94110
void init(InitContext const&)
95111
{
@@ -103,6 +119,26 @@ struct flowJSPCAnalysis {
103119
histManager.setHistRegistryQA(&qaHistRegistry);
104120
histManager.setDebugLog(false);
105121
histManager.createHistQA();
122+
123+
if (!cfgMultCutFormula.value.empty()) {
124+
multCutFormula = std::make_unique<TFormula>("multCutFormula", cfgMultCutFormula.value.c_str());
125+
std::fill_n(multCutFormulaParamIndex.begin(), std::size(multCutFormulaParamIndex), ~0u);
126+
std::array<std::string, aod::cfmultset::NMultiplicityEstimators> pars = {"cFT0C", "mFV0A", "mPV", "mGlob", "cFT0M"}; // must correspond the order of MultiplicityEstimators
127+
for (uint i = 0, n = multCutFormula->GetNpar(); i < n; ++i) {
128+
auto m = std::find(pars.begin(), pars.end(), multCutFormula->GetParName(i));
129+
if (m == pars.end()) {
130+
LOGF(warning, "Unknown parameter in cfgMultCutFormula: %s", multCutFormula->GetParName(i));
131+
continue;
132+
}
133+
const uint estIdx = std::distance(pars.begin(), m);
134+
if ((cfgMultCorrelationsMask.value & (1u << estIdx)) == 0) {
135+
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.", m->c_str());
136+
} else {
137+
multCutFormulaParamIndex[estIdx] = i;
138+
LOGF(info, "Multiplicity cut parameter %s in use.", m->c_str());
139+
}
140+
}
141+
}
106142
}
107143

108144
template <class CollisionT, class TrackT>
@@ -119,6 +155,7 @@ struct flowJSPCAnalysis {
119155
int cBin = histManager.getCentBin(cent);
120156
spcHistograms.fill(HIST("FullCentrality"), cent);
121157
int nTracks = tracks.size();
158+
122159
double wNUA = 1.0;
123160
double wEff = 1.0;
124161
for (const auto& track : tracks) {
@@ -135,6 +172,11 @@ struct flowJSPCAnalysis {
135172
if constexpr (std::experimental::is_detected<HasWeightNUA, const JInputClassIter>::value) {
136173
spcAnalysis.fillQAHistograms(cBin, track.phi(), 1. / track.weightNUA());
137174
}
175+
if constexpr (std::experimental::is_detected<HasTrackType, const JInputClassIter>::value) {
176+
if (track.trackType() != cfgTrackBitMask.value) {
177+
LOGF(warning, "trackType %d (expected %d) is passed to the analysis", track.trackType(), cfgTrackBitMask.value);
178+
}
179+
}
138180
}
139181
}
140182

@@ -146,6 +188,20 @@ struct flowJSPCAnalysis {
146188
spcAnalysis.calculateCorrelators(cBin);
147189
}
148190

191+
template <class CollType>
192+
bool passOutlier(CollType const& collision)
193+
{
194+
if (cfgMultCutFormula.value.empty())
195+
return true;
196+
for (uint i = 0; i < aod::cfmultset::NMultiplicityEstimators; ++i) {
197+
if ((cfgMultCorrelationsMask.value & (1u << i)) == 0 || multCutFormulaParamIndex[i] == ~0u)
198+
continue;
199+
auto estIndex = std::popcount(static_cast<uint32_t>(cfgMultCorrelationsMask.value & ((1u << i) - 1)));
200+
multCutFormula->SetParameter(multCutFormulaParamIndex[i], collision.multiplicities()[estIndex]);
201+
}
202+
return multCutFormula->Eval() > 0.0f;
203+
}
204+
149205
void processJDerived(aod::JCollision const& collision, soa::Filtered<aod::JTracks> const& tracks)
150206
{
151207
analyze(collision, tracks);
@@ -164,11 +220,21 @@ struct flowJSPCAnalysis {
164220
}
165221
PROCESS_SWITCH(flowJSPCAnalysis, processCFDerived, "Process CF derived data", false);
166222

167-
void processCFDerivedCorrected(aod::CFCollision const& collision, soa::Filtered<soa::Join<aod::CFTracks, aod::JWeights>> const& tracks)
223+
void processCFDerivedCorrected(soa::Filtered<aod::CFCollisions>::iterator const& collision, soa::Filtered<soa::Join<aod::CFTracks, aod::JWeights>> const& tracks)
168224
{
169225
analyze(collision, tracks);
170226
}
171227
PROCESS_SWITCH(flowJSPCAnalysis, processCFDerivedCorrected, "Process CF derived data with corrections", true);
228+
229+
void processCFDerivedMultSetCorrected(soa::Filtered<soa::Join<aod::CFCollisions, aod::CFMultSets>>::iterator const& collision, soa::Filtered<soa::Join<aod::CFTracks, aod::JWeights>> const& tracks)
230+
{
231+
if (std::popcount(static_cast<uint32_t>(cfgMultCorrelationsMask.value)) != static_cast<int>(collision.multiplicities().size()))
232+
LOGF(fatal, "Multiplicity selections (cfgMultCorrelationsMask = 0x%x) do not match the size of the table column (%ld).", cfgMultCorrelationsMask.value, collision.multiplicities().size());
233+
if (!passOutlier(collision))
234+
return;
235+
analyze(collision, tracks);
236+
}
237+
PROCESS_SWITCH(flowJSPCAnalysis, processCFDerivedMultSetCorrected, "Process CF derived data with corrections and multiplicity sets", false);
172238
};
173239

174240
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)

0 commit comments

Comments
 (0)