|
| 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 create a table for single track selection. |
| 13 | +/// \author Sofia Tomassini |
| 14 | +/// \since 30 May 2023 |
| 15 | + |
| 16 | +#ifndef PWGCF_DATAMODEL_SINGLETRACKSELECTOR_H_ |
| 17 | +#define PWGCF_DATAMODEL_SINGLETRACKSELECTOR_H_ |
| 18 | + |
| 19 | +#include "Framework/ASoA.h" |
| 20 | +#include "Framework/AnalysisDataModel.h" |
| 21 | +#include "Common/DataModel/PIDResponse.h" |
| 22 | +#include "Framework/Logger.h" |
| 23 | +#include "Common/DataModel/Multiplicity.h" |
| 24 | + |
| 25 | +namespace o2::aod |
| 26 | +{ |
| 27 | +namespace singletrackselector |
| 28 | +{ |
| 29 | +template <typename binningType> |
| 30 | +typename binningType::binned_t packInTable(const float& valueToBin) |
| 31 | +{ |
| 32 | + if (valueToBin <= binningType::binned_min) { |
| 33 | + return binningType::underflowBin; |
| 34 | + } else if (valueToBin >= binningType::binned_max) { |
| 35 | + return binningType::overflowBin; |
| 36 | + } else { |
| 37 | + return static_cast<typename binningType::binned_t>(valueToBin / binningType::bin_width); |
| 38 | + } |
| 39 | +} |
| 40 | + |
| 41 | +template <typename binningType> |
| 42 | +float unPack(const typename binningType::binned_t& b) |
| 43 | +{ |
| 44 | + return static_cast<float>(binningType::bin_width * b); |
| 45 | +} |
| 46 | + |
| 47 | +template <typename binningType> |
| 48 | +typename binningType::binned_t packInTableOffset(const float& valueToBin) |
| 49 | +{ |
| 50 | + if (valueToBin <= binningType::binned_min) { |
| 51 | + return binningType::underflowBin; |
| 52 | + } else if (valueToBin >= binningType::binned_max) { |
| 53 | + return binningType::overflowBin; |
| 54 | + } else { |
| 55 | + return static_cast<typename binningType::binned_t>(((valueToBin - (binningType::binned_max - binningType::binned_min) * 0.5) / binningType::bin_width)); |
| 56 | + } |
| 57 | +} |
| 58 | + |
| 59 | +template <typename binningType> |
| 60 | +float unPackOffset(const typename binningType::binned_t& b) |
| 61 | +{ |
| 62 | + return static_cast<float>((binningType::binned_max - binningType::binned_min) * 0.5 + binningType::bin_width * b); |
| 63 | +} |
| 64 | + |
| 65 | +namespace storedcrossedrows |
| 66 | +{ |
| 67 | +struct binning { |
| 68 | + public: |
| 69 | + typedef int8_t binned_t; |
| 70 | + static constexpr int nbins = (1 << 8 * sizeof(binned_t)) - 2; |
| 71 | + static constexpr binned_t overflowBin = nbins >> 1; |
| 72 | + static constexpr binned_t underflowBin = -(nbins >> 1); |
| 73 | + static constexpr float binned_max = 253.5; |
| 74 | + static constexpr float binned_min = -0.5; |
| 75 | + static constexpr float bin_width = (binned_max - binned_min) / nbins; |
| 76 | +}; |
| 77 | +} // namespace storedcrossedrows |
| 78 | + |
| 79 | +namespace nsigma |
| 80 | +{ |
| 81 | +struct binning { |
| 82 | + public: |
| 83 | + typedef int8_t binned_t; |
| 84 | + static constexpr int nbins = (1 << 8 * sizeof(binned_t)) - 2; |
| 85 | + static constexpr binned_t overflowBin = nbins >> 1; |
| 86 | + static constexpr binned_t underflowBin = -(nbins >> 1); |
| 87 | + static constexpr float binned_max = 10.0; |
| 88 | + static constexpr float binned_min = -10.0; |
| 89 | + static constexpr float bin_width = (binned_max - binned_min) / nbins; |
| 90 | +}; |
| 91 | +} // namespace nsigma |
| 92 | + |
| 93 | +DECLARE_SOA_INDEX_COLUMN(Collision, collision); // Index to the collision |
| 94 | +DECLARE_SOA_COLUMN(HasTOF, hasTOF, bool); |
| 95 | +DECLARE_SOA_COLUMN(HasITS, hasITS, bool); |
| 96 | +DECLARE_SOA_COLUMN(Px, px, float); // Momentum of the track |
| 97 | +DECLARE_SOA_COLUMN(Py, py, float); // Momentum of the track |
| 98 | +DECLARE_SOA_COLUMN(Pz, pz, float); // Momentum of the track |
| 99 | +DECLARE_SOA_DYNAMIC_COLUMN(P, p, |
| 100 | + [](float px, float py, float pz) -> float { return std::sqrt(px * px + py * py + pz * pz); }); // Momentum of the track |
| 101 | +DECLARE_SOA_DYNAMIC_COLUMN(Pt, pt, |
| 102 | + [](float px, float py) -> float { return std::sqrt(px * px + py * py); }); // Momentum of the track |
| 103 | +DECLARE_SOA_COLUMN(TPCInnerParam, tpcInnerParam, float); // vertex position along z |
| 104 | +DECLARE_SOA_COLUMN(TPCSignal, tpcSignal, float); // vertex position along z |
| 105 | +DECLARE_SOA_COLUMN(Beta, beta, float); |
| 106 | +DECLARE_SOA_COLUMN(DcaXY, dcaXY, float); // impact parameter of the track |
| 107 | +DECLARE_SOA_COLUMN(DcaZ, dcaZ, float); // impact parameter of the track |
| 108 | +DECLARE_SOA_COLUMN(TPCNClsFound, tpcNClsFound, float); // Number of TPC clusters |
| 109 | +DECLARE_SOA_COLUMN(TPCCrossedRowsOverFindableCls, tpcCrossedRowsOverFindableCls, float); |
| 110 | +DECLARE_SOA_COLUMN(TPCChi2NCl, tpcChi2NCl, float); // TPC chi2 |
| 111 | +DECLARE_SOA_COLUMN(ITSNCls, itsNCls, float); // Number of ITS clusters |
| 112 | +DECLARE_SOA_COLUMN(ITSChi2NCl, itsChi2NCl, float); // ITS chi2 |
| 113 | +DECLARE_SOA_COLUMN(Sign, sign, int8_t); |
| 114 | +DECLARE_SOA_COLUMN(Eta, eta, float); |
| 115 | +DECLARE_SOA_COLUMN(Phi, phi, float); |
| 116 | +DECLARE_SOA_COLUMN(StoredCrossedRows, storedCrossedRows, storedcrossedrows::binning::binned_t); |
| 117 | +DECLARE_SOA_COLUMN(StoredTOFNSigmaPr, storedTofNSigmaPr, nsigma::binning::binned_t); |
| 118 | +DECLARE_SOA_COLUMN(StoredTPCNSigmaPr, storedTpcNSigmaPr, nsigma::binning::binned_t); |
| 119 | +DECLARE_SOA_COLUMN(StoredTOFNSigmaDe, storedTofNSigmaDe, nsigma::binning::binned_t); |
| 120 | +DECLARE_SOA_COLUMN(StoredTPCNSigmaDe, storedTpcNSigmaDe, nsigma::binning::binned_t); |
| 121 | + |
| 122 | +DECLARE_SOA_DYNAMIC_COLUMN(CrossedRows, tpcNClsCrossedRows, |
| 123 | + [](storedcrossedrows::binning::binned_t binned) -> float { return singletrackselector::unPackOffset<storedcrossedrows::binning>(binned); }); |
| 124 | +DECLARE_SOA_DYNAMIC_COLUMN(TOFNSigmaPr, tofNSigmaPr, |
| 125 | + [](nsigma::binning::binned_t nsigma_binned) -> float { return singletrackselector::unPack<nsigma::binning>(nsigma_binned); }); |
| 126 | +DECLARE_SOA_DYNAMIC_COLUMN(TPCNSigmaPr, tpcNSigmaPr, |
| 127 | + [](nsigma::binning::binned_t nsigma_binned) -> float { return singletrackselector::unPack<nsigma::binning>(nsigma_binned); }); |
| 128 | +DECLARE_SOA_DYNAMIC_COLUMN(TOFNSigmaDe, tofNSigmaDe, |
| 129 | + [](nsigma::binning::binned_t nsigma_binned) -> float { return singletrackselector::unPack<nsigma::binning>(nsigma_binned); }); |
| 130 | +DECLARE_SOA_DYNAMIC_COLUMN(TPCNSigmaDe, tpcNSigmaDe, |
| 131 | + [](nsigma::binning::binned_t nsigma_binned) -> float { return singletrackselector::unPack<nsigma::binning>(nsigma_binned); }); |
| 132 | + |
| 133 | +DECLARE_SOA_DYNAMIC_COLUMN(Energy, energy, |
| 134 | + [](float px, float py, float pz, float mass) -> float { return sqrt(px * px + py * py + pz * pz + mass * mass); }); |
| 135 | + |
| 136 | +DECLARE_SOA_COLUMN(GlobalIndex, globalIndex, int64_t); // Index to the collision |
| 137 | +DECLARE_SOA_COLUMN(Mult, mult, int); // Multiplicity of the collision |
| 138 | +DECLARE_SOA_COLUMN(PosZ, posZ, int); // Vertex of the collision |
| 139 | + |
| 140 | +} // namespace singletrackselector |
| 141 | + |
| 142 | +DECLARE_SOA_TABLE(SingleTrackSel, "AOD", "STSEL", // Table of the variables for single track selection. |
| 143 | + o2::soa::Index<>, |
| 144 | + singletrackselector::CollisionId, |
| 145 | + singletrackselector::HasITS, |
| 146 | + singletrackselector::HasTOF, |
| 147 | + singletrackselector::Px, |
| 148 | + singletrackselector::Py, |
| 149 | + singletrackselector::Pz, |
| 150 | + singletrackselector::TPCInnerParam, |
| 151 | + singletrackselector::TPCSignal, |
| 152 | + singletrackselector::Beta, |
| 153 | + singletrackselector::DcaXY, |
| 154 | + singletrackselector::DcaZ, |
| 155 | + singletrackselector::TPCNClsFound, |
| 156 | + singletrackselector::TPCCrossedRowsOverFindableCls, |
| 157 | + singletrackselector::TPCChi2NCl, |
| 158 | + singletrackselector::ITSNCls, |
| 159 | + singletrackselector::ITSChi2NCl, |
| 160 | + singletrackselector::Sign, |
| 161 | + singletrackselector::Eta, |
| 162 | + singletrackselector::Phi, |
| 163 | + singletrackselector::StoredCrossedRows, |
| 164 | + singletrackselector::StoredTOFNSigmaPr, |
| 165 | + singletrackselector::StoredTPCNSigmaPr, |
| 166 | + singletrackselector::StoredTOFNSigmaDe, |
| 167 | + singletrackselector::StoredTPCNSigmaDe, |
| 168 | + singletrackselector::P<singletrackselector::Px, singletrackselector::Py, singletrackselector::Pz>, |
| 169 | + singletrackselector::Pt<singletrackselector::Px, singletrackselector::Py>, |
| 170 | + singletrackselector::CrossedRows<singletrackselector::StoredCrossedRows>, |
| 171 | + singletrackselector::TOFNSigmaPr<singletrackselector::StoredTOFNSigmaPr>, |
| 172 | + singletrackselector::TPCNSigmaPr<singletrackselector::StoredTPCNSigmaPr>, |
| 173 | + singletrackselector::TOFNSigmaDe<singletrackselector::StoredTOFNSigmaDe>, |
| 174 | + singletrackselector::TPCNSigmaDe<singletrackselector::StoredTPCNSigmaDe>, |
| 175 | + singletrackselector::Energy<singletrackselector::Px, singletrackselector::Py, singletrackselector::Pz>); |
| 176 | + |
| 177 | +DECLARE_SOA_TABLE(SingleCollSel, "AOD", "SCSEL", // Table of the variables for single track selection. |
| 178 | + singletrackselector::GlobalIndex, |
| 179 | + singletrackselector::Mult, |
| 180 | + singletrackselector::PosZ); |
| 181 | +} // namespace o2::aod |
| 182 | +#endif // PWGCF_DATAMODEL_SINGLETRACKSELECTOR_H_ |
0 commit comments