@@ -1644,7 +1644,7 @@ struct StrangenessInJetsIons {
16441644
16451645 std::vector<fastjet::PseudoJet> cleanFjInput;
16461646 cleanFjInput.reserve (fjInput.size ());
1647- for (size_t i = 0 ; i < fjInput.size (); ++i) {
1647+ for (int i = 0 ; i < fjInput.size (); ++i) {
16481648 if (!isTrackReplaced[i])
16491649 cleanFjInput.push_back (fjInput[i]);
16501650 }
@@ -1698,29 +1698,29 @@ struct StrangenessInJetsIons {
16981698 if (motherId < 0 )
16991699 continue ; // if motherId is -1, it means no common mother was found
17001700 const auto & mother = mcParticles.iteratorAt (motherId);
1701- // const bool isPhysPrim = mother.isPhysicalPrimary();
1701+ const bool isPhysPrim = mother.isPhysicalPrimary ();
17021702 int pdgParent = mother.pdgCode ();
17031703
1704- // / NOTE: V0s are not required to be primary particles;
1704+ // / NOTE: V0s are required to be primary particles;
17051705 bool isK0S = false , isLambda = false , isAntiLambda = false ;
17061706 // K0s
1707- if (passedK0ShortSelection (v0, pos, neg, vtxPos) && pdgParent == kK0Short ) {
1707+ if (passedK0ShortSelection (v0, pos, neg, vtxPos) && pdgParent == kK0Short && isPhysPrim ) {
17081708 // LOG(info) << "[AddV0sForJetReconstructionMCD] Add K0S as input for jet finder.";
17091709 double energy = GetEnergy (v0.px (), v0.py (), v0.pz (), o2::constants::physics::MassK0Short);
17101710 fastjet::PseudoJet fourMomentum (v0.px (), v0.py (), v0.pz (), energy);
17111711 v0PseudoJets.emplace_back (fourMomentum);
17121712 isK0S = true ;
17131713 }
17141714 // Lambda
1715- if (passedLambdaSelection (v0, pos, neg, vtxPos) && pdgParent == kLambda0 ) {
1715+ if (passedLambdaSelection (v0, pos, neg, vtxPos) && pdgParent == kLambda0 && isPhysPrim ) {
17161716 // LOG(info) << "[AddV0sForJetReconstructionMCD] Add Lambda as input for jet finder.";
17171717 double energy = GetEnergy (v0.px (), v0.py (), v0.pz (), o2::constants::physics::MassLambda0);
17181718 fastjet::PseudoJet fourMomentum (v0.px (), v0.py (), v0.pz (), energy);
17191719 v0PseudoJets.emplace_back (fourMomentum);
17201720 isLambda = true ;
17211721 }
17221722 // AntiLambda
1723- if (passedAntiLambdaSelection (v0, pos, neg, vtxPos) && pdgParent == kLambda0Bar ) {
1723+ if (passedAntiLambdaSelection (v0, pos, neg, vtxPos) && pdgParent == kLambda0Bar && isPhysPrim ) {
17241724 // LOG(info) << "[AddV0sForJetReconstructionMCD] Add AntiLambda as input for jet finder.";
17251725 double energy = GetEnergy (v0.px (), v0.py (), v0.pz (), o2::constants::physics::MassLambda0Bar);
17261726 fastjet::PseudoJet fourMomentum (v0.px (), v0.py (), v0.pz (), energy);
@@ -1742,7 +1742,7 @@ struct StrangenessInJetsIons {
17421742
17431743 std::vector<fastjet::PseudoJet> cleanFjInput;
17441744 cleanFjInput.reserve (fjInput.size ());
1745- for (size_t i = 0 ; i < fjInput.size (); ++i) {
1745+ for (int i = 0 ; i < fjInput.size (); ++i) {
17461746 if (!isTrackReplaced[i])
17471747 cleanFjInput.push_back (fjInput[i]);
17481748 }
@@ -1754,6 +1754,68 @@ struct StrangenessInJetsIons {
17541754 // LOG(info) << "[AddV0sForJetReconstructionMCD] Size fjInput dopo move: " << fjInput.size();
17551755 }
17561756
1757+ /* *
1758+ * @brief Add V0s as input for the jet finder algorithm at Particle Level (MC Generated)
1759+ *
1760+ * @tparam McParticleType
1761+ * @tparam ParticleColl The container type holding the sliced MC particles.
1762+ *
1763+ * @param[in,out] fjInput Vector of FastJet PseudoJets where V0s will be appended.
1764+ * @param[in] fjParticleObj Vector containing the MC particles already selected for jet finder input.
1765+ * @param[in] mcParticlesPerColl MC particles belonging to this specific collision.
1766+ * @param[in] mcParticles Full McParticles.
1767+ */
1768+ template <typename McParticleType, typename ParticleColl>
1769+ void AddV0sForJetReconstructionMCP (std::vector<fastjet::PseudoJet>& fjInput,
1770+ const std::vector<McParticleType>& fjParticleObj,
1771+ ParticleColl const & mcParticlesPerColl,
1772+ aod::McParticles const & mcParticles)
1773+ {
1774+ std::vector<bool > isTrackReplaced (fjParticleObj.size (), false );
1775+ std::vector<fastjet::PseudoJet> v0PseudoJets;
1776+
1777+ // Add V0s to the input list for the jet finder and eventually remove their daughter particles
1778+ for (const auto & p : mcParticlesPerColl) {
1779+ int pdgAbs = std::abs (p.pdgCode ());
1780+ // / NOTE: p.isPhysicalPrimary() is required
1781+ if (p.isPhysicalPrimary () && (pdgAbs == kK0Short || pdgAbs == kLambda0 )) {
1782+ double mass = (pdgAbs == kK0Short ) ? o2::constants::physics::MassK0Short : o2::constants::physics::MassLambda0;
1783+ double energy = std::sqrt (p.p () * p.p () + mass * mass);
1784+
1785+ fastjet::PseudoJet pj (p.px (), p.py (), p.pz (), energy);
1786+ pj.set_user_index (p.pdgCode ());
1787+ v0PseudoJets.push_back (pj);
1788+ // LOG(info) << "[AddV0sForJetReconstructionMCP] Add V0 as input for jet finder.";
1789+
1790+ // Remove V0 daughter particles if already in the input list for the jet finder
1791+ for (int i = 0 ; i < fjParticleObj.size (); ++i) {
1792+ const auto & mcPart = fjParticleObj[i];
1793+ if (!mcPart.has_mothers ())
1794+ continue ;
1795+ auto mother = mcParticles.iteratorAt (mcPart.mothersIds ()[0 ]);
1796+ int motherPdg = std::abs (mother.pdgCode ());
1797+ if (motherPdg == kK0Short || motherPdg == kLambda0 ) {
1798+ isTrackReplaced[i] = true ;
1799+ // LOG(info) << "[AddV0sForJetReconstructionMCP] V0 daughter particle found in fjParticleObj.";
1800+ }
1801+ }
1802+ }
1803+ }
1804+
1805+ std::vector<fastjet::PseudoJet> cleanFjInput;
1806+ cleanFjInput.reserve (fjInput.size ());
1807+ for (int i = 0 ; i < fjInput.size (); ++i) {
1808+ if (!isTrackReplaced[i])
1809+ cleanFjInput.push_back (fjInput[i]);
1810+ }
1811+ for (const auto & v0pj : v0PseudoJets) {
1812+ cleanFjInput.push_back (v0pj);
1813+ }
1814+ // LOG(info) << "[AddV0sForJetReconstructionMCP] Size fjInput: " << fjInput.size();
1815+ fjInput = std::move (cleanFjInput);
1816+ // LOG(info) << "[AddV0sForJetReconstructionMCP] Size fjInput dopo move: " << fjInput.size();
1817+ }
1818+
17571819 // Process data
17581820 void processData (SelCollisions::iterator const & collision, aod::V0Datas const & fullV0s,
17591821 aod::CascDataExt const & Cascades, DaughterTracks const & tracks,
@@ -2158,6 +2220,7 @@ struct StrangenessInJetsIons {
21582220 auto mcParticlesPerColl = mcParticles.sliceBy (perMCCollision, collision.globalIndex ());
21592221
21602222 // Loop over all MC particles and select physical primaries within acceptance
2223+ std::vector<std::decay_t <decltype (*mcParticlesPerColl.begin ())>> fjParticleObj;
21612224 for (const auto & particle : mcParticlesPerColl) {
21622225 // Store properties of strange hadrons
21632226 int pdgAbs = std::abs (particle.pdgCode ());
@@ -2182,6 +2245,11 @@ struct StrangenessInJetsIons {
21822245 fastjet::PseudoJet fourMomentum (particle.px (), particle.py (), particle.pz (), energy);
21832246 fourMomentum.set_user_index (particle.pdgCode ());
21842247 fjParticles.emplace_back (fourMomentum);
2248+ fjParticleObj.push_back (particle);
2249+ }
2250+
2251+ if (useV0inJetRec && particleOfInterestDict[ParticleOfInterest::kV0Particles ]) {
2252+ AddV0sForJetReconstructionMCP (fjParticles, fjParticleObj, mcParticlesPerColl, mcParticles);
21852253 }
21862254
21872255 // Skip events with no particles
@@ -2650,14 +2718,14 @@ struct StrangenessInJetsIons {
26502718 continue ;
26512719
26522720 // --- alternative method to avoid double for loop
2653- int motherId = GetCommonMotherId (mcParticles, posParticle, negParticle);
2654- if (motherId < 0 )
2655- continue ; // if motherId is -1, it means no common mother was found
2656- const auto & motherTest = mcParticles.iteratorAt (motherId);
2657- // const bool isPhysPrimTest = motherTest.isPhysicalPrimary();
2658- int pdgParentTest = motherTest.pdgCode ();
2659- if (pdgParent != pdgParentTest)
2660- LOG (warning) << " pdgParent != pdgParentTest" << endl;
2721+ // int motherId = GetCommonMotherId(mcParticles, posParticle, negParticle);
2722+ // if (motherId < 0)
2723+ // continue; // if motherId is -1, it means no common mother was found
2724+ // const auto& motherTest = mcParticles.iteratorAt(motherId);
2725+ // // const bool isPhysPrimTest = motherTest.isPhysicalPrimary();
2726+ // int pdgParentTest = motherTest.pdgCode();
2727+ // if (pdgParent != pdgParentTest)
2728+ // LOG(warning) << "pdgParent != pdgParentTest" << endl;
26612729 // ---
26622730
26632731 // Compute distance from jet and UE axes
@@ -2854,9 +2922,6 @@ struct StrangenessInJetsIons {
28542922 // Fill event counter after selection on z-vertex
28552923 registryMC.fill (HIST (" number_of_events_mc_gen" ), 1.5 );
28562924
2857- // Multiplicity of generated event retrived from corresponding MC RECO collision
2858- // float genMultiplicity = multiplicity;
2859-
28602925 // Multiplicity of generated event
28612926 float genMultiplicity;
28622927 if (centrEstimator == 0 ) {
@@ -2870,6 +2935,7 @@ struct StrangenessInJetsIons {
28702935 auto mcParticlesPerColl = mcParticles.sliceBy (perMCCollision, collision.globalIndex ());
28712936
28722937 // Loop over all MC particles and select physical primaries within acceptance
2938+ std::vector<std::decay_t <decltype (*mcParticlesPerColl.begin ())>> fjParticleObj;
28732939 for (const auto & particle : mcParticlesPerColl) {
28742940 // Store properties of strange hadrons
28752941 int pdgAbs = std::abs (particle.pdgCode ());
@@ -2897,6 +2963,10 @@ struct StrangenessInJetsIons {
28972963 fjParticles.emplace_back (fourMomentum);
28982964 }
28992965
2966+ if (useV0inJetRec && particleOfInterestDict[ParticleOfInterest::kV0Particles ]) {
2967+ AddV0sForJetReconstructionMCP (fjParticles, fjParticleObj, mcParticlesPerColl, mcParticles);
2968+ }
2969+
29002970 // Skip events with no particles
29012971 if (fjParticles.size () < 1 )
29022972 continue ;
0 commit comments