Skip to content

Commit acd9966

Browse files
ddobrigkalibuild
andauthored
[Common] add extra legacy data QA and tools (#9143)
Co-authored-by: ALICE Builder <alibuild@users.noreply.github.com>
1 parent feed6ba commit acd9966

File tree

5 files changed

+307
-0
lines changed

5 files changed

+307
-0
lines changed

Common/LegacyDataQA/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,9 @@ o2physics_add_dpl_workflow(otfv0qa
1717
o2physics_add_dpl_workflow(centqa
1818
SOURCES centqa.cxx
1919
PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore
20+
COMPONENT_NAME Analysis)
21+
22+
o2physics_add_dpl_workflow(tpcpidqa
23+
SOURCES tpcpidqa.cxx
24+
PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore
2025
COMPONENT_NAME Analysis)

Common/LegacyDataQA/tpcpidqa.cxx

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
//
12+
// This task converts tiny PID tables into full PID tables.
13+
// It is meant to be used with Run 2 converted data to maintain
14+
// full compatibility with any task that may subscribe to the Full
15+
// tables (at the cost of some memory consumption).
16+
// It is also able to produce very simple QA plots on the stored
17+
// quantities (optionally disabled for simplicity)
18+
//
19+
// Warning: expected resolution is NOT provided.
20+
21+
#include "Framework/runDataProcessing.h"
22+
#include "Framework/AnalysisTask.h"
23+
#include "Framework/AnalysisDataModel.h"
24+
#include "Common/DataModel/PIDResponse.h"
25+
#include "TableHelper.h"
26+
27+
using namespace o2;
28+
using namespace o2::framework;
29+
30+
using tinyPidTracks = soa::Join<aod::Tracks, aod::pidTPCFullEl, aod::pidTPCFullMu, aod::pidTPCFullPi, aod::pidTPCFullKa, aod::pidTPCFullPr, aod::pidTPCFullDe, aod::pidTPCFullTr, aod::pidTPCFullHe, aod::pidTPCFullAl>;
31+
32+
static constexpr int nParameters = 1;
33+
static const std::vector<std::string> tableNames{"Electron", // 0
34+
"Muon", // 1
35+
"Pion", // 2
36+
"Kaon", // 3
37+
"Proton", // 4
38+
"Deuteron", // 5
39+
"Triton", // 6
40+
"Helium", // 7
41+
"Alpha"}; // 8
42+
static const std::vector<std::string> parameterNames{"enable"};
43+
static const int defaultParameters[9][nParameters]{{0}, {0}, {1}, {1}, {1}, {0}, {0}, {0}, {0}};
44+
45+
static constexpr int kPidEl = 0;
46+
static constexpr int kPidMu = 1;
47+
static constexpr int kPidPi = 2;
48+
static constexpr int kPidKa = 3;
49+
static constexpr int kPidPr = 4;
50+
static constexpr int kPidDe = 5;
51+
static constexpr int kPidTr = 6;
52+
static constexpr int kPidHe = 7;
53+
static constexpr int kPidAl = 8;
54+
static constexpr int nTables = 9;
55+
56+
struct TpcPidQa {
57+
Configurable<LabeledArray<int>> enabledTables{"enabledTables",
58+
{defaultParameters[0], nTables, nParameters, tableNames, parameterNames},
59+
"Produce QA for this species: 0 - no, 1 - yes"};
60+
std::vector<int> mEnabledTables; // Vector of enabled tables
61+
62+
HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject};
63+
64+
ConfigurableAxis axisMomentum{"axisMomentum", {VARIABLE_WIDTH, 0.0f, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.0f, 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f, 1.7f, 1.8f, 1.9f, 2.0f, 2.2f, 2.4f, 2.6f, 2.8f, 3.0f, 3.2f, 3.4f, 3.6f, 3.8f, 4.0f, 4.4f, 4.8f, 5.2f, 5.6f, 6.0f, 6.5f, 7.0f, 7.5f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 17.0f, 19.0f, 21.0f, 23.0f, 25.0f, 30.0f, 35.0f, 40.0f, 50.0f}, "momentum"};
65+
66+
ConfigurableAxis axisNSigma{"axisNSigma", {120, -6.0f, 6.0f}, "axisNSigma"};
67+
68+
void init(InitContext&)
69+
{
70+
mEnabledTables.resize(9, 0);
71+
72+
for (int i = 0; i < nTables; i++) {
73+
int f = enabledTables->get(tableNames[i].c_str(), "Enable");
74+
if (f == 1) {
75+
mEnabledTables[i] = 1;
76+
histos.add(fmt::format("hNSigmaVsPTot{}", tableNames[i]).c_str(), "", kTH2F, {axisMomentum, axisNSigma});
77+
}
78+
}
79+
}
80+
81+
void process(tinyPidTracks const& tracks)
82+
{
83+
for (const auto& track : tracks) {
84+
if (mEnabledTables[kPidEl]) {
85+
histos.fill(HIST("hNSigmaVsPTotEl"), track.p(), track.tpcNSigmaEl());
86+
}
87+
if (mEnabledTables[kPidMu]) {
88+
histos.fill(HIST("hNSigmaVsPTotMu"), track.p(), track.tpcNSigmaMu());
89+
}
90+
if (mEnabledTables[kPidPi]) {
91+
histos.fill(HIST("hNSigmaVsPTotPi"), track.p(), track.tpcNSigmaPi());
92+
}
93+
if (mEnabledTables[kPidKa]) {
94+
histos.fill(HIST("hNSigmaVsPTotKa"), track.p(), track.tpcNSigmaKa());
95+
}
96+
if (mEnabledTables[kPidPr]) {
97+
histos.fill(HIST("hNSigmaVsPTotPr"), track.p(), track.tpcNSigmaPr());
98+
}
99+
if (mEnabledTables[kPidDe]) {
100+
histos.fill(HIST("hNSigmaVsPTotDe"), track.p(), track.tpcNSigmaDe());
101+
}
102+
if (mEnabledTables[kPidTr]) {
103+
histos.fill(HIST("hNSigmaVsPTotTr"), track.p(), track.tpcNSigmaTr());
104+
}
105+
if (mEnabledTables[kPidHe]) {
106+
histos.fill(HIST("hNSigmaVsPTotHe"), track.p(), track.tpcNSigmaHe());
107+
}
108+
if (mEnabledTables[kPidAl]) {
109+
histos.fill(HIST("hNSigmaVsPTotAl"), track.p(), track.tpcNSigmaAl());
110+
}
111+
}
112+
}
113+
};
114+
115+
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
116+
{
117+
return WorkflowSpec{
118+
adaptAnalysisTask<TpcPidQa>(cfgc)};
119+
}

Common/TableProducer/Converters/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,7 @@ o2physics_add_dpl_workflow(run2-tracks-extra-converter
104104
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
105105
COMPONENT_NAME Analysis)
106106

107+
o2physics_add_dpl_workflow(run2-tiny-to-full-pid
108+
SOURCES run2TinyToFullPID.cxx
109+
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
110+
COMPONENT_NAME Analysis)
Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
//
12+
// This task converts tiny PID tables into full PID tables.
13+
// It is meant to be used with Run 2 converted data to maintain
14+
// full compatibility with any task that may subscribe to the Full
15+
// tables (at the cost of some memory consumption).
16+
// It is also able to produce very simple QA plots on the stored
17+
// quantities (optionally disabled for simplicity)
18+
//
19+
// Warning: expected resolution is NOT provided.
20+
21+
#include "Framework/runDataProcessing.h"
22+
#include "Framework/AnalysisTask.h"
23+
#include "Framework/AnalysisDataModel.h"
24+
#include "Common/DataModel/PIDResponse.h"
25+
#include "TableHelper.h"
26+
27+
using namespace o2;
28+
using namespace o2::framework;
29+
30+
using tinyPidTracks = soa::Join<aod::Tracks, aod::pidTPCEl, aod::pidTPCMu, aod::pidTPCPi, aod::pidTPCKa, aod::pidTPCPr, aod::pidTPCDe, aod::pidTPCTr, aod::pidTPCHe, aod::pidTPCAl>;
31+
32+
static constexpr int kPidEl = 0;
33+
static constexpr int kPidMu = 1;
34+
static constexpr int kPidPi = 2;
35+
static constexpr int kPidKa = 3;
36+
static constexpr int kPidPr = 4;
37+
static constexpr int kPidDe = 5;
38+
static constexpr int kPidTr = 6;
39+
static constexpr int kPidHe = 7;
40+
static constexpr int kPidAl = 8;
41+
static constexpr int nTables = 9;
42+
43+
static constexpr int nParameters = 1;
44+
static const std::vector<std::string> tableNames{"pidTPCFullEl", // 0
45+
"pidTPCFullMu", // 1
46+
"pidTPCFullPi", // 2
47+
"pidTPCFullKa", // 3
48+
"pidTPCFullPr", // 4
49+
"pidTPCFullDe", // 5
50+
"pidTPCFullTr", // 6
51+
"pidTPCFullHe", // 7
52+
"pidTPCFullAl"}; // 8
53+
static const std::vector<std::string> parameterNames{"enable"};
54+
static const int defaultParameters[nTables][nParameters]{{-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}};
55+
56+
struct Run2TinyToFullPID {
57+
Produces<aod::pidTPCFullEl> pidTPCFullEl;
58+
Produces<aod::pidTPCFullMu> pidTPCFullMu;
59+
Produces<aod::pidTPCFullPi> pidTPCFullPi;
60+
Produces<aod::pidTPCFullKa> pidTPCFullKa;
61+
Produces<aod::pidTPCFullPr> pidTPCFullPr;
62+
Produces<aod::pidTPCFullDe> pidTPCFullDe;
63+
Produces<aod::pidTPCFullTr> pidTPCFullTr;
64+
Produces<aod::pidTPCFullHe> pidTPCFullHe;
65+
Produces<aod::pidTPCFullAl> pidTPCFullAl;
66+
67+
Configurable<LabeledArray<int>> enabledTables{"enabledTables",
68+
{defaultParameters[0], nTables, nParameters, tableNames, parameterNames},
69+
"Produce full PID tables depending on needs. Autodetect is -1, Force no is 0 and force yes is 1."};
70+
71+
std::vector<int> mEnabledTables; // Vector of enabled tables
72+
73+
void init(InitContext& context)
74+
{
75+
for (int i = 0; i < nTables; i++) {
76+
int f = enabledTables->get(tableNames[i].c_str(), "Enable");
77+
enableFlagIfTableRequired(context, tableNames[i], f);
78+
if (f == 1) {
79+
mEnabledTables.push_back(i);
80+
}
81+
}
82+
}
83+
84+
void process(tinyPidTracks const& tracks)
85+
{
86+
// reserve memory
87+
for (auto i : mEnabledTables) {
88+
switch (i) {
89+
case kPidEl:
90+
pidTPCFullEl.reserve(tracks.size());
91+
break;
92+
case kPidMu:
93+
pidTPCFullMu.reserve(tracks.size());
94+
break;
95+
case kPidPi:
96+
pidTPCFullPi.reserve(tracks.size());
97+
break;
98+
case kPidKa:
99+
pidTPCFullKa.reserve(tracks.size());
100+
break;
101+
case kPidPr:
102+
pidTPCFullPr.reserve(tracks.size());
103+
break;
104+
case kPidDe:
105+
pidTPCFullDe.reserve(tracks.size());
106+
break;
107+
case kPidTr:
108+
pidTPCFullTr.reserve(tracks.size());
109+
break;
110+
case kPidHe:
111+
pidTPCFullHe.reserve(tracks.size());
112+
break;
113+
case kPidAl:
114+
pidTPCFullAl.reserve(tracks.size());
115+
break;
116+
default:
117+
LOG(fatal) << "Unknown table requested: " << i;
118+
break;
119+
}
120+
}
121+
122+
for (const auto& track : tracks) {
123+
for (auto i : mEnabledTables) {
124+
switch (i) {
125+
case kPidEl:
126+
pidTPCFullEl(0.0f, track.tpcNSigmaEl());
127+
break;
128+
case kPidMu:
129+
pidTPCFullMu(0.0f, track.tpcNSigmaMu());
130+
break;
131+
case kPidPi:
132+
pidTPCFullPi(0.0f, track.tpcNSigmaPi());
133+
break;
134+
case kPidKa:
135+
pidTPCFullKa(0.0f, track.tpcNSigmaKa());
136+
break;
137+
case kPidPr:
138+
pidTPCFullPr(0.0f, track.tpcNSigmaPr());
139+
break;
140+
case kPidDe:
141+
pidTPCFullDe(0.0f, track.tpcNSigmaDe());
142+
break;
143+
case kPidTr:
144+
pidTPCFullTr(0.0f, track.tpcNSigmaTr());
145+
break;
146+
case kPidHe:
147+
pidTPCFullHe(0.0f, track.tpcNSigmaHe());
148+
break;
149+
case kPidAl:
150+
pidTPCFullAl(0.0f, track.tpcNSigmaAl());
151+
break;
152+
default:
153+
LOG(fatal) << "Unknown table requested: " << i;
154+
break;
155+
}
156+
}
157+
}
158+
}
159+
};
160+
161+
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
162+
{
163+
return WorkflowSpec{
164+
adaptAnalysisTask<Run2TinyToFullPID>(cfgc)};
165+
}

Common/TableProducer/multiplicityTable.cxx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ struct MultiplicityTable {
134134
TProfile* hVtxZFT0A;
135135
TProfile* hVtxZFT0C;
136136
TProfile* hVtxZFDDA;
137+
137138
TProfile* hVtxZFDDC;
138139
TProfile* hVtxZNTracks;
139140
std::vector<int> mEnabledTables; // Vector of enabled tables
@@ -160,6 +161,19 @@ struct MultiplicityTable {
160161
if (doprocessRun2 == true && doprocessRun3 == true) {
161162
LOGF(fatal, "Cannot enable processRun2 and processRun3 at the same time. Please choose one.");
162163
}
164+
165+
// exploratory
166+
auto& workflows = context.services().get<o2::framework::RunningWorkflowInfo const>();
167+
for (auto const& device : workflows.devices) {
168+
for (auto const& input : device.inputs) {
169+
// input.print();
170+
TString devNam = device.name.c_str();
171+
TString inBin = input.matcher.binding.c_str();
172+
// TString subSpec = input.matcher.subspec.c_str();
173+
LOGF(info, Form("device %s input binding %s subspec", devNam.Data(), inBin.Data()));
174+
}
175+
}
176+
163177
bool tEnabled[nTables] = {false};
164178
for (int i = 0; i < nTables; i++) {
165179
int f = enabledTables->get(tableNames[i].c_str(), "Enable");

0 commit comments

Comments
 (0)