|
| 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 | +/// \brief utility functions for femto task |
| 13 | +/// \author Sofia Tomassini, Gleb Romanenko, Nicolò Jacazio |
| 14 | +/// \since 30 May 2023 |
| 15 | + |
| 16 | +#ifndef PWGCF_FEMTO3D_CORE_FEMTO3DPAIRTASK_H_ |
| 17 | +#define PWGCF_FEMTO3D_CORE_FEMTO3DPAIRTASK_H_ |
| 18 | + |
| 19 | +// #include "Framework/ASoA.h" |
| 20 | +// #include "Framework/DataTypes.h" |
| 21 | +// #include "Framework/AnalysisDataModel.h" |
| 22 | +// #include "Common/DataModel/PIDResponse.h" |
| 23 | +// #include "Framework/Logger.h" |
| 24 | +// #include "Common/DataModel/Multiplicity.h" |
| 25 | + |
| 26 | +#include <vector> |
| 27 | +#include "TLorentzVector.h" |
| 28 | +#include "TVector3.h" |
| 29 | +#include "TDatabasePDG.h" |
| 30 | + |
| 31 | +double particle_mass(int PDGcode) |
| 32 | +{ |
| 33 | + // if(PDGcode == 2212) return TDatabasePDG::Instance()->GetParticle(2212)->Mass(); |
| 34 | + if (PDGcode == 1000010020) |
| 35 | + return 1.87561294257; |
| 36 | + else |
| 37 | + return TDatabasePDG::Instance()->GetParticle(PDGcode)->Mass(); |
| 38 | +} |
| 39 | + |
| 40 | +namespace o2::aod::singletrackselector |
| 41 | +{ |
| 42 | +template <typename Type> |
| 43 | +Type getBinIndex(float const& value, std::vector<float> const& binning, int const& NsubBins = 1) |
| 44 | +{ |
| 45 | + Type res = -100; |
| 46 | + for (int i = 0; i < binning.size() - 1; i++) { |
| 47 | + if (value >= binning[i] && binning[i + 1] > value) { |
| 48 | + if (NsubBins < 2) { |
| 49 | + res = (Type)i; |
| 50 | + break; |
| 51 | + } else { |
| 52 | + float subBinWidth = (binning[i + 1] - binning[i]) / NsubBins; |
| 53 | + int subBin = std::floor((value - binning[i]) / subBinWidth); |
| 54 | + int delimeter = std::pow(10, std::to_string(NsubBins).size()); |
| 55 | + |
| 56 | + res = (Type)i + (Type)subBin / delimeter; |
| 57 | + break; |
| 58 | + } |
| 59 | + } |
| 60 | + } |
| 61 | + return res; |
| 62 | +} |
| 63 | + |
| 64 | +//==================================================================================== |
| 65 | + |
| 66 | +float GetKstarFrom4vectors(TLorentzVector& first4momentum, TLorentzVector& second4momentum, bool isIdentical) |
| 67 | +{ |
| 68 | + if (isIdentical) { |
| 69 | + TLorentzVector fourmomentadiff = first4momentum - second4momentum; |
| 70 | + return 0.5 * abs(fourmomentadiff.Mag()); |
| 71 | + } else { |
| 72 | + TLorentzVector fourmomentasum = first4momentum + second4momentum; |
| 73 | + |
| 74 | + first4momentum.Boost((-1) * fourmomentasum.BoostVector()); |
| 75 | + second4momentum.Boost((-1) * fourmomentasum.BoostVector()); |
| 76 | + |
| 77 | + TVector3 qinv = first4momentum.Vect() - second4momentum.Vect(); |
| 78 | + return 0.5 * abs(qinv.Mag()); |
| 79 | + } |
| 80 | +} |
| 81 | + |
| 82 | +//==================================================================================== |
| 83 | + |
| 84 | +template <typename TrackType> |
| 85 | +class FemtoPair |
| 86 | +{ |
| 87 | + public: |
| 88 | + FemtoPair() {} |
| 89 | + FemtoPair(TrackType const& first, TrackType const& second) |
| 90 | + { |
| 91 | + _first = first; |
| 92 | + _second = second; |
| 93 | + } |
| 94 | + FemtoPair(TrackType const& first, TrackType const& second, const bool& isidentical) |
| 95 | + { |
| 96 | + _first = first; |
| 97 | + _second = second; |
| 98 | + _isidentical = isidentical; |
| 99 | + } |
| 100 | + |
| 101 | + FemtoPair(const FemtoPair& obj) |
| 102 | + { |
| 103 | + SetFirstParticle(obj.GetFirstParticle()); |
| 104 | + SetSecondParticle(obj.GetSecondParticle()); |
| 105 | + } |
| 106 | + explicit FemtoPair(const FemtoPair* obj) |
| 107 | + { |
| 108 | + SetFirstParticle(obj->GetFirstParticle()); |
| 109 | + SetSecondParticle(obj->GetSecondParticle()); |
| 110 | + } |
| 111 | + ~FemtoPair() {} |
| 112 | + FemtoPair& operator=(const FemtoPair& obj) |
| 113 | + { |
| 114 | + if (this != &obj) { |
| 115 | + SetFirstParticle(obj.GetFirstParticle()); |
| 116 | + SetSecondParticle(obj.GetSecondParticle()); |
| 117 | + } |
| 118 | + return *this; |
| 119 | + } |
| 120 | + |
| 121 | + void SetPair(TrackType const& first, TrackType const& second) |
| 122 | + { |
| 123 | + _first = first; |
| 124 | + _second = second; |
| 125 | + } |
| 126 | + void SetFirstParticle(TrackType const& first) { _first = first; } |
| 127 | + void SetSecondParticle(TrackType const& second) { _second = second; } |
| 128 | + void SetIdentical(const bool& isidentical) { _isidentical = isidentical; } |
| 129 | + void SetMagField1(const float& magfield1) { _magfield1 = magfield1; } |
| 130 | + void SetMagField2(const float& magfield2) { _magfield2 = magfield2; } |
| 131 | + void SetPDG1(const int& PDG1) { _PDG1 = PDG1; } |
| 132 | + void SetPDG2(const int& PDG2) { _PDG2 = PDG2; } |
| 133 | + void ResetPair(); |
| 134 | + void ResetAll(); |
| 135 | + |
| 136 | + TrackType* GetFirstParticle() const { return _first; } |
| 137 | + TrackType* GetSecondParticle() const { return _second; } |
| 138 | + bool IsIdentical() { return _isidentical; } |
| 139 | + |
| 140 | + bool IsClosePair(const float& deta = 0.01, const float& dphi = 0.01, const float& radius = 1.2); |
| 141 | + float GetEtaDiff() const |
| 142 | + { |
| 143 | + if (_first != NULL && _second != NULL) |
| 144 | + return _first->eta() - _second->eta(); |
| 145 | + else |
| 146 | + return 1000; |
| 147 | + } |
| 148 | + float GetPhiStarDiff(const float& radius = 1.2) const |
| 149 | + { |
| 150 | + if (_first != NULL && _second != NULL) |
| 151 | + return _first->phiStar(_magfield1, radius) - _second->phiStar(_magfield2, radius); |
| 152 | + else |
| 153 | + return 1000; |
| 154 | + } |
| 155 | + float GetKstar() const; |
| 156 | + float GetKt() const; |
| 157 | + |
| 158 | + private: |
| 159 | + TrackType _first = NULL; |
| 160 | + TrackType _second = NULL; |
| 161 | + float _magfield1 = 0.0, _magfield2 = 0.0; |
| 162 | + int _PDG1 = 0, _PDG2 = 0; |
| 163 | + bool _isidentical = true; |
| 164 | +}; |
| 165 | + |
| 166 | +template <typename TrackType> |
| 167 | +void FemtoPair<TrackType>::ResetPair() |
| 168 | +{ |
| 169 | + _first = NULL; |
| 170 | + _second = NULL; |
| 171 | +} |
| 172 | + |
| 173 | +template <typename TrackType> |
| 174 | +void FemtoPair<TrackType>::ResetAll() |
| 175 | +{ |
| 176 | + _first = NULL; |
| 177 | + _second = NULL; |
| 178 | + _magfield1 = 0.0; |
| 179 | + _magfield2 = 0.0; |
| 180 | + _PDG1 = 0; |
| 181 | + _PDG2 = 0; |
| 182 | + _isidentical = true; |
| 183 | +} |
| 184 | + |
| 185 | +template <typename TrackType> |
| 186 | +bool FemtoPair<TrackType>::IsClosePair(const float& deta, const float& dphi, const float& radius) |
| 187 | +{ |
| 188 | + if (_first == NULL || _second == NULL) |
| 189 | + return true; |
| 190 | + if (!(_magfield1 * _magfield2)) |
| 191 | + return true; |
| 192 | + if (abs(GetEtaDiff()) < deta && abs(GetPhiStarDiff(radius)) < dphi) |
| 193 | + return true; |
| 194 | + |
| 195 | + return false; |
| 196 | +} |
| 197 | + |
| 198 | +template <typename TrackType> |
| 199 | +float FemtoPair<TrackType>::GetKstar() const |
| 200 | +{ |
| 201 | + if (_first == NULL || _second == NULL) |
| 202 | + return -1000; |
| 203 | + if (!(_magfield1 * _magfield2)) |
| 204 | + return -1000; |
| 205 | + if (!(_PDG1 * _PDG2)) |
| 206 | + return -1000; |
| 207 | + |
| 208 | + TLorentzVector first4momentum; |
| 209 | + first4momentum.SetPtEtaPhiM(_first->pt(), _first->eta(), _first->phi(), particle_mass(_PDG1)); |
| 210 | + TLorentzVector second4momentum; |
| 211 | + second4momentum.SetPtEtaPhiM(_second->pt(), _second->eta(), _second->phi(), particle_mass(_PDG2)); |
| 212 | + |
| 213 | + return GetKstarFrom4vectors(first4momentum, second4momentum, _isidentical); |
| 214 | +} |
| 215 | + |
| 216 | +template <typename TrackType> |
| 217 | +float FemtoPair<TrackType>::GetKt() const |
| 218 | +{ |
| 219 | + if (_first == NULL || _second == NULL) |
| 220 | + return -1000; |
| 221 | + if (!(_magfield1 * _magfield2)) |
| 222 | + return -1000; |
| 223 | + if (!(_PDG1 * _PDG2)) |
| 224 | + return -1000; |
| 225 | + |
| 226 | + return 0.5 * std::sqrt(std::pow(_first->px() + _second->px(), 2) + std::pow(_first->py() + _second->py(), 2)); |
| 227 | +} |
| 228 | +} // namespace o2::aod::singletrackselector |
| 229 | + |
| 230 | +#endif // PWGCF_FEMTO3D_CORE_FEMTO3DPAIRTASK_H_ |
0 commit comments