@@ -375,6 +375,93 @@ struct HfCorrelatorFlowCharmHadronsReduced {
375375 }
376376 }
377377
378+ // / Correlations for Same Event pairs
379+ // / \param poolBin collision pool bin based on multiplicity and z-vertex position
380+ // / \param trigCandsThisColl are the selected trigger candidates in the collision
381+ // / \param assocTracksThisColl are the selected associated tracks in the collision
382+ template <bool FillSparses, typename TTrigCand, typename TTrackAssoc>
383+ void doCorrelationsSameEvent (int poolBin,
384+ const TTrigCand& trigCandsThisColl,
385+ const TTrackAssoc& assocTracksThisColl)
386+ {
387+ for (const auto & trigCand : trigCandsThisColl) {
388+ double const ptTrig = trigCand.ptTrig ();
389+ if constexpr (requires { trigCand.bdtScore0Trig (); }) { // ML selection on bkg score for Charm-Had case
390+ if (!isSelBdtScoreCut (trigCand, ptTrig)) {
391+ continue ;
392+ }
393+ }
394+
395+ for (const auto & assTrk : assocTracksThisColl) {
396+ // TODO: Remove Ds daughters
397+ /* if (assTrk.originTrackId() == candidate.prong0Id() ||
398+ assTrk.originTrackId() == candidate.prong1Id() ||
399+ assTrk.originTrackId() == candidate.prong2Id()) {
400+ continue;
401+ }*/
402+ // TODO: DCA cut
403+ double deltaPhi = RecoDecay::constrainAngle (assTrk.phiAssoc () - trigCand.phiTrig (), -o2::constants::math::PIHalf);
404+ double deltaEta = assTrk.etaAssoc () - trigCand.etaTrig ();
405+ if constexpr (FillSparses) {
406+ if constexpr (requires { trigCand.bdtScore0Trig (); }) { // Separate Charm-Had and Had-Had cases
407+ registry.fill (HIST (" hSparseCorrelationsSECharmHad" ), poolBin, ptTrig, assTrk.ptAssoc (), deltaEta,
408+ deltaPhi, trigCand.invMassTrig ());
409+ } else {
410+ registry.fill (HIST (" hSparseCorrelationsSEHadHad" ), poolBin, ptTrig, assTrk.ptAssoc (), deltaEta, deltaPhi);
411+ }
412+ }
413+ }
414+ }
415+ }
416+
417+ // / Correlations for Mixed Event pairs
418+ // / \param collisions are the selected collisions
419+ // / \param trigCands are the trigger candidates
420+ // / \param assocTracks are the associated tracks
421+ // / \param binPolicy is the binning policy for the correlation
422+ template <bool FillSparses, typename TCollision, typename TTrigCand, typename TTrackAssoc, typename TBinningType>
423+ void doCorrelationsMixedEvent (const TCollision& collisions,
424+ const TTrigCand& trigCands,
425+ const TTrackAssoc& assocTracks,
426+ TBinningType binPolicy)
427+ {
428+ auto tracksTuple = std::make_tuple (trigCands, assocTracks);
429+
430+ Pair<TCollision, TTrigCand, TTrackAssoc, TBinningType> pairData{binPolicy, numberEventsMixed, -1 , collisions, tracksTuple, &cache};
431+
432+ for (const auto & [c1, tracks1, c2, tracks2] : pairData) {
433+ if (tracks1.size () == 0 ) {
434+ continue ;
435+ }
436+
437+ int poolBin = binPolicy.getBin ({c2.posZ (), c2.multiplicity ()});
438+ int poolBinTrigCand = binPolicy.getBin ({c1.posZ (), c1.multiplicity ()});
439+
440+ if (poolBin != poolBinTrigCand) {
441+ LOGF (info, " Error, poolBins are different" );
442+ continue ;
443+ }
444+
445+ for (const auto & [trigCand, assTrk] : o2::soa::combinations (o2::soa::CombinationsFullIndexPolicy (tracks1, tracks2))) {
446+ if (!isSelBdtScoreCut (trigCand, trigCand.ptTrig ())) {
447+ continue ;
448+ }
449+ LOGF (info, " Mixed event tracks pair: (%d, %d) from events (%d, %d), track event: (%d, %d)" , trigCand.index (), assTrk.index (), c1.index (), c2.index (), trigCand.hfcRedCorrCollId (), assTrk.hfcRedCorrCollId ());
450+
451+ double deltaPhi = RecoDecay::constrainAngle (assTrk.phiAssoc () - trigCand.phiTrig (), -o2::constants::math::PIHalf);
452+ double deltaEta = assTrk.etaAssoc () - trigCand.etaTrig ();
453+ if constexpr (FillSparses) {
454+ if constexpr (requires { trigCand.bdtScore0Trig (); }) { // Separate Charm-Had and Had-Had cases
455+ registry.fill (HIST (" hSparseCorrelationsMECharmHad" ), poolBin, trigCand.ptTrig (), assTrk.ptAssoc (), deltaEta,
456+ deltaPhi, trigCand.invMassTrig ());
457+ } else {
458+ registry.fill (HIST (" hSparseCorrelationsMEHadHad" ), poolBin, trigCand.ptTrig (), assTrk.ptAssoc (), deltaEta, deltaPhi);
459+ }
460+ }
461+ }
462+ }
463+ }
464+
378465 void processSameEventCharmHadWMultMix (SameEvtPairsChHad::iterator const & pair,
379466 aod::HfcRedTrigCharms const &,
380467 aod::HfcRedCorrColls const &)
@@ -520,6 +607,37 @@ struct HfCorrelatorFlowCharmHadronsReduced {
520607 }
521608 }
522609 PROCESS_SWITCH (HfCorrelatorFlowCharmHadronsReduced, processCharmTriggers, " Process charm trigger info" , false );
610+
611+ void processSameEventCharmHadWCentMixBase (aod::HfcRedCorrColls const & collisions,
612+ TrigCharmCands const & candidates,
613+ AssocTracks const & tracks)
614+ {
615+ BinningCentPosZ binPolicyPosZCent{{zPoolBins, centPoolBins}, true };
616+
617+ for (const auto & collision : collisions) {
618+ if (collision.centrality () < centralityMin || collision.centrality () > centralityMax) {
619+ continue ;
620+ }
621+ int poolBin = binPolicyPosZCent.getBin ({collision.posZ (), collision.multiplicity ()});
622+
623+ auto thisCollId = collision.globalIndex ();
624+ auto candsThisColl = candidates.sliceBy (trigCharmCandsPerCol, thisCollId);
625+ auto tracksThisColl = tracks.sliceBy (assocTracksPerCol, thisCollId);
626+
627+ doCorrelationsSameEvent<true >(poolBin, candsThisColl, tracksThisColl);
628+ }
629+ }
630+ PROCESS_SWITCH (HfCorrelatorFlowCharmHadronsReduced, processSameEventCharmHadWCentMixBase, " Process Same Event base" , false );
631+
632+ void processMixedEventCharmHadWCentMixBase (aod::HfcRedCorrColls const & collisions,
633+ TrigCharmCands const & candidates,
634+ AssocTracks const & tracks)
635+ {
636+ BinningCentPosZ binPolicyPosZCent{{zPoolBins, centPoolBins}, true };
637+
638+ doCorrelationsMixedEvent<true >(collisions, candidates, tracks, binPolicyPosZCent);
639+ }
640+ PROCESS_SWITCH (HfCorrelatorFlowCharmHadronsReduced, processMixedEventCharmHadWCentMixBase, " Process Mixed Event base" , false );
523641};
524642
525643WorkflowSpec defineDataProcessing (ConfigContext const & cfgc)
0 commit comments