forked from AliceO2Group/O2Physics
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTrackSelection.h
More file actions
265 lines (240 loc) · 7 KB
/
Copy pathTrackSelection.h
File metadata and controls
265 lines (240 loc) · 7 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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
// 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 TrackSelection.h
/// \brief helper functions for pair track selection
/// \author felix.schlepper@cern.ch
#ifndef PWGEM_PHOTONMESON_UTILS_TRACKSELECTION_H_
#define PWGEM_PHOTONMESON_UTILS_TRACKSELECTION_H_
#include <TPDGCode.h>
#include <cmath>
#include <concepts>
#include <cstdint>
template <typename T>
concept is_iterator = requires(T t) {
typename std::decay_t<T>::policy_t;
typename std::decay_t<T>::all_columns;
t.getIndexBindings();
};
template <typename T>
concept is_sentinel = requires(T t) {
requires(std::same_as<decltype(t.index), int64_t const>);
};
template <typename T>
concept is_track_with_extra = requires(T t) {
{ t.hasITS() } -> std::same_as<bool>;
{ t.hasTPC() } -> std::same_as<bool>;
};
template <typename T>
concept is_mc_particle = requires(T t) {
{ t.pdgCode() } -> std::same_as<const int&>;
};
namespace o2::pwgem::photonmeson
{
/**
* @brief Track has ITS and TPC
*
* @tparam TTrack track
* @param track track
* @return true if has both
*/
template <is_track_with_extra TTrack>
inline bool isITSTPCTrack(TTrack const& track)
{
return track.hasITS() && track.hasTPC();
}
/**
* @brief Track has TPC and TRD
*
* @tparam TTrack track
* @param track track
* @return true if has both
*/
template <is_track_with_extra TTrack>
inline bool isTPCTRDTrack(TTrack const& track)
{
return !track.hasITS() && track.hasTPC() && track.hasTRD() && !track.hasTOF();
}
/**
* @brief Track has ITS,TPC and TRD
*
* @tparam TTrack track
* @param track track
* @return true if has all
*/
template <is_track_with_extra TTrack>
inline bool isITSTPCTRDTrack(TTrack const& track)
{
return track.hasITS() && track.hasTPC() && track.hasTRD() && !track.hasTOF();
}
/**
* @brief Track has TPC and TOF
* @tparam TTrack track
* @param track track
* @return true if has both
*/
template <is_track_with_extra TTrack>
inline bool isTPCTOFTrack(TTrack const& track)
{
return !track.hasITS() && track.hasTPC() && !track.hasTRD() && track.hasTOF();
}
/**
* @brief Track has TPC,TRD and TOF
* @tparam TTrack track
* @param track track
* @return true if has all
*/
template <is_track_with_extra TTrack>
inline bool isTPCTRDTOFTrack(TTrack const& track)
{
return !track.hasITS() && track.hasTPC() && track.hasTRD() && track.hasTOF();
}
/**
* @brief Track has ITS,TPC,TRD and TOF
* @tparam TTrack track
* @param track track
* @return true if has all
*/
template <is_track_with_extra TTrack>
inline bool isITSTPCTRDTOFTrack(TTrack const& track)
{
return track.hasITS() && track.hasTPC() && track.hasTRD() && track.hasTOF();
}
/**
* @brief Track is TPC-only
*
* @tparam TTrack track
* @param track track
* @return true if tracks is TPC-only
*/
template <is_track_with_extra TTrack>
inline bool isTPConlyTrack(TTrack const& track)
{
return !track.hasITS() && track.hasTPC() && !track.hasTRD() && !track.hasTOF();
}
/**
* @brief Track is ITS-only
*
* @tparam TTrack track
* @param track track
* @return true if tracks is ITS-only
*/
template <is_track_with_extra TTrack>
inline bool isITSonlyTrack(TTrack const& track)
{
return track.hasITS() && !track.hasTPC() && !track.hasTRD() && !track.hasTOF();
}
/**
* @brief If both V0 pairs are ITSTPC-tracks
*
* @tparam TTrack track
* @param track0 track from daughter 0
* @param track1 track from daughter 1
* @return true if V0 pairs are ITSTPC-tracks
*/
template <is_track_with_extra TTrack>
inline bool isITSTPC_ITSTPC(TTrack const& track0, TTrack const& track1)
{
return isITSTPCTrack(track0) && isITSTPCTrack(track1);
}
/**
* @brief If one track is TPC-only the other ITSTPC
*
* @tparam TTrack track
* @param track0 track from daughter 0
* @param track1 track from daughter 1
* @return true if one is TPC-only and the other ITSTPC
*/
template <is_track_with_extra TTrack>
inline bool isITSTPC_TPConly(TTrack const& track0, TTrack const& track1)
{
return (isITSTPCTrack(track0) && isTPConlyTrack(track1)) || (isITSTPCTrack(track1) && isTPConlyTrack(track0));
}
/**
* @brief If one track is ITS-only the other ITSTPC
*
* @tparam TTrack track
* @param track0 track from daughter 0
* @param track1 track from daughter 1
* @return true if one is ITS-only and the other ITSTPC
*/
template <is_track_with_extra TTrack>
inline bool isITSTPC_ITSonly(TTrack const& track0, TTrack const& track1)
{
return (isITSTPCTrack(track0) && isITSonlyTrack(track1)) || (isITSTPCTrack(track1) && isITSonlyTrack(track0));
}
/**
* @brief If V0 pairs are TPC-only tracks
*
* @tparam TTrack track
* @param track0 track from daughter 0
* @param track1 track from daughter 1
* @return true if both are TPC-only tracks
*/
template <is_track_with_extra TTrack>
inline bool isTPConly_TPConly(TTrack const& track0, TTrack const& track1)
{
return isTPConlyTrack(track0) && isTPConlyTrack(track1);
}
/**
* @brief If V0 pairs are ITS-only tracks
*
* @tparam TTrack track
* @param track0 track from daughter 0
* @param track1 track from daughter 1
* @return true if both are ITS-only tracks
*/
template <is_track_with_extra TTrack>
inline bool isITSonly_ITSonly(TTrack const& track0, TTrack const& track1)
{
return isITSonlyTrack(track0) && isITSonlyTrack(track1);
}
/**
* @brief If one V0 pair is ITS-only and the other TPC-only
*
* @tparam TTrack track
* @param track0 track from daughter 0
* @param track1 track from daughter 1
* @return true if either one is ITS-only while the other one is TPC-only
*/
template <is_track_with_extra TTrack>
inline bool isTPConly_ITSonly(TTrack const& track0, TTrack const& track1)
{
return (isTPConlyTrack(track0) && isITSonlyTrack(track1)) || (isTPConlyTrack(track1) && isITSonlyTrack(track0));
}
/**
* @brief Check if MC particles have the expected&same mother particle
*
* @param mc1 MCParticle 0
* @param mc2 MCParticle 1
* @return true if the mother particle is the expected type and the same for both
*/
template <PDG_t motherType, is_mc_particle T>
inline bool checkMCParticles(T const& mc1, T const& mc2)
{
if (std::abs(mc1.pdgCode()) != kElectron || std::abs(mc2.pdgCode()) != kElectron) {
return false;
}
if (!mc1.has_mothers() || !mc2.has_mothers()) {
return false;
}
if (mc1.mothersIds()[0] != mc2.mothersIds()[0]) {
return false;
}
if (const auto& mothers = mc1.template mothers_as<typename T::parent_t>(); mothers.empty() || mothers.size() > 1) {
return false;
}
if (mc1.template mothers_first_as<typename T::parent_t>().pdgCode() != motherType) {
return false;
}
return true;
}
} // namespace o2::pwgem::photonmeson
#endif // PWGEM_PHOTONMESON_UTILS_TRACKSELECTION_H_