14void vo006_IndexManipulation()
21 for (
size_t i = 0; i < muon_pt.
size(); i++) {
22 std::cout <<
"Muon " << i + 1 <<
" (pt, eta): " << muon_pt[i] <<
", "
23 << muon_eta[i] << std::endl;
27 auto idx_select =
Nonzero(muon_pt > 15 && abs(muon_eta) < 2.5);
36 auto idx =
Intersect(idx_sort, idx_select);
39 auto good_muon_pt =
Take(muon_pt, idx);
40 auto good_muon_eta =
Take(muon_eta, idx);
42 for (
size_t i = 0; i < idx.size(); i++) {
43 std::cout <<
"Selected muon " << i + 1 <<
" (pt, eta): " << good_muon_pt[i]
44 <<
", " << good_muon_eta[i] << std::endl;
size_type size() const noexcept
RVec< T > Reverse(const RVec< T > &v)
Return copy of reversed vector.
RVec< T > Intersect(const RVec< T > &v1, const RVec< T > &v2, bool v2_is_sorted=false)
Return the intersection of elements of two RVecs.
RVec< typename RVec< T >::size_type > Nonzero(const RVec< T > &v)
Return the indices of the elements which are not zero.
RVec< T > Take(const RVec< T > &v, const RVec< typename RVec< T >::size_type > &i)
Return elements of a vector at given indices.
RVec< typename RVec< T >::size_type > Argsort(const RVec< T > &v)
Return an RVec of indices that sort the input RVec.