Skip to content

[Common] TOF: add dynamic columns for TOFBeta and TOFMass #11071

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 75 additions & 59 deletions Common/DataModel/PIDResponseTOF.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "Framework/AnalysisDataModel.h"
#include "ReconstructionDataFormats/PID.h"
#include "Framework/Logger.h"
#include "Common/Core/PID/PIDTOF.h"

namespace o2::aod
{
Expand Down Expand Up @@ -54,7 +55,7 @@
using hasTOFAl = decltype(std::declval<T&>().tofNSigmaAl());

// PID index as template argument
#define perSpeciesWrapper(functionName) \

Check failure on line 58 in Common/DataModel/PIDResponseTOF.h

View workflow job for this annotation

GitHub Actions / O2 linter

[name/macro]

Use SCREAMING_SNAKE_CASE for names of macros. Leading and double underscores are not allowed.
template <o2::track::PID::ID index, typename TrackType> \
auto functionName(const TrackType& track) \
{ \
Expand Down Expand Up @@ -109,7 +110,7 @@
#undef perSpeciesWrapper

// PID index as function argument for TOF
#define perSpeciesWrapper(functionName) \

Check failure on line 113 in Common/DataModel/PIDResponseTOF.h

View workflow job for this annotation

GitHub Actions / O2 linter

[name/macro]

Use SCREAMING_SNAKE_CASE for names of macros. Leading and double underscores are not allowed.
template <typename TrackType> \
auto functionName(const o2::track::PID::ID index, const TrackType& track) \
{ \
Expand Down Expand Up @@ -209,6 +210,65 @@

} // namespace pidutils

// Extra tables
namespace pidflags
{

namespace enums
{
enum PIDFlags : uint8_t {
EvTimeUndef = 0x0, // Event collision not set, corresponding to the LHC Fill event time
EvTimeTOF = 0x1, // Event collision time from TOF
EvTimeT0AC = 0x2, // Event collision time from the FT0AC
EvTimeTOFT0AC = 0x4 // Event collision time from the TOF and FT0AC
};
}

DECLARE_SOA_COLUMN(GoodTOFMatch, goodTOFMatch, bool); //! Bool for the TOF PID information on the single track information
DECLARE_SOA_COLUMN(TOFFlags, tofFlags, uint8_t); //! Flag for the complementary TOF PID information for the event time
DECLARE_SOA_DYNAMIC_COLUMN(IsEvTimeDefined, isEvTimeDefined, //! True if the Event Time was computed with any method i.e. there is a usable event time
[](uint8_t flags) -> bool { return (flags > 0); });
DECLARE_SOA_DYNAMIC_COLUMN(IsEvTimeTOF, isEvTimeTOF, //! True if the Event Time was computed with the TOF
[](uint8_t flags) -> bool { return (flags & enums::PIDFlags::EvTimeTOF) == enums::PIDFlags::EvTimeTOF; });
DECLARE_SOA_DYNAMIC_COLUMN(IsEvTimeT0AC, isEvTimeT0AC, //! True if the Event Time was computed with the T0AC
[](uint8_t flags) -> bool { return (flags & enums::PIDFlags::EvTimeT0AC) == enums::PIDFlags::EvTimeT0AC; });
DECLARE_SOA_DYNAMIC_COLUMN(IsEvTimeTOFT0AC, isEvTimeTOFT0AC, //! True if the Event Time was computed with the TOF and T0AC
[](uint8_t flags) -> bool { return (flags & enums::PIDFlags::EvTimeTOFT0AC) == enums::PIDFlags::EvTimeTOFT0AC; });

} // namespace pidflags

DECLARE_SOA_TABLE(pidTOFFlags, "AOD", "pidTOFFlags", //! Table of the flags for TOF signal quality on the track level
pidflags::GoodTOFMatch);

DECLARE_SOA_TABLE(pidEvTimeFlags, "AOD", "pidEvTimeFlags", //! Table of the PID flags for the event time tables
pidflags::TOFFlags,
pidflags::IsEvTimeDefined<pidflags::TOFFlags>,
pidflags::IsEvTimeTOF<pidflags::TOFFlags>,
pidflags::IsEvTimeT0AC<pidflags::TOFFlags>,
pidflags::IsEvTimeTOFT0AC<pidflags::TOFFlags>);

namespace pidtofsignal
{
DECLARE_SOA_COLUMN(TOFSignal, tofSignal, float); //! TOF signal from track time
DECLARE_SOA_DYNAMIC_COLUMN(EventCollisionTime, eventCollisionTime, //! Event collision time used for the track. Needs the TOF
[](float signal, float tMinusTexp, float texp) -> float { return texp + tMinusTexp - signal; });

} // namespace pidtofsignal

DECLARE_SOA_TABLE(TOFSignal, "AOD", "TOFSignal", //! Table of the TOF signal
pidtofsignal::TOFSignal,
pidtofsignal::EventCollisionTime<pidtofsignal::TOFSignal>);

namespace pidtofevtime
{
DECLARE_SOA_COLUMN(TOFEvTime, tofEvTime, float); //! event time for TOF signal. Can be obtained via a combination of detectors e.g. TOF, FT0A, FT0C
DECLARE_SOA_COLUMN(TOFEvTimeErr, tofEvTimeErr, float); //! event time error for TOF. Can be obtained via a combination of detectors e.g. TOF, FT0A, FT0C
} // namespace pidtofevtime

DECLARE_SOA_TABLE(TOFEvTime, "AOD", "TOFEvTime", //! Table of the TOF event time. One entry per track.
pidtofevtime::TOFEvTime,
pidtofevtime::TOFEvTimeErr);

namespace pidtof
{
// Expected signals
Expand Down Expand Up @@ -277,12 +337,12 @@
struct binning {
public:
typedef int8_t binned_t;
static constexpr int nbins = (1 << 8 * sizeof(binned_t)) - 2;

Check failure on line 340 in Common/DataModel/PIDResponseTOF.h

View workflow job for this annotation

GitHub Actions / O2 linter

[name/constexpr-constant]

Use UpperCamelCase for names of constexpr constants. Names of special constants may be prefixed with "k".
static constexpr binned_t overflowBin = nbins >> 1;

Check failure on line 341 in Common/DataModel/PIDResponseTOF.h

View workflow job for this annotation

GitHub Actions / O2 linter

[name/constexpr-constant]

Use UpperCamelCase for names of constexpr constants. Names of special constants may be prefixed with "k".
static constexpr binned_t underflowBin = -(nbins >> 1);

Check failure on line 342 in Common/DataModel/PIDResponseTOF.h

View workflow job for this annotation

GitHub Actions / O2 linter

[name/constexpr-constant]

Use UpperCamelCase for names of constexpr constants. Names of special constants may be prefixed with "k".
static constexpr float binned_max = 6.35;

Check failure on line 343 in Common/DataModel/PIDResponseTOF.h

View workflow job for this annotation

GitHub Actions / O2 linter

[name/constexpr-constant]

Use UpperCamelCase for names of constexpr constants. Names of special constants may be prefixed with "k".

Check failure on line 343 in Common/DataModel/PIDResponseTOF.h

View workflow job for this annotation

GitHub Actions / O2 linter

[name/function-variable]

Use lowerCamelCase for names of functions and variables.
static constexpr float binned_min = -6.35;

Check failure on line 344 in Common/DataModel/PIDResponseTOF.h

View workflow job for this annotation

GitHub Actions / O2 linter

[name/constexpr-constant]

Use UpperCamelCase for names of constexpr constants. Names of special constants may be prefixed with "k".

Check failure on line 344 in Common/DataModel/PIDResponseTOF.h

View workflow job for this annotation

GitHub Actions / O2 linter

[name/function-variable]

Use lowerCamelCase for names of functions and variables.
static constexpr float bin_width = (binned_max - binned_min) / nbins;

Check failure on line 345 in Common/DataModel/PIDResponseTOF.h

View workflow job for this annotation

GitHub Actions / O2 linter

[name/function-variable]

Use lowerCamelCase for names of functions and variables.

// Function to pack a float into a binned value in table
template <typename T>
Expand Down Expand Up @@ -397,69 +457,15 @@
DECLARE_SOA_TABLE(pidTOFAl, "AOD", "pidTOFAl", //! Table of the TOF response with binned Nsigma for alpha
pidtof_tiny::TOFNSigmaStoreAl, pidtof_tiny::TOFNSigmaAl<pidtof_tiny::TOFNSigmaStoreAl>);

// Extra tables
namespace pidflags
{

namespace enums
{
enum PIDFlags : uint8_t {
EvTimeUndef = 0x0, // Event collision not set, corresponding to the LHC Fill event time
EvTimeTOF = 0x1, // Event collision time from TOF
EvTimeT0AC = 0x2, // Event collision time from the FT0AC
EvTimeTOFT0AC = 0x4 // Event collision time from the TOF and FT0AC
};
}

DECLARE_SOA_COLUMN(GoodTOFMatch, goodTOFMatch, bool); //! Bool for the TOF PID information on the single track information
DECLARE_SOA_COLUMN(TOFFlags, tofFlags, uint8_t); //! Flag for the complementary TOF PID information for the event time
DECLARE_SOA_DYNAMIC_COLUMN(IsEvTimeDefined, isEvTimeDefined, //! True if the Event Time was computed with any method i.e. there is a usable event time
[](uint8_t flags) -> bool { return (flags > 0); });
DECLARE_SOA_DYNAMIC_COLUMN(IsEvTimeTOF, isEvTimeTOF, //! True if the Event Time was computed with the TOF
[](uint8_t flags) -> bool { return (flags & enums::PIDFlags::EvTimeTOF) == enums::PIDFlags::EvTimeTOF; });
DECLARE_SOA_DYNAMIC_COLUMN(IsEvTimeT0AC, isEvTimeT0AC, //! True if the Event Time was computed with the T0AC
[](uint8_t flags) -> bool { return (flags & enums::PIDFlags::EvTimeT0AC) == enums::PIDFlags::EvTimeT0AC; });
DECLARE_SOA_DYNAMIC_COLUMN(IsEvTimeTOFT0AC, isEvTimeTOFT0AC, //! True if the Event Time was computed with the TOF and T0AC
[](uint8_t flags) -> bool { return (flags & enums::PIDFlags::EvTimeTOFT0AC) == enums::PIDFlags::EvTimeTOFT0AC; });

} // namespace pidflags

DECLARE_SOA_TABLE(pidTOFFlags, "AOD", "pidTOFFlags", //! Table of the flags for TOF signal quality on the track level
pidflags::GoodTOFMatch);

DECLARE_SOA_TABLE(pidEvTimeFlags, "AOD", "pidEvTimeFlags", //! Table of the PID flags for the event time tables
pidflags::TOFFlags,
pidflags::IsEvTimeDefined<pidflags::TOFFlags>,
pidflags::IsEvTimeTOF<pidflags::TOFFlags>,
pidflags::IsEvTimeT0AC<pidflags::TOFFlags>,
pidflags::IsEvTimeTOFT0AC<pidflags::TOFFlags>);

namespace pidtofsignal
{
DECLARE_SOA_COLUMN(TOFSignal, tofSignal, float); //! TOF signal from track time
DECLARE_SOA_DYNAMIC_COLUMN(EventCollisionTime, eventCollisionTime, //! Event collision time used for the track. Needs the TOF
[](float signal, float tMinusTexp, float texp) -> float { return texp + tMinusTexp - signal; });

} // namespace pidtofsignal

DECLARE_SOA_TABLE(TOFSignal, "AOD", "TOFSignal", //! Table of the TOF signal
pidtofsignal::TOFSignal,
pidtofsignal::EventCollisionTime<pidtofsignal::TOFSignal>);

namespace pidtofevtime
{
DECLARE_SOA_COLUMN(TOFEvTime, tofEvTime, float); //! event time for TOF signal. Can be obtained via a combination of detectors e.g. TOF, FT0A, FT0C
DECLARE_SOA_COLUMN(TOFEvTimeErr, tofEvTimeErr, float); //! event time error for TOF. Can be obtained via a combination of detectors e.g. TOF, FT0A, FT0C
} // namespace pidtofevtime

DECLARE_SOA_TABLE(TOFEvTime, "AOD", "TOFEvTime", //! Table of the TOF event time. One entry per track.
pidtofevtime::TOFEvTime,
pidtofevtime::TOFEvTimeErr);

namespace pidtofbeta
{
DECLARE_SOA_COLUMN(Beta, beta, float); //! TOF beta
DECLARE_SOA_COLUMN(BetaError, betaerror, float); //! Uncertainty on the TOF beta
// Dynamic column, i.e. the future
DECLARE_SOA_DYNAMIC_COLUMN(TOFBetaImp, tofBeta, //! TOF Beta value
[](const float length, const float tofSignal, const float collisionTime) -> float {
return o2::pid::tof::Beta::GetBeta(length, tofSignal, collisionTime);
});
//
DECLARE_SOA_COLUMN(ExpBetaEl, expbetael, float); //! Expected beta of electron
DECLARE_SOA_COLUMN(ExpBetaElError, expbetaelerror, float); //! Expected uncertainty on the beta of electron
Expand All @@ -469,14 +475,24 @@
[](float beta, float expbetael) -> float { return beta - expbetael; });
} // namespace pidtofbeta

using TOFBeta = pidtofbeta::TOFBetaImp<o2::aod::track::Length, o2::aod::pidtofsignal::TOFSignal, o2::aod::pidtofevtime::TOFEvTime>;

DECLARE_SOA_TABLE(pidTOFbeta, "AOD", "pidTOFbeta", //! Table of the TOF beta
pidtofbeta::Beta, pidtofbeta::BetaError);

namespace pidtofmass
{
DECLARE_SOA_COLUMN(TOFMass, mass, float); //! TOF mass
// Dynamic column, i.e. the future
DECLARE_SOA_DYNAMIC_COLUMN(TOFMassImp, tofMass, //! TOF Mass value
[](const float length, const float tofSignal, const float collisionTime, const float momentum) -> float {
const float beta = o2::pid::tof::Beta::GetBeta(length, tofSignal, collisionTime);
return o2::pid::tof::TOFMass::GetTOFMass(momentum, beta);
});
} // namespace pidtofmass

using TOFMass = pidtofmass::TOFMassImp<o2::aod::track::Length, o2::aod::pidtofsignal::TOFSignal, o2::aod::pidtofevtime::TOFEvTime, o2::aod::track::TOFExpMom>;

DECLARE_SOA_TABLE(pidTOFmass, "AOD", "pidTOFmass", //! Table of the TOF mass
pidtofmass::TOFMass);

Expand Down
5 changes: 5 additions & 0 deletions DPG/Tasks/AOTTrack/PID/TOF/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ o2physics_add_dpl_workflow(pid-tof-qa-beta
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
COMPONENT_NAME Analysis)

o2physics_add_dpl_workflow(pid-tof-qa-beta-imp
SOURCES qaPIDTOFBetaImp.cxx
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
COMPONENT_NAME Analysis)

o2physics_add_dpl_workflow(pid-tof-qa-mc
SOURCES qaPIDTOFMC.cxx
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
Expand Down
Loading
Loading