Skip to content

Commit 68e5d5a

Browse files
authored
Simplify TOF PID Response parameter usage (#934)
- bypass previous DetectorResponse common structure (will be removed) - New structure holds only parameters - Implementation is left in code only - Add additional param getter - Using data member as mass defined at compile time - Fix warning of overriding streamers - Simplify TOF param handler - Add performance plotting - Add validity based on run range - Add parameters to metadata - Add PID simple mode w/o slicing - Add possibility to turn on and off slices - Extend TOF PID tasks - Fix pidTOF switches - Update default par name to TOFResoParams, add FT0 only ev time - Clean includes - Extend TOF QA plots - Add ev time reso - Fill ev time per class - Align includes, fix ALICE3 TOF param
1 parent eeab638 commit 68e5d5a

20 files changed

Lines changed: 715 additions & 174 deletions

ALICE3/Core/TOFResoALICE3.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
#define O2_ANALYSIS_PID_TOFRESOALICE3_H_
2121

2222
// O2 includes
23-
#include "Common/Core/PID/ParamBase.h"
23+
#include "PID/ParamBase.h"
24+
#include "PID/DetectorResponse.h"
25+
#include "PID/PIDTOF.h"
2426
#include "ReconstructionDataFormats/PID.h"
2527

2628
namespace o2::pid::tof

ALICE3/TableProducer/alice3-pidTOF.cxx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include "ReconstructionDataFormats/Track.h"
2323
#include <CCDB/BasicCCDBManager.h>
2424
#include "Common/DataModel/PIDResponse.h"
25-
#include "Common/Core/PID/PIDTOF.h"
2625
#include "ALICE3/Core/TOFResoALICE3.h"
2726
#include "Common/DataModel/TrackSelectionTables.h"
2827
#include "Framework/RunningWorkflowInfo.h"
@@ -125,8 +124,7 @@ struct ALICE3pidTOFTask {
125124
return -999.f;
126125
}
127126
return ((track.trackTime() - track.collision().collisionTime()) * 1000.f - tof::ExpTimes<Trks::iterator, id>::ComputeExpectedTime(track.tofExpMom() / o2::pid::tof::kCSPEED,
128-
track.length(),
129-
o2::track::PID::getMass2Z(id))) /
127+
track.length())) /
130128
sigma<id>(track);
131129
}
132130
void process(Trks const& tracks, Coll const&)

Common/Core/AnalysisCoreLinkDef.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@
1616
#pragma link C++ class TrackSelection + ;
1717

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

2122
#pragma link C++ class o2::pid::tpc::Response + ;
2223

2324
#pragma link C++ class o2::pid::tof::TOFReso + ;
25+
#pragma link C++ class o2::pid::tof::TOFResoParams + ;
2426
#pragma link C++ class OrbitRange + ;

Common/Core/PID/PIDTOF.h

Lines changed: 62 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#include "Framework/Logger.h"
2828
#include "ReconstructionDataFormats/PID.h"
2929
#include "Framework/DataTypes.h"
30-
#include "Common/Core/PID/DetectorResponse.h"
3130

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

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

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

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

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

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

118+
/// \brief Implementation class to store TOF response parameters for exp. times
119+
class TOFResoParams : public o2::pid::PidParameters<5>
120+
{
121+
public:
122+
TOFResoParams() : PidParameters("TOFResoParams") { SetParameters(std::array<float, 5>{0.008, 0.008, 0.002, 40.0, 60.0}); }; // Default constructor with default parameters
123+
~TOFResoParams() = default;
124+
ClassDef(TOFResoParams, 1);
125+
};
126+
119127
/// \brief Class to handle the the TOF detector response for the expected time
120128
template <typename TrackType, o2::track::PID::ID id>
121129
class ExpTimes
122130
{
123131
public:
124132
ExpTimes() = default;
125133
~ExpTimes() = default;
134+
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)
135+
static constexpr float mMassZSqared = mMassZ * mMassZ; /// (M/z)^2
126136

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

130140
/// Gets the expected signal of the track of interest under the PID assumption
131141
/// \param track Track of interest
@@ -135,9 +145,9 @@ class ExpTimes
135145
return defaultReturnValue;
136146
}
137147
if (track.trackType() == o2::aod::track::Run2Track) {
138-
return ComputeExpectedTime(track.tofExpMom() / kCSPEED, track.length(), o2::track::PID::getMass2Z(id));
148+
return ComputeExpectedTime(track.tofExpMom() / kCSPEED, track.length());
139149
}
140-
return ComputeExpectedTime(track.tofExpMom(), track.length(), o2::track::PID::getMass2Z(id));
150+
return ComputeExpectedTime(track.tofExpMom(), track.length());
141151
}
142152

143153
/// Gets the expected resolution of the t-texp-t0
@@ -146,22 +156,44 @@ class ExpTimes
146156
/// \param track Track of interest
147157
/// \param tofSignal TOF signal of the track of interest
148158
/// \param collisionTimeRes Collision time resolution of the track of interest
149-
static float GetExpectedSigma(const DetectorResponse& response, const TrackType& track, const float& tofSignal, const float& collisionTimeRes)
159+
static float GetExpectedSigma(const DetectorResponse& response, const TrackType& track, const float tofSignal, const float collisionTimeRes)
150160
{
151161
if (!track.hasTOF()) {
152162
return defaultReturnValue;
153163
}
154164
// const float x[7] = {track.p(), tofSignal, collisionTimeRes, o2::track::PID::getMass2Z(id), track.length(), track.sigma1Pt(), track.pt()};
155-
const float x[4] = {track.p(), tofSignal, collisionTimeRes, o2::track::PID::getMass2Z(id)};
165+
const float x[4] = {track.p(), tofSignal, collisionTimeRes, mMassZ};
156166
const float reso = response(response.kSigma, x);
157167
return reso >= 0.f ? reso : 0.f;
158168
}
159169

170+
/// Gets the expected resolution of the t-texp-t0
171+
/// Given a TOF signal and collision time resolutions
172+
/// \param parameters Detector response parameters
173+
/// \param track Track of interest
174+
/// \param tofSignal TOF signal of the track of interest
175+
/// \param collisionTimeRes Collision time resolution of the track of interest
176+
static float GetExpectedSigma(const TOFResoParams& parameters, const TrackType& track, const float tofSignal, const float collisionTimeRes)
177+
{
178+
const float mom = track.p();
179+
if (mom <= 0) {
180+
return -999.f;
181+
}
182+
const float dpp = parameters[0] + parameters[1] * mom + parameters[2] * mMassZ / mom; // mean relative pt resolution;
183+
const float sigma = dpp * tofSignal / (1. + mom * mom / (mMassZSqared));
184+
return std::sqrt(sigma * sigma + parameters[3] * parameters[3] / mom / mom + parameters[4] * parameters[4] + collisionTimeRes * collisionTimeRes);
185+
}
186+
160187
/// Gets the expected resolution of the t-texp-t0
161188
/// \param response Detector response with parameters
162189
/// \param track Track of interest
163190
static float GetExpectedSigma(const DetectorResponse& response, const TrackType& track) { return track.isEvTimeDefined() ? GetExpectedSigma(response, track, track.tofSignal(), track.tofEvTime()) : defaultReturnValue; }
164191

192+
/// Gets the expected resolution of the t-texp-t0
193+
/// \param parameters Detector response parameters
194+
/// \param track Track of interest
195+
static float GetExpectedSigma(const TOFResoParams& parameters, const TrackType& track) { return track.isEvTimeDefined() ? GetExpectedSigma(parameters, track, track.tofSignal(), track.tofEvTime()) : defaultReturnValue; }
196+
165197
/// Gets the expected resolution of the time measurement, uses the expected time and no event time resolution
166198
/// \param response Detector response with parameters
167199
/// \param track Track of interest
@@ -170,25 +202,37 @@ class ExpTimes
170202
/// Gets the separation between the measured signal and the expected one
171203
/// \param track Track of interest
172204
/// \param collisionTime Collision time
173-
static float GetDelta(const TrackType& track, const float& collisionTime) { return track.hasTOF() ? (track.tofSignal() - collisionTime - GetExpectedSignal(track)) : defaultReturnValue; }
205+
static float GetDelta(const TrackType& track, const float collisionTime) { return track.hasTOF() ? (track.tofSignal() - collisionTime - GetExpectedSignal(track)) : defaultReturnValue; }
174206

175207
/// Gets the number of sigmas with respect the expected time
176208
/// \param response Detector response with parameters
177209
/// \param track Track of interest
178210
/// \param collisionTime Collision time
179211
/// \param collisionTimeRes Collision time resolution of the track of interest
180-
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; }
212+
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; }
181213

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

219+
/// Gets the number of sigmas with respect the expected time
220+
/// \param parameters Detector response parameters
221+
/// \param track Track of interest
222+
/// \param collisionTime Collision time
223+
/// \param collisionTimeRes Collision time resolution of the track of interest
224+
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; }
225+
226+
/// Gets the number of sigmas with respect the expected time
227+
/// \param parameters Detector response parameters
228+
/// \param track Track of interest
229+
static float GetSeparation(const TOFResoParams& parameters, const TrackType& track) { return track.isEvTimeDefined() ? GetSeparation(parameters, track, track.tofEvTime(), track.tofEvTimeErr()) : defaultReturnValue; }
230+
187231
/// Gets the expected resolution of the measurement from the track time and from the collision time, explicitly passed as argument
188232
/// \param response Detector response with parameters
189233
/// \param track Track of interest
190234
/// \param collisionTimeRes Collision time resolution of the track of interest
191-
static float GetExpectedSigmaFromTrackTime(const DetectorResponse& response, const TrackType& track, const float& collisionTimeRes);
235+
static float GetExpectedSigmaFromTrackTime(const DetectorResponse& response, const TrackType& track, const float collisionTimeRes);
192236

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

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

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

274318
//_________________________________________________________________________
275319
template <typename TrackType, o2::track::PID::ID id>
276-
float ExpTimes<TrackType, id>::GetExpectedSigmaFromTrackTime(const DetectorResponse& response, const TrackType& track, const float& collisionTimeRes)
320+
float ExpTimes<TrackType, id>::GetExpectedSigmaFromTrackTime(const DetectorResponse& response, const TrackType& track, const float collisionTimeRes)
277321
{
278322
return GetExpectedSigma(response, track, o2::pid::tof::TOFSignal<TrackType>::GetTOFSignal(track), collisionTimeRes);
279323
}
280324

281325
//_________________________________________________________________________
282326
template <typename TrackType, o2::track::PID::ID id>
283-
float ExpTimes<TrackType, id>::GetSeparationFromTrackTime(const DetectorResponse& response, const TrackType& track, const float& collisionTime, const float& collisionTimeRes)
327+
float ExpTimes<TrackType, id>::GetSeparationFromTrackTime(const DetectorResponse& response, const TrackType& track, const float collisionTime, const float collisionTimeRes)
284328
{
285329
return track.hasTOF() ? (o2::pid::tof::TOFSignal<TrackType>::GetTOFSignal(track) - collisionTime - GetExpectedSignal(track)) / GetExpectedSigmaFromTrackTime(response, track, collisionTimeRes) : defaultReturnValue;
286330
}

Common/Core/PID/ParamBase.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
/// These are the basic storage elements to be kept in the CCDB
1818
///
1919

20-
#include "Common/Core/PID/ParamBase.h"
20+
#include "PID/ParamBase.h"
2121
#include "Framework/Logger.h"
2222
#include "TFile.h"
2323

@@ -80,4 +80,4 @@ void Parametrization::LoadParamFromFile(const TString FileName, const TString Pa
8080
Print();
8181
}
8282

83-
} // namespace o2::pid
83+
} // namespace o2::pid

0 commit comments

Comments
 (0)