Skip to content

Commit a0dbc04

Browse files
committed
process MultSet and track selection bit check added
1 parent 1ae64e1 commit a0dbc04

File tree

1 file changed

+96
-2
lines changed

1 file changed

+96
-2
lines changed

PWGCF/JCorran/Tasks/flowJSPCAnalysis.cxx

Lines changed: 96 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
#include <string>
1818
#include <vector>
1919
#include <TRandom3.h>
20+
#include <THnSparse.h>
21+
#include <TFormula.h>
2022

2123
// O2 headers. //
2224
// The first two are mandatory.
@@ -46,6 +48,8 @@ using namespace o2;
4648
using namespace o2::framework;
4749
using namespace o2::framework::expressions;
4850

51+
#define O2_DEFINE_CONFIGURABLE(NAME, TYPE, DEFAULT, HELP) Configurable<TYPE> NAME{#NAME, DEFAULT, HELP};
52+
4953
using MyCollisions = soa::Join<aod::Collisions, aod::EvSels, aod::Mults,
5054
aod::FT0sCorrected, aod::CentFT0Ms,
5155
aod::CentFT0As, aod::CentFT0Cs, aod::CentFV0As,
@@ -61,6 +65,10 @@ struct flowJSPCAnalysis {
6165
using HasWeightNUA = decltype(std::declval<T&>().weightNUA());
6266
template <class T>
6367
using HasWeightEff = decltype(std::declval<T&>().weightEff());
68+
template <class T>
69+
using HasTrackType = decltype(std::declval<T&>().trackType());
70+
template <class T>
71+
using HasMultSet = decltype(std::declval<T&>().multiplicities());
6472

6573
HistogramRegistry qaHistRegistry{"qaHistRegistry", {}, OutputObjHandlingPolicy::AnalysisObject, true, true};
6674
FlowJHistManager histManager;
@@ -84,12 +92,24 @@ 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+
99+
ConfigurableAxis axisMultCorrCent{"axisMultCorrCent", {100, 0, 100}, "multiplicity correlation axis for centralities"};
100+
ConfigurableAxis axisMultCorrV0{"axisMultCorrV0", {1000, 0, 100000}, "multiplicity correlation axis for V0 multiplicities"};
101+
ConfigurableAxis axisMultCorrMult{"axisMultCorrMult", {1000, 0, 1000}, "multiplicity correlation axis for track multiplicities"};
102+
87103
// // Filters to be applied to the received data.
88104
// // The analysis assumes the data has been subjected to a QA of its selection,
89105
// // and thus only the final distributions of the data for analysis are saved.
90106
Filter collFilter = (nabs(aod::collision::posZ) < cfgEventCuts.cfgZvtxMax);
107+
91108
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
109+
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));
110+
111+
std::unique_ptr<TFormula> multCutFormula;
112+
std::array<uint, aod::cfmultset::NMultiplicityEstimators> multCutFormulaParamIndex;
93113

94114
void init(InitContext const&)
95115
{
@@ -103,6 +123,43 @@ struct flowJSPCAnalysis {
103123
histManager.setHistRegistryQA(&qaHistRegistry);
104124
histManager.setDebugLog(false);
105125
histManager.createHistQA();
126+
127+
if (doprocessCFDerivedMultSetCorrected) {
128+
if (cfgMultCorrelationsMask == 0)
129+
LOGF(fatal, "cfgMultCorrelationsMask can not be 0 when MultSet process functions are in use.");
130+
std::vector<AxisSpec> multAxes;
131+
if (cfgMultCorrelationsMask & aod::cfmultset::CentFT0C)
132+
multAxes.emplace_back(axisMultCorrCent, "FT0C centrality");
133+
if (cfgMultCorrelationsMask & aod::cfmultset::MultFV0A)
134+
multAxes.emplace_back(axisMultCorrV0, "V0A multiplicity");
135+
if (cfgMultCorrelationsMask & aod::cfmultset::MultNTracksPV)
136+
multAxes.emplace_back(axisMultCorrMult, "Nch PV");
137+
if (cfgMultCorrelationsMask & aod::cfmultset::MultNTracksGlobal)
138+
multAxes.emplace_back(axisMultCorrMult, "Nch Global");
139+
if (cfgMultCorrelationsMask & aod::cfmultset::CentFT0M)
140+
multAxes.emplace_back(axisMultCorrCent, "FT0M centrality");
141+
qaHistRegistry.add("multCorrelations", "Multiplicity correlations", {HistType::kTHnSparseF, multAxes});
142+
}
143+
144+
if (!cfgMultCutFormula.value.empty()) {
145+
multCutFormula = std::make_unique<TFormula>("multCutFormula", cfgMultCutFormula.value.c_str());
146+
std::fill_n(multCutFormulaParamIndex.begin(), std::size(multCutFormulaParamIndex), ~0u);
147+
std::array<std::string, aod::cfmultset::NMultiplicityEstimators> pars = {"cFT0C", "mFV0A", "mPV", "mGlob", "cFT0M"}; // must correspond the order of MultiplicityEstimators
148+
for (uint i = 0, n = multCutFormula->GetNpar(); i < n; ++i) {
149+
auto m = std::find(pars.begin(), pars.end(), multCutFormula->GetParName(i));
150+
if (m == pars.end()) {
151+
LOGF(warning, "Unknown parameter in cfgMultCutFormula: %s", multCutFormula->GetParName(i));
152+
continue;
153+
}
154+
const uint estIdx = std::distance(pars.begin(), m);
155+
if ((cfgMultCorrelationsMask.value & (1u << estIdx)) == 0) {
156+
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());
157+
} else {
158+
multCutFormulaParamIndex[estIdx] = i;
159+
LOGF(info, "Multiplicity cut parameter %s in use.", m->c_str());
160+
}
161+
}
162+
}
106163
}
107164

108165
template <class CollisionT, class TrackT>
@@ -119,6 +176,14 @@ struct flowJSPCAnalysis {
119176
int cBin = histManager.getCentBin(cent);
120177
spcHistograms.fill(HIST("FullCentrality"), cent);
121178
int nTracks = tracks.size();
179+
180+
if (cfgFillQA) {
181+
if constexpr (std::experimental::is_detected<HasMultSet, CollisionT>::value) {
182+
std::vector<double> v(collision.multiplicities().begin(), collision.multiplicities().end());
183+
qaHistRegistry.get<THnSparse>(HIST("multCorrelations")).get()->Fill(v.data());
184+
}
185+
}
186+
122187
double wNUA = 1.0;
123188
double wEff = 1.0;
124189
for (const auto& track : tracks) {
@@ -135,6 +200,11 @@ struct flowJSPCAnalysis {
135200
if constexpr (std::experimental::is_detected<HasWeightNUA, const JInputClassIter>::value) {
136201
spcAnalysis.fillQAHistograms(cBin, track.phi(), 1. / track.weightNUA());
137202
}
203+
if constexpr (std::experimental::is_detected<HasTrackType, const JInputClassIter>::value) {
204+
if (track.trackType() != cfgTrackBitMask.value) {
205+
LOGF(warning, "trackType %d (expected %d) is passed to the analysis", track.trackType(), cfgTrackBitMask.value);
206+
}
207+
}
138208
}
139209
}
140210

@@ -146,6 +216,20 @@ struct flowJSPCAnalysis {
146216
spcAnalysis.calculateCorrelators(cBin);
147217
}
148218

219+
template <class CollType>
220+
bool passOutlier(CollType const& collision)
221+
{
222+
if (cfgMultCutFormula.value.empty())
223+
return true;
224+
for (uint i = 0; i < aod::cfmultset::NMultiplicityEstimators; ++i) {
225+
if ((cfgMultCorrelationsMask.value & (1u << i)) == 0 || multCutFormulaParamIndex[i] == ~0u)
226+
continue;
227+
auto estIndex = std::popcount(static_cast<uint32_t>(cfgMultCorrelationsMask.value & ((1u << i) - 1)));
228+
multCutFormula->SetParameter(multCutFormulaParamIndex[i], collision.multiplicities()[estIndex]);
229+
}
230+
return multCutFormula->Eval() > 0.0f;
231+
}
232+
149233
void processJDerived(aod::JCollision const& collision, soa::Filtered<aod::JTracks> const& tracks)
150234
{
151235
analyze(collision, tracks);
@@ -164,11 +248,21 @@ struct flowJSPCAnalysis {
164248
}
165249
PROCESS_SWITCH(flowJSPCAnalysis, processCFDerived, "Process CF derived data", false);
166250

167-
void processCFDerivedCorrected(aod::CFCollision const& collision, soa::Filtered<soa::Join<aod::CFTracks, aod::JWeights>> const& tracks)
251+
void processCFDerivedCorrected(soa::Filtered<aod::CFCollisions>::iterator const& collision, soa::Filtered<soa::Join<aod::CFTracks, aod::JWeights>> const& tracks)
168252
{
169253
analyze(collision, tracks);
170254
}
171255
PROCESS_SWITCH(flowJSPCAnalysis, processCFDerivedCorrected, "Process CF derived data with corrections", true);
256+
257+
void processCFDerivedMultSetCorrected(soa::Filtered<soa::Join<aod::CFCollisions, aod::CFMultSets>>::iterator const& collision, soa::Filtered<soa::Join<aod::CFTracks, aod::JWeights>> const& tracks)
258+
{
259+
if (std::popcount(static_cast<uint32_t>(cfgMultCorrelationsMask.value)) != static_cast<int>(collision.multiplicities().size()))
260+
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());
261+
if (!passOutlier(collision))
262+
return;
263+
analyze(collision, tracks);
264+
}
265+
PROCESS_SWITCH(flowJSPCAnalysis, processCFDerivedMultSetCorrected, "Process CF derived data with corrections and multiplicity sets", false);
172266
};
173267

174268
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)

0 commit comments

Comments
 (0)