Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 95 additions & 0 deletions Analysis/DataModel/include/AnalysisDataModel/PID/PIDResponse.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<float>(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,
Expand All @@ -82,6 +119,7 @@ DECLARE_SOA_TABLE(pidRespTOFbeta, "AOD", "pidRespTOFbeta",
DiffBetaEl<Beta, ExpBetaEl>);

using namespace pidtof;
// Table with the full information for all particles
DECLARE_SOA_TABLE(pidRespTOF, "AOD", "pidRespTOF",
// Expected signals
TOFExpSignalDiffEl<TOFNSigmaEl, TOFExpSigmaEl>,
Expand Down Expand Up @@ -113,6 +151,17 @@ DECLARE_SOA_TABLE(pidRespTOFTr, "AOD", "pidRespTOFTr", TOFExpSignalDiffTr<TOFNSi
DECLARE_SOA_TABLE(pidRespTOFHe, "AOD", "pidRespTOFHe", TOFExpSignalDiffHe<TOFNSigmaHe, TOFExpSigmaHe>, TOFExpSigmaHe, TOFNSigmaHe);
DECLARE_SOA_TABLE(pidRespTOFAl, "AOD", "pidRespTOFAl", TOFExpSignalDiffAl<TOFNSigmaAl, TOFExpSigmaAl>, TOFExpSigmaAl, TOFNSigmaAl);

// Tiny size tables
DECLARE_SOA_TABLE(pidRespTOFTEl, "AOD", "pidRespTOFTEl", TOFExpSigmaEl, pidtof_tiny::TOFNSigmaStoreEl, pidtof_tiny::TOFNSigmaEl<pidtof_tiny::TOFNSigmaStoreEl>);
DECLARE_SOA_TABLE(pidRespTOFTMu, "AOD", "pidRespTOFTMu", TOFExpSigmaMu, pidtof_tiny::TOFNSigmaStoreMu, pidtof_tiny::TOFNSigmaMu<pidtof_tiny::TOFNSigmaStoreMu>);
DECLARE_SOA_TABLE(pidRespTOFTPi, "AOD", "pidRespTOFTPi", TOFExpSigmaPi, pidtof_tiny::TOFNSigmaStorePi, pidtof_tiny::TOFNSigmaPi<pidtof_tiny::TOFNSigmaStorePi>);
DECLARE_SOA_TABLE(pidRespTOFTKa, "AOD", "pidRespTOFTKa", TOFExpSigmaKa, pidtof_tiny::TOFNSigmaStoreKa, pidtof_tiny::TOFNSigmaKa<pidtof_tiny::TOFNSigmaStoreKa>);
DECLARE_SOA_TABLE(pidRespTOFTPr, "AOD", "pidRespTOFTPr", TOFExpSigmaPr, pidtof_tiny::TOFNSigmaStorePr, pidtof_tiny::TOFNSigmaPr<pidtof_tiny::TOFNSigmaStorePr>);
DECLARE_SOA_TABLE(pidRespTOFTDe, "AOD", "pidRespTOFTDe", TOFExpSigmaDe, pidtof_tiny::TOFNSigmaStoreDe, pidtof_tiny::TOFNSigmaDe<pidtof_tiny::TOFNSigmaStoreDe>);
DECLARE_SOA_TABLE(pidRespTOFTTr, "AOD", "pidRespTOFTTr", TOFExpSigmaTr, pidtof_tiny::TOFNSigmaStoreTr, pidtof_tiny::TOFNSigmaTr<pidtof_tiny::TOFNSigmaStoreTr>);
DECLARE_SOA_TABLE(pidRespTOFTHe, "AOD", "pidRespTOFTHe", TOFExpSigmaHe, pidtof_tiny::TOFNSigmaStoreHe, pidtof_tiny::TOFNSigmaHe<pidtof_tiny::TOFNSigmaStoreHe>);
DECLARE_SOA_TABLE(pidRespTOFTAl, "AOD", "pidRespTOFTAl", TOFExpSigmaAl, pidtof_tiny::TOFNSigmaStoreAl, pidtof_tiny::TOFNSigmaAl<pidtof_tiny::TOFNSigmaStoreAl>);

namespace pidtpc
{
// Expected signals
Expand Down Expand Up @@ -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<TPCNSigmaEl, TPCExpSigmaEl>,
Expand Down Expand Up @@ -179,6 +261,19 @@ DECLARE_SOA_TABLE(pidRespTPCTr, "AOD", "pidRespTPCTr", TPCExpSignalDiffTr<TPCNSi
DECLARE_SOA_TABLE(pidRespTPCHe, "AOD", "pidRespTPCHe", TPCExpSignalDiffHe<TPCNSigmaHe, TPCExpSigmaHe>, TPCExpSigmaHe, TPCNSigmaHe);
DECLARE_SOA_TABLE(pidRespTPCAl, "AOD", "pidRespTPCAl", TPCExpSignalDiffAl<TPCNSigmaAl, TPCExpSigmaAl>, TPCExpSigmaAl, TPCNSigmaAl);

// Tiny size tables
DECLARE_SOA_TABLE(pidRespTPCTEl, "AOD", "pidRespTPCTEl", TPCExpSigmaEl, pidtpc_tiny::TPCNSigmaStoreEl, pidtpc_tiny::TPCNSigmaEl<pidtpc_tiny::TPCNSigmaStoreEl>);
DECLARE_SOA_TABLE(pidRespTPCTMu, "AOD", "pidRespTPCTMu", TPCExpSigmaMu, pidtpc_tiny::TPCNSigmaStoreMu, pidtpc_tiny::TPCNSigmaMu<pidtpc_tiny::TPCNSigmaStoreMu>);
DECLARE_SOA_TABLE(pidRespTPCTPi, "AOD", "pidRespTPCTPi", TPCExpSigmaPi, pidtpc_tiny::TPCNSigmaStorePi, pidtpc_tiny::TPCNSigmaPi<pidtpc_tiny::TPCNSigmaStorePi>);
DECLARE_SOA_TABLE(pidRespTPCTKa, "AOD", "pidRespTPCTKa", TPCExpSigmaKa, pidtpc_tiny::TPCNSigmaStoreKa, pidtpc_tiny::TPCNSigmaKa<pidtpc_tiny::TPCNSigmaStoreKa>);
DECLARE_SOA_TABLE(pidRespTPCTPr, "AOD", "pidRespTPCTPr", TPCExpSigmaPr, pidtpc_tiny::TPCNSigmaStorePr, pidtpc_tiny::TPCNSigmaPr<pidtpc_tiny::TPCNSigmaStorePr>);
DECLARE_SOA_TABLE(pidRespTPCTDe, "AOD", "pidRespTPCTDe", TPCExpSigmaDe, pidtpc_tiny::TPCNSigmaStoreDe, pidtpc_tiny::TPCNSigmaDe<pidtpc_tiny::TPCNSigmaStoreDe>);
DECLARE_SOA_TABLE(pidRespTPCTTr, "AOD", "pidRespTPCTTr", TPCExpSigmaTr, pidtpc_tiny::TPCNSigmaStoreTr, pidtpc_tiny::TPCNSigmaTr<pidtpc_tiny::TPCNSigmaStoreTr>);
DECLARE_SOA_TABLE(pidRespTPCTHe, "AOD", "pidRespTPCTHe", TPCExpSigmaHe, pidtpc_tiny::TPCNSigmaStoreHe, pidtpc_tiny::TPCNSigmaHe<pidtpc_tiny::TPCNSigmaStoreHe>);
DECLARE_SOA_TABLE(pidRespTPCTAl, "AOD", "pidRespTPCTAl", TPCExpSigmaAl, pidtpc_tiny::TPCNSigmaStoreAl, pidtpc_tiny::TPCNSigmaAl<pidtpc_tiny::TPCNSigmaStoreAl>);

#undef DEFINE_UNWRAP_NSIGMA_COLUMN

} // namespace o2::aod

#endif // O2_FRAMEWORK_PIDRESPONSE_H_
11 changes: 10 additions & 1 deletion Analysis/Tasks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
10 changes: 10 additions & 0 deletions Analysis/Tasks/PWGLF/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
82 changes: 82 additions & 0 deletions Analysis/Tasks/PWGLF/spectraTOF_tiny.cxx
Original file line number Diff line number Diff line change
@@ -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 <std::size_t i, typename T>
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<float> cfgCutVertex{"cfgCutVertex", 10.0f, "Accepted z-vertex range"};
Configurable<float> cfgCutEta{"cfgCutEta", 0.8f, "Eta range for tracks"};
Configurable<float> 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<soa::Join<aod::Tracks, aod::TracksExtra,
aod::pidRespTOFTEl, aod::pidRespTOFTMu, aod::pidRespTOFTPi,
aod::pidRespTOFTKa, aod::pidRespTOFTPr, aod::pidRespTOFTDe,
aod::pidRespTOFTTr, aod::pidRespTOFTHe, aod::pidRespTOFTAl,
aod::pidRespTOFbeta, aod::TrackSelection>>;
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<TOFSpectraTaskTiny>("tofspectra-split-task")};
return workflow;
}
110 changes: 110 additions & 0 deletions Analysis/Tasks/PWGLF/spectraTPC_tiny.cxx
Original file line number Diff line number Diff line change
@@ -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<o2::framework::ConfigParamSpec>& workflowOptions)
{
std::vector<ConfigParamSpec> options{
{"add-tof-histos", VariantType::Int, 0, {"Generate TPC with TOF histograms"}}};
std::swap(workflowOptions, options);
}

#include "Framework/runDataProcessing.h"

template <typename T>
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 <std::size_t i, typename T>
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<float> cfgCutVertex{"cfgCutVertex", 10.0f, "Accepted z-vertex range"};
Configurable<float> cfgCutEta{"cfgCutEta", 0.8f, "Eta range for tracks"};
Configurable<float> 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<soa::Join<aod::Tracks, aod::TracksExtra,
aod::pidRespTPCTEl, aod::pidRespTPCTMu, aod::pidRespTPCTPi,
aod::pidRespTPCTKa, aod::pidRespTPCTPr, aod::pidRespTPCTDe,
aod::pidRespTPCTTr, aod::pidRespTPCTHe, aod::pidRespTPCTAl,
aod::TrackSelection>>;

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<TPCSpectraTaskTiny>("tpcspectra-tiny-task")};
return workflow;
}
Loading