|
| 1 | +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. |
| 2 | +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. |
| 3 | +// All rights not expressly granted are reserved. |
| 4 | +// |
| 5 | +// This software is distributed under the terms of the GNU General Public |
| 6 | +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". |
| 7 | +// |
| 8 | +// In applying this license CERN does not waive the privileges and immunities |
| 9 | +// granted to it by virtue of its status as an Intergovernmental Organization |
| 10 | +// or submit itself to any jurisdiction. |
| 11 | + |
| 12 | +/// \file FemtoWorldDetaDphiStar.h |
| 13 | +/// \brief FemtoWorldDetaDphiStar - Checks particles for the close pair rejection. |
| 14 | +/// \author Laura Serksnyte, TU München, laura.serksnyte@tum.de |
| 15 | + |
| 16 | +#ifndef ANALYSIS_TASKS_PWGCF_O2FEMTO_O2FEMTODETADPHISTAR_H_ |
| 17 | +#define ANALYSIS_TASKS_PWGCF_O2FEMTO_O2FEMTODETADPHISTAR_H_ |
| 18 | + |
| 19 | +#include "PWGCF/DataModel/FemtoDerived.h" |
| 20 | + |
| 21 | +#include "Framework/HistogramRegistry.h" |
| 22 | +#include <string> |
| 23 | + |
| 24 | +namespace o2::analysis |
| 25 | +{ |
| 26 | +namespace femtoWorld |
| 27 | +{ |
| 28 | + |
| 29 | +/// \class FemtoWorldDetaDphiStar |
| 30 | +/// \brief Class to check particles for the close pair rejection. |
| 31 | +/// \tparam partOne Type of particle 1 (Track/V0/Cascade/...) |
| 32 | +/// \tparam partTwo Type of particle 2 (Track/V0/Cascade/...) |
| 33 | +template <o2::aod::femtodreamparticle::ParticleType partOne, o2::aod::femtodreamparticle::ParticleType partTwo> |
| 34 | +class FemtoWorldDetaDphiStar |
| 35 | +{ |
| 36 | + public: |
| 37 | + /// Destructor |
| 38 | + virtual ~FemtoWorldDetaDphiStar() = default; |
| 39 | + /// Initalization of the histograms and setting required values |
| 40 | + void init(HistogramRegistry* registry, HistogramRegistry* registryQA, float ldeltaPhiMax, float ldeltaEtaMax, bool lplotForEveryRadii) |
| 41 | + { |
| 42 | + deltaPhiMax = ldeltaPhiMax; |
| 43 | + deltaEtaMax = ldeltaEtaMax; |
| 44 | + plotForEveryRadii = lplotForEveryRadii; |
| 45 | + mHistogramRegistry = registry; |
| 46 | + mHistogramRegistryQA = registryQA; |
| 47 | + |
| 48 | + if constexpr (mPartOneType == o2::aod::femtodreamparticle::ParticleType::kTrack && mPartTwoType == o2::aod::femtodreamparticle::ParticleType::kTrack) { |
| 49 | + std::string dirName = static_cast<std::string>(dirNames[0]); |
| 50 | + histdetadpi[0][0] = mHistogramRegistry->add<TH2>((dirName + static_cast<std::string>(histNames[0][0])).c_str(), "; #Delta #eta; #Delta #phi", kTH2F, {{100, -0.15, 0.15}, {100, -0.15, 0.15}}); |
| 51 | + histdetadpi[0][1] = mHistogramRegistry->add<TH2>((dirName + static_cast<std::string>(histNames[1][0])).c_str(), "; #Delta #eta; #Delta #phi", kTH2F, {{100, -0.15, 0.15}, {100, -0.15, 0.15}}); |
| 52 | + if (plotForEveryRadii) { |
| 53 | + for (int i = 0; i < 9; i++) { |
| 54 | + histdetadpiRadii[0][i] = mHistogramRegistryQA->add<TH2>((dirName + static_cast<std::string>(histNamesRadii[0][i])).c_str(), "; #Delta #eta; #Delta #phi", kTH2F, {{100, -0.15, 0.15}, {100, -0.15, 0.15}}); |
| 55 | + } |
| 56 | + } |
| 57 | + } |
| 58 | + if constexpr (mPartOneType == o2::aod::femtodreamparticle::ParticleType::kTrack && mPartTwoType == o2::aod::femtodreamparticle::ParticleType::kV0) { |
| 59 | + for (int i = 0; i < 2; i++) { |
| 60 | + std::string dirName = static_cast<std::string>(dirNames[1]); |
| 61 | + histdetadpi[i][0] = mHistogramRegistry->add<TH2>((dirName + static_cast<std::string>(histNames[0][i])).c_str(), "; #Delta #eta; #Delta #phi", kTH2F, {{100, -0.15, 0.15}, {100, -0.15, 0.15}}); |
| 62 | + histdetadpi[i][1] = mHistogramRegistry->add<TH2>((dirName + static_cast<std::string>(histNames[1][i])).c_str(), "; #Delta #eta; #Delta #phi", kTH2F, {{100, -0.15, 0.15}, {100, -0.15, 0.15}}); |
| 63 | + if (plotForEveryRadii) { |
| 64 | + for (int j = 0; j < 9; j++) { |
| 65 | + histdetadpiRadii[i][j] = mHistogramRegistryQA->add<TH2>((dirName + static_cast<std::string>(histNamesRadii[i][j])).c_str(), "; #Delta #eta; #Delta #phi", kTH2F, {{100, -0.15, 0.15}, {100, -0.15, 0.15}}); |
| 66 | + } |
| 67 | + } |
| 68 | + } |
| 69 | + } |
| 70 | + } |
| 71 | + /// Check if pair is close or not |
| 72 | + template <typename Part, typename Parts> |
| 73 | + bool isClosePair(Part const& part1, Part const& part2, Parts const& particles, float lmagfield) |
| 74 | + { |
| 75 | + magfield = lmagfield; |
| 76 | + |
| 77 | + if constexpr (mPartOneType == o2::aod::femtodreamparticle::ParticleType::kTrack && mPartTwoType == o2::aod::femtodreamparticle::ParticleType::kTrack) { |
| 78 | + /// Track-Track combination |
| 79 | + // check if provided particles are in agreement with the class instantiation |
| 80 | + if (part1.partType() != o2::aod::femtodreamparticle::ParticleType::kTrack || part2.partType() != o2::aod::femtodreamparticle::ParticleType::kTrack) { |
| 81 | + LOG(fatal) << "FemtoWorldDetaDphiStar: passed arguments don't agree with FemtoWorldDetaDphiStar instantiation! Please provide kTrack,kTrack candidates."; |
| 82 | + return false; |
| 83 | + } |
| 84 | + auto deta = part1.eta() - part2.eta(); |
| 85 | + auto dphiAvg = AveragePhiStar(part1, part2, 0); |
| 86 | + histdetadpi[0][0]->Fill(deta, dphiAvg); |
| 87 | + if (pow(dphiAvg, 2) / pow(deltaPhiMax, 2) + pow(deta, 2) / pow(deltaEtaMax, 2) < 1.) { |
| 88 | + return true; |
| 89 | + } else { |
| 90 | + histdetadpi[0][1]->Fill(deta, dphiAvg); |
| 91 | + return false; |
| 92 | + } |
| 93 | + |
| 94 | + } else if constexpr (mPartOneType == o2::aod::femtodreamparticle::ParticleType::kTrack && mPartTwoType == o2::aod::femtodreamparticle::ParticleType::kV0) { |
| 95 | + /// Track-V0 combination |
| 96 | + // check if provided particles are in agreement with the class instantiation |
| 97 | + if (part1.partType() != o2::aod::femtodreamparticle::ParticleType::kTrack || part2.partType() != o2::aod::femtodreamparticle::ParticleType::kV0) { |
| 98 | + LOG(fatal) << "FemtoWorldDetaDphiStar: passed arguments don't agree with FemtoWorldDetaDphiStar instantiation! Please provide kTrack,kV0 candidates."; |
| 99 | + return false; |
| 100 | + } |
| 101 | + |
| 102 | + bool pass = false; |
| 103 | + for (int i = 0; i < 2; i++) { |
| 104 | + auto indexOfDaughter = part2.index() - 2 + i; |
| 105 | + auto daughter = particles.begin() + indexOfDaughter; |
| 106 | + auto deta = part1.eta() - daughter.eta(); |
| 107 | + auto dphiAvg = AveragePhiStar(part1, *daughter, i); |
| 108 | + histdetadpi[i][0]->Fill(deta, dphiAvg); |
| 109 | + if (pow(dphiAvg, 2) / pow(deltaPhiMax, 2) + pow(deta, 2) / pow(deltaEtaMax, 2) < 1.) { |
| 110 | + pass = true; |
| 111 | + } else { |
| 112 | + histdetadpi[i][1]->Fill(deta, dphiAvg); |
| 113 | + } |
| 114 | + } |
| 115 | + return pass; |
| 116 | + } else { |
| 117 | + LOG(fatal) << "FemtoWorldPairCleaner: Combination of objects not defined - quitting!"; |
| 118 | + return false; |
| 119 | + } |
| 120 | + } |
| 121 | + |
| 122 | + private: |
| 123 | + HistogramRegistry* mHistogramRegistry = nullptr; ///< For main output |
| 124 | + HistogramRegistry* mHistogramRegistryQA = nullptr; ///< For QA output |
| 125 | + static constexpr std::string_view dirNames[2] = {"kTrack_kTrack/", "kTrack_kV0/"}; |
| 126 | + |
| 127 | + static constexpr std::string_view histNames[2][2] = {{"detadphidetadphi0Before_0", "detadphidetadphi0Before_1"}, |
| 128 | + {"detadphidetadphi0After_0", "detadphidetadphi0After_1"}}; |
| 129 | + static constexpr std::string_view histNamesRadii[2][9] = {{"detadphidetadphi0Before_0_0", "detadphidetadphi0Before_0_1", "detadphidetadphi0Before_0_2", |
| 130 | + "detadphidetadphi0Before_0_3", "detadphidetadphi0Before_0_4", "detadphidetadphi0Before_0_5", |
| 131 | + "detadphidetadphi0Before_0_6", "detadphidetadphi0Before_0_7", "detadphidetadphi0Before_0_8"}, |
| 132 | + {"detadphidetadphi0Before_1_0", "detadphidetadphi0Before_1_1", "detadphidetadphi0Before_1_2", |
| 133 | + "detadphidetadphi0Before_1_3", "detadphidetadphi0Before_1_4", "detadphidetadphi0Before_1_5", |
| 134 | + "detadphidetadphi0Before_1_6", "detadphidetadphi0Before_1_7", "detadphidetadphi0Before_1_8"}}; |
| 135 | + |
| 136 | + static constexpr o2::aod::femtodreamparticle::ParticleType mPartOneType = partOne; ///< Type of particle 1 |
| 137 | + static constexpr o2::aod::femtodreamparticle::ParticleType mPartTwoType = partTwo; ///< Type of particle 2 |
| 138 | + |
| 139 | + static constexpr float tmpRadiiTPC[9] = {85., 105., 125., 145., 165., 185., 205., 225., 245.}; |
| 140 | + |
| 141 | + static constexpr uint32_t kSignMinusMask = 1; |
| 142 | + static constexpr uint32_t kSignPlusMask = 1 << 1; |
| 143 | + static constexpr uint32_t kValue0 = 0; |
| 144 | + |
| 145 | + float deltaPhiMax; |
| 146 | + float deltaEtaMax; |
| 147 | + float magfield; |
| 148 | + bool plotForEveryRadii = false; |
| 149 | + |
| 150 | + std::array<std::array<std::shared_ptr<TH2>, 2>, 2> histdetadpi{}; |
| 151 | + std::array<std::array<std::shared_ptr<TH2>, 9>, 2> histdetadpiRadii{}; |
| 152 | + |
| 153 | + /// Calculate phi at all required radii stored in tmpRadiiTPC |
| 154 | + /// Magnetic field to be provided in Tesla |
| 155 | + template <typename T> |
| 156 | + void PhiAtRadiiTPC(const T& part, std::vector<float>& tmpVec) |
| 157 | + { |
| 158 | + |
| 159 | + float phi0 = part.phi(); |
| 160 | + // Start: Get the charge from cutcontainer using masks |
| 161 | + float charge = 0.; |
| 162 | + if ((part.cut() & kSignMinusMask) == kValue0 && (part.cut() & kSignPlusMask) == kValue0) { |
| 163 | + charge = 0; |
| 164 | + } else if ((part.cut() & kSignPlusMask) == kSignPlusMask) { |
| 165 | + charge = 1; |
| 166 | + } else if ((part.cut() & kSignMinusMask) == kSignMinusMask) { |
| 167 | + charge = -1; |
| 168 | + } else { |
| 169 | + LOG(fatal) << "FemtoWorldDetaDphiStar: Charge bits are set wrong!"; |
| 170 | + } |
| 171 | + // End: Get the charge from cutcontainer using masks |
| 172 | + float pt = part.pt(); |
| 173 | + for (size_t i = 0; i < 9; i++) { |
| 174 | + tmpVec.push_back(phi0 - std::asin(0.3 * charge * 0.1 * magfield * tmpRadiiTPC[i] * 0.01 / (2. * pt))); |
| 175 | + } |
| 176 | + } |
| 177 | + |
| 178 | + /// Calculate average phi |
| 179 | + template <typename T1, typename T2> |
| 180 | + float AveragePhiStar(const T1& part1, const T2& part2, int iHist) |
| 181 | + { |
| 182 | + std::vector<float> tmpVec1; |
| 183 | + std::vector<float> tmpVec2; |
| 184 | + PhiAtRadiiTPC(part1, tmpVec1); |
| 185 | + PhiAtRadiiTPC(part2, tmpVec2); |
| 186 | + const int num = tmpVec1.size(); |
| 187 | + float dPhiAvg = 0; |
| 188 | + for (int i = 0; i < num; i++) { |
| 189 | + float dphi = tmpVec1.at(i) - tmpVec2.at(i); |
| 190 | + dphi = TVector2::Phi_mpi_pi(dphi); |
| 191 | + dPhiAvg += dphi; |
| 192 | + if (plotForEveryRadii) { |
| 193 | + histdetadpiRadii[iHist][i]->Fill(part1.eta() - part2.eta(), dphi); |
| 194 | + } |
| 195 | + } |
| 196 | + return (dPhiAvg / (float)num); |
| 197 | + } |
| 198 | +}; |
| 199 | + |
| 200 | +} /* namespace femtoWorld */ |
| 201 | +} /* namespace o2::analysis */ |
| 202 | + |
| 203 | +#endif /* ANALYSIS_TASKS_PWGCF_O2FEMTO_O2FEMTODETADPHISTAR_H_ */ |
0 commit comments