Skip to content
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
4 changes: 3 additions & 1 deletion ALICE3/Core/TOFResoALICE3.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
#define O2_ANALYSIS_PID_TOFRESOALICE3_H_

// O2 includes
#include "Common/Core/PID/ParamBase.h"
#include "PID/ParamBase.h"
#include "PID/DetectorResponse.h"
#include "PID/PIDTOF.h"
#include "ReconstructionDataFormats/PID.h"

namespace o2::pid::tof
Expand Down
4 changes: 1 addition & 3 deletions ALICE3/TableProducer/alice3-pidTOF.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include "ReconstructionDataFormats/Track.h"
#include <CCDB/BasicCCDBManager.h>
#include "Common/DataModel/PIDResponse.h"
#include "Common/Core/PID/PIDTOF.h"
#include "ALICE3/Core/TOFResoALICE3.h"
#include "Common/DataModel/TrackSelectionTables.h"
#include "Framework/RunningWorkflowInfo.h"
Expand Down Expand Up @@ -125,8 +124,7 @@ struct ALICE3pidTOFTask {
return -999.f;
}
return ((track.trackTime() - track.collision().collisionTime()) * 1000.f - tof::ExpTimes<Trks::iterator, id>::ComputeExpectedTime(track.tofExpMom() / o2::pid::tof::kCSPEED,
track.length(),
o2::track::PID::getMass2Z(id))) /
track.length())) /
sigma<id>(track);
}
void process(Trks const& tracks, Coll const&)
Expand Down
2 changes: 2 additions & 0 deletions Common/Core/AnalysisCoreLinkDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
#pragma link C++ class TrackSelection + ;

#pragma link C++ class o2::pid::Parameters + ;
#pragma link C++ class o2::pid::PidParameters < 5> + ;
#pragma link C++ class o2::pid::Parametrization + ;

#pragma link C++ class o2::pid::tof::TOFReso + ;
#pragma link C++ class o2::pid::tof::TOFResoParams + ;
#pragma link C++ class OrbitRange + ;
80 changes: 62 additions & 18 deletions Common/Core/PID/PIDTOF.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include "Framework/Logger.h"
#include "ReconstructionDataFormats/PID.h"
#include "Framework/DataTypes.h"
#include "Common/Core/PID/DetectorResponse.h"

namespace o2::pid::tof
{
Expand All @@ -48,12 +47,12 @@ class Beta
/// \param length Length in cm of the track
/// \param tofSignal TOF signal in ps for the track
/// \param collisionTime collision time in ps for the event of the track
static float GetBeta(const float& length, const float& tofSignal, const float& collisionTime) { return length / (tofSignal - collisionTime) / kCSPEED; }
static float GetBeta(const float length, const float tofSignal, const float collisionTime) { return length / (tofSignal - collisionTime) / kCSPEED; }

/// Gets the beta for the track of interest
/// \param track Track of interest
/// \param collisionTime Collision time
static float GetBeta(const TrackType& track, const float& collisionTime) { return track.hasTOF() ? GetBeta(track.length(), track.tofSignal(), collisionTime) : defaultReturnValue; }
static float GetBeta(const TrackType& track, const float collisionTime) { return track.hasTOF() ? GetBeta(track.length(), track.tofSignal(), collisionTime) : defaultReturnValue; }

/// Gets the beta for the track of interest
/// \param track Track of interest
Expand All @@ -64,7 +63,7 @@ class Beta
/// \param tofSignal TOF signal in ps for the track
/// \param collisionTime collision time in ps for the event of the track
/// \param time_reso expected time resolution
static float GetExpectedSigma(const float& length, const float& tofSignal, const float& collisionTime, const float& expectedResolution) { return GetBeta(length, tofSignal, collisionTime) / (tofSignal - collisionTime) * expectedResolution; }
static float GetExpectedSigma(const float length, const float tofSignal, const float collisionTime, const float expectedResolution) { return GetBeta(length, tofSignal, collisionTime) / (tofSignal - collisionTime) * expectedResolution; }

/// Gets the expected uncertainty on the beta measurement of the track of interest
/// \param track Track of interest
Expand All @@ -73,7 +72,7 @@ class Beta
/// Gets the expected beta for a given mass hypothesis (no energy loss taken into account)
/// \param momentum momentum in GeV/c of the track
/// \param mass mass in GeV/c2 of the particle of interest
static float GetExpectedSignal(const float& momentum, const float& mass) { return momentum > 0 ? momentum / std::sqrt(momentum * momentum + mass * mass) : 0.f; }
static float GetExpectedSignal(const float momentum, const float mass) { return momentum > 0 ? momentum / std::sqrt(momentum * momentum + mass * mass) : 0.f; }

/// Gets the expected beta given the particle index (no energy loss taken into account) of the track of interest
/// \param track Track of interest
Expand Down Expand Up @@ -105,7 +104,7 @@ class TOFMass
/// Computes the TOF mass of a track given a momentum, a beta measurement
/// \param momentum momentum of the track
/// \param beta TOF beta measurement
static float GetTOFMass(const float& momentum, const float& beta) { return (momentum / beta) * std::sqrt(std::abs(1.f - beta * beta)); }
static float GetTOFMass(const float momentum, const float beta) { return (momentum / beta) * std::sqrt(std::abs(1.f - beta * beta)); }

/// Gets the TOF mass for the track of interest
/// \param track Track of interest
Expand All @@ -116,16 +115,27 @@ class TOFMass
static float GetTOFMass(const TrackType& track) { return track.hasTOF() ? GetTOFMass(track.p(), Beta<TrackType>::GetBeta(track)) : defaultReturnValue; }
};

/// \brief Implementation class to store TOF response parameters for exp. times
class TOFResoParams : public o2::pid::PidParameters<5>
{
public:
TOFResoParams() : PidParameters("TOFResoParams") { SetParameters(std::array<float, 5>{0.008, 0.008, 0.002, 40.0, 60.0}); }; // Default constructor with default parameters
~TOFResoParams() = default;
ClassDef(TOFResoParams, 1);
};

/// \brief Class to handle the the TOF detector response for the expected time
template <typename TrackType, o2::track::PID::ID id>
class ExpTimes
{
public:
ExpTimes() = default;
~ExpTimes() = default;
static constexpr float mMassZ = o2::track::pid_constants::sMasses2Z[id]; /// Mass hypothesis divided by the charge (in units of e): M/z. Equivalent to o2::track::PID::getMass2Z(id)
static constexpr float mMassZSqared = mMassZ * mMassZ; /// (M/z)^2

/// Computes the expected time of a track, given it TOF expected momentum
static float ComputeExpectedTime(const float& tofExpMom, const float& length, const float& massZ) { return length * sqrt((massZ * massZ) + (tofExpMom * tofExpMom)) / (kCSPEED * tofExpMom); }
static float ComputeExpectedTime(const float tofExpMom, const float length) { return length * sqrt((mMassZSqared) + (tofExpMom * tofExpMom)) / (kCSPEED * tofExpMom); }

/// Gets the expected signal of the track of interest under the PID assumption
/// \param track Track of interest
Expand All @@ -135,9 +145,9 @@ class ExpTimes
return defaultReturnValue;
}
if (track.trackType() == o2::aod::track::Run2Track) {
return ComputeExpectedTime(track.tofExpMom() / kCSPEED, track.length(), o2::track::PID::getMass2Z(id));
return ComputeExpectedTime(track.tofExpMom() / kCSPEED, track.length());
}
return ComputeExpectedTime(track.tofExpMom(), track.length(), o2::track::PID::getMass2Z(id));
return ComputeExpectedTime(track.tofExpMom(), track.length());
}

/// Gets the expected resolution of the t-texp-t0
Expand All @@ -146,22 +156,44 @@ class ExpTimes
/// \param track Track of interest
/// \param tofSignal TOF signal of the track of interest
/// \param collisionTimeRes Collision time resolution of the track of interest
static float GetExpectedSigma(const DetectorResponse& response, const TrackType& track, const float& tofSignal, const float& collisionTimeRes)
static float GetExpectedSigma(const DetectorResponse& response, const TrackType& track, const float tofSignal, const float collisionTimeRes)
{
if (!track.hasTOF()) {
return defaultReturnValue;
}
// const float x[7] = {track.p(), tofSignal, collisionTimeRes, o2::track::PID::getMass2Z(id), track.length(), track.sigma1Pt(), track.pt()};
const float x[4] = {track.p(), tofSignal, collisionTimeRes, o2::track::PID::getMass2Z(id)};
const float x[4] = {track.p(), tofSignal, collisionTimeRes, mMassZ};
const float reso = response(response.kSigma, x);
return reso >= 0.f ? reso : 0.f;
}

/// Gets the expected resolution of the t-texp-t0
/// Given a TOF signal and collision time resolutions
/// \param parameters Detector response parameters
/// \param track Track of interest
/// \param tofSignal TOF signal of the track of interest
/// \param collisionTimeRes Collision time resolution of the track of interest
static float GetExpectedSigma(const TOFResoParams& parameters, const TrackType& track, const float tofSignal, const float collisionTimeRes)
{
const float mom = track.p();
if (mom <= 0) {
return -999.f;
}
const float dpp = parameters[0] + parameters[1] * mom + parameters[2] * mMassZ / mom; // mean relative pt resolution;
const float sigma = dpp * tofSignal / (1. + mom * mom / (mMassZSqared));
return std::sqrt(sigma * sigma + parameters[3] * parameters[3] / mom / mom + parameters[4] * parameters[4] + collisionTimeRes * collisionTimeRes);
}

/// Gets the expected resolution of the t-texp-t0
/// \param response Detector response with parameters
/// \param track Track of interest
static float GetExpectedSigma(const DetectorResponse& response, const TrackType& track) { return track.isEvTimeDefined() ? GetExpectedSigma(response, track, track.tofSignal(), track.tofEvTime()) : defaultReturnValue; }

/// Gets the expected resolution of the t-texp-t0
/// \param parameters Detector response parameters
/// \param track Track of interest
static float GetExpectedSigma(const TOFResoParams& parameters, const TrackType& track) { return track.isEvTimeDefined() ? GetExpectedSigma(parameters, track, track.tofSignal(), track.tofEvTime()) : defaultReturnValue; }

/// Gets the expected resolution of the time measurement, uses the expected time and no event time resolution
/// \param response Detector response with parameters
/// \param track Track of interest
Expand All @@ -170,25 +202,37 @@ class ExpTimes
/// Gets the separation between the measured signal and the expected one
/// \param track Track of interest
/// \param collisionTime Collision time
static float GetDelta(const TrackType& track, const float& collisionTime) { return track.hasTOF() ? (track.tofSignal() - collisionTime - GetExpectedSignal(track)) : defaultReturnValue; }
static float GetDelta(const TrackType& track, const float collisionTime) { return track.hasTOF() ? (track.tofSignal() - collisionTime - GetExpectedSignal(track)) : defaultReturnValue; }

/// Gets the number of sigmas with respect the expected time
/// \param response Detector response with parameters
/// \param track Track of interest
/// \param collisionTime Collision time
/// \param collisionTimeRes Collision time resolution of the track of interest
static float GetSeparation(const DetectorResponse& response, const TrackType& track, const float& collisionTime, const float& collisionTimeRes) { return track.hasTOF() ? GetDelta(track, collisionTime) / GetExpectedSigma(response, track, track.tofSignal(), collisionTimeRes) : defaultReturnValue; }
static float GetSeparation(const DetectorResponse& response, const TrackType& track, const float collisionTime, const float collisionTimeRes) { return track.hasTOF() ? GetDelta(track, collisionTime) / GetExpectedSigma(response, track, track.tofSignal(), collisionTimeRes) : defaultReturnValue; }

/// Gets the number of sigmas with respect the expected time
/// \param response Detector response with parameters
/// \param track Track of interest
static float GetSeparation(const DetectorResponse& response, const TrackType& track) { return track.isEvTimeDefined() ? GetSeparation(response, track, track.tofEvTime(), track.tofEvTimeErr()) : defaultReturnValue; }

/// Gets the number of sigmas with respect the expected time
/// \param parameters Detector response parameters
/// \param track Track of interest
/// \param collisionTime Collision time
/// \param collisionTimeRes Collision time resolution of the track of interest
static float GetSeparation(const TOFResoParams& parameters, const TrackType& track, const float collisionTime, const float collisionTimeRes) { return track.hasTOF() ? GetDelta(track, collisionTime) / GetExpectedSigma(parameters, track, track.tofSignal(), collisionTimeRes) : defaultReturnValue; }

/// Gets the number of sigmas with respect the expected time
/// \param parameters Detector response parameters
/// \param track Track of interest
static float GetSeparation(const TOFResoParams& parameters, const TrackType& track) { return track.isEvTimeDefined() ? GetSeparation(parameters, track, track.tofEvTime(), track.tofEvTimeErr()) : defaultReturnValue; }

/// Gets the expected resolution of the measurement from the track time and from the collision time, explicitly passed as argument
/// \param response Detector response with parameters
/// \param track Track of interest
/// \param collisionTimeRes Collision time resolution of the track of interest
static float GetExpectedSigmaFromTrackTime(const DetectorResponse& response, const TrackType& track, const float& collisionTimeRes);
static float GetExpectedSigmaFromTrackTime(const DetectorResponse& response, const TrackType& track, const float collisionTimeRes);

/// Gets the expected resolution of the measurement from the track time
/// \param response Detector response with parameters
Expand All @@ -200,7 +244,7 @@ class ExpTimes
/// \param track Track of interest
/// \param collisionTime Collision time
/// \param collisionTimeRes Collision time resolution of the track of interest
static float GetSeparationFromTrackTime(const DetectorResponse& response, const TrackType& track, const float& collisionTime, const float& collisionTimeRes);
static float GetSeparationFromTrackTime(const DetectorResponse& response, const TrackType& track, const float collisionTime, const float collisionTimeRes);

/// Gets the number of sigmas with respect the expected time from the track time
/// \param response Detector response with parameters
Expand Down Expand Up @@ -231,7 +275,7 @@ class TOFSignal
/// Computes the expected time of a track, given its TOF expected time
/// \param trackTime trackTime in ns
/// \param response response to use to compute the expected time for the propagation from the vertex to TOF
static float ComputeTOFSignal(const float& trackTime, const float& expTime) { return trackTime * 1000.f + expTime; }
static float ComputeTOFSignal(const float trackTime, const float expTime) { return trackTime * 1000.f + expTime; }

/// Returns the expected time of a track, given its TOF response to use to compute the expected time
/// \param track input track
Expand Down Expand Up @@ -273,14 +317,14 @@ class TOFSignal

//_________________________________________________________________________
template <typename TrackType, o2::track::PID::ID id>
float ExpTimes<TrackType, id>::GetExpectedSigmaFromTrackTime(const DetectorResponse& response, const TrackType& track, const float& collisionTimeRes)
float ExpTimes<TrackType, id>::GetExpectedSigmaFromTrackTime(const DetectorResponse& response, const TrackType& track, const float collisionTimeRes)
{
return GetExpectedSigma(response, track, o2::pid::tof::TOFSignal<TrackType>::GetTOFSignal(track), collisionTimeRes);
}

//_________________________________________________________________________
template <typename TrackType, o2::track::PID::ID id>
float ExpTimes<TrackType, id>::GetSeparationFromTrackTime(const DetectorResponse& response, const TrackType& track, const float& collisionTime, const float& collisionTimeRes)
float ExpTimes<TrackType, id>::GetSeparationFromTrackTime(const DetectorResponse& response, const TrackType& track, const float collisionTime, const float collisionTimeRes)
{
return track.hasTOF() ? (o2::pid::tof::TOFSignal<TrackType>::GetTOFSignal(track) - collisionTime - GetExpectedSignal(track)) / GetExpectedSigmaFromTrackTime(response, track, collisionTimeRes) : defaultReturnValue;
}
Expand Down
4 changes: 2 additions & 2 deletions Common/Core/PID/ParamBase.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/// These are the basic storage elements to be kept in the CCDB
///

#include "Common/Core/PID/ParamBase.h"
#include "PID/ParamBase.h"
#include "Framework/Logger.h"
#include "TFile.h"

Expand Down Expand Up @@ -80,4 +80,4 @@ void Parametrization::LoadParamFromFile(const TString FileName, const TString Pa
Print();
}

} // namespace o2::pid
} // namespace o2::pid
Loading