diff --git a/ALICE3/TableProducer/CMakeLists.txt b/ALICE3/TableProducer/CMakeLists.txt index d0b7afce076..51a74195377 100644 --- a/ALICE3/TableProducer/CMakeLists.txt +++ b/ALICE3/TableProducer/CMakeLists.txt @@ -21,11 +21,6 @@ o2physics_add_dpl_workflow(alice3-trackextension PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2::ReconstructionDataFormats COMPONENT_NAME Analysis) -o2physics_add_dpl_workflow(alice3-pid-tof - SOURCES alice3-pidTOF.cxx - PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::ALICE3Core - COMPONENT_NAME Analysis) - o2physics_add_dpl_workflow(alice3-centrality SOURCES alice3-centrality.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore diff --git a/ALICE3/TableProducer/alice3-pidTOF.cxx b/ALICE3/TableProducer/alice3-pidTOF.cxx deleted file mode 100644 index 3e54b1f46dc..00000000000 --- a/ALICE3/TableProducer/alice3-pidTOF.cxx +++ /dev/null @@ -1,324 +0,0 @@ -// 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 alice3-pidTOF.cxx -/// \author Nicolò Jacazio nicolo.jacazio@cern.ch -/// \brief Task to produce PID tables for TOF split for each particle. -/// Only the tables for the mass hypotheses requested are filled, the others are sent empty. -/// - -// O2 includes -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "ReconstructionDataFormats/Track.h" -#include "CCDB/BasicCCDBManager.h" -#include "Common/DataModel/PIDResponse.h" -#include "ALICE3/Core/TOFResoALICE3.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "Framework/RunningWorkflowInfo.h" -#include "Framework/StaticFor.h" - -using namespace o2; -using namespace o2::framework; -using namespace o2::pid; -using namespace o2::framework::expressions; -using namespace o2::track; - -void customize(std::vector& workflowOptions) -{ - std::vector options{{"add-qa", VariantType::Int, 0, {"Produce TOF PID QA histograms"}}}; - std::swap(workflowOptions, options); -} - -#include "Framework/runDataProcessing.h" - -struct ALICE3tofSignal { /// Task that produces the TOF signal from the trackTime - Produces table; - bool enableTable = false; - - void init(o2::framework::InitContext& initContext) - { - // Checking the tables are requested in the workflow and enabling them - auto& workflows = initContext.services().get(); - for (DeviceSpec const& device : workflows.devices) { - for (auto const& input : device.inputs) { - const std::string table = "TOFSignal"; - if (input.matcher.binding == table) { - enableTable = true; - } - } - } - } - using Trks = soa::Join; - void process(Trks const& tracks) - { - if (!enableTable) { - return; - } - table.reserve(tracks.size()); - for (auto& t : tracks) { - table(t.trackTime() * 1000.f); - } - } -}; - -struct ALICE3pidTOFTask { - using Trks = soa::Join; - using Coll = aod::Collisions; - // Tables to produce - Produces tablePIDEl; - Produces tablePIDMu; - Produces tablePIDPi; - Produces tablePIDKa; - Produces tablePIDPr; - Produces tablePIDDe; - Produces tablePIDTr; - Produces tablePIDHe; - Produces tablePIDAl; - Parameters resoParameters{1}; - Service ccdb; - Configurable paramfile{"param-file", "", "Path to the parametrization object, if empty the parametrization is not taken from file"}; - Configurable sigmaname{"param-sigma", "TOFResoALICE3", "Name of the parametrization for the expected sigma, used in both file and CCDB mode"}; - Configurable url{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; - Configurable timestamp{"ccdb-timestamp", -1, "timestamp of the object"}; - - void init(o2::framework::InitContext&) - { - ccdb->setURL(url.value); - ccdb->setTimestamp(timestamp.value); - ccdb->setCaching(true); - ccdb->setLocalObjectValidityChecking(); - // Not later than now objects - ccdb->setCreatedNotAfter(std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count()); - // - const std::vector p = {24.5}; - resoParameters.SetParameters(p); - const std::string fname = paramfile.value; - if (!fname.empty()) { // Loading the parametrization from file - LOG(info) << "Loading parametrization from file" << fname << ", using param: " << sigmaname; - resoParameters.LoadParamFromFile(fname.data(), sigmaname.value.data()); - } else { // Loading it from CCDB - const std::string path = "Analysis/ALICE3/PID/TOF/Parameters"; - resoParameters.SetParameters(ccdb->getForTimeStamp(path + "/" + sigmaname.value, timestamp.value)); - } - } - - template - float sigma(Trks::iterator track) - { - return o2::pid::tof::TOFResoALICE3ParamTrack(track, resoParameters); - } - template - float nsigma(Trks::iterator track) - { - if (!track.hasTOF()) { - return -999.f; - } - return ((track.trackTime() - track.collision().collisionTime()) * 1000.f - o2::pid::tof::ExpTimes::ComputeExpectedTime(track.tofExpMom() * o2::constants::physics::invLightSpeedCm2PS, - track.length())) / - sigma(track); - } - void process(Trks const& tracks, Coll const&) - { - tablePIDEl.reserve(tracks.size()); - tablePIDMu.reserve(tracks.size()); - tablePIDPi.reserve(tracks.size()); - tablePIDKa.reserve(tracks.size()); - tablePIDPr.reserve(tracks.size()); - tablePIDDe.reserve(tracks.size()); - tablePIDTr.reserve(tracks.size()); - tablePIDHe.reserve(tracks.size()); - tablePIDAl.reserve(tracks.size()); - for (auto const& trk : tracks) { - tablePIDEl(sigma(trk), nsigma(trk)); - tablePIDMu(sigma(trk), nsigma(trk)); - tablePIDPi(sigma(trk), nsigma(trk)); - tablePIDKa(sigma(trk), nsigma(trk)); - tablePIDPr(sigma(trk), nsigma(trk)); - tablePIDDe(sigma(trk), nsigma(trk)); - tablePIDTr(sigma(trk), nsigma(trk)); - tablePIDHe(sigma(trk), nsigma(trk)); - tablePIDAl(sigma(trk), nsigma(trk)); - } - } -}; - -struct ALICE3pidTOFTaskQA { - - static constexpr int Np = 9; - static constexpr const char* pT[Np] = {"e", "#mu", "#pi", "K", "p", "d", "t", "^{3}He", "#alpha"}; - static constexpr std::string_view hexpected[Np] = {"expected/El", "expected/Mu", "expected/Pi", - "expected/Ka", "expected/Pr", "expected/De", - "expected/Tr", "expected/He", "expected/Al"}; - static constexpr std::string_view hexpected_diff[Np] = {"expected_diff/El", "expected_diff/Mu", "expected_diff/Pi", - "expected_diff/Ka", "expected_diff/Pr", "expected_diff/De", - "expected_diff/Tr", "expected_diff/He", "expected_diff/Al"}; - static constexpr std::string_view hexpsigma[Np] = {"expsigma/El", "expsigma/Mu", "expsigma/Pi", - "expsigma/Ka", "expsigma/Pr", "expsigma/De", - "expsigma/Tr", "expsigma/He", "expsigma/Al"}; - static constexpr std::string_view hnsigma[Np] = {"nsigma/El", "nsigma/Mu", "nsigma/Pi", - "nsigma/Ka", "nsigma/Pr", "nsigma/De", - "nsigma/Tr", "nsigma/He", "nsigma/Al"}; - HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::QAObject}; - - Configurable logAxis{"logAxis", 1, "Flag to use a log momentum axis"}; - Configurable nBinsP{"nBinsP", 400, "Number of bins for the momentum"}; - Configurable minP{"minP", 0.01f, "Minimum momentum in range"}; - Configurable maxP{"maxP", 20.f, "Maximum momentum in range"}; - Configurable nBinsDelta{"nBinsDelta", 200, "Number of bins for the Delta"}; - Configurable minDelta{"minDelta", -1000.f, "Minimum Delta in range"}; - Configurable maxDelta{"maxDelta", 1000.f, "Maximum Delta in range"}; - Configurable nBinsExpSigma{"nBinsExpSigma", 200, "Number of bins for the ExpSigma"}; - Configurable minExpSigma{"minExpSigma", 0.f, "Minimum ExpSigma in range"}; - Configurable maxExpSigma{"maxExpSigma", 200.f, "Maximum ExpSigma in range"}; - Configurable nBinsNSigma{"nBinsNSigma", 200, "Number of bins for the NSigma"}; - Configurable minNSigma{"minNSigma", -10.f, "Minimum NSigma in range"}; - Configurable maxNSigma{"maxNSigma", 10.f, "Maximum NSigma in range"}; - Configurable minMult{"minMult", 1, "Minimum track multiplicity with TOF"}; - - template - void addParticleHistos(const AxisSpec& pAxis, const AxisSpec& /*ptAxis*/) - { - // Exp signal - const AxisSpec expAxis{1000, 0, 2e6, Form("t_{exp}(%s)", pT[i])}; - histos.add(hexpected[i].data(), "", kTH2F, {pAxis, expAxis}); - - // Signal - Expected signal - const AxisSpec deltaAxis{nBinsDelta, minDelta, maxDelta, Form("(t-t_{evt}-t_{exp}(%s))", pT[i])}; - histos.add(hexpected_diff[i].data(), "", kTH2F, {pAxis, deltaAxis}); - - // Exp Sigma - const AxisSpec expSigmaAxis{nBinsExpSigma, minExpSigma, maxExpSigma, Form("Exp_{#sigma}^{TOF}(%s)", pT[i])}; - histos.add(hexpsigma[i].data(), "", kTH2F, {pAxis, expSigmaAxis}); - - // NSigma - const AxisSpec nSigmaAxis{nBinsNSigma, minNSigma, maxNSigma, Form("N_{#sigma}^{TOF}(%s)", pT[i])}; - histos.add(hnsigma[i].data(), "", kTH2F, {pAxis, nSigmaAxis}); - } - - void init(o2::framework::InitContext&) - { - - const AxisSpec multAxis{100, 0, 100, "TOF multiplicity"}; - const AxisSpec vtxZAxis{100, -20, 20, "Vtx_{z} (cm)"}; - const AxisSpec tofAxis{10000, 0, 2e6, "TOF Signal"}; - const AxisSpec etaAxis{100, -2, 2, "#it{#eta}"}; - const AxisSpec colTimeAxis{100, -2000, 2000, "Collision time (ps)"}; - const AxisSpec colTimeResoAxis{100, 0, 1000, "#sigma_{Collision time} (ps)"}; - const AxisSpec lAxis{100, 0, 500, "Track length (cm)"}; - const AxisSpec ptResoAxis{100, 0, 0.1, "#sigma_{#it{p}_{T}}"}; - AxisSpec ptAxis{nBinsP, minP, maxP, "#it{p}_{T} (GeV/#it{c})"}; - AxisSpec pAxis{nBinsP, minP, maxP, "#it{p} (GeV/#it{c})"}; - AxisSpec pExpAxis{nBinsP, minP, maxP, "#it{p}_{Exp. TOF} (GeV/#it{c})"}; - if (logAxis) { - ptAxis.makeLogarithmic(); - pAxis.makeLogarithmic(); - pExpAxis.makeLogarithmic(); - } - - // Event properties - histos.add("event/vertexz", "", kTH1F, {vtxZAxis}); - histos.add("event/tofmultiplicity", "", kTH1F, {multAxis}); - histos.add("event/colltime", "", kTH1F, {colTimeAxis}); - histos.add("event/colltimereso", "", kTH2F, {multAxis, colTimeResoAxis}); - histos.add("event/tofsignal", "", kTH2F, {pAxis, tofAxis}); - histos.add("event/pexp", "", kTH2F, {pAxis, pExpAxis}); - histos.add("event/eta", "", kTH1F, {etaAxis}); - histos.add("event/length", "", kTH1F, {lAxis}); - histos.add("event/pt", "", kTH1F, {ptAxis}); - histos.add("event/p", "", kTH1F, {pAxis}); - histos.add("event/ptreso", "", kTH2F, {pAxis, ptResoAxis}); - - static_for<0, 8>([&](auto i) { - addParticleHistos(pAxis, ptAxis); - }); - } - - template - void fillParticleHistos(const T& t, const float& tof, const float& exp_diff, const float& expsigma) - { - histos.fill(HIST(hexpected[i]), t.p(), tof - exp_diff); - histos.fill(HIST(hexpected_diff[i]), t.p(), exp_diff); - histos.fill(HIST(hexpsigma[i]), t.p(), expsigma); - histos.fill(HIST(hnsigma[i]), t.p(), o2::aod::pidutils::tofNSigma(i, t)); - } - - void process(aod::Collision const& collision, - soa::Join const& tracks) - { - // Computing Multiplicity first - int mult = 0; - for (auto t : tracks) { - // - if (!t.hasTOF()) { // Skipping tracks without TOF - continue; - } - mult++; - } - if (mult < minMult) { // Cutting on low multiplicity events - return; - } - - const float collisionTime_ps = collision.collisionTime() * 1000.f; - histos.fill(HIST("event/vertexz"), collision.posZ()); - histos.fill(HIST("event/colltime"), collisionTime_ps); - histos.fill(HIST("event/tofmultiplicity"), mult); - histos.fill(HIST("event/colltimereso"), mult, collision.collisionTimeRes() * 1000.f); - - for (auto t : tracks) { - // - if (!t.hasTOF()) { // Skipping tracks without TOF - continue; - } - if (!t.isGlobalTrack()) { - continue; - } - - const float tofSignal = t.trackTime() * 1e3f; - // const float tof = t.tofSignal() - collisionTime_ps; - const float tof = tofSignal - collisionTime_ps; - - // - // histos.fill(HIST("event/tofsignal"), t.p(), t.tofSignal()); - histos.fill(HIST("event/tofsignal"), t.p(), tofSignal); - histos.fill(HIST("event/pexp"), t.p(), t.tofExpMom() * o2::constants::physics::invLightSpeedCm2PS); - histos.fill(HIST("event/eta"), t.eta()); - histos.fill(HIST("event/length"), t.length()); - histos.fill(HIST("event/pt"), t.pt()); - histos.fill(HIST("event/ptreso"), t.p(), t.sigma1Pt() * t.pt() * t.pt()); - // - fillParticleHistos(t, tof, t.tofExpSignalDiffEl(), t.tofExpSigmaEl()); - fillParticleHistos(t, tof, t.tofExpSignalDiffMu(), t.tofExpSigmaMu()); - fillParticleHistos(t, tof, t.tofExpSignalDiffPi(), t.tofExpSigmaPi()); - fillParticleHistos(t, tof, t.tofExpSignalDiffKa(), t.tofExpSigmaKa()); - fillParticleHistos(t, tof, t.tofExpSignalDiffPr(), t.tofExpSigmaPr()); - fillParticleHistos(t, tof, t.tofExpSignalDiffDe(), t.tofExpSigmaDe()); - fillParticleHistos(t, tof, t.tofExpSignalDiffTr(), t.tofExpSigmaTr()); - fillParticleHistos(t, tof, t.tofExpSignalDiffHe(), t.tofExpSigmaHe()); - fillParticleHistos(t, tof, t.tofExpSignalDiffAl(), t.tofExpSigmaAl()); - } - } -}; - -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - auto workflow = WorkflowSpec{adaptAnalysisTask(cfgc, TaskName{"alice3-pidTOF-task"}), - adaptAnalysisTask(cfgc, TaskName{"alice3-tof-signal-task"})}; - if (cfgc.options().get("add-qa")) { - workflow.push_back(adaptAnalysisTask(cfgc, TaskName{"alice3-pidTOFQA-task"})); - } - return workflow; -}