Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:12:13

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 
0011 #include "ActsFatras/EventData/Particle.hpp"
0012 #include "ActsFatras/Selectors/detail/combine_selectors.hpp"
0013 
0014 #include <functional>
0015 #include <limits>
0016 
0017 namespace ActsFatras {
0018 
0019 /// Select all objects with an extracted value equal or larger than the cut.
0020 template <typename cast_t>
0021 struct Min {
0022   double valMin = 0.;
0023 
0024   template <typename T>
0025   bool operator()(const T &thing) const {
0026     return (valMin <= cast_t()(thing));
0027   }
0028 };
0029 
0030 /// Select all objects with an extracted value below the cut.
0031 template <typename cast_t>
0032 struct Max {
0033   double valMax = std::numeric_limits<double>::max();
0034 
0035   template <typename T>
0036   bool operator()(const T &thing) const {
0037     return (cast_t()(thing) < valMax);
0038   }
0039 };
0040 
0041 /// Select all objects with an extracted value within the range.
0042 ///
0043 /// The range is defined as the left, half-open interval within the cuts.
0044 template <typename cast_t>
0045 struct Range {
0046   double valMin = std::numeric_limits<double>::lowest();
0047   double valMax = std::numeric_limits<double>::max();
0048 
0049   template <typename T>
0050   bool operator()(const T &thing) const {
0051     const auto val = cast_t()(thing);
0052     return ((valMin <= val) && (val < valMax));
0053   }
0054 };
0055 
0056 /// Select objects that fulfill all selectors.
0057 template <typename... selectors_t>
0058 using CombineAnd =
0059     detail::CombineSelectors<true, std::logical_and<bool>, selectors_t...>;
0060 
0061 /// Select objects that fulfill at least one selector.
0062 template <typename... selectors_t>
0063 using CombineOr =
0064     detail::CombineSelectors<false, std::logical_or<bool>, selectors_t...>;
0065 
0066 }  // namespace ActsFatras