Skip to content

Commit 6a055fd

Browse files
authored
Setting up Skimming Tasks - spectraTPC (#5217)
1 parent 9f1a366 commit 6a055fd

9 files changed

Lines changed: 433 additions & 0 deletions

File tree

Analysis/Tasks/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ add_subdirectory(PWGJE)
1515
add_subdirectory(PWGLF)
1616
add_subdirectory(PWGUD)
1717
add_subdirectory(ALICE3)
18+
add_subdirectory(SkimmingTutorials)
1819

1920

2021
o2_add_dpl_workflow(trackextension
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright CERN and copyright holders of ALICE O2. This software is distributed
2+
# under the terms of the GNU General Public License v3 (GPL Version 3), copied
3+
# verbatim in the file "COPYING".
4+
#
5+
# See http://alice-o2.web.cern.ch/license for full licensing information.
6+
#
7+
# In applying this license CERN does not waive the privileges and immunities
8+
# granted to it by virtue of its status as an Intergovernmental Organization or
9+
# submit itself to any jurisdiction.
10+
11+
12+
o2_add_dpl_workflow(tpcspectra-task-skim-reference
13+
SOURCES spectraTPCReference.cxx
14+
PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2::AnalysisDataModel
15+
COMPONENT_NAME Analysis)
16+
17+
o2_add_dpl_workflow(tpcspectra-task-skim-provider
18+
SOURCES spectraTPCProvider.cxx
19+
PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2::AnalysisDataModel
20+
COMPONENT_NAME Analysis)
21+
22+
o2_add_dpl_workflow(tpcspectra-task-skim-analyser
23+
SOURCES spectraTPCAnalyser.cxx
24+
PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2::AnalysisDataModel
25+
COMPONENT_NAME Analysis)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright CERN and copyright holders of ALICE O2. This software is
2+
// distributed under the terms of the GNU General Public License v3 (GPL
3+
// Version 3), copied verbatim in the file "COPYING".
4+
//
5+
// See http://alice-o2.web.cern.ch/license for full licensing information.
6+
//
7+
// In applying this license CERN does not waive the privileges and immunities
8+
// granted to it by virtue of its status as an Intergovernmental Organization
9+
// or submit itself to any jurisdiction.
10+
#ifndef O2_ANALYSIS_LFDERIVED_H
11+
#define O2_ANALYSIS_LFDERIVED_H
12+
13+
#include "Framework/ASoA.h"
14+
#include "Framework/AnalysisDataModel.h"
15+
16+
namespace o2::aod
17+
{
18+
//DECLARE_SOA_TABLE(LFCollisions, "AOD", "LFCOLLISION", o2::soa::Index<>,
19+
// o2::aod::bc::RunNumber, o2::aod::collision::PosZ);
20+
//using LFCollision = LFCollisions::iterator;
21+
22+
namespace lftrack
23+
{
24+
//DECLARE_SOA_INDEX_COLUMN(LFCollision, lfCollision);
25+
DECLARE_SOA_COLUMN(Pt, pt, float);
26+
DECLARE_SOA_COLUMN(P, p, float);
27+
DECLARE_SOA_COLUMN(Eta, eta, float);
28+
DECLARE_SOA_COLUMN(TPCNSigma, tpcNSigma, float[9]);
29+
} // namespace lftrack
30+
DECLARE_SOA_TABLE(LFTracks, "AOD", "LFTRACK", o2::soa::Index<>,
31+
//lftrack::LFCollisionId,
32+
lftrack::Pt, lftrack::P, lftrack::Eta,
33+
lftrack::TPCNSigma);
34+
using LFTrack = LFTracks::iterator;
35+
} // namespace o2::aod
36+
37+
#endif // O2_ANALYSIS_LFDERIVED_H
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright CERN and copyright holders of ALICE O2. This software is
2+
// distributed under the terms of the GNU General Public License v3 (GPL
3+
// Version 3), copied verbatim in the file "COPYING".
4+
//
5+
// See http://alice-o2.web.cern.ch/license for full licensing information.
6+
//
7+
// In applying this license CERN does not waive the privileges and immunities
8+
// granted to it by virtue of its status as an Intergovernmental Organization
9+
// or submit itself to any jurisdiction.
10+
/// \author Nima Zardoshti <nima.zardoshti@cern.ch>, CERN
11+
#ifndef O2_ANALYSIS_LFDERIVED_H
12+
#define O2_ANALYSIS_LFDERIVED_H
13+
14+
#include "Framework/ASoA.h"
15+
#include "Framework/AnalysisDataModel.h"
16+
17+
namespace o2::aod
18+
{
19+
//DECLARE_SOA_TABLE(LFCollisions, "AOD", "LFCOLLISION", o2::soa::Index<>,
20+
// o2::aod::bc::RunNumber, o2::aod::collision::PosZ);
21+
//using LFCollision = LFCollisions::iterator;
22+
23+
namespace lftrack
24+
{
25+
//DECLARE_SOA_INDEX_COLUMN(LFCollision, lfCollision);
26+
DECLARE_SOA_COLUMN(Pt, pt, float);
27+
DECLARE_SOA_COLUMN(P, p, float);
28+
DECLARE_SOA_COLUMN(Eta, eta, float);
29+
DECLARE_SOA_COLUMN(TPCNSigma, tpcNSigma, float[9]);
30+
} // namespace lftrack
31+
DECLARE_SOA_TABLE(LFTracks, "AOD", "LFTRACK", o2::soa::Index<>,
32+
//lftrack::LFCollisionId,
33+
lftrack::Pt, lftrack::P, lftrack::Eta,
34+
lftrack::TPCNSigma);
35+
using LFTrack = LFTracks::iterator;
36+
} // namespace o2::aod
37+
38+
#endif // O2_ANALYSIS_LFDERIVED_H
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
// Copyright CERN and copyright holders of ALICE O2. This software is
2+
// distributed under the terms of the GNU General Public License v3 (GPL
3+
// Version 3), copied verbatim in the file "COPYING".
4+
//
5+
// See http://alice-o2.web.cern.ch/license for full licensing information.
6+
//
7+
// In applying this license CERN does not waive the privileges and immunities
8+
// granted to it by virtue of its status as an Intergovernmental Organization
9+
// or submit itself to any jurisdiction.
10+
11+
// O2 includes
12+
#include "ReconstructionDataFormats/Track.h"
13+
#include "Framework/AnalysisTask.h"
14+
#include "Framework/AnalysisDataModel.h"
15+
#include "Framework/ASoAHelpers.h"
16+
#include "AnalysisDataModel/PID/PIDResponse.h"
17+
#include "AnalysisDataModel/TrackSelectionTables.h"
18+
#include "DataModel/LFDerived.h"
19+
20+
using namespace o2;
21+
using namespace o2::framework;
22+
using namespace o2::framework::expressions;
23+
24+
void customize(std::vector<o2::framework::ConfigParamSpec>& workflowOptions)
25+
{
26+
std::vector<ConfigParamSpec> options{
27+
{"add-tof-histos", VariantType::Int, 0, {"Generate TPC with TOF histograms"}}};
28+
std::swap(workflowOptions, options);
29+
}
30+
31+
#include "Framework/runDataProcessing.h"
32+
33+
// FIXME: we should put this function in some common header so it has to be defined only once
34+
template <typename T>
35+
void makelogaxis(T h)
36+
{
37+
const int nbins = h->GetNbinsX();
38+
double binp[nbins + 1];
39+
double max = h->GetXaxis()->GetBinUpEdge(nbins);
40+
double min = h->GetXaxis()->GetBinLowEdge(1);
41+
if (min <= 0) {
42+
min = 0.00001;
43+
}
44+
double lmin = TMath::Log10(min);
45+
double ldelta = (TMath::Log10(max) - lmin) / ((double)nbins);
46+
for (int i = 0; i < nbins; i++) {
47+
binp[i] = TMath::Exp(TMath::Log(10) * (lmin + i * ldelta));
48+
}
49+
binp[nbins] = max + 1;
50+
h->GetXaxis()->Set(nbins, binp);
51+
}
52+
53+
constexpr int Np = 9;
54+
struct TPCSpectraAnalyserTask {
55+
56+
static constexpr const char* pT[Np] = {"e", "#mu", "#pi", "K", "p", "d", "t", "^{3}He", "#alpha"};
57+
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"};
58+
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"};
59+
HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject};
60+
61+
void init(o2::framework::InitContext&)
62+
{
63+
histos.add("p/Unselected", "Unselected;#it{p} (GeV/#it{c})", kTH1F, {{100, 0, 20}});
64+
histos.add("pt/Unselected", "Unselected;#it{p}_{T} (GeV/#it{c})", kTH1F, {{100, 0, 20}});
65+
for (int i = 0; i < Np; i++) {
66+
histos.add(hp[i].data(), Form("%s;#it{p} (GeV/#it{c})", pT[i]), kTH1F, {{100, 0, 20}});
67+
histos.add(hpt[i].data(), Form("%s;#it{p}_{T} (GeV/#it{c})", pT[i]), kTH1F, {{100, 0, 20}});
68+
}
69+
}
70+
71+
Configurable<float> nsigmacut{"nsigmacut", 3, "Value of the Nsigma cut"};
72+
Configurable<float> cfgCutVertex{"cfgCutVertex", 10.0f, "Accepted z-vertex range"};
73+
Configurable<float> cfgCutEta{"cfgCutEta", 0.8f, "Eta range for tracks"};
74+
75+
template <std::size_t i, typename T>
76+
void fillParticleHistos(const T& track, const float nsigma[])
77+
{
78+
if (abs(nsigma[i]) > nsigmacut.value) {
79+
return;
80+
}
81+
histos.fill(HIST(hp[i]), track.p());
82+
histos.fill(HIST(hpt[i]), track.pt());
83+
}
84+
85+
Filter collisionFilter = nabs(aod::collision::posZ) < cfgCutVertex; //collision filters not doing anything now?
86+
Filter trackFilter = nabs(aod::lftrack::eta) < cfgCutEta;
87+
88+
void process(soa::Filtered<aod::LFTracks>::iterator const& track)
89+
{
90+
auto nsigma = track.tpcNSigma();
91+
histos.fill(HIST("p/Unselected"), track.p());
92+
histos.fill(HIST("pt/Unselected"), track.pt());
93+
94+
fillParticleHistos<0>(track, nsigma);
95+
fillParticleHistos<1>(track, nsigma);
96+
fillParticleHistos<2>(track, nsigma);
97+
fillParticleHistos<3>(track, nsigma);
98+
fillParticleHistos<4>(track, nsigma);
99+
fillParticleHistos<5>(track, nsigma);
100+
fillParticleHistos<6>(track, nsigma);
101+
fillParticleHistos<7>(track, nsigma);
102+
fillParticleHistos<8>(track, nsigma);
103+
}
104+
};
105+
106+
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
107+
{
108+
WorkflowSpec workflow{adaptAnalysisTask<TPCSpectraAnalyserTask>("tpcspectra-task-skim-analyser")};
109+
return workflow;
110+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// Copyright CERN and copyright holders of ALICE O2. This software is
2+
// distributed under the terms of the GNU General Public License v3 (GPL
3+
// Version 3), copied verbatim in the file "COPYING".
4+
//
5+
// See http://alice-o2.web.cern.ch/license for full licensing information.
6+
//
7+
// In applying this license CERN does not waive the privileges and immunities
8+
// granted to it by virtue of its status as an Intergovernmental Organization
9+
// or submit itself to any jurisdiction.
10+
/// \author Nima Zardoshti <nima.zardoshti@cern.ch>, CERN
11+
12+
// O2 includes
13+
#include "ReconstructionDataFormats/Track.h"
14+
#include "Framework/AnalysisTask.h"
15+
#include "Framework/AnalysisDataModel.h"
16+
#include "Framework/ASoAHelpers.h"
17+
#include "AnalysisDataModel/PID/PIDResponse.h"
18+
#include "AnalysisDataModel/TrackSelectionTables.h"
19+
#include "MathUtils/Utils.h"
20+
#include "DataModel/LFDerived.h"
21+
22+
using namespace o2;
23+
using namespace o2::framework;
24+
using namespace o2::framework::expressions;
25+
using namespace o2::math_utils::detail;
26+
27+
#include "Framework/runDataProcessing.h"
28+
29+
struct TPCSpectraProviderTask {
30+
31+
//Produces<aod::LFCollisions> outputCollisions; //currently it seems in the spectraTPC task no loop over the collision is made. Leave this here in case it will be added
32+
Produces<aod::LFTracks> outputTracks;
33+
34+
//Configurable<float> cfgCutVertex{"cfgCutVertex", 10.0f, "Accepted z-vertex range"};
35+
Configurable<float> trackEtaCut{"trackEtaCut", 0.9f, "Eta range for tracks"};
36+
37+
//Filter collisionFilter = nabs(aod::collision::posZ) < cfgCutVertex;
38+
Filter trackFilter = (nabs(aod::track::eta) < trackEtaCut) && (aod::track::isGlobalTrack == (uint8_t) true);
39+
40+
Configurable<float> nsigmacut{"nsigmacut", 3, "Value of the Nsigma cut"}; //can we add an upper limit?
41+
42+
using TrackCandidates = soa::Filtered<soa::Join<aod::Tracks, aod::TracksExtra, aod::pidRespTPC, aod::TrackSelection>>;
43+
void process(TrackCandidates::iterator const& track)
44+
{
45+
uint32_t pNsigma = 0xFFFFFF00; //15 bit precision for Nsigma
46+
float nsigma[9] = {truncateFloatFraction(track.tpcNSigmaEl(), pNsigma), truncateFloatFraction(track.tpcNSigmaMu(), pNsigma),
47+
truncateFloatFraction(track.tpcNSigmaPi(), pNsigma), truncateFloatFraction(track.tpcNSigmaKa(), pNsigma),
48+
truncateFloatFraction(track.tpcNSigmaPr(), pNsigma), truncateFloatFraction(track.tpcNSigmaDe(), pNsigma),
49+
truncateFloatFraction(track.tpcNSigmaTr(), pNsigma), truncateFloatFraction(track.tpcNSigmaHe(), pNsigma),
50+
truncateFloatFraction(track.tpcNSigmaAl(), pNsigma)}; //the significance needs to be discussed
51+
52+
//outputTracks(outputCollisions.lastIndex(), track.pt(), track.p(), track.eta(), nsigma);
53+
outputTracks(track.pt(), track.p(), track.eta(), nsigma);
54+
}
55+
};
56+
57+
WorkflowSpec defineDataProcessing(ConfigContext const&)
58+
{
59+
WorkflowSpec workflow{adaptAnalysisTask<TPCSpectraProviderTask>("tpcspectra-task-skim-provider")};
60+
return workflow;
61+
}
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
// Copyright CERN and copyright holders of ALICE O2. This software is
2+
// distributed under the terms of the GNU General Public License v3 (GPL
3+
// Version 3), copied verbatim in the file "COPYING".
4+
//
5+
// See http://alice-o2.web.cern.ch/license for full licensing information.
6+
//
7+
// In applying this license CERN does not waive the privileges and immunities
8+
// granted to it by virtue of its status as an Intergovernmental Organization
9+
// or submit itself to any jurisdiction.
10+
11+
// O2 includes
12+
#include "ReconstructionDataFormats/Track.h"
13+
#include "Framework/AnalysisTask.h"
14+
#include "Framework/AnalysisDataModel.h"
15+
#include "Framework/ASoAHelpers.h"
16+
#include "AnalysisDataModel/PID/PIDResponse.h"
17+
#include "AnalysisDataModel/TrackSelectionTables.h"
18+
19+
using namespace o2;
20+
using namespace o2::framework;
21+
using namespace o2::framework::expressions;
22+
23+
void customize(std::vector<o2::framework::ConfigParamSpec>& workflowOptions)
24+
{
25+
std::vector<ConfigParamSpec> options{
26+
{"add-tof-histos", VariantType::Int, 0, {"Generate TPC with TOF histograms"}}};
27+
std::swap(workflowOptions, options);
28+
}
29+
30+
#include "Framework/runDataProcessing.h"
31+
32+
// FIXME: we should put this function in some common header so it has to be defined only once
33+
template <typename T>
34+
void makelogaxis(T h)
35+
{
36+
const int nbins = h->GetNbinsX();
37+
double binp[nbins + 1];
38+
double max = h->GetXaxis()->GetBinUpEdge(nbins);
39+
double min = h->GetXaxis()->GetBinLowEdge(1);
40+
if (min <= 0) {
41+
min = 0.00001;
42+
}
43+
double lmin = TMath::Log10(min);
44+
double ldelta = (TMath::Log10(max) - lmin) / ((double)nbins);
45+
for (int i = 0; i < nbins; i++) {
46+
binp[i] = TMath::Exp(TMath::Log(10) * (lmin + i * ldelta));
47+
}
48+
binp[nbins] = max + 1;
49+
h->GetXaxis()->Set(nbins, binp);
50+
}
51+
52+
constexpr int Np = 9;
53+
struct TPCSpectraReferenceTask {
54+
static constexpr const char* pT[Np] = {"e", "#mu", "#pi", "K", "p", "d", "t", "^{3}He", "#alpha"};
55+
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"};
56+
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"};
57+
HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject};
58+
59+
void init(o2::framework::InitContext&)
60+
{
61+
histos.add("p/Unselected", "Unselected;#it{p} (GeV/#it{c})", kTH1F, {{100, 0, 20}});
62+
histos.add("pt/Unselected", "Unselected;#it{p}_{T} (GeV/#it{c})", kTH1F, {{100, 0, 20}});
63+
for (int i = 0; i < Np; i++) {
64+
histos.add(hp[i].data(), Form("%s;#it{p} (GeV/#it{c})", pT[i]), kTH1F, {{100, 0, 20}});
65+
histos.add(hpt[i].data(), Form("%s;#it{p}_{T} (GeV/#it{c})", pT[i]), kTH1F, {{100, 0, 20}});
66+
}
67+
}
68+
69+
//Defining filters and input
70+
Configurable<float> cfgCutVertex{"cfgCutVertex", 10.0f, "Accepted z-vertex range"};
71+
Configurable<float> cfgCutEta{"cfgCutEta", 0.8f, "Eta range for tracks"};
72+
Filter collisionFilter = nabs(aod::collision::posZ) < cfgCutVertex;
73+
Filter trackFilter = (nabs(aod::track::eta) < cfgCutEta) && (aod::track::isGlobalTrack == (uint8_t) true);
74+
75+
Configurable<float> nsigmacut{"nsigmacut", 3, "Value of the Nsigma cut"};
76+
77+
template <std::size_t i, typename T>
78+
void fillParticleHistos(const T& track, const float nsigma[])
79+
{
80+
if (abs(nsigma[i]) > nsigmacut.value) {
81+
return;
82+
}
83+
histos.fill(HIST(hp[i]), track.p());
84+
histos.fill(HIST(hpt[i]), track.pt());
85+
}
86+
87+
using TrackCandidates = soa::Filtered<soa::Join<aod::Tracks, aod::TracksExtra, aod::pidRespTPC, aod::TrackSelection>>;
88+
void process(TrackCandidates::iterator const& track)
89+
{
90+
const float nsigma[Np] = {track.tpcNSigmaEl(), track.tpcNSigmaMu(), track.tpcNSigmaPi(),
91+
track.tpcNSigmaKa(), track.tpcNSigmaPr(), track.tpcNSigmaDe(),
92+
track.tpcNSigmaTr(), track.tpcNSigmaHe(), track.tpcNSigmaAl()};
93+
histos.fill(HIST("p/Unselected"), track.p());
94+
histos.fill(HIST("pt/Unselected"), track.pt());
95+
96+
fillParticleHistos<0>(track, nsigma);
97+
fillParticleHistos<1>(track, nsigma);
98+
fillParticleHistos<2>(track, nsigma);
99+
fillParticleHistos<3>(track, nsigma);
100+
fillParticleHistos<4>(track, nsigma);
101+
fillParticleHistos<5>(track, nsigma);
102+
fillParticleHistos<6>(track, nsigma);
103+
fillParticleHistos<7>(track, nsigma);
104+
fillParticleHistos<8>(track, nsigma);
105+
}
106+
};
107+
108+
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
109+
{
110+
WorkflowSpec workflow{adaptAnalysisTask<TPCSpectraReferenceTask>("tpcspectra-task-skim-reference")};
111+
return workflow;
112+
}

0 commit comments

Comments
 (0)