Skip to content

Commit 43ee265

Browse files
committed
Automatically detect centrality estimator
1 parent 4d7e818 commit 43ee265

2 files changed

Lines changed: 178 additions & 162 deletions

File tree

PWGHF/Core/CentralityEstimation.h

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,86 @@ enum CentralityEstimator {
2828
NTracksPV,
2929
NCentralityEstimators
3030
};
31+
32+
template <typename T>
33+
concept hasFT0ACent = requires(T collision) {
34+
collision.centFT0A();
35+
};
36+
37+
template <typename T>
38+
concept hasFT0CCent = requires(T collision) {
39+
collision.centFT0C();
40+
};
41+
42+
template <typename T>
43+
concept hasFT0MCent = requires(T collision) {
44+
collision.centFT0M();
45+
};
46+
47+
template <typename T>
48+
concept hasFV0ACent = requires(T collision) {
49+
collision.centFV0A();
50+
};
51+
52+
template <typename T>
53+
concept hasNTracksPVCent = requires(T collision) {
54+
collision.centNTPV();
55+
};
56+
57+
/// Evaluate centrality/multiplicity percentile using FT0A estimator
58+
/// \param candidate is candidate
59+
/// \return centrality/multiplicity percentile of the collision
60+
template <hasFT0ACent Coll>
61+
float getCentralityColl(const Coll& collision)
62+
{
63+
return collision.centFT0A();
64+
}
65+
66+
/// Evaluate centrality/multiplicity percentile using FT0C estimator
67+
/// \param candidate is candidate
68+
/// \return centrality/multiplicity percentile of the collision
69+
template <hasFT0CCent Coll>
70+
float getCentralityColl(const Coll& collision)
71+
{
72+
return collision.centFT0C();
73+
}
74+
75+
/// Evaluate centrality/multiplicity percentile using FT0M estimator
76+
/// \param candidate is candidate
77+
/// \return centrality/multiplicity percentile of the collision
78+
template <hasFT0MCent Coll>
79+
float getCentralityColl(const Coll& collision)
80+
{
81+
return collision.centFT0M();
82+
}
83+
84+
/// Evaluate centrality/multiplicity percentile using FV0A estimator
85+
/// \param candidate is candidate
86+
/// \return centrality/multiplicity percentile of the collision
87+
template <hasFV0ACent Coll>
88+
float getCentralityColl(const Coll& collision)
89+
{
90+
return collision.centFV0A();
91+
}
92+
93+
/// Evaluate centrality/multiplicity percentile using NTracksPV estimator
94+
/// \param candidate is candidate
95+
/// \return centrality/multiplicity percentile of the collision
96+
template <hasNTracksPVCent Coll>
97+
float getCentralityColl(const Coll& collision)
98+
{
99+
return collision.centNTPV();
100+
}
101+
102+
/// Default case if no centrality/multiplicity estimator is provided
103+
/// \param candidate is candidate
104+
/// \return dummy value for centrality/multiplicity percentile of the collision
105+
template <typename Coll>
106+
float getCentralityColl(const Coll&)
107+
{
108+
return 105.0f;
109+
}
110+
31111
} // namespace o2::hf_centrality
32112

33113
#endif // PWGHF_CORE_CENTRALITYESTIMATION_H_

0 commit comments

Comments
 (0)