@@ -339,6 +339,24 @@ struct HfTaskLc {
339339 return o2::hf_centrality::getCentralityColl<Coll>(collision);
340340 }
341341
342+ template <typename McDaughter, typename CandLcMcGen>
343+ float evaluateMcGenDecayTime (const McDaughter& mcParticleProng0, const CandLcMcGen& motherParticle)
344+ {
345+ const auto mcCollision = motherParticle.template mcCollision_as <aod::McCollisions>();
346+ const float pMother = motherParticle.p ();
347+ const float pvX = mcCollision.posX ();
348+ const float pvY = mcCollision.posY ();
349+ const float pvZ = mcCollision.posZ ();
350+ const float svX = mcParticleProng0.vx ();
351+ const float svY = mcParticleProng0.vy ();
352+ const float svZ = mcParticleProng0.vz ();
353+
354+ const float decayLength = static_cast <float >(RecoDecay::distance (std::array<float , 3 >{svX, svY, svZ}, std::array<float , 3 >{pvX, pvY, pvZ}));
355+ const float properDecayTime = decayLength * static_cast <float >(MassLambdaCPlus) / LightSpeedCm2PS / pMother;
356+
357+ return properDecayTime;
358+ }
359+
342360 // / Helper function for filling MC reconstructed histograms for prompt, nonpromt and common (signal)
343361 // / \param candidate is a reconstructed candidate
344362 // / \tparam SignalType is an enum defining which histogram in which folder (signal, prompt or nonpromt) to fill
@@ -425,17 +443,7 @@ struct HfTaskLc {
425443 const auto numPvContributors = collision.numContrib ();
426444 const auto ptRecB = candidate.ptBhadMotherPart ();
427445
428- const auto mcCollision = particleMother.template mcCollision_as <aod::McCollisions>();
429- const auto p = particleMother.p ();
430- const float pvX = mcCollision.posX ();
431- const float pvY = mcCollision.posY ();
432- const float pvZ = mcCollision.posZ ();
433- const float svX = mcParticleProng0.vx ();
434- const float svY = mcParticleProng0.vy ();
435- const float svZ = mcParticleProng0.vz ();
436-
437- const float decayLengthGen = static_cast <float >(RecoDecay::distance (std::array<float , 3 >{svX, svY, svZ}, std::array<float , 3 >{pvX, pvY, pvZ}));
438- const float properDecayTimeGen = decayLengthGen * static_cast <float >(MassLambdaCPlus) / LightSpeedCm2PS / p;
446+ const float properDecayTimeGen = evaluateMcGenDecayTime (mcParticleProng0, particleMother);
439447
440448 // / MC reconstructed signal
441449 fillHistogramsRecSig<Signal>(candidate);
@@ -541,17 +549,8 @@ struct HfTaskLc {
541549 }
542550
543551 const auto mcDaughter0 = particle.template daughters_as <soa::Join<aod::McParticles, aod::HfCand3ProngMcGen>>().begin ();
544- const auto mcCollision = particle.template mcCollision_as <aod::McCollisions>();
545- const auto p = particle.p ();
546- const float pvX = mcCollision.posX ();
547- const float pvY = mcCollision.posY ();
548- const float pvZ = mcCollision.posZ ();
549- const float svX = mcDaughter0.vx ();
550- const float svY = mcDaughter0.vy ();
551- const float svZ = mcDaughter0.vz ();
552-
553- const float decayLength = static_cast <float >(RecoDecay::distance (std::array<float , 3 >{svX, svY, svZ}, std::array<float , 3 >{pvX, pvY, pvZ}));
554- const float properDecayTime = decayLength * static_cast <float >(MassLambdaCPlus) / LightSpeedCm2PS / p;
552+
553+ const float properDecayTime = evaluateMcGenDecayTime (mcDaughter0, particle);
555554
556555 fillHistogramsGen<Signal>(particle);
557556
0 commit comments