@@ -44,7 +44,20 @@ enum LambdaPid { kLambda = 0,
4444// #define FLOAT_PRECISION 0xFFFFFFF0
4545#define O2_DEFINE_CONFIGURABLE (NAME, TYPE, DEFAULT, HELP ) Configurable<TYPE> NAME{#NAME, DEFAULT, HELP};
4646
47+ namespace o2 ::aod
48+ {
49+ namespace cfmultiplicity
50+ {
51+ DECLARE_SOA_COLUMN (Multiplicity, multiplicity, float );
52+ }
53+ DECLARE_SOA_TABLE (CFMultiplicities, " AOD" , " CFMULTIPLICITY" , cfmultiplicity::Multiplicity);
54+
55+ using CFMultiplicity = CFMultiplicities::iterator;
56+ } // namespace o2::aod
57+
4758struct Filter2Prong {
59+ SliceCache cache;
60+
4861 O2_DEFINE_CONFIGURABLE (cfgVerbosity, int , 0 , " Verbosity level (0 = major, 1 = per collision)" )
4962 O2_DEFINE_CONFIGURABLE (cfgYMax, float , -1 .0f , " Maximum candidate rapidity" )
5063 O2_DEFINE_CONFIGURABLE (cfgImPart1Mass, float , o2::constants::physics::MassKPlus, " Daughter particle 1 mass in GeV" )
@@ -146,6 +159,10 @@ struct Filter2Prong {
146159 O2_DEFINE_CONFIGURABLE (applyTOF, bool , false , " Flag for applying TOF" );
147160 } grpPhi;
148161
162+ O2_DEFINE_CONFIGURABLE (cfgNoMixedEvents, int , 5 , " Number of mixed events per event for mixed phi building" )
163+ ConfigurableAxis axisVertexMix{" axisVertexMix" , {7 , -7 , 7 }, " vertex axis for phi event mixing" };
164+ ConfigurableAxis axisMultiplicityMix{" axisMultiplicityMix" , {VARIABLE_WIDTH, 0 , 5 , 10 , 20 , 30 , 40 , 50 , 100.1 }, " multiplicity axis for phi event mixing" };
165+
149166 HfHelper hfHelper;
150167 Produces<aod::CF2ProngTracks> output2ProngTracks;
151168 Produces<aod::CF2ProngTrackmls> output2ProngTrackmls;
@@ -772,6 +789,106 @@ struct Filter2Prong {
772789 }
773790 PROCESS_SWITCH (Filter2Prong, processDataPhiV0, " Process data Phi and V0 candidates with invariant mass method" , false );
774791
792+ using DerivedCollisions = soa::Join<aod::Collisions, aod::EvSels, aod::CFMultiplicities>;
793+ void processDataPhiMixed (DerivedCollisions const & collisions, Filter2Prong::PIDTrack const & tracksP, aod::CFTrackRefs const & cftracks)
794+ {
795+ auto getMultiplicity = [](auto const & col) {
796+ return col.multiplicity ();
797+ };
798+ using BinningTypeDerived = FlexibleBinningPolicy<std::tuple<decltype (getMultiplicity)>, aod::collision::PosZ, decltype (getMultiplicity)>;
799+ BinningTypeDerived configurableBinningDerived{{getMultiplicity}, {axisVertexMix, axisMultiplicityMix}, true };
800+ auto tracksTuple = std::make_tuple (cftracks, cftracks);
801+ using TA = std::tuple_element<0 , decltype (tracksTuple)>::type;
802+ using TB = std::tuple_element<std::tuple_size_v<decltype (tracksTuple)> - 1 , decltype (tracksTuple)>::type;
803+ Pair<DerivedCollisions, TA, TB, BinningTypeDerived> pairs{configurableBinningDerived, cfgNoMixedEvents, -1 , collisions, tracksTuple, &cache}; // -1 is the number of the bin to skip
804+
805+ o2::aod::ITSResponse itsResponse;
806+
807+ for (auto it = pairs.begin (); it != pairs.end (); it++) {
808+ auto & [collision1, tracks1, collision2, tracks2] = *it;
809+ // float multiplicity = getMultiplicity(collision1);
810+ // int bin = configurableBinningDerived.getBin(std::tuple(collision1.posZ(), multiplicity));
811+ // float eventWeight = 1.0f / it.currentWindowNeighbours();
812+ if (!(collision1.sel8 () &&
813+ collision1.selection_bit (aod::evsel::kNoSameBunchPileup ) &&
814+ collision1.selection_bit (aod::evsel::kIsGoodZvtxFT0vsPV ) &&
815+ collision1.selection_bit (aod::evsel::kIsGoodITSLayersAll ))) {
816+ continue ;
817+ }
818+
819+ if (!(collision2.sel8 () &&
820+ collision2.selection_bit (aod::evsel::kNoSameBunchPileup ) &&
821+ collision2.selection_bit (aod::evsel::kIsGoodZvtxFT0vsPV ) &&
822+ collision2.selection_bit (aod::evsel::kIsGoodITSLayersAll ))) {
823+ continue ;
824+ }
825+
826+ for (const auto & cftrack1 : tracks1) {
827+ const auto & p1 = tracksP.iteratorAt (cftrack1.trackId () - tracksP.begin ().globalIndex ());
828+
829+ if (p1.sign () != 1 ) {
830+ continue ;
831+ }
832+ if (!selectionTrack (p1)) {
833+ continue ;
834+ }
835+ if (grpPhi.ITSPIDSelection &&
836+ p1.p () < grpPhi.ITSPIDPthreshold .value &&
837+ !(itsResponse.nSigmaITS <o2::track::PID::Kaon>(p1) > grpPhi.lowITSPIDNsigma .value &&
838+ itsResponse.nSigmaITS <o2::track::PID::Kaon>(p1) < grpPhi.highITSPIDNsigma .value )) {
839+ continue ;
840+ }
841+ if (grpPhi.removefaketrack && isFakeTrack (p1)) {
842+ continue ;
843+ }
844+
845+ for (const auto & cftrack2 : tracks2) {
846+ const auto & p2 = tracksP.iteratorAt (cftrack2.trackId () - tracksP.begin ().globalIndex ());
847+
848+ if (p2.sign () != -1 ) {
849+ continue ;
850+ }
851+ if (!selectionTrack (p2)) {
852+ continue ;
853+ }
854+ if (grpPhi.ITSPIDSelection &&
855+ p2.p () < grpPhi.ITSPIDPthreshold .value &&
856+ !(itsResponse.nSigmaITS <o2::track::PID::Kaon>(p2) > grpPhi.lowITSPIDNsigma .value &&
857+ itsResponse.nSigmaITS <o2::track::PID::Kaon>(p2) < grpPhi.highITSPIDNsigma .value )) {
858+ continue ;
859+ }
860+ if (grpPhi.removefaketrack && isFakeTrack (p2)) {
861+ continue ;
862+ }
863+ if (!selectionPair (p1, p2)) {
864+ continue ;
865+ }
866+
867+ ROOT::Math::PtEtaPhiMVector vec1 (p1.pt (), p1.eta (), p1.phi (), cfgImPart1Mass);
868+ ROOT::Math::PtEtaPhiMVector vec2 (p2.pt (), p2.eta (), p2.phi (), cfgImPart2Mass);
869+ ROOT::Math::PtEtaPhiMVector s = vec1 + vec2;
870+
871+ if (s.M () < grpPhi.ImMinInvMassPhiMeson || s.M () > grpPhi.ImMaxInvMassPhiMeson ) {
872+ continue ;
873+ }
874+
875+ float phi = RecoDecay::constrainAngle (s.Phi (), 0 .0f );
876+
877+ if (selectionPID3 (p1) && selectionPID3 (p2)) {
878+ if (selectionSys (p1, false , false ) && selectionSys (p2, false , false )) {
879+ output2ProngTracks (collision1.globalIndex (),
880+ cftrack1.globalIndex (), cftrack2.globalIndex (),
881+ s.pt (), s.eta (), phi, s.M (),
882+ aod::cf2prongtrack::PhiToKKPID3Mixed);
883+ }
884+ }
885+ }
886+ }
887+ }
888+ }
889+
890+ PROCESS_SWITCH (Filter2Prong, processDataPhiMixed, " Process mixed-event phi candidates using O2 framework" , false );
891+
775892 // Phi and V0s invariant mass method candidate finder. Only works for non-identical daughters of opposite charge for now.
776893 void processDataV0 (aod::Collisions::iterator const & collision, aod::BCsWithTimestamps const &, aod::CFCollRefs const & cfcollisions, aod::CFTrackRefs const & cftracks, Filter2Prong::PIDTrack const &, aod::V0Datas const & V0s)
777894 {
0 commit comments