Skip to content
Open
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
154 changes: 126 additions & 28 deletions Common/DataModel/PIDResponseTOF.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,33 +57,38 @@
using hasTOFAl = decltype(std::declval<T&>().tofNSigmaAl());

// PID index as template argument
#define perSpeciesWrapper(functionName) \
template <o2::track::PID::ID index, typename TrackType> \
auto functionName(const TrackType& track) \
{ \
if constexpr (index == o2::track::PID::Electron) { \
return track.functionName##El(); \
} else if constexpr (index == o2::track::PID::Muon) { \
return track.functionName##Mu(); \
} else if constexpr (index == o2::track::PID::Pion) { \
return track.functionName##Pi(); \
} else if constexpr (index == o2::track::PID::Kaon) { \
return track.functionName##Ka(); \
} else if constexpr (index == o2::track::PID::Proton) { \
return track.functionName##Pr(); \
} else if constexpr (index == o2::track::PID::Deuteron) { \
return track.functionName##De(); \
} else if constexpr (index == o2::track::PID::Triton) { \
return track.functionName##Tr(); \
} else if constexpr (index == o2::track::PID::Helium3) { \
return track.functionName##He(); \
} else if constexpr (index == o2::track::PID::Alpha) { \
return track.functionName##Al(); \
} \
#define perSpeciesWrapper(functionName) \
template <o2::track::PID::ID index, typename TrackType> \
auto functionName(const TrackType& track) \
{ \
if constexpr (index == o2::track::PID::Electron) { \
return track.functionName##El(); \
} else if constexpr (index == o2::track::PID::Muon) { \
return track.functionName##Mu(); \
} else if constexpr (index == o2::track::PID::Pion) { \
return track.functionName##Pi(); \
} else if constexpr (index == o2::track::PID::Kaon) { \
return track.functionName##Ka(); \
} else if constexpr (index == o2::track::PID::Proton) { \
return track.functionName##Pr(); \
} else if constexpr (index == o2::track::PID::Deuteron) { \
return track.functionName##De(); \
} else if constexpr (index == o2::track::PID::Triton) { \
return track.functionName##Tr(); \
} else if constexpr (index == o2::track::PID::Helium3) { \
return track.functionName##He(); \
} else if constexpr (index == o2::track::PID::Alpha) { \
return track.functionName##Al(); \
} \
LOGF(fatal, "%s %i (%s) is not available", #functionName, index, o2::track::PID::getName(index)); \
return 0.f; \
}

perSpeciesWrapper(tofNSigma);
perSpeciesWrapper(tofExpSigma);
perSpeciesWrapper(tofExpSignalDiff);
#undef perSpeciesWrapper

template <o2::track::PID::ID index, typename TrackType>
auto tofExpSignal(const TrackType& track)
{
Expand All @@ -106,10 +111,35 @@
} else if constexpr (index == o2::track::PID::Alpha) {
return track.tofExpSignalAl(track.tofSignal());
}
LOGF(fatal, "tofExpSignal %i (%s) is not available", index, o2::track::PID::getName(index));
return 0.f;
}
perSpeciesWrapper(tofExpSignalDiff);

#undef perSpeciesWrapper
template <o2::track::PID::ID index, typename TrackType>
auto tofExpTime(const TrackType& track)
{
if constexpr (index == o2::track::PID::Electron) {
return track.tofExpTimeEl();
} else if constexpr (index == o2::track::PID::Muon) {
return track.tofExpTimeMu();
} else if constexpr (index == o2::track::PID::Pion) {
return track.tofExpTimePi();
} else if constexpr (index == o2::track::PID::Kaon) {
return track.tofExpTimeKa();
} else if constexpr (index == o2::track::PID::Proton) {
return track.tofExpTimePr();
} else if constexpr (index == o2::track::PID::Deuteron) {
return track.tofExpTimeDe();
} else if constexpr (index == o2::track::PID::Triton) {
return track.tofExpTimeTr();
} else if constexpr (index == o2::track::PID::Helium3) {
return track.tofExpTimeHe();
} else if constexpr (index == o2::track::PID::Alpha) {
return track.tofExpTimeAl();
}
LOGF(fatal, "tofExpTime %i (%s) is not available", index, o2::track::PID::getName(index));
return 0.f;
}

// PID index as function argument for TOF
#define perSpeciesWrapper(functionName) \
Expand Down Expand Up @@ -161,6 +191,9 @@

perSpeciesWrapper(tofNSigma);
perSpeciesWrapper(tofExpSigma);
perSpeciesWrapper(tofExpSignalDiff);
#undef perSpeciesWrapper

template <typename TrackType>
auto tofExpSignal(const o2::track::PID::ID index, const TrackType& track)
{
Expand Down Expand Up @@ -206,9 +239,6 @@
return 0.f;
}
}
perSpeciesWrapper(tofExpSignalDiff);

#undef perSpeciesWrapper

} // namespace pidutils

Expand All @@ -227,7 +257,7 @@
}

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

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

View workflow job for this annotation

GitHub Actions / O2 linter

[name/o2-column]

Use UpperCamelCase for names of O2 columns and matching lowerCamelCase names for their getters.
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
Expand All @@ -251,10 +281,10 @@

namespace pidtofsignal
{
DECLARE_SOA_COLUMN(TOFSignal, tofSignal, float); //! TOF signal from track time

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

View workflow job for this annotation

GitHub Actions / O2 linter

[name/o2-column]

Use UpperCamelCase for names of O2 columns and matching lowerCamelCase names for their getters.
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; });
DECLARE_SOA_DYNAMIC_COLUMN(TOFSignalInAnotherBC, tofSignalInAnotherBC, //! TOF signal but computed in another Bunch Crossing. Needs the original globalBC and the new globalBC to compute the delta time to apply to the signal.

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

View workflow job for this annotation

GitHub Actions / O2 linter

[name/o2-column]

Use UpperCamelCase for names of O2 columns and matching lowerCamelCase names for their getters.
[](float signal, int64_t originalGlobalBC, int64_t newGlobalBC) -> float {
const int64_t deltaBcPos = originalGlobalBC - newGlobalBC;
return signal + o2::constants::lhc::LHCBunchSpacingNS * deltaBcPos * 1000.0f;
Expand All @@ -269,8 +299,8 @@

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

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

View workflow job for this annotation

GitHub Actions / O2 linter

[name/o2-column]

Use UpperCamelCase for names of O2 columns and matching lowerCamelCase names for their getters.
DECLARE_SOA_COLUMN(TOFEvTimeErr, tofEvTimeErr, float); //! event time error for TOF. Can be obtained via a combination of detectors e.g. TOF, FT0A, FT0C

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

View workflow job for this annotation

GitHub Actions / O2 linter

[name/o2-column]

Use UpperCamelCase for names of O2 columns and matching lowerCamelCase names for their getters.
} // namespace pidtofevtime

DECLARE_SOA_TABLE(TOFEvTime, "AOD", "TOFEvTime", //! Table of the TOF event time. One entry per track.
Expand All @@ -280,15 +310,15 @@
namespace pidtof
{
// Expected signals
DECLARE_SOA_DYNAMIC_COLUMN(TOFExpSignalEl, tofExpSignalEl, //! Expected time for electron

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

View workflow job for this annotation

GitHub Actions / O2 linter

[name/o2-column]

Use UpperCamelCase for names of O2 columns and matching lowerCamelCase names for their getters.
[](float nsigma, float sigma, float tofsignal) -> float { return tofsignal - nsigma * sigma; });
DECLARE_SOA_DYNAMIC_COLUMN(TOFExpSignalMu, tofExpSignalMu, //! Expected time for muon

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

View workflow job for this annotation

GitHub Actions / O2 linter

[name/o2-column]

Use UpperCamelCase for names of O2 columns and matching lowerCamelCase names for their getters.
[](float nsigma, float sigma, float tofsignal) -> float { return tofsignal - nsigma * sigma; });
DECLARE_SOA_DYNAMIC_COLUMN(TOFExpSignalPi, tofExpSignalPi, //! Expected time for pion

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

View workflow job for this annotation

GitHub Actions / O2 linter

[name/o2-column]

Use UpperCamelCase for names of O2 columns and matching lowerCamelCase names for their getters.
[](float nsigma, float sigma, float tofsignal) -> float { return tofsignal - nsigma * sigma; });
DECLARE_SOA_DYNAMIC_COLUMN(TOFExpSignalKa, tofExpSignalKa, //! Expected time for kaon

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

View workflow job for this annotation

GitHub Actions / O2 linter

[name/o2-column]

Use UpperCamelCase for names of O2 columns and matching lowerCamelCase names for their getters.
[](float nsigma, float sigma, float tofsignal) -> float { return tofsignal - nsigma * sigma; });
DECLARE_SOA_DYNAMIC_COLUMN(TOFExpSignalPr, tofExpSignalPr, //! Expected time for proton

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

View workflow job for this annotation

GitHub Actions / O2 linter

[name/o2-column]

Use UpperCamelCase for names of O2 columns and matching lowerCamelCase names for their getters.
[](float nsigma, float sigma, float tofsignal) -> float { return tofsignal - nsigma * sigma; });
DECLARE_SOA_DYNAMIC_COLUMN(TOFExpSignalDe, tofExpSignalDe, //! Expected time for deuteron
[](float nsigma, float sigma, float tofsignal) -> float { return tofsignal - nsigma * sigma; });
Expand Down Expand Up @@ -364,6 +394,38 @@
PERSPECIES_TOF_SIGMA_COLUMN(Al, o2::track::PID::Alpha);
#undef PERSPECIES_TOF_SIGMA_COLUMN

DECLARE_SOA_DYNAMIC_COLUMN(TOFExpSigmaImp, tofExpSigmaDyn,
[](float tofExpMom,
float momentum,
float eta,
float tofSignal,
float tofEvTimeErr,
o2::track::PID::ID particleId) -> float {
switch (particleId) {
case o2::track::PID::Electron: // El
return o2::pid::tof::TOFResponseImpl::expectedSigma<o2::track::PID::Electron>(tofSignal, tofExpMom, momentum, eta, tofEvTimeErr);
case o2::track::PID::Muon: // Mu
return o2::pid::tof::TOFResponseImpl::expectedSigma<o2::track::PID::Muon>(tofSignal, tofExpMom, momentum, eta, tofEvTimeErr);
case o2::track::PID::Pion: // Pi
return o2::pid::tof::TOFResponseImpl::expectedSigma<o2::track::PID::Pion>(tofSignal, tofExpMom, momentum, eta, tofEvTimeErr);
case o2::track::PID::Kaon: // Ka
return o2::pid::tof::TOFResponseImpl::expectedSigma<o2::track::PID::Kaon>(tofSignal, tofExpMom, momentum, eta, tofEvTimeErr);
case o2::track::PID::Proton: // Pr
return o2::pid::tof::TOFResponseImpl::expectedSigma<o2::track::PID::Proton>(tofSignal, tofExpMom, momentum, eta, tofEvTimeErr);
case o2::track::PID::Deuteron: // De
return o2::pid::tof::TOFResponseImpl::expectedSigma<o2::track::PID::Deuteron>(tofSignal, tofExpMom, momentum, eta, tofEvTimeErr);
case o2::track::PID::Triton: // Tr
return o2::pid::tof::TOFResponseImpl::expectedSigma<o2::track::PID::Triton>(tofSignal, tofExpMom, momentum, eta, tofEvTimeErr);
case o2::track::PID::Helium3: // He3
return o2::pid::tof::TOFResponseImpl::expectedSigma<o2::track::PID::Helium3>(tofSignal, tofExpMom, momentum, eta, tofEvTimeErr);
case o2::track::PID::Alpha: // Al
return o2::pid::tof::TOFResponseImpl::expectedSigma<o2::track::PID::Alpha>(tofSignal, tofExpMom, momentum, eta, tofEvTimeErr);
default:
LOGF(fatal, "TOFExpSigmaImp for PID index %i (%s) is not available", particleId, o2::track::PID::getName(particleId));
return 0.f;
}
});

#define PERSPECIES_TOF_SEPARATION_COLUMN(name, id) \
DECLARE_SOA_DYNAMIC_COLUMN(TOFNSigma##name##Imp, tofNSigmaDyn##name, \
[](const float tofExpMom, \
Expand Down Expand Up @@ -393,8 +455,43 @@
PERSPECIES_TOF_SEPARATION_COLUMN(Al, o2::track::PID::Alpha);
#undef PERSPECIES_TOF_SEPARATION_COLUMN

DECLARE_SOA_DYNAMIC_COLUMN(TOFNSigmaImp, tofNSigmaDyn,
[](float tofExpMom,
const float length,
float momentum,
float eta,
float tofSignal,
float tofEvTime,
float tofEvTimeErr,
o2::track::PID::ID particleId) -> float {
switch (particleId) {
case o2::track::PID::Electron: // El
return o2::pid::tof::TOFResponseImpl::nSigma<o2::track::PID::Electron>(tofSignal, tofExpMom, length, momentum, eta, tofEvTime, tofEvTimeErr);
case o2::track::PID::Muon: // Mu
return o2::pid::tof::TOFResponseImpl::nSigma<o2::track::PID::Muon>(tofSignal, tofExpMom, length, momentum, eta, tofEvTime, tofEvTimeErr);
case o2::track::PID::Pion: // Pi
return o2::pid::tof::TOFResponseImpl::nSigma<o2::track::PID::Pion>(tofSignal, tofExpMom, length, momentum, eta, tofEvTime, tofEvTimeErr);
case o2::track::PID::Kaon: // Ka
return o2::pid::tof::TOFResponseImpl::nSigma<o2::track::PID::Kaon>(tofSignal, tofExpMom, length, momentum, eta, tofEvTime, tofEvTimeErr);
case o2::track::PID::Proton: // Pr
return o2::pid::tof::TOFResponseImpl::nSigma<o2::track::PID::Proton>(tofSignal, tofExpMom, length, momentum, eta, tofEvTime, tofEvTimeErr);
case o2::track::PID::Deuteron: // De
return o2::pid::tof::TOFResponseImpl::nSigma<o2::track::PID::Deuteron>(tofSignal, tofExpMom, length, momentum, eta, tofEvTime, tofEvTimeErr);
case o2::track::PID::Triton: // Tr
return o2::pid::tof::TOFResponseImpl::nSigma<o2::track::PID::Triton>(tofSignal, tofExpMom, length, momentum, eta, tofEvTime, tofEvTimeErr);
case o2::track::PID::Helium3: // He3
return o2::pid::tof::TOFResponseImpl::nSigma<o2::track::PID::Helium3>(tofSignal, tofExpMom, length, momentum, eta, tofEvTime, tofEvTimeErr);
case o2::track::PID::Alpha: // Al
return o2::pid::tof::TOFResponseImpl::nSigma<o2::track::PID::Alpha>(tofSignal, tofExpMom, length, momentum, eta, tofEvTime, tofEvTimeErr);
default:
LOGF(fatal, "TOFNSigmaImp for PID index %i (%s) is not available", particleId, o2::track::PID::getName(particleId));
return 0.f;
}
});

} // namespace pidtof

using TOFExpSigmaDyn = pidtof::TOFExpSigmaImp<track::TOFExpMom, track::P, track::Eta, pidtofsignal::TOFSignal, pidtofevtime::TOFEvTimeErr>;
using TOFExpSigmaDynEl = pidtof::TOFExpSigmaElImp<track::TOFExpMom, track::P, track::Eta, pidtofsignal::TOFSignal, pidtofevtime::TOFEvTimeErr>;
using TOFExpSigmaDynMu = pidtof::TOFExpSigmaMuImp<track::TOFExpMom, track::P, track::Eta, pidtofsignal::TOFSignal, pidtofevtime::TOFEvTimeErr>;
using TOFExpSigmaDynPi = pidtof::TOFExpSigmaPiImp<track::TOFExpMom, track::P, track::Eta, pidtofsignal::TOFSignal, pidtofevtime::TOFEvTimeErr>;
Expand All @@ -405,6 +502,7 @@
using TOFExpSigmaDynHe = pidtof::TOFExpSigmaHeImp<track::TOFExpMom, track::P, track::Eta, pidtofsignal::TOFSignal, pidtofevtime::TOFEvTimeErr>;
using TOFExpSigmaDynAl = pidtof::TOFExpSigmaAlImp<track::TOFExpMom, track::P, track::Eta, pidtofsignal::TOFSignal, pidtofevtime::TOFEvTimeErr>;

using TOFNSigmaDyn = pidtof::TOFNSigmaImp<track::TOFExpMom, track::Length, track::P, track::Eta, pidtofsignal::TOFSignal, pidtofevtime::TOFEvTime, pidtofevtime::TOFEvTimeErr>;
using TOFNSigmaDynEl = pidtof::TOFNSigmaElImp<track::TOFExpMom, track::Length, track::P, track::Eta, pidtofsignal::TOFSignal, pidtofevtime::TOFEvTime, pidtofevtime::TOFEvTimeErr>;
using TOFNSigmaDynMu = pidtof::TOFNSigmaMuImp<track::TOFExpMom, track::Length, track::P, track::Eta, pidtofsignal::TOFSignal, pidtofevtime::TOFEvTime, pidtofevtime::TOFEvTimeErr>;
using TOFNSigmaDynPi = pidtof::TOFNSigmaPiImp<track::TOFExpMom, track::Length, track::P, track::Eta, pidtofsignal::TOFSignal, pidtofevtime::TOFEvTime, pidtofevtime::TOFEvTimeErr>;
Expand Down
Loading