Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 59 additions & 6 deletions PWGCF/TableProducer/filter2Prong.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
#include <iterator>
#include <memory>
#include <string>
#include <unordered_map>
#include <vector>

using namespace o2;
Expand All @@ -71,6 +72,7 @@
struct Filter2Prong {
SliceCache cache;
Preslice<aod::CFTrackRefs> perCollisionCFTrackRefs = aod::track::collisionId;
Preslice<aod::CFCollRefs> perCollisionCFCollRefs = aod::track::collisionId;

O2_DEFINE_CONFIGURABLE(cfgVerbosity, int, 0, "Verbosity level (0 = major, 1 = per collision)")
O2_DEFINE_CONFIGURABLE(cfgYMax, float, -1.0f, "Maximum candidate rapidity")
Expand Down Expand Up @@ -256,10 +258,10 @@
prongCFId[0], prongCFId[1], c.pt(), c.eta(), c.phi(), hfHelper.invMassD0ToPiK(c), aod::cf2prongtrack::D0ToPiK);
if constexpr (std::experimental::is_detected<HasMLProb, typename HFCandidatesType::iterator>::value) {
mlvecd.clear();
for (const float val : c.mlProbD0())

Check failure on line 261 in PWGCF/TableProducer/filter2Prong.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[const-ref-in-for-loop]

Use constant references for non-modified iterators in range-based for loops.
mlvecd.push_back(val);
mlvecdbar.clear();
for (const float val : c.mlProbD0bar())

Check failure on line 264 in PWGCF/TableProducer/filter2Prong.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[const-ref-in-for-loop]

Use constant references for non-modified iterators in range-based for loops.
mlvecdbar.push_back(val);
output2ProngTrackmls(cfcollisions.begin().globalIndex(), mlvecd, mlvecdbar);
}
Expand All @@ -271,10 +273,10 @@
c.isSelD0() > 0 ? aod::cf2prongtrack::D0barToKPi : aod::cf2prongtrack::D0barToKPiExclusive);
if constexpr (std::experimental::is_detected<HasMLProb, typename HFCandidatesType::iterator>::value) {
mlvecd.clear();
for (const float val : c.mlProbD0())

Check failure on line 276 in PWGCF/TableProducer/filter2Prong.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[const-ref-in-for-loop]

Use constant references for non-modified iterators in range-based for loops.
mlvecd.push_back(val);
mlvecdbar.clear();
for (const float val : c.mlProbD0bar())

Check failure on line 279 in PWGCF/TableProducer/filter2Prong.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[const-ref-in-for-loop]

Use constant references for non-modified iterators in range-based for loops.
mlvecdbar.push_back(val);
output2ProngTrackmls(cfcollisions.begin().globalIndex(), mlvecd, mlvecdbar);
}
Expand Down Expand Up @@ -306,12 +308,12 @@
// The main filter outputs the primary MC particles. Here we just resolve the daughter indices that are needed for the efficiency matching.
for (const auto& r : cfmcparticles) {
const auto& mcParticle = r.mcParticle_as<HFMCTrack>();
if ((std::abs(mcParticle.flagMcMatchGen()) != o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) || mcParticle.daughtersIds().size() != 2) {

Check failure on line 311 in PWGCF/TableProducer/filter2Prong.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
output2ProngMcParts(-1, -1, aod::cf2prongtrack::Generic2Prong);
continue;
}
int prongCFId[2] = {-1, -1};
for (uint i = 0; i < 2; ++i) {

Check failure on line 316 in PWGCF/TableProducer/filter2Prong.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
for (const auto& cfmcpart : cfmcparticles) {
if (mcParticle.daughtersIds()[i] == cfmcpart.mcParticleId()) {
prongCFId[i] = cfmcpart.globalIndex();
Expand All @@ -332,12 +334,12 @@
// The main filter outputs the primary MC particles. Here we just resolve the daughter indices that are needed for the efficiency matching.
for (const auto& r : cfmcparticles) {
const auto& mcParticle = r.mcParticle();
if (mcParticle.daughtersIds().size() != 2) {

Check failure on line 337 in PWGCF/TableProducer/filter2Prong.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
output2ProngMcParts(-1, -1, aod::cf2prongtrack::Generic2Prong); // not a 2-prong
continue;
}
int prongCFId[2] = {-1, -1};
for (uint i = 0; i < 2; ++i) {

Check failure on line 342 in PWGCF/TableProducer/filter2Prong.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
for (const auto& cfmcpart : cfmcparticles) {
if (mcParticle.daughtersIds()[i] == cfmcpart.mcParticleId()) {
prongCFId[i] = cfmcpart.globalIndex();
Expand Down Expand Up @@ -488,7 +490,7 @@
if (posTrack.tpcNClsCrossedRows() < grpV0.tpcNClsCrossedRowsTrackMin || negTrack.tpcNClsCrossedRows() < grpV0.tpcNClsCrossedRowsTrackMin) {
return false;
}
if (posTrack.tpcCrossedRowsOverFindableCls() < 0.8 || negTrack.tpcCrossedRowsOverFindableCls() < 0.8) {

Check failure on line 493 in PWGCF/TableProducer/filter2Prong.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
return false;
}
if (std::abs(v0.positiveeta()) > grpV0.etaTrackMax || std::abs(v0.negativeeta()) > grpV0.etaTrackMax) {
Expand All @@ -504,7 +506,7 @@
bool selectionPID(const T& candidate)
{
if (cfgMomDepPID) {
if (candidate.p() < 0.5) {

Check failure on line 509 in PWGCF/TableProducer/filter2Prong.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
if (!candidate.hasTOF() && TMath::Abs(candidate.tpcNSigmaKa()) < grpPhi.nsigmaCutTPC) {
return true;
} else if (candidate.hasTOF() && TMath::Sqrt(candidate.tpcNSigmaKa() * candidate.tpcNSigmaKa() + candidate.tofNSigmaKa() * candidate.tofNSigmaKa()) < grpPhi.nsigmaCutTOF && candidate.beta() > grpPhi.cutTOFBeta) {
Expand Down Expand Up @@ -806,8 +808,23 @@
PROCESS_SWITCH(Filter2Prong, processDataPhiV0, "Process data Phi and V0 candidates with invariant mass method", false);

using DerivedCollisions = soa::Join<aod::Collisions, aod::EvSels, aod::CFMultiplicities>;
void processDataPhiMixed(DerivedCollisions const& collisions, Filter2Prong::PIDTrack const& /*tracksP*/, aod::CFTrackRefs const& cftracks)
void processDataPhiMixed(DerivedCollisions const& collisions, Filter2Prong::PIDTrack const& /*tracksP*/, aod::CFCollRefs const& cfcollrefs, aod::CFTrackRefs const& cftracks)
{
struct MixedPhiCandidate {
int64_t cfCollisionId;
int64_t cfTrackProng0Id;
int64_t cfTrackProng1Id;
float pt;
float eta;
float phi;
float invMass;
uint8_t decay;
};

if (cfcollrefs.size() <= 0 || cftracks.size() <= 0) {
return;
}

auto getMultiplicity = [](auto const& col) {
return col.multiplicity();
};
Expand All @@ -819,11 +836,23 @@
using TB = std::tuple_element<std::tuple_size_v<decltype(tracksTuple)> - 1, decltype(tracksTuple)>::type;
Pair<DerivedCollisions, TA, TB, BinningTypeDerived> pairs{configurableBinningDerived, cfgNoMixedEvents, -1, collisions, tracksTuple, &cache}; // -1 is the number of the bin to skip

std::unordered_map<int64_t, int64_t> collToCF;
collToCF.reserve(cfcollrefs.size());
for (const auto& cfcollref : cfcollrefs) {
collToCF.emplace(cfcollref.collisionId(), cfcollref.globalIndex());
}

std::vector<MixedPhiCandidate> mixedPhiCandidates;
o2::aod::ITSResponse itsResponse;

for (auto it = pairs.begin(); it != pairs.end(); it++) {
auto& [collision1, tracks1, collision2, tracks2] = *it;

auto cfColl1 = collToCF.find(collision1.globalIndex());
if (cfColl1 == collToCF.end() || collToCF.find(collision2.globalIndex()) == collToCF.end()) {
continue;
}

if (!(collision1.sel8() &&
collision1.selection_bit(aod::evsel::kNoSameBunchPileup) &&
collision1.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV) &&
Expand Down Expand Up @@ -890,16 +919,40 @@
}

float phi = RecoDecay::constrainAngle(s.Phi(), 0.0f);

output2ProngTracks(collision1.globalIndex(),
cftrack1.globalIndex(), cftrack2.globalIndex(),
s.pt(), s.eta(), phi, s.M(),
aod::cf2prongtrack::PhiToKKPID3Mixed);
mixedPhiCandidates.push_back({cfColl1->second,
cftrack1.globalIndex(),
cftrack2.globalIndex(),
static_cast<float>(s.pt()),
static_cast<float>(s.eta()),
phi,
static_cast<float>(s.M()),
aod::cf2prongtrack::PhiToKKPID3Mixed});
}
}
}
}
}

std::sort(mixedPhiCandidates.begin(), mixedPhiCandidates.end(), [](const auto& lhs, const auto& rhs) {
if (lhs.cfCollisionId != rhs.cfCollisionId) {
return lhs.cfCollisionId < rhs.cfCollisionId;
}
if (lhs.cfTrackProng0Id != rhs.cfTrackProng0Id) {
return lhs.cfTrackProng0Id < rhs.cfTrackProng0Id;
}
return lhs.cfTrackProng1Id < rhs.cfTrackProng1Id;
});

for (const auto& candidate : mixedPhiCandidates) {
output2ProngTracks(candidate.cfCollisionId,
candidate.cfTrackProng0Id,
candidate.cfTrackProng1Id,
candidate.pt,
candidate.eta,
candidate.phi,
candidate.invMass,
candidate.decay);
}
}

PROCESS_SWITCH(Filter2Prong, processDataPhiMixed, "Process mixed-event phi candidates using O2 framework", false);
Expand Down
Loading