Skip to content

Commit

Permalink
[DM] Add expected time computation in Framework (#13528)
Browse files Browse the repository at this point in the history
* [DM] Add expected time computation in Framework

- Use expected time functions in datamodel
- add tofSignal computation in DM from ex. time
- next: use utilities in AOD producer

* Remove TOFValue and TOFExpTime
  • Loading branch information
njacazio authored Oct 8, 2024
1 parent 1d16cac commit bb1000d
Show file tree
Hide file tree
Showing 2 changed files with 110 additions and 24 deletions.
78 changes: 54 additions & 24 deletions Framework/Core/include/Framework/AnalysisDataModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "CommonConstants/GeomConstants.h"
#include "CommonConstants/ZDCConstants.h"
#include "SimulationDataFormat/MCGenProperties.h"
#include "Framework/PID.h"

namespace o2
{
Expand Down Expand Up @@ -266,39 +267,58 @@ DECLARE_SOA_EXPRESSION_COLUMN(DetectorMap, detectorMap, uint8_t, //! Detector ma
ifnode(aod::track::trdPattern > (uint8_t)0, static_cast<uint8_t>(o2::aod::track::TRD), (uint8_t)0x0) |
ifnode((aod::track::tofChi2 >= 0.f) && (aod::track::tofExpMom > 0.f), static_cast<uint8_t>(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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -535,10 +555,15 @@ DECLARE_SOA_TABLE_FULL(StoredTracksExtra_000, "TracksExtra", "AOD", "TRACKEXTRA"
track::HasTRD<track::DetectorMap>, track::HasTOF<track::DetectorMap>,
track::TPCNClsFound<track::TPCNClsFindable, track::TPCNClsFindableMinusFound>,
track::TPCNClsCrossedRows<track::TPCNClsFindable, track::TPCNClsFindableMinusCrossedRows>,
track::TOFExpTime<track::Length, track::TOFExpMom>,
track::TOFExpTimeEl<track::Length, track::TOFExpMom>,
track::TOFExpTimeMu<track::Length, track::TOFExpMom>,
track::TOFExpTimePi<track::Length, track::TOFExpMom>,
track::TOFExpTimeKa<track::Length, track::TOFExpMom>,
track::TOFExpTimePr<track::Length, track::TOFExpMom>,
track::TOFExpTimeDe<track::Length, track::TOFExpMom>,
track::TOFExpTimeTr<track::Length, track::TOFExpMom>,
track::TOFExpTimeHe<track::Length, track::TOFExpMom>,
track::TOFExpTimeAl<track::Length, track::TOFExpMom>,
track::ITSNCls<track::ITSClusterMap>, track::ITSNClsInnerBarrel<track::ITSClusterMap>,
track::TPCCrossedRowsOverFindableCls<track::TPCNClsFindable, track::TPCNClsFindableMinusCrossedRows>,
track::TPCFoundOverFindableCls<track::TPCNClsFindable, track::TPCNClsFindableMinusFound>,
Expand All @@ -560,10 +585,15 @@ DECLARE_SOA_TABLE_FULL_VERSIONED(StoredTracksExtra_001, "TracksExtra", "AOD", "T
track::v001::ITSClusterMap<track::ITSClusterSizes>, track::v001::ITSNCls<track::ITSClusterSizes>, track::v001::ITSNClsInnerBarrel<track::ITSClusterSizes>,
track::v001::ITSClsSizeInLayer<track::ITSClusterSizes>,
track::v001::IsITSAfterburner<track::v001::DetectorMap, track::ITSChi2NCl>,
track::TOFExpTime<track::Length, track::TOFExpMom>,
track::TOFExpTimeEl<track::Length, track::TOFExpMom>,
track::TOFExpTimeMu<track::Length, track::TOFExpMom>,
track::TOFExpTimePi<track::Length, track::TOFExpMom>,
track::TOFExpTimeKa<track::Length, track::TOFExpMom>,
track::TOFExpTimePr<track::Length, track::TOFExpMom>,
track::TOFExpTimeDe<track::Length, track::TOFExpMom>,
track::TOFExpTimeTr<track::Length, track::TOFExpMom>,
track::TOFExpTimeHe<track::Length, track::TOFExpMom>,
track::TOFExpTimeAl<track::Length, track::TOFExpMom>,
track::TPCCrossedRowsOverFindableCls<track::TPCNClsFindable, track::TPCNClsFindableMinusCrossedRows>,
track::TPCFoundOverFindableCls<track::TPCNClsFindable, track::TPCNClsFindableMinusFound>,
track::TPCFractionSharedCls<track::TPCNClsShared, track::TPCNClsFindable, track::TPCNClsFindableMinusFound>,
Expand Down
56 changes: 56 additions & 0 deletions Framework/Core/include/Framework/PID.h
Original file line number Diff line number Diff line change
@@ -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 <cmath>
#include "CommonConstants/PhysicsConstants.h"

///
/// \file PID.h
/// \author Nicolò Jacazio [email protected]
/// \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

0 comments on commit bb1000d

Please sign in to comment.