void vo003_LogicalOperations()
{
std::cout <<
v1 <<
" > " <<
v2 <<
" = " << v1_gr_v2 << std::endl;
auto v1_noteq_v2 =
v1 !=
v2;
std::cout <<
v1 <<
" != " <<
v2 <<
" = " << v1_noteq_v2 << std::endl;
auto all_true =
v1 > .5 *
v2;
std::cout << std::boolalpha;
std::cout <<
"All( " <<
v1 <<
" > .5 * " <<
v2 <<
" ) = " <<
All(all_true) << std::endl;
std::cout <<
"Any( " <<
v1 <<
" > " <<
v2 <<
" ) = " <<
Any(v1_noteq_v2) << std::endl;
auto v_filtered =
v[
v > 3.];
std::cout <<
"v = " <<
v <<
". v[ v > 3. ] = " << v_filtered << std::endl;
auto good_mu_pt = mu_pt[mu_pt > 10 &&
abs(mu_eta) < 2.1];
std::cout << "mu_pt = " << mu_pt << " mu_pt[ mu_pt > 10 && abs(mu_eta) < 2.1] = " << good_mu_pt << std::endl;
auto masked_mu_pt =
Where(
abs(mu_eta) < 2., mu_pt, -999.);
std::cout << "mu_pt if abs(mu_eta) < 2 else -999 = " << masked_mu_pt << std::endl;
}
RVec< PromoteType< T > > abs(const RVec< T > &v)
RVec< T > Where(const RVec< int > &c, const RVec< T > &v1, const RVec< T > &v2)
Return the elements of v1 if the condition c is true and v2 if the condition c is false.
auto Any(const RVec< T > &v) -> decltype(v[0]==true)
Return true if any of the elements equates to true, return false otherwise.
constexpr bool All(const bool *vals, std::size_t size)
{ 1, 2, 3 } > { 3, 2, 1 } = { 0, 0, 1 }
{ 1, 2, 3 } != { 3, 2, 1 } = { 1, 0, 1 }
All( { 1, 2, 3 } > .5 * { 3, 2, 1 } ) = false
Any( { 1, 2, 3 } > { 3, 2, 1 } ) = true
v = { 1, 2, 3, 4, 5 }. v[ v > 3. ] = { 4, 5 }
mu_pt = { 15, 12, 10.6, 2.3, 4, 3 } mu_pt[ mu_pt > 10 && abs(mu_eta) < 2.1] = { 15, 12 }
mu_pt if abs(mu_eta) < 2 else -999 = { 15, 12, -999, -999, 4, -999 }