From 7ec91265a3d78d5b111cec782c237a4dc1153fc2 Mon Sep 17 00:00:00 2001 From: ALICE Action Bot Date: Tue, 23 Sep 2025 11:59:28 +0200 Subject: [PATCH 1/2] Add deta constrain in CPR with fractions of separation --- .../Core/FemtoUniverseDetaDphiStar.h | 861 +++++++++--------- 1 file changed, 438 insertions(+), 423 deletions(-) diff --git a/PWGCF/FemtoUniverse/Core/FemtoUniverseDetaDphiStar.h b/PWGCF/FemtoUniverse/Core/FemtoUniverseDetaDphiStar.h index ac5f1c9aad5..2856c0de95f 100644 --- a/PWGCF/FemtoUniverse/Core/FemtoUniverseDetaDphiStar.h +++ b/PWGCF/FemtoUniverse/Core/FemtoUniverseDetaDphiStar.h @@ -315,519 +315,534 @@ class FemtoUniverseDetaDphiStar continue; auto deta = daughterpart1.eta() - daughterpart2.eta(); auto dphiAvg = averagePhiStar(*daughterpart1, *daughterpart2, i); - if (ChosenEventType == femto_universe_container::EventType::same) { - histdetadpisame[i][0]->Fill(deta, dphiAvg); - } else if (ChosenEventType == femto_universe_container::EventType::mixed) { - histdetadpimixed[i][0]->Fill(deta, dphiAvg); - } else { - LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed."; + if (ChosenEventType if (distfrac > FracMax) { + == femto_universe_container::EventType::same) + { + histdetadpisame[i][0]->Fill(deta, dphiAvg); + } + else if (ChosenEventType == femto_universe_container::EventType::mixed) + { + histdetadpimixed[i][0]->Fill(deta, dphiAvg); + } + else + { + LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed."; + } + + if ((dphiAvg > cutDeltaPhiStarMin) && (dphiAvg < cutDeltaPhiStarMax) && (deta > cutDeltaEtaMin) && (deta < cutDeltaEtaMax)) { + pass = true; + } else { + if (ChosenEventType == femto_universe_container::EventType::same) { + histdetadpisame[i][1]->Fill(deta, dphiAvg); + } else if (ChosenEventType == femto_universe_container::EventType::mixed) { + histdetadpimixed[i][1]->Fill(deta, dphiAvg); + } else { + LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed."; + } + } + } + return pass; + } + else if constexpr (kPartOneType == o2::aod::femtouniverseparticle::ParticleType::kTrack && kPartTwoType == o2::aod::femtouniverseparticle::ParticleType::kCascade) + { + /// Track-Cascade combination + if (part1.partType() != o2::aod::femtouniverseparticle::ParticleType::kTrack || part2.partType() != o2::aod::femtouniverseparticle::ParticleType::kCascade) { + LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar instantiation! Please provide kTrack,kCascade candidates."; + return false; } - if ((dphiAvg > cutDeltaPhiStarMin) && (dphiAvg < cutDeltaPhiStarMax) && (deta > cutDeltaEtaMin) && (deta < cutDeltaEtaMax)) { - pass = true; - } else { + bool pass = false; + for (int i = 0; i < 3; i++) { + auto indexOfDaughter = (ChosenEventType == femto_universe_container::EventType::mixed ? part2.globalIndex() : part2.index()) - 3 + i; + auto daughter = particles.begin() + indexOfDaughter; + if (isSameSignCPR && (part1.mAntiLambda() != daughter.mAntiLambda())) // mAntiLambda() is used here as sign getter + continue; + auto deta = part1.eta() - daughter.eta(); + auto dphiAvg = averagePhiStar(*part1, *daughter, i); if (ChosenEventType == femto_universe_container::EventType::same) { - histdetadpisame[i][1]->Fill(deta, dphiAvg); + histdetadpisame[i][0]->Fill(deta, dphiAvg); } else if (ChosenEventType == femto_universe_container::EventType::mixed) { - histdetadpimixed[i][1]->Fill(deta, dphiAvg); + histdetadpimixed[i][0]->Fill(deta, dphiAvg); } else { LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed."; } - } - } - return pass; - } else if constexpr (kPartOneType == o2::aod::femtouniverseparticle::ParticleType::kTrack && kPartTwoType == o2::aod::femtouniverseparticle::ParticleType::kCascade) { - /// Track-Cascade combination - if (part1.partType() != o2::aod::femtouniverseparticle::ParticleType::kTrack || part2.partType() != o2::aod::femtouniverseparticle::ParticleType::kCascade) { - LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar instantiation! Please provide kTrack,kCascade candidates."; - return false; + if ((dphiAvg > cutDeltaPhiStarMin) && (dphiAvg < cutDeltaPhiStarMax) && (deta > cutDeltaEtaMin) && (deta < cutDeltaEtaMax)) { + pass = true; + } else { + if (ChosenEventType == femto_universe_container::EventType::same) { + histdetadpisame[i][1]->Fill(deta, dphiAvg); + } else if (ChosenEventType == femto_universe_container::EventType::mixed) { + histdetadpimixed[i][1]->Fill(deta, dphiAvg); + } else { + LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed."; + } + } + } + return pass; } - - bool pass = false; - for (int i = 0; i < 3; i++) { - auto indexOfDaughter = (ChosenEventType == femto_universe_container::EventType::mixed ? part2.globalIndex() : part2.index()) - 3 + i; - auto daughter = particles.begin() + indexOfDaughter; - if (isSameSignCPR && (part1.mAntiLambda() != daughter.mAntiLambda())) // mAntiLambda() is used here as sign getter - continue; - auto deta = part1.eta() - daughter.eta(); - auto dphiAvg = averagePhiStar(*part1, *daughter, i); - if (ChosenEventType == femto_universe_container::EventType::same) { - histdetadpisame[i][0]->Fill(deta, dphiAvg); - } else if (ChosenEventType == femto_universe_container::EventType::mixed) { - histdetadpimixed[i][0]->Fill(deta, dphiAvg); - } else { - LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed."; + else if constexpr (kPartOneType == o2::aod::femtouniverseparticle::ParticleType::kV0 && kPartTwoType == o2::aod::femtouniverseparticle::ParticleType::kCascade) + { + /// V0-Cascade combination + if (part1.partType() != o2::aod::femtouniverseparticle::ParticleType::kV0 || part2.partType() != o2::aod::femtouniverseparticle::ParticleType::kCascade) { + LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar instantiation! Please provide kV0,kCascade candidates."; + return false; } - if ((dphiAvg > cutDeltaPhiStarMin) && (dphiAvg < cutDeltaPhiStarMax) && (deta > cutDeltaEtaMin) && (deta < cutDeltaEtaMax)) { - pass = true; - } else { + bool pass = false; + static constexpr int V0CascChildTable[][2] = {{-1, -1}, {-1, -2}, {-1, -3}, {-2, -1}, {-2, -2}, {-2, -3}}; + for (int i = 0; i < 3; i++) { + auto indexOfDaughterV0 = (ChosenEventType == femto_universe_container::EventType::mixed ? part1.globalIndex() : part1.index()) + V0CascChildTable[i][0]; + auto indexOfDaughterCasc = (ChosenEventType == femto_universe_container::EventType::mixed ? part2.globalIndex() : part2.index()) + V0CascChildTable[i][1]; + auto daughterV0 = particles.begin() + indexOfDaughterV0; + auto daughterCasc = particles.begin() + indexOfDaughterCasc; + if (isSameSignCPR && (daughterV0.mAntiLambda() != daughterCasc.mAntiLambda())) // mAntiLambda() is used here as sign getter + continue; + auto deta = daughterV0.eta() - daughterCasc.eta(); + auto dphiAvg = averagePhiStar(*daughterV0, *daughterCasc, i); if (ChosenEventType == femto_universe_container::EventType::same) { - histdetadpisame[i][1]->Fill(deta, dphiAvg); + histdetadpisame[i][0]->Fill(deta, dphiAvg); } else if (ChosenEventType == femto_universe_container::EventType::mixed) { - histdetadpimixed[i][1]->Fill(deta, dphiAvg); + histdetadpimixed[i][0]->Fill(deta, dphiAvg); } else { LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed."; } + + if ((dphiAvg > cutDeltaPhiStarMin) && (dphiAvg < cutDeltaPhiStarMax) && (deta > cutDeltaEtaMin) && (deta < cutDeltaEtaMax)) { + pass = true; + } else { + if (ChosenEventType == femto_universe_container::EventType::same) { + histdetadpisame[i][1]->Fill(deta, dphiAvg); + } else if (ChosenEventType == femto_universe_container::EventType::mixed) { + histdetadpimixed[i][1]->Fill(deta, dphiAvg); + } else { + LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed."; + } + } + } + return pass; + } + else if constexpr (kPartOneType == o2::aod::femtouniverseparticle::ParticleType::kTrack && kPartTwoType == o2::aod::femtouniverseparticle::ParticleType::kD0) + { + /// Track-D0 combination + // check if provided particles are in agreement with the class instantiation + if (part1.partType() != o2::aod::femtouniverseparticle::ParticleType::kTrack || part2.partType() != o2::aod::femtouniverseparticle::ParticleType::kD0) { + LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar instantiation! Please provide kTrack, kD0 candidates."; + return false; } - } - return pass; - } else if constexpr (kPartOneType == o2::aod::femtouniverseparticle::ParticleType::kV0 && kPartTwoType == o2::aod::femtouniverseparticle::ParticleType::kCascade) { - /// V0-Cascade combination - if (part1.partType() != o2::aod::femtouniverseparticle::ParticleType::kV0 || part2.partType() != o2::aod::femtouniverseparticle::ParticleType::kCascade) { - LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar instantiation! Please provide kV0,kCascade candidates."; - return false; - } + bool pass = false; + for (int i = 0; i < 2; i++) { + auto indexOfDaughter = 0; + if (ChosenEventType == femto_universe_container::EventType::mixed) { + indexOfDaughter = part2.globalIndex() - 2 + i; + } else if (ChosenEventType == femto_universe_container::EventType::same) { + indexOfDaughter = part2.index() - 2 + i; + } - bool pass = false; - static constexpr int V0CascChildTable[][2] = {{-1, -1}, {-1, -2}, {-1, -3}, {-2, -1}, {-2, -2}, {-2, -3}}; - for (int i = 0; i < 3; i++) { - auto indexOfDaughterV0 = (ChosenEventType == femto_universe_container::EventType::mixed ? part1.globalIndex() : part1.index()) + V0CascChildTable[i][0]; - auto indexOfDaughterCasc = (ChosenEventType == femto_universe_container::EventType::mixed ? part2.globalIndex() : part2.index()) + V0CascChildTable[i][1]; - auto daughterV0 = particles.begin() + indexOfDaughterV0; - auto daughterCasc = particles.begin() + indexOfDaughterCasc; - if (isSameSignCPR && (daughterV0.mAntiLambda() != daughterCasc.mAntiLambda())) // mAntiLambda() is used here as sign getter - continue; - auto deta = daughterV0.eta() - daughterCasc.eta(); - auto dphiAvg = averagePhiStar(*daughterV0, *daughterCasc, i); - if (ChosenEventType == femto_universe_container::EventType::same) { - histdetadpisame[i][0]->Fill(deta, dphiAvg); - } else if (ChosenEventType == femto_universe_container::EventType::mixed) { - histdetadpimixed[i][0]->Fill(deta, dphiAvg); - } else { - LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed."; + auto daughter = particles.begin() + indexOfDaughter; + auto deta = part1.eta() - daughter.eta(); + auto dphiAvg = averagePhiStar(part1, *daughter, i); // auto dphiAvg = calculateDphiStar(part1, *daughter); + dphiAvg = TVector2::Phi_mpi_pi(dphiAvg); + if (ChosenEventType == femto_universe_container::EventType::same) { + histdetadpisame[i][0]->Fill(deta, dphiAvg); + } else if (ChosenEventType == femto_universe_container::EventType::mixed) { + histdetadpimixed[i][0]->Fill(deta, dphiAvg); + } else { + LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed."; + } + + if ((dphiAvg > cutDeltaPhiStarMin) && (dphiAvg < cutDeltaPhiStarMax) && (deta > cutDeltaEtaMin) && (deta < cutDeltaEtaMax)) { + pass = true; // pair is close + } else { + if (ChosenEventType == femto_universe_container::EventType::same) { + histdetadpisame[i][1]->Fill(deta, dphiAvg); + } else if (ChosenEventType == femto_universe_container::EventType::mixed) { + histdetadpimixed[i][1]->Fill(deta, dphiAvg); + } else { + LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed."; + } + } + } + return pass; + } + else if constexpr (kPartOneType == o2::aod::femtouniverseparticle::ParticleType::kTrack && kPartTwoType == o2::aod::femtouniverseparticle::ParticleType::kPhi) + { + /// Track-Phi combination + // check if provided particles are in agreement with the class instantiation + if (part1.partType() != o2::aod::femtouniverseparticle::ParticleType::kTrack || part2.partType() != o2::aod::femtouniverseparticle::ParticleType::kPhi) { + LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar instantiation! Please provide kTrack,kPhi candidates."; + return false; } - if ((dphiAvg > cutDeltaPhiStarMin) && (dphiAvg < cutDeltaPhiStarMax) && (deta > cutDeltaEtaMin) && (deta < cutDeltaEtaMax)) { - pass = true; - } else { + bool pass = false; + for (int i = 0; i < 2; i++) { + auto indexOfDaughter = 0; + if (ChosenEventType == femto_universe_container::EventType::mixed) { + indexOfDaughter = part2.globalIndex() - 2 + i; + } else if (ChosenEventType == femto_universe_container::EventType::same) { + indexOfDaughter = part2.index() - 2 + i; + } + + auto daughter = particles.begin() + indexOfDaughter; + auto deta = part1.eta() - daughter.eta(); + auto dphiAvg = averagePhiStar(part1, *daughter, i); // calculateDphiStar(part1, *daughter); + dphiAvg = TVector2::Phi_mpi_pi(dphiAvg); if (ChosenEventType == femto_universe_container::EventType::same) { - histdetadpisame[i][1]->Fill(deta, dphiAvg); + histdetadpisame[i][0]->Fill(deta, dphiAvg); } else if (ChosenEventType == femto_universe_container::EventType::mixed) { - histdetadpimixed[i][1]->Fill(deta, dphiAvg); + histdetadpimixed[i][0]->Fill(deta, dphiAvg); } else { LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed."; } + + // REMOVING THE "RING" -- CALCULATING THE INVARIANT MASS + TLorentzVector part1Vec; + TLorentzVector part2Vec; + float mMassOne = o2::constants::physics::MassKPlus; + float mMassTwo = o2::constants::physics::MassKMinus; + part1Vec.SetPtEtaPhiM(part1.pt(), part1.eta(), part1.phi(), mMassOne); + part2Vec.SetPtEtaPhiM(daughter.pt(), daughter.eta(), daughter.phi(), mMassTwo); + TLorentzVector sumVec(part1Vec); + sumVec += part2Vec; + float phiM = sumVec.M(); + if ((phiM > cutPhiInvMassLow) && (phiM < cutPhiInvMassHigh)) { + pass = true; // pair comes from Phi meson decay + } + + // APPLYING THE CUTS + if ((dphiAvg > cutDeltaPhiStarMin) && (dphiAvg < cutDeltaPhiStarMax) && (deta > cutDeltaEtaMin) && (deta < cutDeltaEtaMax)) { + pass = true; // pair is close + } else { + if (ChosenEventType == femto_universe_container::EventType::same) { + histdetadpisame[i][1]->Fill(deta, dphiAvg); + } else if (ChosenEventType == femto_universe_container::EventType::mixed) { + histdetadpimixed[i][1]->Fill(deta, dphiAvg); + } else { + LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed."; + } + } } + return pass; } - return pass; - - } else if constexpr (kPartOneType == o2::aod::femtouniverseparticle::ParticleType::kTrack && kPartTwoType == o2::aod::femtouniverseparticle::ParticleType::kD0) { - /// Track-D0 combination - // check if provided particles are in agreement with the class instantiation - if (part1.partType() != o2::aod::femtouniverseparticle::ParticleType::kTrack || part2.partType() != o2::aod::femtouniverseparticle::ParticleType::kD0) { - LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar instantiation! Please provide kTrack, kD0 candidates."; + else + { + LOG(fatal) << "FemtoUniversePairCleaner: Combination of objects not defined - quitting!"; return false; } + } - bool pass = false; - for (int i = 0; i < 2; i++) { - auto indexOfDaughter = 0; - if (ChosenEventType == femto_universe_container::EventType::mixed) { - indexOfDaughter = part2.globalIndex() - 2 + i; - } else if (ChosenEventType == femto_universe_container::EventType::same) { - indexOfDaughter = part2.index() - 2 + i; + /// Check if pair is close or not + template + bool isClosePairAtITS(Part const& part1, Part const& part2, float lmagfield, uint8_t ChosenEventType) + { + magfield = lmagfield; + + if constexpr (kPartOneType == o2::aod::femtouniverseparticle::ParticleType::kTrack && kPartTwoType == o2::aod::femtouniverseparticle::ParticleType::kTrack) { + /// Track-Track combination + // check if provided particles are in agreement with the class instantiation + if (part1.partType() != o2::aod::femtouniverseparticle::ParticleType::kTrack || part2.partType() != o2::aod::femtouniverseparticle::ParticleType::kTrack) { + LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar instantiation! Please provide kTrack,kTrack candidates."; + return false; } - - auto daughter = particles.begin() + indexOfDaughter; - auto deta = part1.eta() - daughter.eta(); - auto dphiAvg = averagePhiStar(part1, *daughter, i); // auto dphiAvg = calculateDphiStar(part1, *daughter); - dphiAvg = TVector2::Phi_mpi_pi(dphiAvg); + auto deta = part1.eta() - part2.eta(); + auto dphiAvg = part1.phi() - part2.phi(); if (ChosenEventType == femto_universe_container::EventType::same) { - histdetadpisame[i][0]->Fill(deta, dphiAvg); + histdetadpisame[0][0]->Fill(deta, dphiAvg); } else if (ChosenEventType == femto_universe_container::EventType::mixed) { - histdetadpimixed[i][0]->Fill(deta, dphiAvg); + histdetadpimixed[0][0]->Fill(deta, dphiAvg); } else { LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed."; } - if ((dphiAvg > cutDeltaPhiStarMin) && (dphiAvg < cutDeltaPhiStarMax) && (deta > cutDeltaEtaMin) && (deta < cutDeltaEtaMax)) { - pass = true; // pair is close + if (std::pow(dphiAvg, 2) / std::pow(cutDeltaPhiStarMax, 2) + std::pow(deta, 2) / std::pow(cutDeltaEtaMax, 2) < 1.) { + return true; } else { if (ChosenEventType == femto_universe_container::EventType::same) { - histdetadpisame[i][1]->Fill(deta, dphiAvg); + histdetadpisame[0][1]->Fill(deta, dphiAvg); } else if (ChosenEventType == femto_universe_container::EventType::mixed) { - histdetadpimixed[i][1]->Fill(deta, dphiAvg); + histdetadpimixed[0][1]->Fill(deta, dphiAvg); } else { LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed."; } + return false; } - } - return pass; - } else if constexpr (kPartOneType == o2::aod::femtouniverseparticle::ParticleType::kTrack && kPartTwoType == o2::aod::femtouniverseparticle::ParticleType::kPhi) { - /// Track-Phi combination - // check if provided particles are in agreement with the class instantiation - if (part1.partType() != o2::aod::femtouniverseparticle::ParticleType::kTrack || part2.partType() != o2::aod::femtouniverseparticle::ParticleType::kPhi) { - LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar instantiation! Please provide kTrack,kPhi candidates."; + } else { + LOG(fatal) << "FemtoUniversePairCleaner: Combination of objects not defined - quitting!"; return false; } + } - bool pass = false; - for (int i = 0; i < 2; i++) { - auto indexOfDaughter = 0; - if (ChosenEventType == femto_universe_container::EventType::mixed) { - indexOfDaughter = part2.globalIndex() - 2 + i; - } else if (ChosenEventType == femto_universe_container::EventType::same) { - indexOfDaughter = part2.index() - 2 + i; + /// Check if pair is close or not + template + bool isClosePairFrac(Part const& part1, Part const& part2, float lmagfield, uint8_t ChosenEventType, bool IsDphiAvgOrDist, float DistMax, float FracMax) + { + magfield = lmagfield; + + if constexpr (kPartOneType == o2::aod::femtouniverseparticle::ParticleType::kTrack && kPartTwoType == o2::aod::femtouniverseparticle::ParticleType::kTrack) { + /// Track-Track combination + // check if provided particles are in agreement with the class instantiation + if (part1.partType() != o2::aod::femtouniverseparticle::ParticleType::kTrack || part2.partType() != o2::aod::femtouniverseparticle::ParticleType::kTrack) { + LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar instantiation! Please provide kTrack,kTrack candidates."; + return false; } - - auto daughter = particles.begin() + indexOfDaughter; - auto deta = part1.eta() - daughter.eta(); - auto dphiAvg = averagePhiStar(part1, *daughter, i); // calculateDphiStar(part1, *daughter); - dphiAvg = TVector2::Phi_mpi_pi(dphiAvg); + auto deta = part1.eta() - part2.eta(); + auto dphiAvg = averagePhiStar(part1, part2, 0); + auto distfrac = averagePhiStarFrac(part1, part2, DistMax); if (ChosenEventType == femto_universe_container::EventType::same) { - histdetadpisame[i][0]->Fill(deta, dphiAvg); + histdetadpisame[0][0]->Fill(deta, dphiAvg); } else if (ChosenEventType == femto_universe_container::EventType::mixed) { - histdetadpimixed[i][0]->Fill(deta, dphiAvg); + histdetadpimixed[0][0]->Fill(deta, dphiAvg); } else { LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed."; } - // REMOVING THE "RING" -- CALCULATING THE INVARIANT MASS - TLorentzVector part1Vec; - TLorentzVector part2Vec; - float mMassOne = o2::constants::physics::MassKPlus; - float mMassTwo = o2::constants::physics::MassKMinus; - part1Vec.SetPtEtaPhiM(part1.pt(), part1.eta(), part1.phi(), mMassOne); - part2Vec.SetPtEtaPhiM(daughter.pt(), daughter.eta(), daughter.phi(), mMassTwo); - TLorentzVector sumVec(part1Vec); - sumVec += part2Vec; - float phiM = sumVec.M(); - if ((phiM > cutPhiInvMassLow) && (phiM < cutPhiInvMassHigh)) { - pass = true; // pair comes from Phi meson decay - } - - // APPLYING THE CUTS - if ((dphiAvg > cutDeltaPhiStarMin) && (dphiAvg < cutDeltaPhiStarMax) && (deta > cutDeltaEtaMin) && (deta < cutDeltaEtaMax)) { - pass = true; // pair is close + if (IsDphiAvgOrDist) { + if (std::pow(dphiAvg, 2) / std::pow(cutDeltaPhiStarMax, 2) + std::pow(deta, 2) / std::pow(cutDeltaEtaMax, 2) < 1.) { + return true; + } else { + if (ChosenEventType == femto_universe_container::EventType::same) { + histdetadpisame[0][1]->Fill(deta, dphiAvg); + } else if (ChosenEventType == femto_universe_container::EventType::mixed) { + histdetadpimixed[0][1]->Fill(deta, dphiAvg); + } else { + LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed."; + } + return false; + } } else { - if (ChosenEventType == femto_universe_container::EventType::same) { - histdetadpisame[i][1]->Fill(deta, dphiAvg); - } else if (ChosenEventType == femto_universe_container::EventType::mixed) { - histdetadpimixed[i][1]->Fill(deta, dphiAvg); + if ((deta > cutDeltaEtaMin) && (deta < cutDeltaEtaMax)) { + if (distfrac > FracMax) { + return true; + } } else { - LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed."; + if (ChosenEventType == femto_universe_container::EventType::same) { + histdetadpisame[0][1]->Fill(deta, dphiAvg); + } else if (ChosenEventType == femto_universe_container::EventType::mixed) { + histdetadpimixed[0][1]->Fill(deta, dphiAvg); + } else { + LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed."; + } + return false; } } - } - return pass; - } else { - LOG(fatal) << "FemtoUniversePairCleaner: Combination of objects not defined - quitting!"; - return false; - } - } - /// Check if pair is close or not - template - bool isClosePairAtITS(Part const& part1, Part const& part2, float lmagfield, uint8_t ChosenEventType) - { - magfield = lmagfield; - - if constexpr (kPartOneType == o2::aod::femtouniverseparticle::ParticleType::kTrack && kPartTwoType == o2::aod::femtouniverseparticle::ParticleType::kTrack) { - /// Track-Track combination - // check if provided particles are in agreement with the class instantiation - if (part1.partType() != o2::aod::femtouniverseparticle::ParticleType::kTrack || part2.partType() != o2::aod::femtouniverseparticle::ParticleType::kTrack) { - LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar instantiation! Please provide kTrack,kTrack candidates."; - return false; - } - auto deta = part1.eta() - part2.eta(); - auto dphiAvg = part1.phi() - part2.phi(); - if (ChosenEventType == femto_universe_container::EventType::same) { - histdetadpisame[0][0]->Fill(deta, dphiAvg); - } else if (ChosenEventType == femto_universe_container::EventType::mixed) { - histdetadpimixed[0][0]->Fill(deta, dphiAvg); } else { - LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed."; + LOG(fatal) << "FemtoUniversePairCleaner: Combination of objects not defined - quitting!"; + return false; } + } + + /// Check if pair is close or not + template + void ClosePairqLCMS(Part const& part1, Part const& part2, float lmagfield, uint8_t ChosenEventType, double qlcms) // add typename Parts and variable parts for adding MClabels + { + magfield = lmagfield; + if constexpr (kPartOneType == o2::aod::femtouniverseparticle::ParticleType::kTrack && kPartTwoType == o2::aod::femtouniverseparticle::ParticleType::kTrack) { + auto deta = part1.eta() - part2.eta(); + auto dphiAvg = averagePhiStar(part1, part2, 0); - if (std::pow(dphiAvg, 2) / std::pow(cutDeltaPhiStarMax, 2) + std::pow(deta, 2) / std::pow(cutDeltaEtaMax, 2) < 1.) { - return true; - } else { if (ChosenEventType == femto_universe_container::EventType::same) { - histdetadpisame[0][1]->Fill(deta, dphiAvg); + histdetadpiqlcmssame->Fill(qlcms, deta, dphiAvg); } else if (ChosenEventType == femto_universe_container::EventType::mixed) { - histdetadpimixed[0][1]->Fill(deta, dphiAvg); + histdetadpiqlcmsmixed->Fill(qlcms, deta, dphiAvg); } else { LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed."; } - return false; } - } else { - LOG(fatal) << "FemtoUniversePairCleaner: Combination of objects not defined - quitting!"; - return false; } - } - - /// Check if pair is close or not - template - bool isClosePairFrac(Part const& part1, Part const& part2, float lmagfield, uint8_t ChosenEventType, bool IsDphiAvgOrDist, float DistMax, float FracMax) - { - magfield = lmagfield; - - if constexpr (kPartOneType == o2::aod::femtouniverseparticle::ParticleType::kTrack && kPartTwoType == o2::aod::femtouniverseparticle::ParticleType::kTrack) { - /// Track-Track combination - // check if provided particles are in agreement with the class instantiation - if (part1.partType() != o2::aod::femtouniverseparticle::ParticleType::kTrack || part2.partType() != o2::aod::femtouniverseparticle::ParticleType::kTrack) { - LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar instantiation! Please provide kTrack,kTrack candidates."; - return false; - } - auto deta = part1.eta() - part2.eta(); - auto dphiAvg = averagePhiStar(part1, part2, 0); - auto distfrac = averagePhiStarFrac(part1, part2, DistMax); - if (ChosenEventType == femto_universe_container::EventType::same) { - histdetadpisame[0][0]->Fill(deta, dphiAvg); - } else if (ChosenEventType == femto_universe_container::EventType::mixed) { - histdetadpimixed[0][0]->Fill(deta, dphiAvg); - } else { - LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed."; - } - if (IsDphiAvgOrDist) { - if (std::pow(dphiAvg, 2) / std::pow(cutDeltaPhiStarMax, 2) + std::pow(deta, 2) / std::pow(cutDeltaEtaMax, 2) < 1.) { - return true; - } else { - if (ChosenEventType == femto_universe_container::EventType::same) { - histdetadpisame[0][1]->Fill(deta, dphiAvg); - } else if (ChosenEventType == femto_universe_container::EventType::mixed) { - histdetadpimixed[0][1]->Fill(deta, dphiAvg); - } else { - LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed."; - } - return false; - } + private: + HistogramRegistry* mHistogramRegistry = nullptr; ///< For main output + HistogramRegistry* mHistogramRegistryQA = nullptr; ///< For QA output + static constexpr std::string_view DirNames[8] = {"kTrack_kTrack/", "kTrack_kV0/", "kV0_kV0/", "kTrack_kPhi/", "kTrack_kD0/", "kCascade_kCascade/", "kTrack_kCascade/", "kV0_kCascade/"}; + + static constexpr std::string_view HistNamesSame[2][8] = {{"detadphidetadphi0BeforeSame_0", "detadphidetadphi0BeforeSame_1", "detadphidetadphi0BeforeSame_2", + "detadphidetadphi0BeforeSame_3", "detadphidetadphi0BeforeSame_4", "detadphidetadphi0BeforeSame_5", + "detadphidetadphi0BeforeSame_6", "detadphidetadphi0BeforeSameqLCMS"}, + {"detadphidetadphi0AfterSame_0", "detadphidetadphi0AfterSame_1", "detadphidetadphi0AfterSame_2", + "detadphidetadphi0AfterSame_3", "detadphidetadphi0AfterSame_4", "detadphidetadphi0AfterSame_5", + "detadphidetadphi0AfterSame_6", "detadphidetadphi0AfterSameqLCMS"}}; + static constexpr std::string_view HistNamesMixed[2][8] = {{"detadphidetadphi0BeforeMixed_0", "detadphidetadphi0BeforeMixed_1", "detadphidetadphi0BeforeMixed_2", + "detadphidetadphi0BeforeMixed_3", "detadphidetadphi0BeforeMixed_4", "detadphidetadphi0BeforeMixed_5", + "detadphidetadphi0BeforeMixed_6", "detadphidetadphi0BeforeMixedqLCMS"}, + {"detadphidetadphi0AfterMixed_0", "detadphidetadphi0AfterMixed_1", "detadphidetadphi0AfterMixed_2", + "detadphidetadphi0AfterMixed_3", "detadphidetadphi0AfterMixed_4", "detadphidetadphi0AfterMixed_5", + "detadphidetadphi0AfterMixed_6", "detadphidetadphi0AfterMixedqLCMS"}}; + + static constexpr std::string_view HistNamesRadii[7][9] = {{"detadphidetadphi0Before_0_0", "detadphidetadphi0Before_0_1", "detadphidetadphi0Before_0_2", + "detadphidetadphi0Before_0_3", "detadphidetadphi0Before_0_4", "detadphidetadphi0Before_0_5", + "detadphidetadphi0Before_0_6", "detadphidetadphi0Before_0_7", "detadphidetadphi0Before_0_8"}, + {"detadphidetadphi0Before_1_0", "detadphidetadphi0Before_1_1", "detadphidetadphi0Before_1_2", + "detadphidetadphi0Before_1_3", "detadphidetadphi0Before_1_4", "detadphidetadphi0Before_1_5", + "detadphidetadphi0Before_1_6", "detadphidetadphi0Before_1_7", "detadphidetadphi0Before_1_8"}, + {"detadphidetadphi0Before_2_0", "detadphidetadphi0Before_2_1", "detadphidetadphi0Before_2_2", + "detadphidetadphi0Before_2_3", "detadphidetadphi0Before_2_4", "detadphidetadphi0Before_2_5", + "detadphidetadphi0Before_2_6", "detadphidetadphi0Before_2_7", "detadphidetadphi0Before_2_8"}, + {"detadphidetadphi0Before_3_0", "detadphidetadphi0Before_3_1", "detadphidetadphi0Before_3_2", + "detadphidetadphi0Before_3_3", "detadphidetadphi0Before_3_4", "detadphidetadphi0Before_3_5", + "detadphidetadphi0Before_3_6", "detadphidetadphi0Before_3_7", "detadphidetadphi0Before_3_8"}, + {"detadphidetadphi0Before_4_0", "detadphidetadphi0Before_4_1", "detadphidetadphi0Before_4_2", + "detadphidetadphi0Before_4_3", "detadphidetadphi0Before_4_4", "detadphidetadphi0Before_4_5", + "detadphidetadphi0Before_4_6", "detadphidetadphi0Before_4_7", "detadphidetadphi0Before_4_8"}, + {"detadphidetadphi0Before_5_0", "detadphidetadphi0Before_5_1", "detadphidetadphi0Before_5_2", + "detadphidetadphi0Before_5_3", "detadphidetadphi0Before_5_4", "detadphidetadphi0Before_5_5", + "detadphidetadphi0Before_5_6", "detadphidetadphi0Before_5_7", "detadphidetadphi0Before_5_8"}, + {"detadphidetadphi0Before_6_0", "detadphidetadphi0Before_6_1", "detadphidetadphi0Before_6_2", + "detadphidetadphi0Before_6_3", "detadphidetadphi0Before_6_4", "detadphidetadphi0Before_6_5", + "detadphidetadphi0Before_6_6", "detadphidetadphi0Before_6_7", "detadphidetadphi0Before_6_8"}}; + + static constexpr o2::aod::femtouniverseparticle::ParticleType kPartOneType = partOne; ///< Type of particle 1 + static constexpr o2::aod::femtouniverseparticle::ParticleType kPartTwoType = partTwo; ///< Type of particle 2 + + static constexpr float TmpRadiiTPC[9] = {85., 105., 125., 145., 165., 185., 205., 225., 245.}; + + static constexpr uint32_t kSignMinusMask = 1; + static constexpr uint32_t kSignPlusMask = 1 << 1; + static constexpr uint32_t kValue0 = 0; + + float chosenRadii; + float cutDeltaPhiStarMax; + float cutDeltaPhiStarMin; + float cutDeltaEtaMax; + float cutDeltaEtaMin; + float magfield; + bool plotForEveryRadii = false; + float cutPhiInvMassLow; + float cutPhiInvMassHigh; + bool isSameSignCPR = false; + + std::array, 2>, 7> histdetadpisame{}; + std::array, 2>, 7> histdetadpimixed{}; + std::array, 9>, 7> histdetadpiRadii{}; + + std::shared_ptr histdetadpiqlcmssame{}; + std::shared_ptr histdetadpiqlcmsmixed{}; + + /// Calculate phi at all required radii stored in TmpRadiiTPC + /// Magnetic field to be provided in Tesla + template + void phiAtRadiiTPC(const T& part, std::vector& tmpVec) + { + + float phi0 = part.phi(); + // Start: Get the charge from cutcontainer using masks + float charge = 0.; + if ((part.cut() & kSignMinusMask) == kValue0 && (part.cut() & kSignPlusMask) == kValue0) { + charge = 0; + } else if ((part.cut() & kSignPlusMask) == kSignPlusMask) { + charge = 1; + } else if ((part.cut() & kSignMinusMask) == kSignMinusMask) { + charge = -1; } else { - if (distfrac > FracMax) { - return true; + LOG(fatal) << "FemtoUniverseDetaDphiStar: Charge bits are set wrong!"; + } + // End: Get the charge from cutcontainer using masks + float pt = part.pt(); + for (size_t i = 0; i < 9; i++) { + double arg = 0.3 * charge * magfield * TmpRadiiTPC[i] * 0.01 / (2. * pt); + if (std::abs(arg) < 1.0) { + tmpVec.push_back(phi0 - std::asin(arg)); } else { - if (ChosenEventType == femto_universe_container::EventType::same) { - histdetadpisame[0][1]->Fill(deta, dphiAvg); - } else if (ChosenEventType == femto_universe_container::EventType::mixed) { - histdetadpimixed[0][1]->Fill(deta, dphiAvg); - } else { - LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed."; - } - return false; + tmpVec.push_back(999.0); } } - - } else { - LOG(fatal) << "FemtoUniversePairCleaner: Combination of objects not defined - quitting!"; - return false; - } - } - - /// Check if pair is close or not - template - void ClosePairqLCMS(Part const& part1, Part const& part2, float lmagfield, uint8_t ChosenEventType, double qlcms) // add typename Parts and variable parts for adding MClabels - { - magfield = lmagfield; - if constexpr (kPartOneType == o2::aod::femtouniverseparticle::ParticleType::kTrack && kPartTwoType == o2::aod::femtouniverseparticle::ParticleType::kTrack) { - auto deta = part1.eta() - part2.eta(); - auto dphiAvg = averagePhiStar(part1, part2, 0); - - if (ChosenEventType == femto_universe_container::EventType::same) { - histdetadpiqlcmssame->Fill(qlcms, deta, dphiAvg); - } else if (ChosenEventType == femto_universe_container::EventType::mixed) { - histdetadpiqlcmsmixed->Fill(qlcms, deta, dphiAvg); - } else { - LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed."; - } } - } - - private: - HistogramRegistry* mHistogramRegistry = nullptr; ///< For main output - HistogramRegistry* mHistogramRegistryQA = nullptr; ///< For QA output - static constexpr std::string_view DirNames[8] = {"kTrack_kTrack/", "kTrack_kV0/", "kV0_kV0/", "kTrack_kPhi/", "kTrack_kD0/", "kCascade_kCascade/", "kTrack_kCascade/", "kV0_kCascade/"}; - - static constexpr std::string_view HistNamesSame[2][8] = {{"detadphidetadphi0BeforeSame_0", "detadphidetadphi0BeforeSame_1", "detadphidetadphi0BeforeSame_2", - "detadphidetadphi0BeforeSame_3", "detadphidetadphi0BeforeSame_4", "detadphidetadphi0BeforeSame_5", - "detadphidetadphi0BeforeSame_6", "detadphidetadphi0BeforeSameqLCMS"}, - {"detadphidetadphi0AfterSame_0", "detadphidetadphi0AfterSame_1", "detadphidetadphi0AfterSame_2", - "detadphidetadphi0AfterSame_3", "detadphidetadphi0AfterSame_4", "detadphidetadphi0AfterSame_5", - "detadphidetadphi0AfterSame_6", "detadphidetadphi0AfterSameqLCMS"}}; - static constexpr std::string_view HistNamesMixed[2][8] = {{"detadphidetadphi0BeforeMixed_0", "detadphidetadphi0BeforeMixed_1", "detadphidetadphi0BeforeMixed_2", - "detadphidetadphi0BeforeMixed_3", "detadphidetadphi0BeforeMixed_4", "detadphidetadphi0BeforeMixed_5", - "detadphidetadphi0BeforeMixed_6", "detadphidetadphi0BeforeMixedqLCMS"}, - {"detadphidetadphi0AfterMixed_0", "detadphidetadphi0AfterMixed_1", "detadphidetadphi0AfterMixed_2", - "detadphidetadphi0AfterMixed_3", "detadphidetadphi0AfterMixed_4", "detadphidetadphi0AfterMixed_5", - "detadphidetadphi0AfterMixed_6", "detadphidetadphi0AfterMixedqLCMS"}}; - - static constexpr std::string_view HistNamesRadii[7][9] = {{"detadphidetadphi0Before_0_0", "detadphidetadphi0Before_0_1", "detadphidetadphi0Before_0_2", - "detadphidetadphi0Before_0_3", "detadphidetadphi0Before_0_4", "detadphidetadphi0Before_0_5", - "detadphidetadphi0Before_0_6", "detadphidetadphi0Before_0_7", "detadphidetadphi0Before_0_8"}, - {"detadphidetadphi0Before_1_0", "detadphidetadphi0Before_1_1", "detadphidetadphi0Before_1_2", - "detadphidetadphi0Before_1_3", "detadphidetadphi0Before_1_4", "detadphidetadphi0Before_1_5", - "detadphidetadphi0Before_1_6", "detadphidetadphi0Before_1_7", "detadphidetadphi0Before_1_8"}, - {"detadphidetadphi0Before_2_0", "detadphidetadphi0Before_2_1", "detadphidetadphi0Before_2_2", - "detadphidetadphi0Before_2_3", "detadphidetadphi0Before_2_4", "detadphidetadphi0Before_2_5", - "detadphidetadphi0Before_2_6", "detadphidetadphi0Before_2_7", "detadphidetadphi0Before_2_8"}, - {"detadphidetadphi0Before_3_0", "detadphidetadphi0Before_3_1", "detadphidetadphi0Before_3_2", - "detadphidetadphi0Before_3_3", "detadphidetadphi0Before_3_4", "detadphidetadphi0Before_3_5", - "detadphidetadphi0Before_3_6", "detadphidetadphi0Before_3_7", "detadphidetadphi0Before_3_8"}, - {"detadphidetadphi0Before_4_0", "detadphidetadphi0Before_4_1", "detadphidetadphi0Before_4_2", - "detadphidetadphi0Before_4_3", "detadphidetadphi0Before_4_4", "detadphidetadphi0Before_4_5", - "detadphidetadphi0Before_4_6", "detadphidetadphi0Before_4_7", "detadphidetadphi0Before_4_8"}, - {"detadphidetadphi0Before_5_0", "detadphidetadphi0Before_5_1", "detadphidetadphi0Before_5_2", - "detadphidetadphi0Before_5_3", "detadphidetadphi0Before_5_4", "detadphidetadphi0Before_5_5", - "detadphidetadphi0Before_5_6", "detadphidetadphi0Before_5_7", "detadphidetadphi0Before_5_8"}, - {"detadphidetadphi0Before_6_0", "detadphidetadphi0Before_6_1", "detadphidetadphi0Before_6_2", - "detadphidetadphi0Before_6_3", "detadphidetadphi0Before_6_4", "detadphidetadphi0Before_6_5", - "detadphidetadphi0Before_6_6", "detadphidetadphi0Before_6_7", "detadphidetadphi0Before_6_8"}}; - - static constexpr o2::aod::femtouniverseparticle::ParticleType kPartOneType = partOne; ///< Type of particle 1 - static constexpr o2::aod::femtouniverseparticle::ParticleType kPartTwoType = partTwo; ///< Type of particle 2 - - static constexpr float TmpRadiiTPC[9] = {85., 105., 125., 145., 165., 185., 205., 225., 245.}; - - static constexpr uint32_t kSignMinusMask = 1; - static constexpr uint32_t kSignPlusMask = 1 << 1; - static constexpr uint32_t kValue0 = 0; - - float chosenRadii; - float cutDeltaPhiStarMax; - float cutDeltaPhiStarMin; - float cutDeltaEtaMax; - float cutDeltaEtaMin; - float magfield; - bool plotForEveryRadii = false; - float cutPhiInvMassLow; - float cutPhiInvMassHigh; - bool isSameSignCPR = false; - - std::array, 2>, 7> histdetadpisame{}; - std::array, 2>, 7> histdetadpimixed{}; - std::array, 9>, 7> histdetadpiRadii{}; - - std::shared_ptr histdetadpiqlcmssame{}; - std::shared_ptr histdetadpiqlcmsmixed{}; - - /// Calculate phi at all required radii stored in TmpRadiiTPC - /// Magnetic field to be provided in Tesla - template - void phiAtRadiiTPC(const T& part, std::vector& tmpVec) - { - float phi0 = part.phi(); - // Start: Get the charge from cutcontainer using masks - float charge = 0.; - if ((part.cut() & kSignMinusMask) == kValue0 && (part.cut() & kSignPlusMask) == kValue0) { - charge = 0; - } else if ((part.cut() & kSignPlusMask) == kSignPlusMask) { - charge = 1; - } else if ((part.cut() & kSignMinusMask) == kSignMinusMask) { - charge = -1; - } else { - LOG(fatal) << "FemtoUniverseDetaDphiStar: Charge bits are set wrong!"; - } - // End: Get the charge from cutcontainer using masks - float pt = part.pt(); - for (size_t i = 0; i < 9; i++) { - double arg = 0.3 * charge * magfield * TmpRadiiTPC[i] * 0.01 / (2. * pt); - if (std::abs(arg) < 1.0) { - tmpVec.push_back(phi0 - std::asin(arg)); - } else { - tmpVec.push_back(999.0); + /// Calculate average phi + template + float averagePhiStar(const T1& part1, const T2& part2, int iHist) + { + std::vector tmpVec1; + std::vector tmpVec2; + phiAtRadiiTPC(part1, tmpVec1); + phiAtRadiiTPC(part2, tmpVec2); + int num = tmpVec1.size(); + float dPhiAvg = 0; + float dphi = 0; + int entries = 0; + for (int i = 0; i < num; i++) { + if (tmpVec1.at(i) != 999 && tmpVec2.at(i) != 999) { + dphi = tmpVec1.at(i) - tmpVec2.at(i); + entries++; + } else { + dphi = 0; + } + dphi = TVector2::Phi_mpi_pi(dphi); + dPhiAvg += dphi; + if (plotForEveryRadii) { + histdetadpiRadii[iHist][i]->Fill(part1.eta() - part2.eta(), dphi); + } } + return dPhiAvg / static_cast(entries); } - } - /// Calculate average phi - template - float averagePhiStar(const T1& part1, const T2& part2, int iHist) - { - std::vector tmpVec1; - std::vector tmpVec2; - phiAtRadiiTPC(part1, tmpVec1); - phiAtRadiiTPC(part2, tmpVec2); - int num = tmpVec1.size(); - float dPhiAvg = 0; - float dphi = 0; - int entries = 0; - for (int i = 0; i < num; i++) { - if (tmpVec1.at(i) != 999 && tmpVec2.at(i) != 999) { - dphi = tmpVec1.at(i) - tmpVec2.at(i); - entries++; - } else { - dphi = 0; - } - dphi = TVector2::Phi_mpi_pi(dphi); - dPhiAvg += dphi; - if (plotForEveryRadii) { - histdetadpiRadii[iHist][i]->Fill(part1.eta() - part2.eta(), dphi); + /// Calculate average phi + template + float averagePhiStarFrac(const T1& part1, const T2& part2, float maxdist) + { + std::vector tmpVec1; + std::vector tmpVec2; + phiAtRadiiTPC(part1, tmpVec1); + phiAtRadiiTPC(part2, tmpVec2); + int num = tmpVec1.size(); + float dphi = 0; + int entries = 0; + double distance = 0; + int badpoints = 0; + + for (int i = 0; i < num; i++) { + if (tmpVec1.at(i) != 999 && tmpVec2.at(i) != 999) { + dphi = tmpVec1.at(i) - tmpVec2.at(i); + entries++; + } else { + dphi = 0; + } + dphi = TVector2::Phi_mpi_pi(dphi); + distance = 2 * TMath::Sin(TMath::Abs(dphi) * 0.5) * TmpRadiiTPC[i]; + if (distance < maxdist) { + badpoints++; + } } + return badpoints / entries; } - return dPhiAvg / static_cast(entries); - } - /// Calculate average phi - template - float averagePhiStarFrac(const T1& part1, const T2& part2, float maxdist) - { - std::vector tmpVec1; - std::vector tmpVec2; - phiAtRadiiTPC(part1, tmpVec1); - phiAtRadiiTPC(part2, tmpVec2); - int num = tmpVec1.size(); - float dphi = 0; - int entries = 0; - double distance = 0; - int badpoints = 0; - - for (int i = 0; i < num; i++) { - if (tmpVec1.at(i) != 999 && tmpVec2.at(i) != 999) { - dphi = tmpVec1.at(i) - tmpVec2.at(i); - entries++; + // Get particle charge from mask + template + float getCharge(const T1& part) + { + float charge = 0; + if ((part.cut() & kSignMinusMask) == kValue0 && (part.cut() & kSignPlusMask) == kValue0) { + charge = 0; + } else if ((part.cut() & kSignPlusMask) == kSignPlusMask) { + charge = 1; + } else if ((part.cut() & kSignMinusMask) == kSignMinusMask) { + charge = -1; } else { - dphi = 0; - } - dphi = TVector2::Phi_mpi_pi(dphi); - distance = 2 * TMath::Sin(TMath::Abs(dphi) * 0.5) * TmpRadiiTPC[i]; - if (distance < maxdist) { - badpoints++; + LOG(fatal) << "FemtoUniverseDetaDphiStar: Charge bits are set wrong!"; } + return charge; } - return badpoints / entries; - } - // Get particle charge from mask - template - float getCharge(const T1& part) - { - float charge = 0; - if ((part.cut() & kSignMinusMask) == kValue0 && (part.cut() & kSignPlusMask) == kValue0) { - charge = 0; - } else if ((part.cut() & kSignPlusMask) == kSignPlusMask) { - charge = 1; - } else if ((part.cut() & kSignMinusMask) == kSignMinusMask) { - charge = -1; - } else { - LOG(fatal) << "FemtoUniverseDetaDphiStar: Charge bits are set wrong!"; - } - return charge; - } + // Calculate phi* as in https://github.com/alisw/AliPhysics/blob/master/PWGCF/FEMTOSCOPY/AliFemtoUser/AliFemtoPairCutRadialDistance.cxx + template + double calculateDphiStar(const T1& part1, const T2& part2) + { + float charge1 = getCharge(part1); + float charge2 = getCharge(part2); - // Calculate phi* as in https://github.com/alisw/AliPhysics/blob/master/PWGCF/FEMTOSCOPY/AliFemtoUser/AliFemtoPairCutRadialDistance.cxx - template - double calculateDphiStar(const T1& part1, const T2& part2) - { - float charge1 = getCharge(part1); - float charge2 = getCharge(part2); + double deltaphiconstFD = 0.3 / 2; + // double deltaphiconstAF = 0.15; + double afsi0b = deltaphiconstFD * magfield * charge1 * chosenRadii / part1.pt(); + double afsi1b = deltaphiconstFD * magfield * charge2 * chosenRadii / part2.pt(); + double dphis = 0.0; - double deltaphiconstFD = 0.3 / 2; - // double deltaphiconstAF = 0.15; - double afsi0b = deltaphiconstFD * magfield * charge1 * chosenRadii / part1.pt(); - double afsi1b = deltaphiconstFD * magfield * charge2 * chosenRadii / part2.pt(); - double dphis = 0.0; - - if (std::abs(afsi0b) < 1.0 && std::abs(afsi0b) < 1.0) { - dphis = part2.phi() - part1.phi() + std::asin(afsi1b) - std::asin(afsi0b); + if (std::abs(afsi0b) < 1.0 && std::abs(afsi0b) < 1.0) { + dphis = part2.phi() - part1.phi() + std::asin(afsi1b) - std::asin(afsi0b); + } + return dphis; } - return dphis; - } -}; + }; } /* namespace femto_universe */ } /* namespace o2::analysis */ From 34c36421e9d42ebdb9979262d7f35c5d900b3ccd Mon Sep 17 00:00:00 2001 From: Pritam Chakraborty <47203359+prchakra@users.noreply.github.com> Date: Tue, 23 Sep 2025 15:54:28 +0200 Subject: [PATCH 2/2] Fix the bug --- .../Core/FemtoUniverseDetaDphiStar.h | 861 +++++++++--------- 1 file changed, 423 insertions(+), 438 deletions(-) diff --git a/PWGCF/FemtoUniverse/Core/FemtoUniverseDetaDphiStar.h b/PWGCF/FemtoUniverse/Core/FemtoUniverseDetaDphiStar.h index 2856c0de95f..778e0c4772b 100644 --- a/PWGCF/FemtoUniverse/Core/FemtoUniverseDetaDphiStar.h +++ b/PWGCF/FemtoUniverse/Core/FemtoUniverseDetaDphiStar.h @@ -315,534 +315,519 @@ class FemtoUniverseDetaDphiStar continue; auto deta = daughterpart1.eta() - daughterpart2.eta(); auto dphiAvg = averagePhiStar(*daughterpart1, *daughterpart2, i); - if (ChosenEventType if (distfrac > FracMax) { - == femto_universe_container::EventType::same) - { - histdetadpisame[i][0]->Fill(deta, dphiAvg); - } - else if (ChosenEventType == femto_universe_container::EventType::mixed) - { - histdetadpimixed[i][0]->Fill(deta, dphiAvg); - } - else - { - LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed."; - } - - if ((dphiAvg > cutDeltaPhiStarMin) && (dphiAvg < cutDeltaPhiStarMax) && (deta > cutDeltaEtaMin) && (deta < cutDeltaEtaMax)) { - pass = true; - } else { - if (ChosenEventType == femto_universe_container::EventType::same) { - histdetadpisame[i][1]->Fill(deta, dphiAvg); - } else if (ChosenEventType == femto_universe_container::EventType::mixed) { - histdetadpimixed[i][1]->Fill(deta, dphiAvg); - } else { - LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed."; - } - } - } - return pass; - } - else if constexpr (kPartOneType == o2::aod::femtouniverseparticle::ParticleType::kTrack && kPartTwoType == o2::aod::femtouniverseparticle::ParticleType::kCascade) - { - /// Track-Cascade combination - if (part1.partType() != o2::aod::femtouniverseparticle::ParticleType::kTrack || part2.partType() != o2::aod::femtouniverseparticle::ParticleType::kCascade) { - LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar instantiation! Please provide kTrack,kCascade candidates."; - return false; + if (ChosenEventType == femto_universe_container::EventType::same) { + histdetadpisame[i][0]->Fill(deta, dphiAvg); + } else if (ChosenEventType == femto_universe_container::EventType::mixed) { + histdetadpimixed[i][0]->Fill(deta, dphiAvg); + } else { + LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed."; } - bool pass = false; - for (int i = 0; i < 3; i++) { - auto indexOfDaughter = (ChosenEventType == femto_universe_container::EventType::mixed ? part2.globalIndex() : part2.index()) - 3 + i; - auto daughter = particles.begin() + indexOfDaughter; - if (isSameSignCPR && (part1.mAntiLambda() != daughter.mAntiLambda())) // mAntiLambda() is used here as sign getter - continue; - auto deta = part1.eta() - daughter.eta(); - auto dphiAvg = averagePhiStar(*part1, *daughter, i); + if ((dphiAvg > cutDeltaPhiStarMin) && (dphiAvg < cutDeltaPhiStarMax) && (deta > cutDeltaEtaMin) && (deta < cutDeltaEtaMax)) { + pass = true; + } else { if (ChosenEventType == femto_universe_container::EventType::same) { - histdetadpisame[i][0]->Fill(deta, dphiAvg); + histdetadpisame[i][1]->Fill(deta, dphiAvg); } else if (ChosenEventType == femto_universe_container::EventType::mixed) { - histdetadpimixed[i][0]->Fill(deta, dphiAvg); + histdetadpimixed[i][1]->Fill(deta, dphiAvg); } else { LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed."; } - - if ((dphiAvg > cutDeltaPhiStarMin) && (dphiAvg < cutDeltaPhiStarMax) && (deta > cutDeltaEtaMin) && (deta < cutDeltaEtaMax)) { - pass = true; - } else { - if (ChosenEventType == femto_universe_container::EventType::same) { - histdetadpisame[i][1]->Fill(deta, dphiAvg); - } else if (ChosenEventType == femto_universe_container::EventType::mixed) { - histdetadpimixed[i][1]->Fill(deta, dphiAvg); - } else { - LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed."; - } - } } - return pass; } - else if constexpr (kPartOneType == o2::aod::femtouniverseparticle::ParticleType::kV0 && kPartTwoType == o2::aod::femtouniverseparticle::ParticleType::kCascade) - { - /// V0-Cascade combination - if (part1.partType() != o2::aod::femtouniverseparticle::ParticleType::kV0 || part2.partType() != o2::aod::femtouniverseparticle::ParticleType::kCascade) { - LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar instantiation! Please provide kV0,kCascade candidates."; - return false; - } + return pass; - bool pass = false; - static constexpr int V0CascChildTable[][2] = {{-1, -1}, {-1, -2}, {-1, -3}, {-2, -1}, {-2, -2}, {-2, -3}}; - for (int i = 0; i < 3; i++) { - auto indexOfDaughterV0 = (ChosenEventType == femto_universe_container::EventType::mixed ? part1.globalIndex() : part1.index()) + V0CascChildTable[i][0]; - auto indexOfDaughterCasc = (ChosenEventType == femto_universe_container::EventType::mixed ? part2.globalIndex() : part2.index()) + V0CascChildTable[i][1]; - auto daughterV0 = particles.begin() + indexOfDaughterV0; - auto daughterCasc = particles.begin() + indexOfDaughterCasc; - if (isSameSignCPR && (daughterV0.mAntiLambda() != daughterCasc.mAntiLambda())) // mAntiLambda() is used here as sign getter - continue; - auto deta = daughterV0.eta() - daughterCasc.eta(); - auto dphiAvg = averagePhiStar(*daughterV0, *daughterCasc, i); - if (ChosenEventType == femto_universe_container::EventType::same) { - histdetadpisame[i][0]->Fill(deta, dphiAvg); - } else if (ChosenEventType == femto_universe_container::EventType::mixed) { - histdetadpimixed[i][0]->Fill(deta, dphiAvg); - } else { - LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed."; - } + } else if constexpr (kPartOneType == o2::aod::femtouniverseparticle::ParticleType::kTrack && kPartTwoType == o2::aod::femtouniverseparticle::ParticleType::kCascade) { + /// Track-Cascade combination + if (part1.partType() != o2::aod::femtouniverseparticle::ParticleType::kTrack || part2.partType() != o2::aod::femtouniverseparticle::ParticleType::kCascade) { + LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar instantiation! Please provide kTrack,kCascade candidates."; + return false; + } - if ((dphiAvg > cutDeltaPhiStarMin) && (dphiAvg < cutDeltaPhiStarMax) && (deta > cutDeltaEtaMin) && (deta < cutDeltaEtaMax)) { - pass = true; - } else { - if (ChosenEventType == femto_universe_container::EventType::same) { - histdetadpisame[i][1]->Fill(deta, dphiAvg); - } else if (ChosenEventType == femto_universe_container::EventType::mixed) { - histdetadpimixed[i][1]->Fill(deta, dphiAvg); - } else { - LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed."; - } - } - } - return pass; - } - else if constexpr (kPartOneType == o2::aod::femtouniverseparticle::ParticleType::kTrack && kPartTwoType == o2::aod::femtouniverseparticle::ParticleType::kD0) - { - /// Track-D0 combination - // check if provided particles are in agreement with the class instantiation - if (part1.partType() != o2::aod::femtouniverseparticle::ParticleType::kTrack || part2.partType() != o2::aod::femtouniverseparticle::ParticleType::kD0) { - LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar instantiation! Please provide kTrack, kD0 candidates."; - return false; + bool pass = false; + for (int i = 0; i < 3; i++) { + auto indexOfDaughter = (ChosenEventType == femto_universe_container::EventType::mixed ? part2.globalIndex() : part2.index()) - 3 + i; + auto daughter = particles.begin() + indexOfDaughter; + if (isSameSignCPR && (part1.mAntiLambda() != daughter.mAntiLambda())) // mAntiLambda() is used here as sign getter + continue; + auto deta = part1.eta() - daughter.eta(); + auto dphiAvg = averagePhiStar(*part1, *daughter, i); + if (ChosenEventType == femto_universe_container::EventType::same) { + histdetadpisame[i][0]->Fill(deta, dphiAvg); + } else if (ChosenEventType == femto_universe_container::EventType::mixed) { + histdetadpimixed[i][0]->Fill(deta, dphiAvg); + } else { + LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed."; } - bool pass = false; - for (int i = 0; i < 2; i++) { - auto indexOfDaughter = 0; - if (ChosenEventType == femto_universe_container::EventType::mixed) { - indexOfDaughter = part2.globalIndex() - 2 + i; - } else if (ChosenEventType == femto_universe_container::EventType::same) { - indexOfDaughter = part2.index() - 2 + i; - } - - auto daughter = particles.begin() + indexOfDaughter; - auto deta = part1.eta() - daughter.eta(); - auto dphiAvg = averagePhiStar(part1, *daughter, i); // auto dphiAvg = calculateDphiStar(part1, *daughter); - dphiAvg = TVector2::Phi_mpi_pi(dphiAvg); + if ((dphiAvg > cutDeltaPhiStarMin) && (dphiAvg < cutDeltaPhiStarMax) && (deta > cutDeltaEtaMin) && (deta < cutDeltaEtaMax)) { + pass = true; + } else { if (ChosenEventType == femto_universe_container::EventType::same) { - histdetadpisame[i][0]->Fill(deta, dphiAvg); + histdetadpisame[i][1]->Fill(deta, dphiAvg); } else if (ChosenEventType == femto_universe_container::EventType::mixed) { - histdetadpimixed[i][0]->Fill(deta, dphiAvg); + histdetadpimixed[i][1]->Fill(deta, dphiAvg); } else { LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed."; } - - if ((dphiAvg > cutDeltaPhiStarMin) && (dphiAvg < cutDeltaPhiStarMax) && (deta > cutDeltaEtaMin) && (deta < cutDeltaEtaMax)) { - pass = true; // pair is close - } else { - if (ChosenEventType == femto_universe_container::EventType::same) { - histdetadpisame[i][1]->Fill(deta, dphiAvg); - } else if (ChosenEventType == femto_universe_container::EventType::mixed) { - histdetadpimixed[i][1]->Fill(deta, dphiAvg); - } else { - LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed."; - } - } - } - return pass; - } - else if constexpr (kPartOneType == o2::aod::femtouniverseparticle::ParticleType::kTrack && kPartTwoType == o2::aod::femtouniverseparticle::ParticleType::kPhi) - { - /// Track-Phi combination - // check if provided particles are in agreement with the class instantiation - if (part1.partType() != o2::aod::femtouniverseparticle::ParticleType::kTrack || part2.partType() != o2::aod::femtouniverseparticle::ParticleType::kPhi) { - LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar instantiation! Please provide kTrack,kPhi candidates."; - return false; } + } + return pass; - bool pass = false; - for (int i = 0; i < 2; i++) { - auto indexOfDaughter = 0; - if (ChosenEventType == femto_universe_container::EventType::mixed) { - indexOfDaughter = part2.globalIndex() - 2 + i; - } else if (ChosenEventType == femto_universe_container::EventType::same) { - indexOfDaughter = part2.index() - 2 + i; - } + } else if constexpr (kPartOneType == o2::aod::femtouniverseparticle::ParticleType::kV0 && kPartTwoType == o2::aod::femtouniverseparticle::ParticleType::kCascade) { + /// V0-Cascade combination + if (part1.partType() != o2::aod::femtouniverseparticle::ParticleType::kV0 || part2.partType() != o2::aod::femtouniverseparticle::ParticleType::kCascade) { + LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar instantiation! Please provide kV0,kCascade candidates."; + return false; + } - auto daughter = particles.begin() + indexOfDaughter; - auto deta = part1.eta() - daughter.eta(); - auto dphiAvg = averagePhiStar(part1, *daughter, i); // calculateDphiStar(part1, *daughter); - dphiAvg = TVector2::Phi_mpi_pi(dphiAvg); + bool pass = false; + static constexpr int V0CascChildTable[][2] = {{-1, -1}, {-1, -2}, {-1, -3}, {-2, -1}, {-2, -2}, {-2, -3}}; + for (int i = 0; i < 3; i++) { + auto indexOfDaughterV0 = (ChosenEventType == femto_universe_container::EventType::mixed ? part1.globalIndex() : part1.index()) + V0CascChildTable[i][0]; + auto indexOfDaughterCasc = (ChosenEventType == femto_universe_container::EventType::mixed ? part2.globalIndex() : part2.index()) + V0CascChildTable[i][1]; + auto daughterV0 = particles.begin() + indexOfDaughterV0; + auto daughterCasc = particles.begin() + indexOfDaughterCasc; + if (isSameSignCPR && (daughterV0.mAntiLambda() != daughterCasc.mAntiLambda())) // mAntiLambda() is used here as sign getter + continue; + auto deta = daughterV0.eta() - daughterCasc.eta(); + auto dphiAvg = averagePhiStar(*daughterV0, *daughterCasc, i); + if (ChosenEventType == femto_universe_container::EventType::same) { + histdetadpisame[i][0]->Fill(deta, dphiAvg); + } else if (ChosenEventType == femto_universe_container::EventType::mixed) { + histdetadpimixed[i][0]->Fill(deta, dphiAvg); + } else { + LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed."; + } + + if ((dphiAvg > cutDeltaPhiStarMin) && (dphiAvg < cutDeltaPhiStarMax) && (deta > cutDeltaEtaMin) && (deta < cutDeltaEtaMax)) { + pass = true; + } else { if (ChosenEventType == femto_universe_container::EventType::same) { - histdetadpisame[i][0]->Fill(deta, dphiAvg); + histdetadpisame[i][1]->Fill(deta, dphiAvg); } else if (ChosenEventType == femto_universe_container::EventType::mixed) { - histdetadpimixed[i][0]->Fill(deta, dphiAvg); + histdetadpimixed[i][1]->Fill(deta, dphiAvg); } else { LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed."; } - - // REMOVING THE "RING" -- CALCULATING THE INVARIANT MASS - TLorentzVector part1Vec; - TLorentzVector part2Vec; - float mMassOne = o2::constants::physics::MassKPlus; - float mMassTwo = o2::constants::physics::MassKMinus; - part1Vec.SetPtEtaPhiM(part1.pt(), part1.eta(), part1.phi(), mMassOne); - part2Vec.SetPtEtaPhiM(daughter.pt(), daughter.eta(), daughter.phi(), mMassTwo); - TLorentzVector sumVec(part1Vec); - sumVec += part2Vec; - float phiM = sumVec.M(); - if ((phiM > cutPhiInvMassLow) && (phiM < cutPhiInvMassHigh)) { - pass = true; // pair comes from Phi meson decay - } - - // APPLYING THE CUTS - if ((dphiAvg > cutDeltaPhiStarMin) && (dphiAvg < cutDeltaPhiStarMax) && (deta > cutDeltaEtaMin) && (deta < cutDeltaEtaMax)) { - pass = true; // pair is close - } else { - if (ChosenEventType == femto_universe_container::EventType::same) { - histdetadpisame[i][1]->Fill(deta, dphiAvg); - } else if (ChosenEventType == femto_universe_container::EventType::mixed) { - histdetadpimixed[i][1]->Fill(deta, dphiAvg); - } else { - LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed."; - } - } } - return pass; } - else - { - LOG(fatal) << "FemtoUniversePairCleaner: Combination of objects not defined - quitting!"; + return pass; + + } else if constexpr (kPartOneType == o2::aod::femtouniverseparticle::ParticleType::kTrack && kPartTwoType == o2::aod::femtouniverseparticle::ParticleType::kD0) { + /// Track-D0 combination + // check if provided particles are in agreement with the class instantiation + if (part1.partType() != o2::aod::femtouniverseparticle::ParticleType::kTrack || part2.partType() != o2::aod::femtouniverseparticle::ParticleType::kD0) { + LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar instantiation! Please provide kTrack, kD0 candidates."; return false; } - } - /// Check if pair is close or not - template - bool isClosePairAtITS(Part const& part1, Part const& part2, float lmagfield, uint8_t ChosenEventType) - { - magfield = lmagfield; - - if constexpr (kPartOneType == o2::aod::femtouniverseparticle::ParticleType::kTrack && kPartTwoType == o2::aod::femtouniverseparticle::ParticleType::kTrack) { - /// Track-Track combination - // check if provided particles are in agreement with the class instantiation - if (part1.partType() != o2::aod::femtouniverseparticle::ParticleType::kTrack || part2.partType() != o2::aod::femtouniverseparticle::ParticleType::kTrack) { - LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar instantiation! Please provide kTrack,kTrack candidates."; - return false; + bool pass = false; + for (int i = 0; i < 2; i++) { + auto indexOfDaughter = 0; + if (ChosenEventType == femto_universe_container::EventType::mixed) { + indexOfDaughter = part2.globalIndex() - 2 + i; + } else if (ChosenEventType == femto_universe_container::EventType::same) { + indexOfDaughter = part2.index() - 2 + i; } - auto deta = part1.eta() - part2.eta(); - auto dphiAvg = part1.phi() - part2.phi(); + + auto daughter = particles.begin() + indexOfDaughter; + auto deta = part1.eta() - daughter.eta(); + auto dphiAvg = averagePhiStar(part1, *daughter, i); // auto dphiAvg = calculateDphiStar(part1, *daughter); + dphiAvg = TVector2::Phi_mpi_pi(dphiAvg); if (ChosenEventType == femto_universe_container::EventType::same) { - histdetadpisame[0][0]->Fill(deta, dphiAvg); + histdetadpisame[i][0]->Fill(deta, dphiAvg); } else if (ChosenEventType == femto_universe_container::EventType::mixed) { - histdetadpimixed[0][0]->Fill(deta, dphiAvg); + histdetadpimixed[i][0]->Fill(deta, dphiAvg); } else { LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed."; } - if (std::pow(dphiAvg, 2) / std::pow(cutDeltaPhiStarMax, 2) + std::pow(deta, 2) / std::pow(cutDeltaEtaMax, 2) < 1.) { - return true; + if ((dphiAvg > cutDeltaPhiStarMin) && (dphiAvg < cutDeltaPhiStarMax) && (deta > cutDeltaEtaMin) && (deta < cutDeltaEtaMax)) { + pass = true; // pair is close } else { if (ChosenEventType == femto_universe_container::EventType::same) { - histdetadpisame[0][1]->Fill(deta, dphiAvg); + histdetadpisame[i][1]->Fill(deta, dphiAvg); } else if (ChosenEventType == femto_universe_container::EventType::mixed) { - histdetadpimixed[0][1]->Fill(deta, dphiAvg); + histdetadpimixed[i][1]->Fill(deta, dphiAvg); } else { LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed."; } - return false; } - } else { - LOG(fatal) << "FemtoUniversePairCleaner: Combination of objects not defined - quitting!"; + } + return pass; + } else if constexpr (kPartOneType == o2::aod::femtouniverseparticle::ParticleType::kTrack && kPartTwoType == o2::aod::femtouniverseparticle::ParticleType::kPhi) { + /// Track-Phi combination + // check if provided particles are in agreement with the class instantiation + if (part1.partType() != o2::aod::femtouniverseparticle::ParticleType::kTrack || part2.partType() != o2::aod::femtouniverseparticle::ParticleType::kPhi) { + LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar instantiation! Please provide kTrack,kPhi candidates."; return false; } - } - /// Check if pair is close or not - template - bool isClosePairFrac(Part const& part1, Part const& part2, float lmagfield, uint8_t ChosenEventType, bool IsDphiAvgOrDist, float DistMax, float FracMax) - { - magfield = lmagfield; - - if constexpr (kPartOneType == o2::aod::femtouniverseparticle::ParticleType::kTrack && kPartTwoType == o2::aod::femtouniverseparticle::ParticleType::kTrack) { - /// Track-Track combination - // check if provided particles are in agreement with the class instantiation - if (part1.partType() != o2::aod::femtouniverseparticle::ParticleType::kTrack || part2.partType() != o2::aod::femtouniverseparticle::ParticleType::kTrack) { - LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar instantiation! Please provide kTrack,kTrack candidates."; - return false; + bool pass = false; + for (int i = 0; i < 2; i++) { + auto indexOfDaughter = 0; + if (ChosenEventType == femto_universe_container::EventType::mixed) { + indexOfDaughter = part2.globalIndex() - 2 + i; + } else if (ChosenEventType == femto_universe_container::EventType::same) { + indexOfDaughter = part2.index() - 2 + i; } - auto deta = part1.eta() - part2.eta(); - auto dphiAvg = averagePhiStar(part1, part2, 0); - auto distfrac = averagePhiStarFrac(part1, part2, DistMax); + + auto daughter = particles.begin() + indexOfDaughter; + auto deta = part1.eta() - daughter.eta(); + auto dphiAvg = averagePhiStar(part1, *daughter, i); // calculateDphiStar(part1, *daughter); + dphiAvg = TVector2::Phi_mpi_pi(dphiAvg); if (ChosenEventType == femto_universe_container::EventType::same) { - histdetadpisame[0][0]->Fill(deta, dphiAvg); + histdetadpisame[i][0]->Fill(deta, dphiAvg); } else if (ChosenEventType == femto_universe_container::EventType::mixed) { - histdetadpimixed[0][0]->Fill(deta, dphiAvg); + histdetadpimixed[i][0]->Fill(deta, dphiAvg); } else { LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed."; } - if (IsDphiAvgOrDist) { - if (std::pow(dphiAvg, 2) / std::pow(cutDeltaPhiStarMax, 2) + std::pow(deta, 2) / std::pow(cutDeltaEtaMax, 2) < 1.) { - return true; - } else { - if (ChosenEventType == femto_universe_container::EventType::same) { - histdetadpisame[0][1]->Fill(deta, dphiAvg); - } else if (ChosenEventType == femto_universe_container::EventType::mixed) { - histdetadpimixed[0][1]->Fill(deta, dphiAvg); - } else { - LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed."; - } - return false; - } + // REMOVING THE "RING" -- CALCULATING THE INVARIANT MASS + TLorentzVector part1Vec; + TLorentzVector part2Vec; + float mMassOne = o2::constants::physics::MassKPlus; + float mMassTwo = o2::constants::physics::MassKMinus; + part1Vec.SetPtEtaPhiM(part1.pt(), part1.eta(), part1.phi(), mMassOne); + part2Vec.SetPtEtaPhiM(daughter.pt(), daughter.eta(), daughter.phi(), mMassTwo); + TLorentzVector sumVec(part1Vec); + sumVec += part2Vec; + float phiM = sumVec.M(); + if ((phiM > cutPhiInvMassLow) && (phiM < cutPhiInvMassHigh)) { + pass = true; // pair comes from Phi meson decay + } + + // APPLYING THE CUTS + if ((dphiAvg > cutDeltaPhiStarMin) && (dphiAvg < cutDeltaPhiStarMax) && (deta > cutDeltaEtaMin) && (deta < cutDeltaEtaMax)) { + pass = true; // pair is close } else { - if ((deta > cutDeltaEtaMin) && (deta < cutDeltaEtaMax)) { - if (distfrac > FracMax) { - return true; - } + if (ChosenEventType == femto_universe_container::EventType::same) { + histdetadpisame[i][1]->Fill(deta, dphiAvg); + } else if (ChosenEventType == femto_universe_container::EventType::mixed) { + histdetadpimixed[i][1]->Fill(deta, dphiAvg); } else { - if (ChosenEventType == femto_universe_container::EventType::same) { - histdetadpisame[0][1]->Fill(deta, dphiAvg); - } else if (ChosenEventType == femto_universe_container::EventType::mixed) { - histdetadpimixed[0][1]->Fill(deta, dphiAvg); - } else { - LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed."; - } - return false; + LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed."; } } - - } else { - LOG(fatal) << "FemtoUniversePairCleaner: Combination of objects not defined - quitting!"; - return false; } + return pass; + } else { + LOG(fatal) << "FemtoUniversePairCleaner: Combination of objects not defined - quitting!"; + return false; } + } - /// Check if pair is close or not - template - void ClosePairqLCMS(Part const& part1, Part const& part2, float lmagfield, uint8_t ChosenEventType, double qlcms) // add typename Parts and variable parts for adding MClabels - { - magfield = lmagfield; - if constexpr (kPartOneType == o2::aod::femtouniverseparticle::ParticleType::kTrack && kPartTwoType == o2::aod::femtouniverseparticle::ParticleType::kTrack) { - auto deta = part1.eta() - part2.eta(); - auto dphiAvg = averagePhiStar(part1, part2, 0); + /// Check if pair is close or not + template + bool isClosePairAtITS(Part const& part1, Part const& part2, float lmagfield, uint8_t ChosenEventType) + { + magfield = lmagfield; + + if constexpr (kPartOneType == o2::aod::femtouniverseparticle::ParticleType::kTrack && kPartTwoType == o2::aod::femtouniverseparticle::ParticleType::kTrack) { + /// Track-Track combination + // check if provided particles are in agreement with the class instantiation + if (part1.partType() != o2::aod::femtouniverseparticle::ParticleType::kTrack || part2.partType() != o2::aod::femtouniverseparticle::ParticleType::kTrack) { + LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar instantiation! Please provide kTrack,kTrack candidates."; + return false; + } + auto deta = part1.eta() - part2.eta(); + auto dphiAvg = part1.phi() - part2.phi(); + if (ChosenEventType == femto_universe_container::EventType::same) { + histdetadpisame[0][0]->Fill(deta, dphiAvg); + } else if (ChosenEventType == femto_universe_container::EventType::mixed) { + histdetadpimixed[0][0]->Fill(deta, dphiAvg); + } else { + LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed."; + } + if (std::pow(dphiAvg, 2) / std::pow(cutDeltaPhiStarMax, 2) + std::pow(deta, 2) / std::pow(cutDeltaEtaMax, 2) < 1.) { + return true; + } else { if (ChosenEventType == femto_universe_container::EventType::same) { - histdetadpiqlcmssame->Fill(qlcms, deta, dphiAvg); + histdetadpisame[0][1]->Fill(deta, dphiAvg); } else if (ChosenEventType == femto_universe_container::EventType::mixed) { - histdetadpiqlcmsmixed->Fill(qlcms, deta, dphiAvg); + histdetadpimixed[0][1]->Fill(deta, dphiAvg); } else { LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed."; } + return false; } + } else { + LOG(fatal) << "FemtoUniversePairCleaner: Combination of objects not defined - quitting!"; + return false; } + } + + /// Check if pair is close or not + template + bool isClosePairFrac(Part const& part1, Part const& part2, float lmagfield, uint8_t ChosenEventType, bool IsDphiAvgOrDist, float DistMax, float FracMax) + { + magfield = lmagfield; - private: - HistogramRegistry* mHistogramRegistry = nullptr; ///< For main output - HistogramRegistry* mHistogramRegistryQA = nullptr; ///< For QA output - static constexpr std::string_view DirNames[8] = {"kTrack_kTrack/", "kTrack_kV0/", "kV0_kV0/", "kTrack_kPhi/", "kTrack_kD0/", "kCascade_kCascade/", "kTrack_kCascade/", "kV0_kCascade/"}; - - static constexpr std::string_view HistNamesSame[2][8] = {{"detadphidetadphi0BeforeSame_0", "detadphidetadphi0BeforeSame_1", "detadphidetadphi0BeforeSame_2", - "detadphidetadphi0BeforeSame_3", "detadphidetadphi0BeforeSame_4", "detadphidetadphi0BeforeSame_5", - "detadphidetadphi0BeforeSame_6", "detadphidetadphi0BeforeSameqLCMS"}, - {"detadphidetadphi0AfterSame_0", "detadphidetadphi0AfterSame_1", "detadphidetadphi0AfterSame_2", - "detadphidetadphi0AfterSame_3", "detadphidetadphi0AfterSame_4", "detadphidetadphi0AfterSame_5", - "detadphidetadphi0AfterSame_6", "detadphidetadphi0AfterSameqLCMS"}}; - static constexpr std::string_view HistNamesMixed[2][8] = {{"detadphidetadphi0BeforeMixed_0", "detadphidetadphi0BeforeMixed_1", "detadphidetadphi0BeforeMixed_2", - "detadphidetadphi0BeforeMixed_3", "detadphidetadphi0BeforeMixed_4", "detadphidetadphi0BeforeMixed_5", - "detadphidetadphi0BeforeMixed_6", "detadphidetadphi0BeforeMixedqLCMS"}, - {"detadphidetadphi0AfterMixed_0", "detadphidetadphi0AfterMixed_1", "detadphidetadphi0AfterMixed_2", - "detadphidetadphi0AfterMixed_3", "detadphidetadphi0AfterMixed_4", "detadphidetadphi0AfterMixed_5", - "detadphidetadphi0AfterMixed_6", "detadphidetadphi0AfterMixedqLCMS"}}; - - static constexpr std::string_view HistNamesRadii[7][9] = {{"detadphidetadphi0Before_0_0", "detadphidetadphi0Before_0_1", "detadphidetadphi0Before_0_2", - "detadphidetadphi0Before_0_3", "detadphidetadphi0Before_0_4", "detadphidetadphi0Before_0_5", - "detadphidetadphi0Before_0_6", "detadphidetadphi0Before_0_7", "detadphidetadphi0Before_0_8"}, - {"detadphidetadphi0Before_1_0", "detadphidetadphi0Before_1_1", "detadphidetadphi0Before_1_2", - "detadphidetadphi0Before_1_3", "detadphidetadphi0Before_1_4", "detadphidetadphi0Before_1_5", - "detadphidetadphi0Before_1_6", "detadphidetadphi0Before_1_7", "detadphidetadphi0Before_1_8"}, - {"detadphidetadphi0Before_2_0", "detadphidetadphi0Before_2_1", "detadphidetadphi0Before_2_2", - "detadphidetadphi0Before_2_3", "detadphidetadphi0Before_2_4", "detadphidetadphi0Before_2_5", - "detadphidetadphi0Before_2_6", "detadphidetadphi0Before_2_7", "detadphidetadphi0Before_2_8"}, - {"detadphidetadphi0Before_3_0", "detadphidetadphi0Before_3_1", "detadphidetadphi0Before_3_2", - "detadphidetadphi0Before_3_3", "detadphidetadphi0Before_3_4", "detadphidetadphi0Before_3_5", - "detadphidetadphi0Before_3_6", "detadphidetadphi0Before_3_7", "detadphidetadphi0Before_3_8"}, - {"detadphidetadphi0Before_4_0", "detadphidetadphi0Before_4_1", "detadphidetadphi0Before_4_2", - "detadphidetadphi0Before_4_3", "detadphidetadphi0Before_4_4", "detadphidetadphi0Before_4_5", - "detadphidetadphi0Before_4_6", "detadphidetadphi0Before_4_7", "detadphidetadphi0Before_4_8"}, - {"detadphidetadphi0Before_5_0", "detadphidetadphi0Before_5_1", "detadphidetadphi0Before_5_2", - "detadphidetadphi0Before_5_3", "detadphidetadphi0Before_5_4", "detadphidetadphi0Before_5_5", - "detadphidetadphi0Before_5_6", "detadphidetadphi0Before_5_7", "detadphidetadphi0Before_5_8"}, - {"detadphidetadphi0Before_6_0", "detadphidetadphi0Before_6_1", "detadphidetadphi0Before_6_2", - "detadphidetadphi0Before_6_3", "detadphidetadphi0Before_6_4", "detadphidetadphi0Before_6_5", - "detadphidetadphi0Before_6_6", "detadphidetadphi0Before_6_7", "detadphidetadphi0Before_6_8"}}; - - static constexpr o2::aod::femtouniverseparticle::ParticleType kPartOneType = partOne; ///< Type of particle 1 - static constexpr o2::aod::femtouniverseparticle::ParticleType kPartTwoType = partTwo; ///< Type of particle 2 - - static constexpr float TmpRadiiTPC[9] = {85., 105., 125., 145., 165., 185., 205., 225., 245.}; - - static constexpr uint32_t kSignMinusMask = 1; - static constexpr uint32_t kSignPlusMask = 1 << 1; - static constexpr uint32_t kValue0 = 0; - - float chosenRadii; - float cutDeltaPhiStarMax; - float cutDeltaPhiStarMin; - float cutDeltaEtaMax; - float cutDeltaEtaMin; - float magfield; - bool plotForEveryRadii = false; - float cutPhiInvMassLow; - float cutPhiInvMassHigh; - bool isSameSignCPR = false; - - std::array, 2>, 7> histdetadpisame{}; - std::array, 2>, 7> histdetadpimixed{}; - std::array, 9>, 7> histdetadpiRadii{}; - - std::shared_ptr histdetadpiqlcmssame{}; - std::shared_ptr histdetadpiqlcmsmixed{}; - - /// Calculate phi at all required radii stored in TmpRadiiTPC - /// Magnetic field to be provided in Tesla - template - void phiAtRadiiTPC(const T& part, std::vector& tmpVec) - { - - float phi0 = part.phi(); - // Start: Get the charge from cutcontainer using masks - float charge = 0.; - if ((part.cut() & kSignMinusMask) == kValue0 && (part.cut() & kSignPlusMask) == kValue0) { - charge = 0; - } else if ((part.cut() & kSignPlusMask) == kSignPlusMask) { - charge = 1; - } else if ((part.cut() & kSignMinusMask) == kSignMinusMask) { - charge = -1; + if constexpr (kPartOneType == o2::aod::femtouniverseparticle::ParticleType::kTrack && kPartTwoType == o2::aod::femtouniverseparticle::ParticleType::kTrack) { + /// Track-Track combination + // check if provided particles are in agreement with the class instantiation + if (part1.partType() != o2::aod::femtouniverseparticle::ParticleType::kTrack || part2.partType() != o2::aod::femtouniverseparticle::ParticleType::kTrack) { + LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar instantiation! Please provide kTrack,kTrack candidates."; + return false; + } + auto deta = part1.eta() - part2.eta(); + auto dphiAvg = averagePhiStar(part1, part2, 0); + auto distfrac = averagePhiStarFrac(part1, part2, DistMax); + if (ChosenEventType == femto_universe_container::EventType::same) { + histdetadpisame[0][0]->Fill(deta, dphiAvg); + } else if (ChosenEventType == femto_universe_container::EventType::mixed) { + histdetadpimixed[0][0]->Fill(deta, dphiAvg); } else { - LOG(fatal) << "FemtoUniverseDetaDphiStar: Charge bits are set wrong!"; - } - // End: Get the charge from cutcontainer using masks - float pt = part.pt(); - for (size_t i = 0; i < 9; i++) { - double arg = 0.3 * charge * magfield * TmpRadiiTPC[i] * 0.01 / (2. * pt); - if (std::abs(arg) < 1.0) { - tmpVec.push_back(phi0 - std::asin(arg)); - } else { - tmpVec.push_back(999.0); - } + LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed."; } - } - /// Calculate average phi - template - float averagePhiStar(const T1& part1, const T2& part2, int iHist) - { - std::vector tmpVec1; - std::vector tmpVec2; - phiAtRadiiTPC(part1, tmpVec1); - phiAtRadiiTPC(part2, tmpVec2); - int num = tmpVec1.size(); - float dPhiAvg = 0; - float dphi = 0; - int entries = 0; - for (int i = 0; i < num; i++) { - if (tmpVec1.at(i) != 999 && tmpVec2.at(i) != 999) { - dphi = tmpVec1.at(i) - tmpVec2.at(i); - entries++; + if (IsDphiAvgOrDist) { + if (std::pow(dphiAvg, 2) / std::pow(cutDeltaPhiStarMax, 2) + std::pow(deta, 2) / std::pow(cutDeltaEtaMax, 2) < 1.) { + return true; } else { - dphi = 0; + if (ChosenEventType == femto_universe_container::EventType::same) { + histdetadpisame[0][1]->Fill(deta, dphiAvg); + } else if (ChosenEventType == femto_universe_container::EventType::mixed) { + histdetadpimixed[0][1]->Fill(deta, dphiAvg); + } else { + LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed."; + } + return false; } - dphi = TVector2::Phi_mpi_pi(dphi); - dPhiAvg += dphi; - if (plotForEveryRadii) { - histdetadpiRadii[iHist][i]->Fill(part1.eta() - part2.eta(), dphi); + } else { + if (((deta > cutDeltaEtaMin) && (deta < cutDeltaEtaMax)) && (distfrac > FracMax)) { + return true; + } else { + if (ChosenEventType == femto_universe_container::EventType::same) { + histdetadpisame[0][1]->Fill(deta, dphiAvg); + } else if (ChosenEventType == femto_universe_container::EventType::mixed) { + histdetadpimixed[0][1]->Fill(deta, dphiAvg); + } else { + LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed."; + } + return false; } } - return dPhiAvg / static_cast(entries); + + } else { + LOG(fatal) << "FemtoUniversePairCleaner: Combination of objects not defined - quitting!"; + return false; } + } - /// Calculate average phi - template - float averagePhiStarFrac(const T1& part1, const T2& part2, float maxdist) - { - std::vector tmpVec1; - std::vector tmpVec2; - phiAtRadiiTPC(part1, tmpVec1); - phiAtRadiiTPC(part2, tmpVec2); - int num = tmpVec1.size(); - float dphi = 0; - int entries = 0; - double distance = 0; - int badpoints = 0; - - for (int i = 0; i < num; i++) { - if (tmpVec1.at(i) != 999 && tmpVec2.at(i) != 999) { - dphi = tmpVec1.at(i) - tmpVec2.at(i); - entries++; - } else { - dphi = 0; - } - dphi = TVector2::Phi_mpi_pi(dphi); - distance = 2 * TMath::Sin(TMath::Abs(dphi) * 0.5) * TmpRadiiTPC[i]; - if (distance < maxdist) { - badpoints++; - } + /// Check if pair is close or not + template + void ClosePairqLCMS(Part const& part1, Part const& part2, float lmagfield, uint8_t ChosenEventType, double qlcms) // add typename Parts and variable parts for adding MClabels + { + magfield = lmagfield; + if constexpr (kPartOneType == o2::aod::femtouniverseparticle::ParticleType::kTrack && kPartTwoType == o2::aod::femtouniverseparticle::ParticleType::kTrack) { + auto deta = part1.eta() - part2.eta(); + auto dphiAvg = averagePhiStar(part1, part2, 0); + + if (ChosenEventType == femto_universe_container::EventType::same) { + histdetadpiqlcmssame->Fill(qlcms, deta, dphiAvg); + } else if (ChosenEventType == femto_universe_container::EventType::mixed) { + histdetadpiqlcmsmixed->Fill(qlcms, deta, dphiAvg); + } else { + LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed."; } - return badpoints / entries; } + } - // Get particle charge from mask - template - float getCharge(const T1& part) - { - float charge = 0; - if ((part.cut() & kSignMinusMask) == kValue0 && (part.cut() & kSignPlusMask) == kValue0) { - charge = 0; - } else if ((part.cut() & kSignPlusMask) == kSignPlusMask) { - charge = 1; - } else if ((part.cut() & kSignMinusMask) == kSignMinusMask) { - charge = -1; + private: + HistogramRegistry* mHistogramRegistry = nullptr; ///< For main output + HistogramRegistry* mHistogramRegistryQA = nullptr; ///< For QA output + static constexpr std::string_view DirNames[8] = {"kTrack_kTrack/", "kTrack_kV0/", "kV0_kV0/", "kTrack_kPhi/", "kTrack_kD0/", "kCascade_kCascade/", "kTrack_kCascade/", "kV0_kCascade/"}; + + static constexpr std::string_view HistNamesSame[2][8] = {{"detadphidetadphi0BeforeSame_0", "detadphidetadphi0BeforeSame_1", "detadphidetadphi0BeforeSame_2", + "detadphidetadphi0BeforeSame_3", "detadphidetadphi0BeforeSame_4", "detadphidetadphi0BeforeSame_5", + "detadphidetadphi0BeforeSame_6", "detadphidetadphi0BeforeSameqLCMS"}, + {"detadphidetadphi0AfterSame_0", "detadphidetadphi0AfterSame_1", "detadphidetadphi0AfterSame_2", + "detadphidetadphi0AfterSame_3", "detadphidetadphi0AfterSame_4", "detadphidetadphi0AfterSame_5", + "detadphidetadphi0AfterSame_6", "detadphidetadphi0AfterSameqLCMS"}}; + static constexpr std::string_view HistNamesMixed[2][8] = {{"detadphidetadphi0BeforeMixed_0", "detadphidetadphi0BeforeMixed_1", "detadphidetadphi0BeforeMixed_2", + "detadphidetadphi0BeforeMixed_3", "detadphidetadphi0BeforeMixed_4", "detadphidetadphi0BeforeMixed_5", + "detadphidetadphi0BeforeMixed_6", "detadphidetadphi0BeforeMixedqLCMS"}, + {"detadphidetadphi0AfterMixed_0", "detadphidetadphi0AfterMixed_1", "detadphidetadphi0AfterMixed_2", + "detadphidetadphi0AfterMixed_3", "detadphidetadphi0AfterMixed_4", "detadphidetadphi0AfterMixed_5", + "detadphidetadphi0AfterMixed_6", "detadphidetadphi0AfterMixedqLCMS"}}; + + static constexpr std::string_view HistNamesRadii[7][9] = {{"detadphidetadphi0Before_0_0", "detadphidetadphi0Before_0_1", "detadphidetadphi0Before_0_2", + "detadphidetadphi0Before_0_3", "detadphidetadphi0Before_0_4", "detadphidetadphi0Before_0_5", + "detadphidetadphi0Before_0_6", "detadphidetadphi0Before_0_7", "detadphidetadphi0Before_0_8"}, + {"detadphidetadphi0Before_1_0", "detadphidetadphi0Before_1_1", "detadphidetadphi0Before_1_2", + "detadphidetadphi0Before_1_3", "detadphidetadphi0Before_1_4", "detadphidetadphi0Before_1_5", + "detadphidetadphi0Before_1_6", "detadphidetadphi0Before_1_7", "detadphidetadphi0Before_1_8"}, + {"detadphidetadphi0Before_2_0", "detadphidetadphi0Before_2_1", "detadphidetadphi0Before_2_2", + "detadphidetadphi0Before_2_3", "detadphidetadphi0Before_2_4", "detadphidetadphi0Before_2_5", + "detadphidetadphi0Before_2_6", "detadphidetadphi0Before_2_7", "detadphidetadphi0Before_2_8"}, + {"detadphidetadphi0Before_3_0", "detadphidetadphi0Before_3_1", "detadphidetadphi0Before_3_2", + "detadphidetadphi0Before_3_3", "detadphidetadphi0Before_3_4", "detadphidetadphi0Before_3_5", + "detadphidetadphi0Before_3_6", "detadphidetadphi0Before_3_7", "detadphidetadphi0Before_3_8"}, + {"detadphidetadphi0Before_4_0", "detadphidetadphi0Before_4_1", "detadphidetadphi0Before_4_2", + "detadphidetadphi0Before_4_3", "detadphidetadphi0Before_4_4", "detadphidetadphi0Before_4_5", + "detadphidetadphi0Before_4_6", "detadphidetadphi0Before_4_7", "detadphidetadphi0Before_4_8"}, + {"detadphidetadphi0Before_5_0", "detadphidetadphi0Before_5_1", "detadphidetadphi0Before_5_2", + "detadphidetadphi0Before_5_3", "detadphidetadphi0Before_5_4", "detadphidetadphi0Before_5_5", + "detadphidetadphi0Before_5_6", "detadphidetadphi0Before_5_7", "detadphidetadphi0Before_5_8"}, + {"detadphidetadphi0Before_6_0", "detadphidetadphi0Before_6_1", "detadphidetadphi0Before_6_2", + "detadphidetadphi0Before_6_3", "detadphidetadphi0Before_6_4", "detadphidetadphi0Before_6_5", + "detadphidetadphi0Before_6_6", "detadphidetadphi0Before_6_7", "detadphidetadphi0Before_6_8"}}; + + static constexpr o2::aod::femtouniverseparticle::ParticleType kPartOneType = partOne; ///< Type of particle 1 + static constexpr o2::aod::femtouniverseparticle::ParticleType kPartTwoType = partTwo; ///< Type of particle 2 + + static constexpr float TmpRadiiTPC[9] = {85., 105., 125., 145., 165., 185., 205., 225., 245.}; + + static constexpr uint32_t kSignMinusMask = 1; + static constexpr uint32_t kSignPlusMask = 1 << 1; + static constexpr uint32_t kValue0 = 0; + + float chosenRadii; + float cutDeltaPhiStarMax; + float cutDeltaPhiStarMin; + float cutDeltaEtaMax; + float cutDeltaEtaMin; + float magfield; + bool plotForEveryRadii = false; + float cutPhiInvMassLow; + float cutPhiInvMassHigh; + bool isSameSignCPR = false; + + std::array, 2>, 7> histdetadpisame{}; + std::array, 2>, 7> histdetadpimixed{}; + std::array, 9>, 7> histdetadpiRadii{}; + + std::shared_ptr histdetadpiqlcmssame{}; + std::shared_ptr histdetadpiqlcmsmixed{}; + + /// Calculate phi at all required radii stored in TmpRadiiTPC + /// Magnetic field to be provided in Tesla + template + void phiAtRadiiTPC(const T& part, std::vector& tmpVec) + { + + float phi0 = part.phi(); + // Start: Get the charge from cutcontainer using masks + float charge = 0.; + if ((part.cut() & kSignMinusMask) == kValue0 && (part.cut() & kSignPlusMask) == kValue0) { + charge = 0; + } else if ((part.cut() & kSignPlusMask) == kSignPlusMask) { + charge = 1; + } else if ((part.cut() & kSignMinusMask) == kSignMinusMask) { + charge = -1; + } else { + LOG(fatal) << "FemtoUniverseDetaDphiStar: Charge bits are set wrong!"; + } + // End: Get the charge from cutcontainer using masks + float pt = part.pt(); + for (size_t i = 0; i < 9; i++) { + double arg = 0.3 * charge * magfield * TmpRadiiTPC[i] * 0.01 / (2. * pt); + if (std::abs(arg) < 1.0) { + tmpVec.push_back(phi0 - std::asin(arg)); } else { - LOG(fatal) << "FemtoUniverseDetaDphiStar: Charge bits are set wrong!"; + tmpVec.push_back(999.0); } - return charge; } + } - // Calculate phi* as in https://github.com/alisw/AliPhysics/blob/master/PWGCF/FEMTOSCOPY/AliFemtoUser/AliFemtoPairCutRadialDistance.cxx - template - double calculateDphiStar(const T1& part1, const T2& part2) - { - float charge1 = getCharge(part1); - float charge2 = getCharge(part2); - - double deltaphiconstFD = 0.3 / 2; - // double deltaphiconstAF = 0.15; - double afsi0b = deltaphiconstFD * magfield * charge1 * chosenRadii / part1.pt(); - double afsi1b = deltaphiconstFD * magfield * charge2 * chosenRadii / part2.pt(); - double dphis = 0.0; + /// Calculate average phi + template + float averagePhiStar(const T1& part1, const T2& part2, int iHist) + { + std::vector tmpVec1; + std::vector tmpVec2; + phiAtRadiiTPC(part1, tmpVec1); + phiAtRadiiTPC(part2, tmpVec2); + int num = tmpVec1.size(); + float dPhiAvg = 0; + float dphi = 0; + int entries = 0; + for (int i = 0; i < num; i++) { + if (tmpVec1.at(i) != 999 && tmpVec2.at(i) != 999) { + dphi = tmpVec1.at(i) - tmpVec2.at(i); + entries++; + } else { + dphi = 0; + } + dphi = TVector2::Phi_mpi_pi(dphi); + dPhiAvg += dphi; + if (plotForEveryRadii) { + histdetadpiRadii[iHist][i]->Fill(part1.eta() - part2.eta(), dphi); + } + } + return dPhiAvg / static_cast(entries); + } - if (std::abs(afsi0b) < 1.0 && std::abs(afsi0b) < 1.0) { - dphis = part2.phi() - part1.phi() + std::asin(afsi1b) - std::asin(afsi0b); + /// Calculate average phi + template + float averagePhiStarFrac(const T1& part1, const T2& part2, float maxdist) + { + std::vector tmpVec1; + std::vector tmpVec2; + phiAtRadiiTPC(part1, tmpVec1); + phiAtRadiiTPC(part2, tmpVec2); + int num = tmpVec1.size(); + float dphi = 0; + int entries = 0; + double distance = 0; + int badpoints = 0; + + for (int i = 0; i < num; i++) { + if (tmpVec1.at(i) != 999 && tmpVec2.at(i) != 999) { + dphi = tmpVec1.at(i) - tmpVec2.at(i); + entries++; + } else { + dphi = 0; + } + dphi = TVector2::Phi_mpi_pi(dphi); + distance = 2 * TMath::Sin(TMath::Abs(dphi) * 0.5) * TmpRadiiTPC[i]; + if (distance < maxdist) { + badpoints++; } - return dphis; } - }; + return badpoints / entries; + } + + // Get particle charge from mask + template + float getCharge(const T1& part) + { + float charge = 0; + if ((part.cut() & kSignMinusMask) == kValue0 && (part.cut() & kSignPlusMask) == kValue0) { + charge = 0; + } else if ((part.cut() & kSignPlusMask) == kSignPlusMask) { + charge = 1; + } else if ((part.cut() & kSignMinusMask) == kSignMinusMask) { + charge = -1; + } else { + LOG(fatal) << "FemtoUniverseDetaDphiStar: Charge bits are set wrong!"; + } + return charge; + } + + // Calculate phi* as in https://github.com/alisw/AliPhysics/blob/master/PWGCF/FEMTOSCOPY/AliFemtoUser/AliFemtoPairCutRadialDistance.cxx + template + double calculateDphiStar(const T1& part1, const T2& part2) + { + float charge1 = getCharge(part1); + float charge2 = getCharge(part2); + + double deltaphiconstFD = 0.3 / 2; + // double deltaphiconstAF = 0.15; + double afsi0b = deltaphiconstFD * magfield * charge1 * chosenRadii / part1.pt(); + double afsi1b = deltaphiconstFD * magfield * charge2 * chosenRadii / part2.pt(); + double dphis = 0.0; + + if (std::abs(afsi0b) < 1.0 && std::abs(afsi0b) < 1.0) { + dphis = part2.phi() - part1.phi() + std::asin(afsi1b) - std::asin(afsi0b); + } + return dphis; + } +}; } /* namespace femto_universe */ } /* namespace o2::analysis */