diff --git a/Analysis/DataModel/include/AnalysisDataModel/PID/PIDResponse.h b/Analysis/DataModel/include/AnalysisDataModel/PID/PIDResponse.h index 41ceb03a16e03..fec4c42041bea 100644 --- a/Analysis/DataModel/include/AnalysisDataModel/PID/PIDResponse.h +++ b/Analysis/DataModel/include/AnalysisDataModel/PID/PIDResponse.h @@ -74,6 +74,43 @@ DECLARE_SOA_COLUMN(TOFNSigmaHe, tofNSigmaHe, float); DECLARE_SOA_COLUMN(TOFNSigmaAl, tofNSigmaAl, float); } // namespace pidtof +// Macro to convert the stored Nsigmas to floats +#define DEFINE_UNWRAP_NSIGMA_COLUMN(COLUMN, COLUMN_NAME) \ + DECLARE_SOA_DYNAMIC_COLUMN(COLUMN, COLUMN_NAME, \ + [](binned_nsigma_t nsigma_binned) -> float { return bin_width * static_cast(nsigma_binned); }); + +namespace pidtof_tiny +{ +typedef int8_t binned_nsigma_t; +constexpr int nbins = (1 << 8 * sizeof(binned_nsigma_t)) - 2; +constexpr binned_nsigma_t upper_bin = nbins >> 1; +constexpr binned_nsigma_t lower_bin = -(nbins >> 1); +constexpr float binned_max = 6.35; +constexpr float binned_min = -6.35; +constexpr float bin_width = (binned_max - binned_min) / nbins; +// NSigma with reduced size 8 bit +DECLARE_SOA_COLUMN(TOFNSigmaStoreEl, tofNSigmaStoreEl, binned_nsigma_t); +DECLARE_SOA_COLUMN(TOFNSigmaStoreMu, tofNSigmaStoreMu, binned_nsigma_t); +DECLARE_SOA_COLUMN(TOFNSigmaStorePi, tofNSigmaStorePi, binned_nsigma_t); +DECLARE_SOA_COLUMN(TOFNSigmaStoreKa, tofNSigmaStoreKa, binned_nsigma_t); +DECLARE_SOA_COLUMN(TOFNSigmaStorePr, tofNSigmaStorePr, binned_nsigma_t); +DECLARE_SOA_COLUMN(TOFNSigmaStoreDe, tofNSigmaStoreDe, binned_nsigma_t); +DECLARE_SOA_COLUMN(TOFNSigmaStoreTr, tofNSigmaStoreTr, binned_nsigma_t); +DECLARE_SOA_COLUMN(TOFNSigmaStoreHe, tofNSigmaStoreHe, binned_nsigma_t); +DECLARE_SOA_COLUMN(TOFNSigmaStoreAl, tofNSigmaStoreAl, binned_nsigma_t); +// NSigma with reduced size in [binned_min, binned_max] bin size bin_width +DEFINE_UNWRAP_NSIGMA_COLUMN(TOFNSigmaEl, tofNSigmaEl); +DEFINE_UNWRAP_NSIGMA_COLUMN(TOFNSigmaMu, tofNSigmaMu); +DEFINE_UNWRAP_NSIGMA_COLUMN(TOFNSigmaPi, tofNSigmaPi); +DEFINE_UNWRAP_NSIGMA_COLUMN(TOFNSigmaKa, tofNSigmaKa); +DEFINE_UNWRAP_NSIGMA_COLUMN(TOFNSigmaPr, tofNSigmaPr); +DEFINE_UNWRAP_NSIGMA_COLUMN(TOFNSigmaDe, tofNSigmaDe); +DEFINE_UNWRAP_NSIGMA_COLUMN(TOFNSigmaTr, tofNSigmaTr); +DEFINE_UNWRAP_NSIGMA_COLUMN(TOFNSigmaHe, tofNSigmaHe); +DEFINE_UNWRAP_NSIGMA_COLUMN(TOFNSigmaAl, tofNSigmaAl); + +} // namespace pidtof_tiny + using namespace pidtofbeta; DECLARE_SOA_TABLE(pidRespTOFbeta, "AOD", "pidRespTOFbeta", Beta, BetaError, @@ -82,6 +119,7 @@ DECLARE_SOA_TABLE(pidRespTOFbeta, "AOD", "pidRespTOFbeta", DiffBetaEl); using namespace pidtof; +// Table with the full information for all particles DECLARE_SOA_TABLE(pidRespTOF, "AOD", "pidRespTOF", // Expected signals TOFExpSignalDiffEl, @@ -113,6 +151,17 @@ DECLARE_SOA_TABLE(pidRespTOFTr, "AOD", "pidRespTOFTr", TOFExpSignalDiffTr, TOFExpSigmaHe, TOFNSigmaHe); DECLARE_SOA_TABLE(pidRespTOFAl, "AOD", "pidRespTOFAl", TOFExpSignalDiffAl, TOFExpSigmaAl, TOFNSigmaAl); +// Tiny size tables +DECLARE_SOA_TABLE(pidRespTOFTEl, "AOD", "pidRespTOFTEl", TOFExpSigmaEl, pidtof_tiny::TOFNSigmaStoreEl, pidtof_tiny::TOFNSigmaEl); +DECLARE_SOA_TABLE(pidRespTOFTMu, "AOD", "pidRespTOFTMu", TOFExpSigmaMu, pidtof_tiny::TOFNSigmaStoreMu, pidtof_tiny::TOFNSigmaMu); +DECLARE_SOA_TABLE(pidRespTOFTPi, "AOD", "pidRespTOFTPi", TOFExpSigmaPi, pidtof_tiny::TOFNSigmaStorePi, pidtof_tiny::TOFNSigmaPi); +DECLARE_SOA_TABLE(pidRespTOFTKa, "AOD", "pidRespTOFTKa", TOFExpSigmaKa, pidtof_tiny::TOFNSigmaStoreKa, pidtof_tiny::TOFNSigmaKa); +DECLARE_SOA_TABLE(pidRespTOFTPr, "AOD", "pidRespTOFTPr", TOFExpSigmaPr, pidtof_tiny::TOFNSigmaStorePr, pidtof_tiny::TOFNSigmaPr); +DECLARE_SOA_TABLE(pidRespTOFTDe, "AOD", "pidRespTOFTDe", TOFExpSigmaDe, pidtof_tiny::TOFNSigmaStoreDe, pidtof_tiny::TOFNSigmaDe); +DECLARE_SOA_TABLE(pidRespTOFTTr, "AOD", "pidRespTOFTTr", TOFExpSigmaTr, pidtof_tiny::TOFNSigmaStoreTr, pidtof_tiny::TOFNSigmaTr); +DECLARE_SOA_TABLE(pidRespTOFTHe, "AOD", "pidRespTOFTHe", TOFExpSigmaHe, pidtof_tiny::TOFNSigmaStoreHe, pidtof_tiny::TOFNSigmaHe); +DECLARE_SOA_TABLE(pidRespTOFTAl, "AOD", "pidRespTOFTAl", TOFExpSigmaAl, pidtof_tiny::TOFNSigmaStoreAl, pidtof_tiny::TOFNSigmaAl); + namespace pidtpc { // Expected signals @@ -147,7 +196,40 @@ DECLARE_SOA_COLUMN(TPCNSigmaHe, tpcNSigmaHe, float); DECLARE_SOA_COLUMN(TPCNSigmaAl, tpcNSigmaAl, float); } // namespace pidtpc +namespace pidtpc_tiny +{ +typedef int8_t binned_nsigma_t; +constexpr int nbins = (1 << 8 * sizeof(binned_nsigma_t)) - 2; +constexpr binned_nsigma_t upper_bin = nbins >> 1; +constexpr binned_nsigma_t lower_bin = -(nbins >> 1); +constexpr float binned_max = 6.35; +constexpr float binned_min = -6.35; +constexpr float bin_width = (binned_max - binned_min) / nbins; +// NSigma with reduced size +DECLARE_SOA_COLUMN(TPCNSigmaStoreEl, tpcNSigmaStoreEl, binned_nsigma_t); +DECLARE_SOA_COLUMN(TPCNSigmaStoreMu, tpcNSigmaStoreMu, binned_nsigma_t); +DECLARE_SOA_COLUMN(TPCNSigmaStorePi, tpcNSigmaStorePi, binned_nsigma_t); +DECLARE_SOA_COLUMN(TPCNSigmaStoreKa, tpcNSigmaStoreKa, binned_nsigma_t); +DECLARE_SOA_COLUMN(TPCNSigmaStorePr, tpcNSigmaStorePr, binned_nsigma_t); +DECLARE_SOA_COLUMN(TPCNSigmaStoreDe, tpcNSigmaStoreDe, binned_nsigma_t); +DECLARE_SOA_COLUMN(TPCNSigmaStoreTr, tpcNSigmaStoreTr, binned_nsigma_t); +DECLARE_SOA_COLUMN(TPCNSigmaStoreHe, tpcNSigmaStoreHe, binned_nsigma_t); +DECLARE_SOA_COLUMN(TPCNSigmaStoreAl, tpcNSigmaStoreAl, binned_nsigma_t); +// NSigma with reduced size in [binned_min, binned_max] bin size bin_width +DEFINE_UNWRAP_NSIGMA_COLUMN(TPCNSigmaEl, tpcNSigmaEl); +DEFINE_UNWRAP_NSIGMA_COLUMN(TPCNSigmaMu, tpcNSigmaMu); +DEFINE_UNWRAP_NSIGMA_COLUMN(TPCNSigmaPi, tpcNSigmaPi); +DEFINE_UNWRAP_NSIGMA_COLUMN(TPCNSigmaKa, tpcNSigmaKa); +DEFINE_UNWRAP_NSIGMA_COLUMN(TPCNSigmaPr, tpcNSigmaPr); +DEFINE_UNWRAP_NSIGMA_COLUMN(TPCNSigmaDe, tpcNSigmaDe); +DEFINE_UNWRAP_NSIGMA_COLUMN(TPCNSigmaTr, tpcNSigmaTr); +DEFINE_UNWRAP_NSIGMA_COLUMN(TPCNSigmaHe, tpcNSigmaHe); +DEFINE_UNWRAP_NSIGMA_COLUMN(TPCNSigmaAl, tpcNSigmaAl); + +} // namespace pidtpc_tiny + using namespace pidtpc; +// Table with the full information for all particles DECLARE_SOA_TABLE(pidRespTPC, "AOD", "pidRespTPC", // Expected signals TPCExpSignalDiffEl, @@ -179,6 +261,19 @@ DECLARE_SOA_TABLE(pidRespTPCTr, "AOD", "pidRespTPCTr", TPCExpSignalDiffTr, TPCExpSigmaHe, TPCNSigmaHe); DECLARE_SOA_TABLE(pidRespTPCAl, "AOD", "pidRespTPCAl", TPCExpSignalDiffAl, TPCExpSigmaAl, TPCNSigmaAl); +// Tiny size tables +DECLARE_SOA_TABLE(pidRespTPCTEl, "AOD", "pidRespTPCTEl", TPCExpSigmaEl, pidtpc_tiny::TPCNSigmaStoreEl, pidtpc_tiny::TPCNSigmaEl); +DECLARE_SOA_TABLE(pidRespTPCTMu, "AOD", "pidRespTPCTMu", TPCExpSigmaMu, pidtpc_tiny::TPCNSigmaStoreMu, pidtpc_tiny::TPCNSigmaMu); +DECLARE_SOA_TABLE(pidRespTPCTPi, "AOD", "pidRespTPCTPi", TPCExpSigmaPi, pidtpc_tiny::TPCNSigmaStorePi, pidtpc_tiny::TPCNSigmaPi); +DECLARE_SOA_TABLE(pidRespTPCTKa, "AOD", "pidRespTPCTKa", TPCExpSigmaKa, pidtpc_tiny::TPCNSigmaStoreKa, pidtpc_tiny::TPCNSigmaKa); +DECLARE_SOA_TABLE(pidRespTPCTPr, "AOD", "pidRespTPCTPr", TPCExpSigmaPr, pidtpc_tiny::TPCNSigmaStorePr, pidtpc_tiny::TPCNSigmaPr); +DECLARE_SOA_TABLE(pidRespTPCTDe, "AOD", "pidRespTPCTDe", TPCExpSigmaDe, pidtpc_tiny::TPCNSigmaStoreDe, pidtpc_tiny::TPCNSigmaDe); +DECLARE_SOA_TABLE(pidRespTPCTTr, "AOD", "pidRespTPCTTr", TPCExpSigmaTr, pidtpc_tiny::TPCNSigmaStoreTr, pidtpc_tiny::TPCNSigmaTr); +DECLARE_SOA_TABLE(pidRespTPCTHe, "AOD", "pidRespTPCTHe", TPCExpSigmaHe, pidtpc_tiny::TPCNSigmaStoreHe, pidtpc_tiny::TPCNSigmaHe); +DECLARE_SOA_TABLE(pidRespTPCTAl, "AOD", "pidRespTPCTAl", TPCExpSigmaAl, pidtpc_tiny::TPCNSigmaStoreAl, pidtpc_tiny::TPCNSigmaAl); + +#undef DEFINE_UNWRAP_NSIGMA_COLUMN + } // namespace o2::aod #endif // O2_FRAMEWORK_PIDRESPONSE_H_ diff --git a/Analysis/Tasks/CMakeLists.txt b/Analysis/Tasks/CMakeLists.txt index d947c15445630..a46155cd32455 100644 --- a/Analysis/Tasks/CMakeLists.txt +++ b/Analysis/Tasks/CMakeLists.txt @@ -32,7 +32,6 @@ o2_add_dpl_workflow(trackqa PUBLIC_LINK_LIBRARIES O2::Framework O2::AnalysisDataModel O2::AnalysisCore COMPONENT_NAME Analysis) - o2_add_dpl_workflow(pid-tof SOURCES pidTOF.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2::AnalysisDataModel O2::AnalysisCore @@ -43,6 +42,11 @@ o2_add_dpl_workflow(pid-tof-split PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2::AnalysisDataModel O2::AnalysisCore COMPONENT_NAME Analysis) +o2_add_dpl_workflow(pid-tof-tiny + SOURCES pidTOF_tiny.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2::AnalysisDataModel O2::AnalysisCore + COMPONENT_NAME Analysis) + o2_add_dpl_workflow(pid-tpc SOURCES pidTPC.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2::AnalysisDataModel O2::AnalysisCore @@ -53,6 +57,11 @@ o2_add_dpl_workflow(pid-tpc-split PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2::AnalysisDataModel O2::AnalysisCore COMPONENT_NAME Analysis) +o2_add_dpl_workflow(pid-tpc-tiny + SOURCES pidTPC_tiny.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2::AnalysisDataModel O2::AnalysisCore + COMPONENT_NAME Analysis) + o2_add_dpl_workflow(validation SOURCES validation.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase diff --git a/Analysis/Tasks/PWGLF/CMakeLists.txt b/Analysis/Tasks/PWGLF/CMakeLists.txt index 5232832778379..cc679097f5f70 100644 --- a/Analysis/Tasks/PWGLF/CMakeLists.txt +++ b/Analysis/Tasks/PWGLF/CMakeLists.txt @@ -23,6 +23,11 @@ o2_add_dpl_workflow(spectra-tof-split PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2::AnalysisDataModel COMPONENT_NAME Analysis) +o2_add_dpl_workflow(spectra-tof-tiny + SOURCES spectraTOF_tiny.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2::AnalysisDataModel + COMPONENT_NAME Analysis) + o2_add_dpl_workflow(spectra-tpc SOURCES spectraTPC.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2::AnalysisDataModel @@ -33,6 +38,11 @@ o2_add_dpl_workflow(spectra-tpc-split PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2::AnalysisDataModel COMPONENT_NAME Analysis) +o2_add_dpl_workflow(spectra-tpc-tiny + SOURCES spectraTPC_tiny.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2::AnalysisDataModel + COMPONENT_NAME Analysis) + o2_add_dpl_workflow(nuclei-spectra SOURCES NucleiSpectraTask.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2::AnalysisDataModel diff --git a/Analysis/Tasks/PWGLF/spectraTOF_tiny.cxx b/Analysis/Tasks/PWGLF/spectraTOF_tiny.cxx new file mode 100644 index 0000000000000..b48bf79a2aa88 --- /dev/null +++ b/Analysis/Tasks/PWGLF/spectraTOF_tiny.cxx @@ -0,0 +1,82 @@ +// Copyright CERN and copyright holders of ALICE O2. This software is +// distributed under the terms of the GNU General Public License v3 (GPL +// Version 3), copied verbatim in the file "COPYING". +// +// See http://alice-o2.web.cern.ch/license for full licensing information. +// +// 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. + +// O2 includes +#include "ReconstructionDataFormats/Track.h" +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/ASoAHelpers.h" +#include "AnalysisDataModel/PID/PIDResponse.h" +#include "AnalysisDataModel/TrackSelectionTables.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +struct TOFSpectraTaskTiny { + 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 hp[Np] = {"p/El", "p/Mu", "p/Pi", "p/Ka", "p/Pr", "p/De", "p/Tr", "p/He", "p/Al"}; + static constexpr std::string_view hpt[Np] = {"pt/El", "pt/Mu", "pt/Pi", "pt/Ka", "pt/Pr", "pt/De", "pt/Tr", "pt/He", "pt/Al"}; + HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + + void init(o2::framework::InitContext&) + { + histos.add("p/Unselected", "Unselected;#it{p} (GeV/#it{c})", kTH1F, {{100, 0, 20}}); + histos.add("pt/Unselected", "Unselected;#it{p}_{T} (GeV/#it{c})", kTH1F, {{100, 0, 20}}); + for (int i = 0; i < Np; i++) { + histos.add(hp[i].data(), Form("%s;#it{p} (GeV/#it{c})", pT[i]), kTH1F, {{100, 0, 20}}); + histos.add(hpt[i].data(), Form("%s;#it{p}_{T} (GeV/#it{c})", pT[i]), kTH1F, {{100, 0, 20}}); + } + } + + template + void fillParticleHistos(const T& track, const float& nsigma) + { + if (abs(nsigma) > nsigmacut.value) { + return; + } + histos.fill(HIST(hp[i]), track.p()); + histos.fill(HIST(hpt[i]), track.pt()); + } + + Configurable cfgCutVertex{"cfgCutVertex", 10.0f, "Accepted z-vertex range"}; + Configurable cfgCutEta{"cfgCutEta", 0.8f, "Eta range for tracks"}; + Configurable nsigmacut{"nsigmacut", 3, "Value of the Nsigma cut"}; + Filter collisionFilter = nabs(aod::collision::posZ) < cfgCutVertex; + Filter trackFilter = (nabs(aod::track::eta) < cfgCutEta) && (aod::track::isGlobalTrack == (uint8_t) true) && (aod::track::tofSignal > 0.f); + using TrackCandidates = soa::Filtered>; + void process(TrackCandidates::iterator const& track) + { + histos.fill(HIST("p/Unselected"), track.p()); + histos.fill(HIST("pt/Unselected"), track.pt()); + + fillParticleHistos<0>(track, track.tofNSigmaEl()); + fillParticleHistos<1>(track, track.tofNSigmaMu()); + fillParticleHistos<2>(track, track.tofNSigmaPi()); + fillParticleHistos<3>(track, track.tofNSigmaKa()); + fillParticleHistos<4>(track, track.tofNSigmaPr()); + fillParticleHistos<5>(track, track.tofNSigmaDe()); + fillParticleHistos<6>(track, track.tofNSigmaTr()); + fillParticleHistos<7>(track, track.tofNSigmaHe()); + fillParticleHistos<8>(track, track.tofNSigmaAl()); + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const&) +{ + WorkflowSpec workflow{adaptAnalysisTask("tofspectra-split-task")}; + return workflow; +} diff --git a/Analysis/Tasks/PWGLF/spectraTPC_tiny.cxx b/Analysis/Tasks/PWGLF/spectraTPC_tiny.cxx new file mode 100644 index 0000000000000..ad49a15637b5d --- /dev/null +++ b/Analysis/Tasks/PWGLF/spectraTPC_tiny.cxx @@ -0,0 +1,110 @@ +// Copyright CERN and copyright holders of ALICE O2. This software is +// distributed under the terms of the GNU General Public License v3 (GPL +// Version 3), copied verbatim in the file "COPYING". +// +// See http://alice-o2.web.cern.ch/license for full licensing information. +// +// 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. + +// O2 includes +#include "ReconstructionDataFormats/Track.h" +#include "Framework/AnalysisTask.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/ASoAHelpers.h" +#include "AnalysisDataModel/PID/PIDResponse.h" +#include "AnalysisDataModel/TrackSelectionTables.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +void customize(std::vector& workflowOptions) +{ + std::vector options{ + {"add-tof-histos", VariantType::Int, 0, {"Generate TPC with TOF histograms"}}}; + std::swap(workflowOptions, options); +} + +#include "Framework/runDataProcessing.h" + +template +void makelogaxis(T h) +{ + const int nbins = h->GetNbinsX(); + double binp[nbins + 1]; + double max = h->GetXaxis()->GetBinUpEdge(nbins); + double min = h->GetXaxis()->GetBinLowEdge(1); + if (min <= 0) { + min = 0.00001; + } + double lmin = TMath::Log10(min); + double ldelta = (TMath::Log10(max) - lmin) / ((double)nbins); + for (int i = 0; i < nbins; i++) { + binp[i] = TMath::Exp(TMath::Log(10) * (lmin + i * ldelta)); + } + binp[nbins] = max + 1; + h->GetXaxis()->Set(nbins, binp); +} + +struct TPCSpectraTaskTiny { + 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 hp[Np] = {"p/El", "p/Mu", "p/Pi", "p/Ka", "p/Pr", "p/De", "p/Tr", "p/He", "p/Al"}; + static constexpr std::string_view hpt[Np] = {"pt/El", "pt/Mu", "pt/Pi", "pt/Ka", "pt/Pr", "pt/De", "pt/Tr", "pt/He", "pt/Al"}; + HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + + void init(o2::framework::InitContext&) + { + histos.add("p/Unselected", "Unselected;#it{p} (GeV/#it{c})", kTH1F, {{100, 0, 20}}); + histos.add("pt/Unselected", "Unselected;#it{p}_{T} (GeV/#it{c})", kTH1F, {{100, 0, 20}}); + for (int i = 0; i < Np; i++) { + histos.add(hp[i].data(), Form("%s;#it{p} (GeV/#it{c})", pT[i]), kTH1F, {{100, 0, 20}}); + histos.add(hpt[i].data(), Form("%s;#it{p}_{T} (GeV/#it{c})", pT[i]), kTH1F, {{100, 0, 20}}); + } + } + + template + void fillParticleHistos(const T& track, const float& nsigma) + { + if (abs(nsigma) > nsigmacut.value) { + return; + } + histos.fill(HIST(hp[i]), track.p()); + histos.fill(HIST(hpt[i]), track.pt()); + } + + Configurable cfgCutVertex{"cfgCutVertex", 10.0f, "Accepted z-vertex range"}; + Configurable cfgCutEta{"cfgCutEta", 0.8f, "Eta range for tracks"}; + Configurable nsigmacut{"nsigmacut", 3, "Value of the Nsigma cut"}; + Filter collisionFilter = nabs(aod::collision::posZ) < cfgCutVertex; + Filter trackFilter = (nabs(aod::track::eta) < cfgCutEta) && (aod::track::isGlobalTrack == (uint8_t) true); + using TrackCandidates = soa::Filtered>; + + void process(TrackCandidates::iterator const& track) + { + histos.fill(HIST("p/Unselected"), track.p()); + histos.fill(HIST("pt/Unselected"), track.pt()); + + fillParticleHistos<0>(track, track.tpcNSigmaEl()); + fillParticleHistos<1>(track, track.tpcNSigmaMu()); + fillParticleHistos<2>(track, track.tpcNSigmaPi()); + fillParticleHistos<3>(track, track.tpcNSigmaKa()); + fillParticleHistos<4>(track, track.tpcNSigmaPr()); + fillParticleHistos<5>(track, track.tpcNSigmaDe()); + fillParticleHistos<6>(track, track.tpcNSigmaTr()); + fillParticleHistos<7>(track, track.tpcNSigmaHe()); + fillParticleHistos<8>(track, track.tpcNSigmaAl()); + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + WorkflowSpec workflow{adaptAnalysisTask("tpcspectra-tiny-task")}; + return workflow; +} diff --git a/Analysis/Tasks/pidTOF_tiny.cxx b/Analysis/Tasks/pidTOF_tiny.cxx new file mode 100644 index 0000000000000..fdfc215d36641 --- /dev/null +++ b/Analysis/Tasks/pidTOF_tiny.cxx @@ -0,0 +1,114 @@ +// Copyright CERN and copyright holders of ALICE O2. This software is +// distributed under the terms of the GNU General Public License v3 (GPL +// Version 3), copied verbatim in the file "COPYING". +// +// See http://alice-o2.web.cern.ch/license for full licensing information. +// +// 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. + +// O2 includes +#include "Framework/AnalysisTask.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/HistogramRegistry.h" +#include "ReconstructionDataFormats/Track.h" +#include +#include "AnalysisDataModel/PID/PIDResponse.h" +#include "AnalysisDataModel/PID/PIDTOF.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, 1, {"Produce TOF PID QA histograms"}}, + {"pid-el", VariantType::Int, 1, {"Produce PID information for the electron mass hypothesis"}}, + {"pid-mu", VariantType::Int, 1, {"Produce PID information for the muon mass hypothesis"}}, + {"pid-pikapr", VariantType::Int, 1, {"Produce PID information for the Pion, Kaon, Proton mass hypothesis"}}, + {"pid-nuclei", VariantType::Int, 1, {"Produce PID information for the Deuteron, Triton, Alpha mass hypothesis"}}}; + std::swap(workflowOptions, options); +} + +#include "Framework/runDataProcessing.h" + +template +struct pidTOFTaskPerTiny { + using Trks = soa::Join; + using Coll = aod::Collisions; + Produces tofpid; + DetectorResponse resp; + Service ccdb; + Configurable paramfile{"param-file", "", "Path to the parametrization object, if emtpy the parametrization is not taken from file"}; + Configurable sigmaname{"param-sigma", "TOFReso", "Name of the parametrization for the expected sigma, used in both file and CCDB mode"}; + Configurable url{"ccdb-url", "http://ccdb-test.cern.ch:8080", "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 = {0.008, 0.008, 0.002, 40.0}; + resp.SetParameters(DetectorResponse::kSigma, p); + const std::string fname = paramfile.value; + if (!fname.empty()) { // Loading the parametrization from file + resp.LoadParamFromFile(fname.data(), sigmaname.value, DetectorResponse::kSigma); + } else { // Loading it from CCDB + const std::string path = "Analysis/PID/TOF"; + resp.LoadParam(DetectorResponse::kSigma, ccdb->getForTimeStamp(path + "/" + sigmaname.value, timestamp.value)); + } + } + + void process(Coll const& collisions, Trks const& tracks) + { + constexpr tof::ExpTimes resp_PID = tof::ExpTimes(); + + tofpid.reserve(tracks.size()); + for (auto const& trk : tracks) { + const float exp_sigma = resp_PID.GetExpectedSigma(resp, trk.collision(), trk); + const float separation = resp_PID.GetSeparation(resp, trk.collision(), trk); + if (separation <= o2::aod::pidtof_tiny::binned_min) { + tofpid(exp_sigma, o2::aod::pidtof_tiny::lower_bin); + } else if (separation >= o2::aod::pidtof_tiny::binned_max) { + tofpid(exp_sigma, o2::aod::pidtof_tiny::upper_bin); + } else if (separation >= 0) { + tofpid(exp_sigma, separation / o2::aod::pidtof_tiny::bin_width + 0.5f); + } else { + tofpid(exp_sigma, separation / o2::aod::pidtof_tiny::bin_width - 0.5f); + } + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + WorkflowSpec workflow; + if (cfgc.options().get("pid-el")) { + workflow.push_back(adaptAnalysisTask>("pidTOFEl-task-tiny")); + } + if (cfgc.options().get("pid-mu")) { + workflow.push_back(adaptAnalysisTask>("pidTOFMu-task-tiny")); + } + if (cfgc.options().get("pid-pikapr")) { + workflow.push_back(adaptAnalysisTask>("pidTOFPi-task-tiny")); + workflow.push_back(adaptAnalysisTask>("pidTOFKa-task-tiny")); + workflow.push_back(adaptAnalysisTask>("pidTOFPr-task-tiny")); + } + if (cfgc.options().get("pid-nuclei")) { + workflow.push_back(adaptAnalysisTask>("pidTOFDe-task-tiny")); + workflow.push_back(adaptAnalysisTask>("pidTOFTr-task-tiny")); + workflow.push_back(adaptAnalysisTask>("pidTOFHe-task-tiny")); + workflow.push_back(adaptAnalysisTask>("pidTOFAl-task-tiny")); + } + return workflow; +} diff --git a/Analysis/Tasks/pidTPC_tiny.cxx b/Analysis/Tasks/pidTPC_tiny.cxx new file mode 100644 index 0000000000000..e7e43c4c3b553 --- /dev/null +++ b/Analysis/Tasks/pidTPC_tiny.cxx @@ -0,0 +1,115 @@ +// Copyright CERN and copyright holders of ALICE O2. This software is +// distributed under the terms of the GNU General Public License v3 (GPL +// Version 3), copied verbatim in the file "COPYING". +// +// See http://alice-o2.web.cern.ch/license for full licensing information. +// +// 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. + +// O2 includes +#include "Framework/AnalysisTask.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/HistogramRegistry.h" +#include "ReconstructionDataFormats/Track.h" +#include +#include "AnalysisDataModel/PID/PIDResponse.h" +#include "AnalysisDataModel/PID/PIDTPC.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, 1, {"Produce TPC PID QA histograms"}}, + {"pid-el", VariantType::Int, 1, {"Produce PID information for the electron mass hypothesis"}}, + {"pid-mu", VariantType::Int, 1, {"Produce PID information for the muon mass hypothesis"}}, + {"pid-pikapr", VariantType::Int, 1, {"Produce PID information for the Pion, Kaon, Proton mass hypothesis"}}, + {"pid-nuclei", VariantType::Int, 1, {"Produce PID information for the Deuteron, Triton, Alpha mass hypothesis"}}}; + std::swap(workflowOptions, options); +} + +#include "Framework/runDataProcessing.h" + +template +struct pidTPCTaskPerTiny { + using Trks = soa::Join; + using Coll = aod::Collisions; + Produces
tpcpid; + DetectorResponse resp; + Service ccdb; + Configurable paramfile{"param-file", "", "Path to the parametrization object, if emtpy the parametrization is not taken from file"}; + Configurable signalname{"param-signal", "BetheBloch", "Name of the parametrization for the expected signal, used in both file and CCDB mode"}; + Configurable sigmaname{"param-sigma", "TPCReso", "Name of the parametrization for the expected sigma, used in both file and CCDB mode"}; + Configurable url{"ccdb-url", "http://ccdb-test.cern.ch:8080", "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::string fname = paramfile.value; + if (!fname.empty()) { // Loading the parametrization from file + resp.LoadParamFromFile(fname.data(), signalname.value, DetectorResponse::kSignal); + resp.LoadParamFromFile(fname.data(), sigmaname.value, DetectorResponse::kSigma); + } else { // Loading it from CCDB + const std::string path = "Analysis/PID/TPC"; + resp.LoadParam(DetectorResponse::kSignal, ccdb->getForTimeStamp(path + "/" + signalname.value, timestamp.value)); + resp.LoadParam(DetectorResponse::kSigma, ccdb->getForTimeStamp(path + "/" + sigmaname.value, timestamp.value)); + } + } + + void process(Coll const& collisions, Trks const& tracks) + { + constexpr tpc::ELoss resp_PID = tpc::ELoss(); + + tpcpid.reserve(tracks.size()); + for (auto const& trk : tracks) { + const float exp_sigma = resp_PID.GetExpectedSigma(resp, trk.collision(), trk); + const float separation = resp_PID.GetSeparation(resp, trk.collision(), trk); + if (separation <= o2::aod::pidtpc_tiny::binned_min) { + tpcpid(exp_sigma, o2::aod::pidtpc_tiny::lower_bin); + } else if (separation >= o2::aod::pidtpc_tiny::binned_max) { + tpcpid(exp_sigma, o2::aod::pidtpc_tiny::upper_bin); + } else if (separation >= 0) { + tpcpid(exp_sigma, separation / o2::aod::pidtpc_tiny::bin_width + 0.5f); + } else { + tpcpid(exp_sigma, separation / o2::aod::pidtpc_tiny::bin_width - 0.5f); + } + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + WorkflowSpec workflow; + if (cfgc.options().get("pid-el")) { + workflow.push_back(adaptAnalysisTask>("pidTPCEl-task")); + } + if (cfgc.options().get("pid-mu")) { + workflow.push_back(adaptAnalysisTask>("pidTPCMu-task")); + } + if (cfgc.options().get("pid-pikapr")) { + workflow.push_back(adaptAnalysisTask>("pidTPCPi-task")); + workflow.push_back(adaptAnalysisTask>("pidTPCKa-task")); + workflow.push_back(adaptAnalysisTask>("pidTPCPr-task")); + } + if (cfgc.options().get("pid-nuclei")) { + workflow.push_back(adaptAnalysisTask>("pidTPCDe-task")); + workflow.push_back(adaptAnalysisTask>("pidTPCTr-task")); + workflow.push_back(adaptAnalysisTask>("pidTPCHe-task")); + workflow.push_back(adaptAnalysisTask>("pidTPCAl-task")); + } + return workflow; +}