Skip to content

Commit b8d5738

Browse files
committed
Include Run2 compatibility
1 parent ecfafc2 commit b8d5738

6 files changed

Lines changed: 39 additions & 27 deletions

File tree

ALICE3/TableProducer/alice3-pidTOF.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ struct ALICE3pidTOFTask {
120120
template <o2::track::PID::ID id>
121121
float nsigma(Trks::iterator track)
122122
{
123-
return ((track.trackTime() - track.collision().collisionTime()) * 1000.f - tof::ExpTimes<Trks::iterator, id>::GetExpectedSignal(track)) / sigma<id>(track);
123+
return ((track.trackTime() - track.collision().collisionTime()) * 1000.f - tof::ExpTimes<Trks::iterator, id, true>::GetExpectedSignal(track)) / sigma<id>(track);
124124
}
125125
void process(Coll const& collisions, Trks const& tracks)
126126
{

Common/Core/PID/PIDTOF.h

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class TOFMass
112112
};
113113

114114
/// \brief Class to handle the the TOF detector response for the expected time
115-
template <typename TrackType, o2::track::PID::ID id>
115+
template <typename TrackType, o2::track::PID::ID id, bool isRun2Data>
116116
class ExpTimes
117117
{
118118
public:
@@ -124,7 +124,16 @@ class ExpTimes
124124

125125
/// Gets the expected signal of the track of interest under the PID assumption
126126
/// \param track Track of interest
127-
static float GetExpectedSignal(const TrackType& track) { return track.hasTOF() ? ComputeExpectedTime(track.tofExpMom(), track.length(), o2::track::PID::getMass2Z(id)) : defaultReturnValue; }
127+
static float GetExpectedSignal(const TrackType& track)
128+
{
129+
if (!track.hasTOF()) {
130+
return defaultReturnValue;
131+
}
132+
if constexpr (isRun2Data) {
133+
return ComputeExpectedTime(track.tofExpMom() / kCSPEED, track.length(), o2::track::PID::getMass2Z(id));
134+
}
135+
return ComputeExpectedTime(track.tofExpMom(), track.length(), o2::track::PID::getMass2Z(id));
136+
}
128137

129138
/// Gets the expected resolution of the t-texp-t0
130139
/// Given a TOF signal and collision time resolutions
@@ -194,15 +203,15 @@ class ExpTimes
194203
};
195204

196205
/// \brief Class to convert the trackTime to the tofSignal used for PID
197-
template <typename TrackType>
206+
template <typename TrackType, bool isRun2Data>
198207
class TOFSignal
199208
{
200209
public:
201210
TOFSignal() = default;
202211
~TOFSignal() = default;
203212

204213
template <o2::track::PID::ID pid>
205-
using ResponseImplementation = tof::ExpTimes<TrackType, pid>;
214+
using ResponseImplementation = tof::ExpTimes<TrackType, pid, isRun2Data>;
206215
static constexpr auto responseEl = ResponseImplementation<o2::track::PID::Electron>();
207216
static constexpr auto responseMu = ResponseImplementation<o2::track::PID::Muon>();
208217
static constexpr auto responsePi = ResponseImplementation<o2::track::PID::Pion>();
@@ -257,17 +266,17 @@ class TOFSignal
257266
};
258267

259268
//_________________________________________________________________________
260-
template <typename TrackType, o2::track::PID::ID id>
261-
float ExpTimes<TrackType, id>::GetExpectedSigmaFromTrackTime(const DetectorResponse& response, const TrackType& track, const float& collisionTimeRes)
269+
template <typename TrackType, o2::track::PID::ID id, bool isRun2Data>
270+
float ExpTimes<TrackType, id, isRun2Data>::GetExpectedSigmaFromTrackTime(const DetectorResponse& response, const TrackType& track, const float& collisionTimeRes)
262271
{
263-
return GetExpectedSigma(response, track, o2::pid::tof::TOFSignal<TrackType>::GetTOFSignal(track), collisionTimeRes);
272+
return GetExpectedSigma(response, track, o2::pid::tof::TOFSignal<TrackType, isRun2Data>::GetTOFSignal(track), collisionTimeRes);
264273
}
265274

266275
//_________________________________________________________________________
267-
template <typename TrackType, o2::track::PID::ID id>
268-
float ExpTimes<TrackType, id>::GetSeparationFromTrackTime(const DetectorResponse& response, const TrackType& track, const float& collisionTime, const float& collisionTimeRes)
276+
template <typename TrackType, o2::track::PID::ID id, bool isRun2Data>
277+
float ExpTimes<TrackType, id, isRun2Data>::GetSeparationFromTrackTime(const DetectorResponse& response, const TrackType& track, const float& collisionTime, const float& collisionTimeRes)
269278
{
270-
return track.hasTOF() ? (o2::pid::tof::TOFSignal<TrackType>::GetTOFSignal(track) - collisionTime - GetExpectedSignal(track)) / GetExpectedSigmaFromTrackTime(response, track, collisionTimeRes) : defaultReturnValue;
279+
return track.hasTOF() ? (o2::pid::tof::TOFSignal<TrackType, isRun2Data>::GetTOFSignal(track) - collisionTime - GetExpectedSignal(track)) / GetExpectedSigmaFromTrackTime(response, track, collisionTimeRes) : defaultReturnValue;
271280
}
272281

273282
} // namespace o2::pid::tof

Common/TableProducer/PID/pidTOF.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ struct tofPid {
121121
}
122122

123123
template <o2::track::PID::ID pid>
124-
using ResponseImplementation = tof::ExpTimes<Trks::iterator, pid>;
124+
using ResponseImplementation = tof::ExpTimes<Trks::iterator, pid, true>;
125125
void process(Trks const& tracks, Colls const&)
126126
{
127127
constexpr auto responseEl = ResponseImplementation<PID::Electron>();
@@ -283,7 +283,7 @@ struct tofPidQa {
283283

284284
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
285285
{
286-
auto workflow = WorkflowSpec{adaptAnalysisTask<tofSignal>(cfgc),
286+
auto workflow = WorkflowSpec{adaptAnalysisTask<tofSignal<true>>(cfgc),
287287
adaptAnalysisTask<tofPid>(cfgc)};
288288
if (cfgc.options().get<int>("add-qa")) {
289289
workflow.push_back(adaptAnalysisTask<tofPidQa>(cfgc));

Common/TableProducer/PID/pidTOFBase.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ bool isPidTableRequired(o2::framework::InitContext& initContext, const std::stri
4141
}
4242

4343
/// Task to produce the TOF signal from the trackTime information
44+
template <bool isRun2Data>
4445
struct tofSignal {
4546
o2::framework::Produces<o2::aod::TOFSignal> table;
4647
bool enableTable = false;
@@ -58,12 +59,13 @@ struct tofSignal {
5859
}
5960
table.reserve(tracks.size());
6061
for (auto& t : tracks) {
61-
table(o2::pid::tof::TOFSignal<Trks::iterator>::GetTOFSignal(t));
62+
table(o2::pid::tof::TOFSignal<Trks::iterator, isRun2Data>::GetTOFSignal(t));
6263
}
6364
}
6465
};
6566

6667
/// Task to produce the TOF QA plots
68+
template <bool isRun2Data>
6769
struct tofPidFullQa {
6870
static constexpr int Np = 9;
6971
static constexpr const char* pT[Np] = {"e", "#mu", "#pi", "K", "p", "d", "t", "^{3}He", "#alpha"};
@@ -177,7 +179,7 @@ struct tofPidFullQa {
177179
aod::pidTOFFullEl, aod::pidTOFFullMu, aod::pidTOFFullPi,
178180
aod::pidTOFFullKa, aod::pidTOFFullPr, aod::pidTOFFullDe,
179181
aod::pidTOFFullTr, aod::pidTOFFullHe, aod::pidTOFFullAl,
180-
aod::TrackSelection>;
182+
aod::TOFSignal, aod::TrackSelection>;
181183
void process(aod::Collision const& collision, Trks const& tracks)
182184
{
183185
// Computing Multiplicity first
@@ -205,11 +207,10 @@ struct tofPidFullQa {
205207
continue;
206208
}
207209

208-
const float tofSignal = o2::pid::tof::TOFSignal<Trks::iterator>::GetTOFSignal(t);
209-
const float tof = tofSignal - collisionTime_ps;
210+
const float tof = t.tofSignal() - collisionTime_ps;
210211

211212
//
212-
histos.fill(HIST("event/tofsignal"), t.p(), tofSignal);
213+
histos.fill(HIST("event/tofsignal"), t.p(), t.tofSignal());
213214
histos.fill(HIST("event/pexp"), t.p(), t.tofExpMom());
214215
histos.fill(HIST("event/eta"), t.eta());
215216
histos.fill(HIST("event/length"), t.length());

Common/TableProducer/PID/pidTOFFull.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ struct tofPidFull {
119119
}
120120

121121
template <o2::track::PID::ID pid>
122-
using ResponseImplementation = tof::ExpTimes<Trks::iterator, pid>;
122+
using ResponseImplementation = tof::ExpTimes<Trks::iterator, pid, true>;
123123
void process(Coll const& collisions, Trks const& tracks)
124124
{
125125
constexpr auto responseEl = ResponseImplementation<PID::Electron>();
@@ -157,10 +157,10 @@ struct tofPidFull {
157157

158158
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
159159
{
160-
auto workflow = WorkflowSpec{adaptAnalysisTask<tofSignal>(cfgc),
160+
auto workflow = WorkflowSpec{adaptAnalysisTask<tofSignal<true>>(cfgc),
161161
adaptAnalysisTask<tofPidFull>(cfgc)};
162162
if (cfgc.options().get<int>("add-qa")) {
163-
workflow.push_back(adaptAnalysisTask<tofPidFullQa>(cfgc));
163+
workflow.push_back(adaptAnalysisTask<tofPidFullQa<true>>(cfgc));
164164
}
165165
return workflow;
166166
}

Common/TableProducer/PID/pidTOFFullRun3.cxx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,9 @@ struct tofPidFullRun3 {
143143
}
144144
int ncoll = 0;
145145
template <o2::track::PID::ID pid>
146-
using ResponseImplementation = o2::pid::tof::ExpTimes<Trks::iterator, pid>;
146+
using ResponseImplementation = o2::pid::tof::ExpTimes<Trks::iterator, pid, false>;
147+
template <typename T, o2::track::PID::ID pid>
148+
using ResponseImplementationForEvTime = o2::pid::tof::ExpTimes<T, pid, false>;
147149
void process(Coll const& collisions, Trks const& tracks)
148150
{
149151
tableEvTime.reserve(tracks.size());
@@ -158,7 +160,7 @@ struct tofPidFullRun3 {
158160
constexpr auto responseAl = ResponseImplementation<PID::Alpha>();
159161

160162
// First make table for event time
161-
auto evTime = o2::tof::evTimeMakerFromParam<Trks, Trks::iterator, filterForTOFEventTime, o2::pid::tof::ExpTimes>(tracks, response);
163+
auto evTime = o2::tof::evTimeMakerFromParam<Trks, Trks::iterator, filterForTOFEventTime, ResponseImplementationForEvTime>(tracks, response);
162164
static constexpr bool removebias = true;
163165
int ngoodtracks = 0;
164166
for (auto const& trk : tracks) { // Loop on Tracks
@@ -296,7 +298,7 @@ struct tofPidCollisionTimeQa { /// Task that produces the TOF collision time
296298
histos.fill(HIST("withtof/length"), t.length());
297299
histos.fill(HIST("withtof/tofSignal"), t.tofSignal());
298300
histos.fill(HIST("withtof/beta"), t.p(), beta);
299-
histos.fill(HIST("withtof/delta"), t.p(), t.tofSignal() - t.tofEvTime() - o2::pid::tof::ExpTimes<Trks::iterator, PID::Pion>::GetExpectedSignal(t));
301+
histos.fill(HIST("withtof/delta"), t.p(), t.tofSignal() - t.tofEvTime() - o2::pid::tof::ExpTimes<Trks::iterator, PID::Pion, false>::GetExpectedSignal(t));
300302
histos.fill(HIST("withtof/expP"), t.p(), t.tofExpMom());
301303
histos.fill(HIST("withtof/mass"), mass);
302304
histos.fill(HIST("withtof/tofSignalPerCollision"), ncolls % 6000, t.tofSignal());
@@ -317,7 +319,7 @@ struct tofPidCollisionTimeQa { /// Task that produces the TOF collision time
317319
histos.fill(HIST("goodforevtime/length"), t.length());
318320
histos.fill(HIST("goodforevtime/tofSignal"), t.tofSignal());
319321
histos.fill(HIST("goodforevtime/beta"), t.p(), beta);
320-
histos.fill(HIST("goodforevtime/delta"), t.p(), t.tofSignal() - t.tofEvTime() - o2::pid::tof::ExpTimes<Trks::iterator, PID::Pion>::GetExpectedSignal(t));
322+
histos.fill(HIST("goodforevtime/delta"), t.p(), t.tofSignal() - t.tofEvTime() - o2::pid::tof::ExpTimes<Trks::iterator, PID::Pion, false>::GetExpectedSignal(t));
321323
histos.fill(HIST("goodforevtime/expP"), t.p(), t.tofExpMom());
322324
histos.fill(HIST("goodforevtime/mass"), mass);
323325
histos.fill(HIST("goodforevtime/tofSignalPerCollision"), ncolls % 6000, t.tofSignal());
@@ -327,10 +329,10 @@ struct tofPidCollisionTimeQa { /// Task that produces the TOF collision time
327329

328330
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
329331
{
330-
auto workflow = WorkflowSpec{adaptAnalysisTask<tofSignal>(cfgc),
332+
auto workflow = WorkflowSpec{adaptAnalysisTask<tofSignal<false>>(cfgc),
331333
adaptAnalysisTask<tofPidFullRun3>(cfgc)};
332334
if (cfgc.options().get<int>("add-qa")) {
333-
workflow.push_back(adaptAnalysisTask<tofPidFullQa>(cfgc));
335+
workflow.push_back(adaptAnalysisTask<tofPidFullQa<false>>(cfgc));
334336
workflow.push_back(adaptAnalysisTask<tofPidCollisionTimeQa>(cfgc));
335337
}
336338
return workflow;

0 commit comments

Comments
 (0)