23 static constexpr
double inf = std::numeric_limits<double>::infinity();
142 const std::function<
void(
Config&)>& callback = {});
181 template <
typename input_tracks_t,
typename output_tracks_t>
189 template <
typename track_proxy_t>
232 if (absEtaMin != 0.0 || absEtaMax !=
inf) {
233 throw std::invalid_argument(
234 "Cannot set both eta and absEta cuts in the same cut set");
243 if (etaMin != -
inf || etaMax !=
inf) {
244 throw std::invalid_argument(
245 "Cannot set both eta and absEta cuts in the same cut set");
261 auto print = [&](
const char*
name,
const auto&
min,
const auto& max) {
262 os <<
" - " << min <<
" <= " << name <<
" < " << max <<
"\n";
278 double etaMax,
const std::function<
void(
Config&)>& callback) {
279 if (etaMax <= absEtaEdges.back()) {
280 throw std::invalid_argument{
281 "Abs Eta bin edges must be in increasing order"};
285 throw std::invalid_argument{
"Abs Eta bin edges must be positive"};
288 absEtaEdges.push_back(etaMax);
289 cutSets.emplace_back();
291 callback(cutSets.back());
297 const std::function<
void(
Config&)>& callback) {
298 return addCuts(
inf, callback);
302 if (std::abs(eta) >= absEtaEdges.back()) {
303 throw std::invalid_argument{
"Eta is outside the abs eta bin edges"};
307 std::upper_bound(absEtaEdges.begin(), absEtaEdges.end(), std::abs(eta));
314 return nEtaBins() == 1 ? cutSets[0] : cutSets[binIndex(eta)];
319 os <<
"TrackSelector::EtaBinnedConfig:\n";
329 template <
typename input_tracks_t,
typename output_tracks_t>
332 for (
auto track : inputTracks) {
336 auto destProxy = outputTracks.getTrack(outputTracks.addTrack());
337 destProxy.copyFrom(track,
false);
338 destProxy.tipIndex() = track.tipIndex();
342 template <
typename track_proxy_t>
344 auto checkMin = [](
auto x,
auto min) {
return min <=
x; };
345 auto within = [](
double x,
double min,
double max) {
346 return (min <= x) and (x < max);
349 const auto theta = track.theta();
351 constexpr
double kUnset = -std::numeric_limits<double>::infinity();
353 double _eta = kUnset;
354 double _absEta = kUnset;
357 if (_absEta == kUnset) {
358 _eta = -std::log(std::tan(
theta / 2));
359 _absEta = std::abs(_eta);
364 const Config* cutsPtr{
nullptr};
377 return within(track.transverseMomentum(), cuts.
ptMin, cuts.
ptMax) and
391 throw std::invalid_argument{
392 "TrackSelector cut / eta bin configuration is inconsistent"};
397 static const std::vector<double> infVec = {0,
inf};
405 throw std::invalid_argument{
406 "Explicit eta cuts are only valid for single eta bin"};