Skip to content

Commit 8d1b4da

Browse files
authored
Enhance TOF event time computation with FT0 corrections
Updated FT0 handling in TOF event time computation by introducing a new table for corrected FT0 values. Adjusted logic to utilize the corrected FT0 data when available.
1 parent 776a3ff commit 8d1b4da

File tree

1 file changed

+76
-13
lines changed

1 file changed

+76
-13
lines changed

Common/TableProducer/PID/pidTOFMerge.cxx

Lines changed: 76 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "Common/DataModel/PIDResponseTOF.h"
2929

3030
#include <CCDB/BasicCCDBManager.h>
31+
#include <DataFormatsFT0/Digit.h>
3132
#include <DataFormatsParameters/GRPLHCIFData.h>
3233
#include <DataFormatsTOF/ParameterContainers.h>
3334
#include <Framework/ASoA.h>
@@ -72,7 +73,8 @@ using Run3TrksWtof = soa::Join<Run3Trks, aod::TOFSignal>;
7273
using Run3TrksWtofWevTime = soa::Join<Run3TrksWtof, aod::TOFEvTime, aod::pidEvTimeFlags>;
7374

7475
using EvTimeCollisions = soa::Join<aod::Collisions, aod::EvSels>;
75-
using EvTimeCollisionsFT0 = soa::Join<EvTimeCollisions, aod::FT0sCorrected>;
76+
// using EvTimeCollisionsFT0 = soa::Join<EvTimeCollisions, aod::FT0sCorrected>;
77+
using EvTimeCollisionsFT0 = EvTimeCollisions;
7678

7779
using Run2Trks = o2::soa::Join<aod::Tracks, aod::TracksExtra>;
7880
using Run2TrksWtofWevTime = soa::Join<Run2Trks, aod::TOFSignal, aod::TOFEvTime, aod::pidEvTimeFlags>;
@@ -248,16 +250,18 @@ struct tofEventTime {
248250
Service<o2::ccdb::BasicCCDBManager> ccdb;
249251
Service<o2::pid::tof::TOFResponse> tofResponse;
250252
// Tables to produce
251-
Produces<o2::aod::TOFEvTime> tableEvTime;
252-
Produces<o2::aod::EvTimeTOFOnly> tableEvTimeTOFOnly;
253-
Produces<o2::aod::pidEvTimeFlags> tableFlags;
254-
static constexpr bool kRemoveTOFEvTimeBias = true; // Flag to subtract the Ev. Time bias for low multiplicity events with TOF
255-
static constexpr float kDiamond = 6.0; // Collision diamond used in the estimation of the TOF event time
253+
// Produces<o2::aod::FT0sCorrected> tableFT0Corrected; // Table with corrected FT0 values, to be used in the TOF event time computation
254+
Produces<o2::aod::TOFEvTime> tableEvTime; // Table with the TOF event time, computed with the tracks that pass the filterForTOFEventTime selection and the TOF response
255+
Produces<o2::aod::EvTimeTOFOnly> tableEvTimeTOFOnly; // Table with the TOF event time, computed only with the TOF itself
256+
Produces<o2::aod::pidEvTimeFlags> tableFlags; // Table with flags for the TOF event time, e.g. how it was computed
257+
static constexpr bool kRemoveTOFEvTimeBias = true; // Flag to subtract the Ev. Time bias for low multiplicity events with TOF
258+
static constexpr float kDiamond = 6.0; // Collision diamond used in the estimation of the TOF event time
256259
static constexpr float kErrDiamond = kDiamond * 33.356409f;
257260
static constexpr float kWeightDiamond = 1.f / (kErrDiamond * kErrDiamond);
258261

259262
bool enableTableTOFEvTime = false;
260263
bool enableTableEvTimeTOFOnly = false;
264+
bool enableTableFT0Corrected = false;
261265

262266
// Event time configurations
263267
Configurable<float> minMomentum{"minMomentum", 0.5f, "Minimum momentum to select track sample for TOF event time"};
@@ -285,7 +289,12 @@ struct tofEventTime {
285289
LOG(info) << "Table EvTimeTOFOnly enabled!";
286290
}
287291

288-
if (!enableTableTOFEvTime && !enableTableEvTimeTOFOnly) {
292+
enableTableFT0Corrected = isTableRequiredInWorkflow(initContext, "FT0Corrected");
293+
if (enableTableFT0Corrected) {
294+
LOG(info) << "Table FT0Corrected enabled!";
295+
}
296+
297+
if (!enableTableTOFEvTime && !enableTableEvTimeTOFOnly && !enableTableFT0Corrected) {
289298
LOG(info) << "No table is enabled. Disabling task";
290299
return;
291300
}
@@ -362,6 +371,19 @@ struct tofEventTime {
362371
}
363372
PROCESS_SWITCH(tofEventTime, processRun2, "Process with Run2 data", true);
364373

374+
struct ft0Container {
375+
ft0Container() = default;
376+
ft0Container(float t0A, float t0C) : mT0A(t0A), mT0C(t0C) {}
377+
float t0AC() const { return 0.5f * (mT0A + mT0C); }
378+
float t0ACorrectedValid() const { return (mT0A < 1e9); }
379+
float t0CCorrectedValid() const { return (mT0C < 1e9); }
380+
float t0resolution() const { return 0.5f * (mT0A - mT0C); }
381+
float t0ACValid() const { return (mT0A < 1e9) && (mT0C < 1e9); }
382+
383+
private:
384+
float mT0A = 1e10f;
385+
float mT0C = 1e10f;
386+
};
365387
///
366388
/// Process function to prepare the event for each track on Run 3 data without the FT0
367389
// Define slice per collision
@@ -370,7 +392,7 @@ struct tofEventTime {
370392
using ResponseImplementationEvTime = o2::pid::tof::ExpTimes<Run3TrksWtof::iterator, pid>;
371393
void processRun3(Run3TrksWtof const& tracks,
372394
aod::FT0s const&,
373-
EvTimeCollisionsFT0 const&,
395+
EvTimeCollisionsFT0 const& collisions,
374396
aod::BCsWithTimestamps const& bcs)
375397
{
376398
if (!enableTableTOFEvTime) {
@@ -385,6 +407,36 @@ struct tofEventTime {
385407
}
386408
tofResponse->processSetup(bcs.iteratorAt(0)); // Update the response parameters
387409

410+
std::unordered_map<int64_t, ft0Container> tableFT0Corrected;
411+
if (1) {
412+
float t0A = 1e10f;
413+
float t0C = 1e10f;
414+
for (const auto& collision : collisions) {
415+
t0A = 1e10f;
416+
t0C = 1e10f;
417+
const float vertexPV = collision.posZ();
418+
constexpr float invLightSpeedCm2NS = 1.f / o2::constants::physics::LightSpeedCm2NS;
419+
const float vertex_corr = vertexPV * invLightSpeedCm2NS;
420+
constexpr float dummyTime = 30.; // Due to HW limitations time can be only within range (-25,25) ns, dummy time is around 32 ns
421+
if (collision.has_foundFT0()) {
422+
const auto& ft0 = collision.foundFT0();
423+
const std::bitset<8>& triggers = ft0.triggerMask();
424+
const bool ora = triggers[o2::ft0::Triggers::bitA];
425+
const bool orc = triggers[o2::ft0::Triggers::bitC];
426+
LOGF(debug, "triggers OrA %i OrC %i ", ora, orc);
427+
LOGF(debug, " T0A = %f, T0C %f, vertex_corr %f", ft0.timeA(), ft0.timeC(), vertex_corr);
428+
if (ora && ft0.timeA() < dummyTime) {
429+
t0A = ft0.timeA() + vertex_corr;
430+
}
431+
if (orc && ft0.timeC() < dummyTime) {
432+
t0C = ft0.timeC() - vertex_corr;
433+
}
434+
}
435+
LOGF(debug, " T0 collision time T0A = %f, T0C = %f", t0A, t0C);
436+
tableFT0Corrected.emplace(collision.globalIndex(), ft0Container(t0A, t0C));
437+
}
438+
}
439+
388440
// Autoset the processing mode for the event time computation
389441
if (mComputeEvTimeWithTOF == -1 || mComputeEvTimeWithFT0 == -1) {
390442
switch (tofResponse->cfgCollisionType()) {
@@ -455,11 +507,16 @@ struct tofEventTime {
455507

456508
if (collision.has_foundFT0()) { // T0 measurement is available
457509
// const auto& ft0 = collision.foundFT0();
458-
if (collision.t0ACValid()) {
459-
t0AC[0] = collision.t0AC() * 1000.f;
460-
t0AC[1] = collision.t0resolution() * 1000.f;
510+
if (tableFT0Corrected[collision.globalIndex()].t0ACValid()) {
511+
t0AC[0] = tableFT0Corrected[collision.globalIndex()].t0AC() * 1000.f;
512+
t0AC[1] = tableFT0Corrected[collision.globalIndex()].t0resolution() * 1000.f;
461513
flags |= o2::aod::pidflags::enums::PIDFlags::EvTimeT0AC;
462514
}
515+
// if (collision.t0ACValid()) {
516+
// t0AC[0] = collision.t0AC() * 1000.f;
517+
// t0AC[1] = collision.t0resolution() * 1000.f;
518+
// flags |= o2::aod::pidflags::enums::PIDFlags::EvTimeT0AC;
519+
// }
463520

464521
weight = 1.f / (t0AC[1] * t0AC[1]);
465522
eventTime += t0AC[0] * weight;
@@ -535,10 +592,16 @@ struct tofEventTime {
535592
const auto& collision = t.collision_as<EvTimeCollisionsFT0>();
536593

537594
if (collision.has_foundFT0()) { // T0 measurement is available
595+
538596
// const auto& ft0 = collision.foundFT0();
539-
if (collision.t0ACValid()) {
597+
// if (collision.t0ACValid()) {
598+
// tableFlags(o2::aod::pidflags::enums::PIDFlags::EvTimeT0AC);
599+
// tableEvTime(collision.t0AC() * 1000.f, collision.t0resolution() * 1000.f);
600+
// continue;
601+
// }
602+
if (tableFT0Corrected[collision.globalIndex()].t0ACValid()) {
540603
tableFlags(o2::aod::pidflags::enums::PIDFlags::EvTimeT0AC);
541-
tableEvTime(collision.t0AC() * 1000.f, collision.t0resolution() * 1000.f);
604+
tableEvTime(tableFT0Corrected[collision.globalIndex()].t0AC() * 1000.f, tableFT0Corrected[collision.globalIndex()].t0resolution() * 1000.f);
542605
continue;
543606
}
544607
}

0 commit comments

Comments
 (0)