diff --git a/Framework/Core/include/Framework/AnalysisDataModel.h b/Framework/Core/include/Framework/AnalysisDataModel.h index 9c939412cd941..2a1f9dbadf67f 100644 --- a/Framework/Core/include/Framework/AnalysisDataModel.h +++ b/Framework/Core/include/Framework/AnalysisDataModel.h @@ -24,6 +24,7 @@ #include "CommonConstants/GeomConstants.h" #include "CommonConstants/ZDCConstants.h" #include "SimulationDataFormat/MCGenProperties.h" +#include "Framework/PID.h" namespace o2 { @@ -266,39 +267,58 @@ DECLARE_SOA_EXPRESSION_COLUMN(DetectorMap, detectorMap, uint8_t, //! Detector ma ifnode(aod::track::trdPattern > (uint8_t)0, static_cast(o2::aod::track::TRD), (uint8_t)0x0) | ifnode((aod::track::tofChi2 >= 0.f) && (aod::track::tofExpMom > 0.f), static_cast(o2::aod::track::TOF), (uint8_t)0x0)); -DECLARE_SOA_DYNAMIC_COLUMN(TOFExpTime, tofExpTime, //! Expected time for the track to reach the TOF - [](float length, float tofExpMom, float mMassZSqared) -> float { - if (tofExpMom <= 0.f) { - return -999.f; - } - return length * std::sqrt((mMassZSqared) + (tofExpMom * tofExpMom)) / (o2::constants::physics::LightSpeedCm2PS * tofExpMom); +DECLARE_SOA_DYNAMIC_COLUMN(TOFExpTimeEl, tofExpTimeEl, //! Expected time for the track to reach the TOF under the electron hypothesis + [](float length, float tofExpMom) -> float { + constexpr float massSquared = o2::constants::physics::MassElectron * o2::constants::physics::MassElectron; + return o2::framework::pid::tof::MassToExpTime(tofExpMom, length, massSquared); + }); + +DECLARE_SOA_DYNAMIC_COLUMN(TOFExpTimeMu, tofExpTimeMu, //! Expected time for the track to reach the TOF under the muon hypothesis + [](float length, float tofExpMom) -> float { + constexpr float massSquared = o2::constants::physics::MassMuon * o2::constants::physics::MassMuon; + return o2::framework::pid::tof::MassToExpTime(tofExpMom, length, massSquared); }); DECLARE_SOA_DYNAMIC_COLUMN(TOFExpTimePi, tofExpTimePi, //! Expected time for the track to reach the TOF under the pion hypothesis [](float length, float tofExpMom) -> float { - if (tofExpMom <= 0.f) { - return -999.f; - } - constexpr float mMassZSqared = o2::constants::physics::MassPionCharged * o2::constants::physics::MassPionCharged; - return length * std::sqrt((mMassZSqared) + (tofExpMom * tofExpMom)) / (o2::constants::physics::LightSpeedCm2PS * tofExpMom); + constexpr float massSquared = o2::constants::physics::MassPionCharged * o2::constants::physics::MassPionCharged; + return o2::framework::pid::tof::MassToExpTime(tofExpMom, length, massSquared); }); DECLARE_SOA_DYNAMIC_COLUMN(TOFExpTimeKa, tofExpTimeKa, //! Expected time for the track to reach the TOF under the kaon hypothesis [](float length, float tofExpMom) -> float { - if (tofExpMom <= 0.f) { - return -999.f; - } - constexpr float mMassZSqared = o2::constants::physics::MassKaonCharged * o2::constants::physics::MassKaonCharged; - return length * std::sqrt((mMassZSqared) + (tofExpMom * tofExpMom)) / (o2::constants::physics::LightSpeedCm2PS * tofExpMom); + constexpr float massSquared = o2::constants::physics::MassKaonCharged * o2::constants::physics::MassKaonCharged; + return o2::framework::pid::tof::MassToExpTime(tofExpMom, length, massSquared); }); DECLARE_SOA_DYNAMIC_COLUMN(TOFExpTimePr, tofExpTimePr, //! Expected time for the track to reach the TOF under the proton hypothesis [](float length, float tofExpMom) -> float { - if (tofExpMom <= 0.f) { - return -999.f; - } - constexpr float mMassZSqared = o2::constants::physics::MassProton * o2::constants::physics::MassProton; - return length * std::sqrt((mMassZSqared) + (tofExpMom * tofExpMom)) / (o2::constants::physics::LightSpeedCm2PS * tofExpMom); + constexpr float massSquared = o2::constants::physics::MassProton * o2::constants::physics::MassProton; + return o2::framework::pid::tof::MassToExpTime(tofExpMom, length, massSquared); + }); + +DECLARE_SOA_DYNAMIC_COLUMN(TOFExpTimeDe, tofExpTimeDe, //! Expected time for the track to reach the TOF under the deuteron hypothesis + [](float length, float tofExpMom) -> float { + constexpr float massSquared = o2::constants::physics::MassDeuteron * o2::constants::physics::MassDeuteron; + return o2::framework::pid::tof::MassToExpTime(tofExpMom, length, massSquared); + }); + +DECLARE_SOA_DYNAMIC_COLUMN(TOFExpTimeTr, tofExpTimeTr, //! Expected time for the track to reach the TOF under the triton hypothesis + [](float length, float tofExpMom) -> float { + constexpr float massSquared = o2::constants::physics::MassTriton * o2::constants::physics::MassTriton; + return o2::framework::pid::tof::MassToExpTime(tofExpMom, length, massSquared); + }); + +DECLARE_SOA_DYNAMIC_COLUMN(TOFExpTimeHe, tofExpTimeHe, //! Expected time for the track to reach the TOF under the helium3 hypothesis + [](float length, float tofExpMom) -> float { + constexpr float massSquared = o2::constants::physics::MassHelium3 * o2::constants::physics::MassHelium3; + return o2::framework::pid::tof::MassToExpTime(tofExpMom, length, massSquared); + }); + +DECLARE_SOA_DYNAMIC_COLUMN(TOFExpTimeAl, tofExpTimeAl, //! Expected time for the track to reach the TOF under the helium4 hypothesis + [](float length, float tofExpMom) -> float { + constexpr float massSquared = o2::constants::physics::MassAlpha * o2::constants::physics::MassAlpha; + return o2::framework::pid::tof::MassToExpTime(tofExpMom, length, massSquared); }); namespace v001 @@ -338,7 +358,7 @@ DECLARE_SOA_DYNAMIC_COLUMN(ITSNClsInnerBarrel, itsNClsInnerBarrel, //! Number of }); DECLARE_SOA_DYNAMIC_COLUMN(ITSClsSizeInLayer, itsClsSizeInLayer, //! Size of the ITS cluster in a given layer [](uint32_t itsClusterSizes, int layer) -> uint8_t { - if (layer >= 7) { + if (layer >= 7 || layer < 0) { return 0; } return (itsClusterSizes >> (layer * 4)) & 0xf; @@ -535,10 +555,15 @@ DECLARE_SOA_TABLE_FULL(StoredTracksExtra_000, "TracksExtra", "AOD", "TRACKEXTRA" track::HasTRD, track::HasTOF, track::TPCNClsFound, track::TPCNClsCrossedRows, - track::TOFExpTime, + track::TOFExpTimeEl, + track::TOFExpTimeMu, track::TOFExpTimePi, track::TOFExpTimeKa, track::TOFExpTimePr, + track::TOFExpTimeDe, + track::TOFExpTimeTr, + track::TOFExpTimeHe, + track::TOFExpTimeAl, track::ITSNCls, track::ITSNClsInnerBarrel, track::TPCCrossedRowsOverFindableCls, track::TPCFoundOverFindableCls, @@ -560,10 +585,15 @@ DECLARE_SOA_TABLE_FULL_VERSIONED(StoredTracksExtra_001, "TracksExtra", "AOD", "T track::v001::ITSClusterMap, track::v001::ITSNCls, track::v001::ITSNClsInnerBarrel, track::v001::ITSClsSizeInLayer, track::v001::IsITSAfterburner, - track::TOFExpTime, + track::TOFExpTimeEl, + track::TOFExpTimeMu, track::TOFExpTimePi, track::TOFExpTimeKa, track::TOFExpTimePr, + track::TOFExpTimeDe, + track::TOFExpTimeTr, + track::TOFExpTimeHe, + track::TOFExpTimeAl, track::TPCCrossedRowsOverFindableCls, track::TPCFoundOverFindableCls, track::TPCFractionSharedCls, diff --git a/Framework/Core/include/Framework/PID.h b/Framework/Core/include/Framework/PID.h new file mode 100644 index 0000000000000..3c8c27b27bae6 --- /dev/null +++ b/Framework/Core/include/Framework/PID.h @@ -0,0 +1,56 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +#ifndef o2_framework_PID_H_DEFINED +#define o2_framework_PID_H_DEFINED + +#include +#include "CommonConstants/PhysicsConstants.h" + +/// +/// \file PID.h +/// \author Nicolò Jacazio nicolo.jacazio@cern.ch +/// \since 2024-09-11 +/// \brief TOF PID utilities to work with the information stored in the AO2D +/// + +namespace o2::framework::pid +{ + +namespace tof +{ + +/// @brief Compute the expected time of flight for a given momentum, length and massSquared +/// @param tofExpMom the expected momentum of the particle in GeV/c +/// @param length the track length in cm +/// @param massSquared the squared mass of the particle in GeV^2/c^4 +/// @return the expected time of flight of the particle in ps +inline float MassToExpTime(float tofExpMom, float length, float massSquared) +{ + if (tofExpMom <= 0.f) { + return -999.f; + } + return length * std::sqrt((massSquared) + (tofExpMom * tofExpMom)) / (o2::constants::physics::LightSpeedCm2PS * tofExpMom); +} + +/// @brief Compute the signal of the time of flight for a given track time and expected time of flight +/// @param tracktime the measured time of flight (at the vertex) in ps +/// @param exptime the expected time of flight in ps +/// @return the signal of the time of flight +inline float TrackTimeToTOFSignal(float tracktime, float exptime) +{ + return tracktime * 1000.f + exptime; +} +} // namespace tof + +} // namespace o2::framework::pid + +#endif // o2_framework_PID_H_DEFINED