-
Notifications
You must be signed in to change notification settings - Fork 499
Expand file tree
/
Copy pathpidTOFqa.cxx
More file actions
207 lines (192 loc) · 9.82 KB
/
pidTOFqa.cxx
File metadata and controls
207 lines (192 loc) · 9.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
// 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 <CCDB/BasicCCDBManager.h>
#include "AnalysisDataModel/PID/PIDResponse.h"
#include "AnalysisDataModel/PID/PIDTOF.h"
#include "AnalysisCore/MC.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<o2::framework::ConfigParamSpec>& workflowOptions)
{
std::vector<ConfigParamSpec> options{
{"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, 0, {"Produce PID information for the Deuteron, Triton, Alpha mass hypothesis"}}};
std::swap(workflowOptions, options);
}
#include "Framework/runDataProcessing.h"
template <o2::track::PID::ID pid_type>
struct pidTOFTaskQA {
static constexpr int Np = 9;
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"};
static constexpr std::string_view hnsigmaprm[Np] = {"nsigmaprm/El", "nsigmaprm/Mu", "nsigmaprm/Pi",
"nsigmaprm/Ka", "nsigmaprm/Pr", "nsigmaprm/De",
"nsigmaprm/Tr", "nsigmaprm/He", "nsigmaprm/Al"};
static constexpr std::string_view hnsigmasec[Np] = {"nsigmasec/El", "nsigmasec/Mu", "nsigmasec/Pi",
"nsigmasec/Ka", "nsigmasec/Pr", "nsigmasec/De",
"nsigmasec/Tr", "nsigmasec/He", "nsigmasec/Al"};
static constexpr std::string_view hnsigmaMC[Np] = {"nsigmaMC/El", "nsigmaMC/Mu", "nsigmaMC/Pi",
"nsigmaMC/Ka", "nsigmaMC/Pr", "nsigmaMC/De",
"nsigmaMC/Tr", "nsigmaMC/He", "nsigmaMC/Al"};
static constexpr std::string_view hnsigmaMCsec[Np] = {"nsigmaMCsec/El", "nsigmaMCsec/Mu", "nsigmaMCsec/Pi",
"nsigmaMCsec/Ka", "nsigmaMCsec/Pr", "nsigmaMCsec/De",
"nsigmaMCsec/Tr", "nsigmaMCsec/He", "nsigmaMCsec/Al"};
static constexpr std::string_view hnsigmaMCprm[Np] = {"nsigmaMCprm/El", "nsigmaMCprm/Mu", "nsigmaMCprm/Pi",
"nsigmaMCprm/Ka", "nsigmaMCprm/Pr", "nsigmaMCprm/De",
"nsigmaMCprm/Tr", "nsigmaMCprm/He", "nsigmaMCprm/Al"};
static constexpr const char* pT[Np] = {"e", "#mu", "#pi", "K", "p", "d", "t", "^{3}He", "#alpha"};
static constexpr int PDGs[Np] = {11, 13, 211, 321, 2212, 1, 1, 1, 1};
HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::QAObject};
Configurable<int> nBinsP{"nBinsP", 400, "Number of bins for the momentum"};
Configurable<float> MinP{"MinP", 0.1, "Minimum momentum in range"};
Configurable<float> MaxP{"MaxP", 5, "Maximum momentum in range"};
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);
}
template <uint8_t i>
void addParticleHistos()
{
// NSigma
histos.add(hnsigmaMC[i].data(), Form("True %s;#it{p}_{T} (GeV/#it{c});N_{#sigma}^{TOF}(%s)", pT[i], pT[pid_type]), HistType::kTH2F, {{nBinsP, MinP, MaxP}, {2000, -30, 30}});
makelogaxis(histos.get<TH2>(HIST(hnsigmaMC[i])));
histos.add(hnsigmaMCprm[i].data(), Form("True Primary %s;#it{p}_{T} (GeV/#it{c});N_{#sigma}^{TOF}(%s)", pT[i], pT[pid_type]), HistType::kTH2F, {{nBinsP, MinP, MaxP}, {2000, -30, 30}});
makelogaxis(histos.get<TH2>(HIST(hnsigmaMCprm[i])));
histos.add(hnsigmaMCsec[i].data(), Form("True Secondary %s;#it{p}_{T} (GeV/#it{c});N_{#sigma}^{TOF}(%s)", pT[i], pT[pid_type]), HistType::kTH2F, {{nBinsP, MinP, MaxP}, {2000, -30, 30}});
makelogaxis(histos.get<TH2>(HIST(hnsigmaMCsec[i])));
}
void init(o2::framework::InitContext&)
{
histos.add(hnsigma[pid_type].data(), Form(";#it{p}_{T} (GeV/#it{c});N_{#sigma}^{TOF}(%s)", pT[pid_type]), HistType::kTH2F, {{nBinsP, MinP, MaxP}, {2000, -30, 30}});
makelogaxis(histos.get<TH2>(HIST(hnsigma[pid_type])));
histos.add(hnsigmaprm[pid_type].data(), Form("Primary;#it{p}_{T} (GeV/#it{c});N_{#sigma}^{TOF}(%s)", pT[pid_type]), HistType::kTH2F, {{nBinsP, MinP, MaxP}, {2000, -30, 30}});
makelogaxis(histos.get<TH2>(HIST(hnsigmaprm[pid_type])));
histos.add(hnsigmasec[pid_type].data(), Form("Secondary;#it{p}_{T} (GeV/#it{c});N_{#sigma}^{TOF}(%s)", pT[pid_type]), HistType::kTH2F, {{nBinsP, MinP, MaxP}, {2000, -30, 30}});
makelogaxis(histos.get<TH2>(HIST(hnsigmasec[pid_type])));
addParticleHistos<0>();
addParticleHistos<1>();
addParticleHistos<2>();
addParticleHistos<3>();
addParticleHistos<4>();
addParticleHistos<5>();
addParticleHistos<6>();
addParticleHistos<7>();
addParticleHistos<8>();
}
template <uint8_t pidIndex, typename T, typename TT>
void fillNsigma(const T& track, const TT& mcParticles, const float& nsigma)
{
if (abs(track.mcParticle().pdgCode()) == PDGs[pidIndex]) {
histos.fill(HIST(hnsigmaMC[pidIndex]), track.pt(), nsigma);
if (MC::isPhysicalPrimary(mcParticles, track.mcParticle())) { // Selecting primaries
histos.fill(HIST(hnsigmaMCprm[pidIndex]), track.pt(), nsigma);
} else {
histos.fill(HIST(hnsigmaMCsec[pidIndex]), track.pt(), nsigma);
}
}
}
void process(aod::Collision const& collision,
soa::Join<aod::Tracks, aod::TracksExtra, aod::pidRespTOF, aod::McTrackLabels> const& tracks,
aod::McParticles& mcParticles)
{
const float collisionTime_ps = collision.collisionTime() * 1000.f;
for (auto t : tracks) {
//
if (t.tofSignal() < 0) { // Skipping tracks without TOF
continue;
}
float nsigma = -999.f;
if constexpr (pid_type == 0) {
nsigma = t.tofNSigmaEl();
} else if constexpr (pid_type == 1) {
nsigma = t.tofNSigmaMu();
} else if constexpr (pid_type == 2) {
nsigma = t.tofNSigmaPi();
} else if constexpr (pid_type == 3) {
nsigma = t.tofNSigmaKa();
} else if constexpr (pid_type == 4) {
nsigma = t.tofNSigmaPr();
} else if constexpr (pid_type == 5) {
nsigma = t.tofNSigmaDe();
} else if constexpr (pid_type == 6) {
nsigma = t.tofNSigmaTr();
} else if constexpr (pid_type == 7) {
nsigma = t.tofNSigmaHe();
} else if constexpr (pid_type == 8) {
nsigma = t.tofNSigmaAl();
}
// Fill for all
histos.fill(HIST(hnsigma[pid_type]), t.pt(), nsigma);
if (MC::isPhysicalPrimary(mcParticles, t.mcParticle())) { // Selecting primaries
histos.fill(HIST(hnsigmaprm[pid_type]), t.pt(), nsigma);
} else {
histos.fill(HIST(hnsigmasec[pid_type]), t.pt(), nsigma);
}
// Fill with PDG codes
fillNsigma<0>(t, mcParticles, nsigma);
fillNsigma<1>(t, mcParticles, nsigma);
fillNsigma<2>(t, mcParticles, nsigma);
fillNsigma<3>(t, mcParticles, nsigma);
fillNsigma<4>(t, mcParticles, nsigma);
fillNsigma<5>(t, mcParticles, nsigma);
fillNsigma<6>(t, mcParticles, nsigma);
fillNsigma<7>(t, mcParticles, nsigma);
fillNsigma<8>(t, mcParticles, nsigma);
}
}
};
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
{
auto workflow = WorkflowSpec{};
if (cfgc.options().get<int>("pid-el")) {
workflow.push_back(adaptAnalysisTask<pidTOFTaskQA<PID::Electron>>(cfgc, TaskName{"pidTOF-qa-El"}));
}
if (cfgc.options().get<int>("pid-mu")) {
workflow.push_back(adaptAnalysisTask<pidTOFTaskQA<PID::Muon>>(cfgc, TaskName{"pidTOF-qa-Mu"}));
}
if (cfgc.options().get<int>("pid-pikapr")) {
workflow.push_back(adaptAnalysisTask<pidTOFTaskQA<PID::Pion>>(cfgc, TaskName{"pidTOF-qa-Pi"}));
workflow.push_back(adaptAnalysisTask<pidTOFTaskQA<PID::Kaon>>(cfgc, TaskName{"pidTOF-qa-Ka"}));
workflow.push_back(adaptAnalysisTask<pidTOFTaskQA<PID::Proton>>(cfgc, TaskName{"pidTOF-qa-Pr"}));
}
if (cfgc.options().get<int>("pid-nuclei")) {
workflow.push_back(adaptAnalysisTask<pidTOFTaskQA<PID::Deuteron>>(cfgc, TaskName{"pidTOF-qa-De"}));
workflow.push_back(adaptAnalysisTask<pidTOFTaskQA<PID::Triton>>(cfgc, TaskName{"pidTOF-qa-Tr"}));
workflow.push_back(adaptAnalysisTask<pidTOFTaskQA<PID::Helium3>>(cfgc, TaskName{"pidTOF-qa-He"}));
workflow.push_back(adaptAnalysisTask<pidTOFTaskQA<PID::Alpha>>(cfgc, TaskName{"pidTOF-qa-Al"}));
}
return workflow;
}