From 4e12b12ea08077bebdcebe18eb8e461b27aad436 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Mon, 19 Jul 2021 16:51:14 +0200 Subject: [PATCH 1/7] Fix the way TOF is written --- Detectors/AOD/src/AODProducerWorkflowSpec.cxx | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/Detectors/AOD/src/AODProducerWorkflowSpec.cxx b/Detectors/AOD/src/AODProducerWorkflowSpec.cxx index 61a14f40f9df0..8e3bdd05dc69e 100644 --- a/Detectors/AOD/src/AODProducerWorkflowSpec.cxx +++ b/Detectors/AOD/src/AODProducerWorkflowSpec.cxx @@ -249,16 +249,14 @@ void AODProducerWorkflowDPL::fillTrackTablesPerCollision(int collisionID, const auto& tofInt = tofMatch.getLTIntegralOut(); float intLen = tofInt.getL(); extraInfoHolder.length = intLen; - extraInfoHolder.tofSignal = tofMatch.getSignal(); - float mass = o2::constants::physics::MassPionCharged; // default pid = pion - float expSig = tofInt.getTOF(o2::track::PID::Pion); - float expMom = 0.f; - if (expSig > 0 && interactionTime > 0) { - float tof = expSig - interactionTime; - float expBeta = (intLen / tof / cSpeed); - expMom = mass * expBeta / std::sqrt(1.f - expBeta * expBeta); + if (interactionTime > 0) { + extraInfoHolder.tofSignal = static_cast(tofMatch.getSignal() - interactionTime); + } + const float mass = o2::constants::physics::MassPionCharged; // default pid = pion + if (tofInt.getTOF(o2::track::PID::Pion) > 0.f) { + const float expBeta = (intLen / tofInt.getTOF(o2::track::PID::Pion) / cSpeed); + extraInfoHolder.tofExpMom = mass * expBeta / std::sqrt(1.f - expBeta * expBeta); } - extraInfoHolder.tofExpMom = expMom; } if (src == GIndex::Source::TPCTRD || src == GIndex::Source::ITSTPCTRD) { const auto& trdOrig = data.getTrack(src, contributorsGID[src].getIndex()); From 024c6fc42dc95184d917a388db2cddf13a28625a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Mon, 19 Jul 2021 16:52:19 +0200 Subject: [PATCH 2/7] Add PDG codes of heavier particles --- Analysis/Tasks/PID/qaTOFMC.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Analysis/Tasks/PID/qaTOFMC.cxx b/Analysis/Tasks/PID/qaTOFMC.cxx index 822d08641dba6..5c9f3b3448cac 100644 --- a/Analysis/Tasks/PID/qaTOFMC.cxx +++ b/Analysis/Tasks/PID/qaTOFMC.cxx @@ -61,7 +61,7 @@ struct pidTOFTaskQA { "nsigmaMCprm/Ka", "nsigmaMCprm/Pr", "nsigmaMCprm/De", "nsigmaMCprm/Tr", "nsigmaMCprm/He", "nsigmaMCprm/Al"}; static constexpr const char* pT[Np] = {"e", "#mu", "#pi", "K", "p", "d", "t", "^{3}He", "#alpha"}; - static constexpr int PDGs[Np] = {11, 13, 211, 321, 2212, 1, 1, 1, 1}; + static constexpr int PDGs[Np] = {11, 13, 211, 321, 2212, 1000010020, 1000010030, 1000020030}; HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::QAObject}; Configurable nBinsP{"nBinsP", 400, "Number of bins for the momentum"}; From 7b20edcf21d8cde4b24359f751d94c38cace82db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Tue, 20 Jul 2021 14:59:05 +0200 Subject: [PATCH 3/7] Add shift in momentum energy hack --- Detectors/AOD/src/AODProducerWorkflowSpec.cxx | 30 ++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/Detectors/AOD/src/AODProducerWorkflowSpec.cxx b/Detectors/AOD/src/AODProducerWorkflowSpec.cxx index 8e3bdd05dc69e..08ea3a9054d6b 100644 --- a/Detectors/AOD/src/AODProducerWorkflowSpec.cxx +++ b/Detectors/AOD/src/AODProducerWorkflowSpec.cxx @@ -393,6 +393,28 @@ void AODProducerWorkflowDPL::fillMCParticlesTable(o2::steer::MCKinematicsReader& if (item != toStore.end()) { daughterL = item->second; } + float pX = (float)mcParticles[particle].Px(); + float pY = (float)mcParticles[particle].Py(); + float pZ = (float)mcParticles[particle].Pz(); + float energy = (float)mcParticles[particle].GetEnergy(); + // HACK to avoid FPE in expression columns. Affect only particles in the Beam Pipe. + // TO BE REMOVED asap + { + const float limit = 1e-4; + const float mom = TMath::Sqrt(pX * pX + pY * pY + pZ * pZ); + const float eta = 0.5f * TMath::Log((mom + pZ) / (mom - pZ)); + if (TMath::Abs(eta) > 0.9) { + if (TMath::Abs((mom - pZ) / pZ) <= limit) { + pX = truncateFloatFraction(TMath::Sqrt((1.f + limit) * (1.f + limit) - 1.f) * pZ * 0.5, mMcParticleMom); + pY = truncateFloatFraction(TMath::Sqrt((1.f + limit) * (1.f + limit) - 1.f) * pZ * 0.5, mMcParticleMom); + } + if (TMath::Abs(energy - pZ) < limit) { + energy = truncateFloatFraction(pZ + limit, mMcParticleMom); + } + } + } + // End of HACK + mcParticlesCursor(0, mccolid, mcParticles[particle].GetPdgCode(), @@ -403,10 +425,10 @@ void AODProducerWorkflowDPL::fillMCParticlesTable(o2::steer::MCKinematicsReader& daughter0, daughterL, truncateFloatFraction(weight, mMcParticleW), - truncateFloatFraction((float)mcParticles[particle].Px(), mMcParticleMom), - truncateFloatFraction((float)mcParticles[particle].Py(), mMcParticleMom), - truncateFloatFraction((float)mcParticles[particle].Pz(), mMcParticleMom), - truncateFloatFraction((float)mcParticles[particle].GetEnergy(), mMcParticleMom), + truncateFloatFraction(pX, mMcParticleMom), + truncateFloatFraction(pY, mMcParticleMom), + truncateFloatFraction(pZ, mMcParticleMom), + truncateFloatFraction(energy, mMcParticleMom), truncateFloatFraction((float)mcParticles[particle].Vx(), mMcParticlePos), truncateFloatFraction((float)mcParticles[particle].Vy(), mMcParticlePos), truncateFloatFraction((float)mcParticles[particle].Vz(), mMcParticlePos), From b64203ae21911853c894aa13f59abb9a70798f7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Tue, 20 Jul 2021 16:13:12 +0200 Subject: [PATCH 4/7] Add more fixes --- Detectors/AOD/src/AODProducerWorkflowSpec.cxx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Detectors/AOD/src/AODProducerWorkflowSpec.cxx b/Detectors/AOD/src/AODProducerWorkflowSpec.cxx index 08ea3a9054d6b..785d50371f252 100644 --- a/Detectors/AOD/src/AODProducerWorkflowSpec.cxx +++ b/Detectors/AOD/src/AODProducerWorkflowSpec.cxx @@ -763,8 +763,8 @@ void AODProducerWorkflowDPL::run(ProcessingContext& pc) bcID, aAmplitudesA, aAmplitudesC, - truncateFloatFraction(ft0RecPoint.getCollisionTimeA() / 1E3, mT0Time), // ps to ns - truncateFloatFraction(ft0RecPoint.getCollisionTimeC() / 1E3, mT0Time), // ps to ns + truncateFloatFraction(ft0RecPoint.getCollisionTimeA() * 1E-3, mT0Time), // ps to ns + truncateFloatFraction(ft0RecPoint.getCollisionTimeC() * 1E-3, mT0Time), // ps to ns ft0RecPoint.getTrigger().triggersignals); } @@ -790,11 +790,11 @@ void AODProducerWorkflowDPL::run(ProcessingContext& pc) for (auto& vertex : primVertices) { auto& cov = vertex.getCov(); auto& timeStamp = vertex.getTimeStamp(); - double tsTimeStamp = timeStamp.getTimeStamp() * 1E3; // mus to ns - uint64_t globalBC = std::round(tsTimeStamp / o2::constants::lhc::LHCBunchSpacingNS); - LOG(DEBUG) << globalBC << " " << tsTimeStamp; + const double interactionTime = timeStamp.getTimeStamp() * 1E3; // mus to ns + uint64_t globalBC = std::round(interactionTime / o2::constants::lhc::LHCBunchSpacingNS); + LOG(DEBUG) << globalBC << " " << interactionTime; // collision timestamp in ns wrt the beginning of collision BC - tsTimeStamp = globalBC * o2::constants::lhc::LHCBunchSpacingNS - tsTimeStamp; + const float relInteractionTime = static_cast(globalBC * o2::constants::lhc::LHCBunchSpacingNS - interactionTime); auto item = bcsMap.find(globalBC); int bcID = -1; if (item != bcsMap.end()) { @@ -818,12 +818,12 @@ void AODProducerWorkflowDPL::run(ProcessingContext& pc) vertex.getFlags(), truncateFloatFraction(vertex.getChi2(), mCollisionPositionCov), vertex.getNContributors(), - truncateFloatFraction(tsTimeStamp, mCollisionPosition), + truncateFloatFraction(relInteractionTime, mCollisionPosition), truncateFloatFraction(timeStamp.getTimeStampError() * 1E3, mCollisionPositionCov), collisionTimeMask); auto& trackRef = primVer2TRefs[collisionID]; // passing interaction time in [ps] - fillTrackTablesPerCollision(collisionID, tsTimeStamp * 1E3, trackRef, primVerGIs, recoData, + fillTrackTablesPerCollision(collisionID, interactionTime * 1E3, trackRef, primVerGIs, recoData, tracksCursor, tracksCovCursor, tracksExtraCursor, mftTracksCursor); collisionID++; } From 0cd3f782fe75bf1550b47820df7684f3f9e34ff8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Tue, 20 Jul 2021 16:36:52 +0200 Subject: [PATCH 5/7] Add dummy TOF EventTime maker --- Detectors/TOF/reconstruction/CMakeLists.txt | 6 ++- .../TOFReconstruction/EventTimeMaker.h | 41 +++++++++++++++++++ .../TOF/reconstruction/src/EventTimeMaker.cxx | 24 +++++++++++ 3 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 Detectors/TOF/reconstruction/include/TOFReconstruction/EventTimeMaker.h create mode 100644 Detectors/TOF/reconstruction/src/EventTimeMaker.cxx diff --git a/Detectors/TOF/reconstruction/CMakeLists.txt b/Detectors/TOF/reconstruction/CMakeLists.txt index 3b1cf2577c47b..0e79336416683 100644 --- a/Detectors/TOF/reconstruction/CMakeLists.txt +++ b/Detectors/TOF/reconstruction/CMakeLists.txt @@ -15,20 +15,22 @@ o2_add_library(TOFReconstruction src/DecoderBase.cxx src/Decoder.cxx src/CTFCoder.cxx + src/EventTimeMaker.cxx src/CosmicProcessor.cxx PUBLIC_LINK_LIBRARIES O2::TOFBase O2::DataFormatsTOF O2::SimulationDataFormat O2::CommonDataFormat O2::DataFormatsTOF O2::rANS O2::DPLUtils - O2::TOFCalibration O2::DetectorsRaw) + O2::TOFCalibration O2::DetectorsRaw) o2_target_root_dictionary(TOFReconstruction HEADERS include/TOFReconstruction/DataReader.h include/TOFReconstruction/Clusterer.h include/TOFReconstruction/ClustererTask.h include/TOFReconstruction/Encoder.h - include/TOFReconstruction/DecoderBase.h + include/TOFReconstruction/DecoderBase.h include/TOFReconstruction/Decoder.h include/TOFReconstruction/CTFCoder.h + include/TOFReconstruction/EventTimeMaker.h include/TOFReconstruction/CosmicProcessor.h) diff --git a/Detectors/TOF/reconstruction/include/TOFReconstruction/EventTimeMaker.h b/Detectors/TOF/reconstruction/include/TOFReconstruction/EventTimeMaker.h new file mode 100644 index 0000000000000..18e14bd5b15c2 --- /dev/null +++ b/Detectors/TOF/reconstruction/include/TOFReconstruction/EventTimeMaker.h @@ -0,0 +1,41 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +/// \file EventTimeMaker.h +/// \brief Definition of the TOF event time maker + +#ifndef ALICEO2_TOF_EVENTTIMEMAKER_H +#define ALICEO2_TOF_EVENTTIMEMAKER_H + +namespace o2 +{ + +namespace tof +{ + +struct eventTimeContainer { + eventTimeContainer(const float& e) : eventTime{e} {}; + float eventTime = 0.f; +}; + +template +eventTimeContainer evTimeMaker(const tTracks& tracks) +{ + for (auto track : tracks) { + track.tofSignal(); + } + return eventTimeContainer{0}; +} + +} // namespace tof +} // namespace o2 + +#endif /* ALICEO2_TOF_EVENTTIMEMAKER_H */ \ No newline at end of file diff --git a/Detectors/TOF/reconstruction/src/EventTimeMaker.cxx b/Detectors/TOF/reconstruction/src/EventTimeMaker.cxx new file mode 100644 index 0000000000000..32123466296c1 --- /dev/null +++ b/Detectors/TOF/reconstruction/src/EventTimeMaker.cxx @@ -0,0 +1,24 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +/// \file EventTimeMaker.cxx +/// \brief Implementation of the TOF event time maker + +#include "TOFReconstruction/EventTimeMaker.h" + +namespace o2 +{ + +namespace tof +{ + +} // namespace tof +} // namespace o2 \ No newline at end of file From e6a56b5f505a42d38f784320decb3ac7363ff271 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Thu, 22 Jul 2021 17:27:06 +0200 Subject: [PATCH 6/7] Resolve extra division --- Detectors/AOD/src/AODProducerWorkflowSpec.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Detectors/AOD/src/AODProducerWorkflowSpec.cxx b/Detectors/AOD/src/AODProducerWorkflowSpec.cxx index 785d50371f252..fd47c756cd969 100644 --- a/Detectors/AOD/src/AODProducerWorkflowSpec.cxx +++ b/Detectors/AOD/src/AODProducerWorkflowSpec.cxx @@ -254,7 +254,7 @@ void AODProducerWorkflowDPL::fillTrackTablesPerCollision(int collisionID, } const float mass = o2::constants::physics::MassPionCharged; // default pid = pion if (tofInt.getTOF(o2::track::PID::Pion) > 0.f) { - const float expBeta = (intLen / tofInt.getTOF(o2::track::PID::Pion) / cSpeed); + const float expBeta = (intLen / (tofInt.getTOF(o2::track::PID::Pion) * cSpeed)); extraInfoHolder.tofExpMom = mass * expBeta / std::sqrt(1.f - expBeta * expBeta); } } From ac8b4bdca49fc2c16de4557390e0f39ae455cec5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Thu, 22 Jul 2021 17:41:12 +0200 Subject: [PATCH 7/7] Fix for sqrt(2) in FPE protection hack --- Detectors/AOD/src/AODProducerWorkflowSpec.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Detectors/AOD/src/AODProducerWorkflowSpec.cxx b/Detectors/AOD/src/AODProducerWorkflowSpec.cxx index fd47c756cd969..6234c43fecaf2 100644 --- a/Detectors/AOD/src/AODProducerWorkflowSpec.cxx +++ b/Detectors/AOD/src/AODProducerWorkflowSpec.cxx @@ -405,8 +405,8 @@ void AODProducerWorkflowDPL::fillMCParticlesTable(o2::steer::MCKinematicsReader& const float eta = 0.5f * TMath::Log((mom + pZ) / (mom - pZ)); if (TMath::Abs(eta) > 0.9) { if (TMath::Abs((mom - pZ) / pZ) <= limit) { - pX = truncateFloatFraction(TMath::Sqrt((1.f + limit) * (1.f + limit) - 1.f) * pZ * 0.5, mMcParticleMom); - pY = truncateFloatFraction(TMath::Sqrt((1.f + limit) * (1.f + limit) - 1.f) * pZ * 0.5, mMcParticleMom); + pX = truncateFloatFraction(TMath::Sqrt((1.f + limit) * (1.f + limit) - 1.f) * pZ * 0.70710678, mMcParticleMom); + pY = truncateFloatFraction(TMath::Sqrt((1.f + limit) * (1.f + limit) - 1.f) * pZ * 0.70710678, mMcParticleMom); } if (TMath::Abs(energy - pZ) < limit) { energy = truncateFloatFraction(pZ + limit, mMcParticleMom);