forked from AliceO2Group/O2Physics
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCentralityEstimation.h
More file actions
191 lines (171 loc) · 5.52 KB
/
CentralityEstimation.h
File metadata and controls
191 lines (171 loc) · 5.52 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
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// 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.
/// \file CentralityEstimation.h
/// \brief Definitions of centrality estimators
/// \author Vít Kučera <vit.kucera@cern.ch>, Inha University
#ifndef PWGHF_CORE_CENTRALITYESTIMATION_H_
#define PWGHF_CORE_CENTRALITYESTIMATION_H_
#include <fairlogger/Logger.h>
namespace o2::hf_centrality
{
// centrality selection estimators
enum CentralityEstimator {
None = 0,
FT0A,
FT0C,
FT0M,
FV0A,
NTracksPV,
NCentralityEstimators
};
template <typename T>
concept hasFT0ACent = requires(T collision) {
collision.centFT0A();
};
template <typename T>
concept hasFT0CCent = requires(T collision) {
collision.centFT0C();
};
template <typename T>
concept hasFT0MCent = requires(T collision) {
collision.centFT0M();
};
template <typename T>
concept hasFV0ACent = requires(T collision) {
collision.centFV0A();
};
template <typename T>
concept hasNTracksPVCent = requires(T collision) {
collision.centNTPV();
};
/// Evaluate centrality/multiplicity percentile using FT0A estimator
/// \param candidate is candidate
/// \return centrality/multiplicity percentile of the collision
template <hasFT0ACent Coll>
float getCentralityColl(const Coll& collision)
{
return collision.centFT0A();
}
/// Evaluate centrality/multiplicity percentile using FT0C estimator
/// \param candidate is candidate
/// \return centrality/multiplicity percentile of the collision
template <hasFT0CCent Coll>
float getCentralityColl(const Coll& collision)
{
return collision.centFT0C();
}
/// Evaluate centrality/multiplicity percentile using FT0M estimator
/// \param candidate is candidate
/// \return centrality/multiplicity percentile of the collision
template <hasFT0MCent Coll>
float getCentralityColl(const Coll& collision)
{
return collision.centFT0M();
}
/// Evaluate centrality/multiplicity percentile using FV0A estimator
/// \param candidate is candidate
/// \return centrality/multiplicity percentile of the collision
template <hasFV0ACent Coll>
float getCentralityColl(const Coll& collision)
{
return collision.centFV0A();
}
/// Evaluate centrality/multiplicity percentile using NTracksPV estimator
/// \param candidate is candidate
/// \return centrality/multiplicity percentile of the collision
template <hasNTracksPVCent Coll>
float getCentralityColl(const Coll& collision)
{
return collision.centNTPV();
}
/// Default case if no centrality/multiplicity estimator is provided
/// \param candidate is candidate
/// \return dummy value for centrality/multiplicity percentile of the collision
template <typename Coll>
float getCentralityColl(const Coll&)
{
return 105.0f;
}
/// Get the centrality
/// \param collision is the collision with the centrality information
/// \param centEstimator integer to select the centrality estimator
/// \return collision centrality
template <typename Coll>
float getCentralityColl(const Coll& collision, int centEstimator)
{
switch (centEstimator) {
case CentralityEstimator::FT0A:
if constexpr (hasFT0ACent<Coll>) {
return collision.centFT0A();
}
LOG(fatal) << "Collision does not have centFT0A().";
break;
case CentralityEstimator::FT0C:
if constexpr (hasFT0CCent<Coll>) {
return collision.centFT0C();
}
LOG(fatal) << "Collision does not have centFT0C().";
break;
case CentralityEstimator::FT0M:
if constexpr (hasFT0MCent<Coll>) {
return collision.centFT0M();
}
LOG(fatal) << "Collision does not have centFT0M().";
break;
case CentralityEstimator::FV0A:
if constexpr (hasFV0ACent<Coll>) {
return collision.centFV0A();
}
LOG(fatal) << "Collision does not have centFV0A().";
break;
default:
LOG(fatal) << "Centrality estimator not valid. Possible values are V0A, T0M, T0A, T0C.";
break;
}
return -999.f;
}
/// \brief Function to get MC collision centrality
/// \param collSlice collection of reconstructed collisions associated to a generated one
/// \return generated MC collision centrality
template <typename CCs>
float getCentralityGenColl(CCs const& collSlice)
{
float centrality{-1};
float multiplicity{0.f};
for (const auto& collision : collSlice) {
float collMult = collision.numContrib();
if (collMult > multiplicity) {
centrality = getCentralityColl(collision);
multiplicity = collMult;
}
}
return centrality;
}
/// \brief Function to get MC collision centrality
/// \param collSlice collection of reconstructed collisions associated to a generated one
/// \param centEstimator integer to select the centrality estimator
/// \return generated MC collision centrality
template <typename CCs>
float getCentralityGenColl(CCs const& collSlice, int centEstimator)
{
float centrality{-1};
float multiplicity{0.f};
for (const auto& collision : collSlice) {
float collMult = collision.numContrib();
if (collMult > multiplicity) {
centrality = getCentralityColl(collision, centEstimator);
multiplicity = collMult;
}
}
return centrality;
}
} // namespace o2::hf_centrality
#endif // PWGHF_CORE_CENTRALITYESTIMATION_H_