Skip to content

Commit ff03ce9

Browse files
njacazioshahor02
authored andcommitted
Fix AOD writer workflow
- Use TOF Utils to subtract bunch crossing time - Add PID in tracking into track flags - Clean TOF signal from output object
1 parent 8ef948e commit ff03ce9

2 files changed

Lines changed: 15 additions & 9 deletions

File tree

Detectors/AOD/include/AODProducerWorkflow/AODProducerWorkflowSpec.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,6 @@ class AODProducerWorkflowDPL : public Task
290290
float tofChi2 = -999.f;
291291
float tpcSignal = -999.f;
292292
float trdSignal = -999.f;
293-
float tofSignal = -999.f;
294293
float length = -999.f;
295294
float tofExpMom = -999.f;
296295
float trackEtaEMCAL = -999.f;

Detectors/AOD/src/AODProducerWorkflowSpec.cxx

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
#include "SimulationDataFormat/MCTrack.h"
5555
#include "SimulationDataFormat/MCTruthContainer.h"
5656
#include "GPUTPCGMMergedTrackHit.h"
57+
#include "TOFBase/Utils.h"
5758
#include "O2Version.h"
5859
#include "TMath.h"
5960
#include "MathUtils/Utils.h"
@@ -301,6 +302,7 @@ void AODProducerWorkflowDPL::fillTrackTablesPerCollision(int collisionID,
301302
// normal tracks table
302303
auto contributorsGID = data.getSingleDetectorRefs(trackIndex);
303304
const auto& trackPar = data.getTrackParam(trackIndex);
305+
extraInfoHolder.flags |= trackPar.getPID() << 28;
304306
if (contributorsGID[GIndex::Source::ITS].isIndexSet()) {
305307
int nClusters = itsTracks[contributorsGID[GIndex::ITS].getIndex()].getNClusters();
306308
float chi2 = itsTracks[contributorsGID[GIndex::ITS].getIndex()].getChi2();
@@ -326,10 +328,9 @@ void AODProducerWorkflowDPL::fillTrackTablesPerCollision(int collisionID,
326328
extraInfoHolder.tofChi2 = tofMatch.getChi2();
327329
const auto& tofInt = tofMatch.getLTIntegralOut();
328330
const float intLen = tofInt.getL();
331+
double timeOrbit = static_cast<int>(tofMatch.getSignal() / o2::constants::lhc::LHCOrbitNS * 1E-3) * o2::constants::lhc::LHCOrbitNS * 1E3;
332+
const float tofSignal = static_cast<float>(o2::tof::Utils::subtractInteractionBC(tofMatch.getSignal() - timeOrbit));
329333
extraInfoHolder.length = intLen;
330-
if (interactionTime > 0) {
331-
extraInfoHolder.tofSignal = static_cast<float>(tofMatch.getSignal() - interactionTime * 1E3);
332-
}
333334
const float mass = o2::constants::physics::MassPionCharged; // default pid = pion
334335
if (tofInt.getTOF(o2::track::PID::Pion) > 0.f) {
335336
const float expBeta = (intLen / (tofInt.getTOF(o2::track::PID::Pion) * cSpeed));
@@ -339,8 +340,8 @@ void AODProducerWorkflowDPL::fillTrackTablesPerCollision(int collisionID,
339340
const double massZ = o2::track::PID::getMass2Z(trackPar.getPID());
340341
const double energy = sqrt((massZ * massZ) + (extraInfoHolder.tofExpMom * extraInfoHolder.tofExpMom));
341342
const double exp = extraInfoHolder.length * energy / (cSpeed * extraInfoHolder.tofExpMom);
342-
extraInfoHolder.trackTime = static_cast<float>((tofMatch.getSignal() - exp) * 1e-3 - interactionTime); // tof time in \mus, FIXME: account for time of flight to R TOF
343-
extraInfoHolder.trackTimeRes = 200e-3; // FIXME: calculate actual resolution (if possible?)
343+
extraInfoHolder.trackTime = static_cast<float>((tofSignal - exp) * 1e-3); // tof time in ns, taken from the definition of Ruben scaled by 1000 to convert from mus to ns to match the collisionTime
344+
extraInfoHolder.trackTimeRes = 200e-3; // FIXME: calculate actual resolution (if possible?)
344345
}
345346
if (src == GIndex::Source::TPCTRD || src == GIndex::Source::ITSTPCTRD) {
346347
const auto& trdOrig = data.getTrack<o2::trd::TrackTRD>(src, contributorsGID[src].getIndex());
@@ -1106,11 +1107,17 @@ void AODProducerWorkflowDPL::run(ProcessingContext& pc)
11061107
auto caloCellsCursor = caloCellsBuilder.cursor<o2::aod::Calos>();
11071108
auto caloCellsTRGTableCursor = caloCellsTRGTableBuilder.cursor<o2::aod::CaloTriggers>();
11081109

1109-
std::unique_ptr<o2::steer::MCKinematicsReader> mcReader;
1110-
if (mUseMC) {
1111-
mcReader = std::make_unique<o2::steer::MCKinematicsReader>("collisioncontext.root");
1110+
std::unique_ptr<o2::steer::MCKinematicsReader> mcReader = std::make_unique<o2::steer::MCKinematicsReader>("collisioncontext.root");
1111+
if (!o2::tof::Utils::hasFillScheme()) {
11121112
LOG(debug) << "FOUND " << mcReader->getDigitizationContext()->getEventRecords().size()
11131113
<< " records" << mcReader->getDigitizationContext()->getEventParts().size() << " parts";
1114+
o2::BunchFilling bcf = mcReader->getDigitizationContext()->getBunchFilling();
1115+
std::bitset<3564> bs = bcf.getBCPattern();
1116+
for (int i = 0; i < bs.size(); i++) {
1117+
if (bs.test(i)) {
1118+
o2::tof::Utils::addInteractionBC(i);
1119+
}
1120+
}
11141121
}
11151122

11161123
std::map<uint64_t, int> bcsMap;

0 commit comments

Comments
 (0)