ATLAS Offline Software
Loading...
Searching...
No Matches
AnalysisUtils::Permutation< COLL > Class Template Reference

permutation More...

#include <AnalysisPermutation.h>

Collaboration diagram for AnalysisUtils::Permutation< COLL >:

Public Member Functions

 Permutation (COLL *coll, const unsigned int nElement)
 constructor
 ~Permutation ()
 destructor
 Permutation (const Permutation &)=delete
Permutationoperator= (const Permutation &)=delete
template<class OUT>
bool get (OUT &perm)
 get a permutation.
template<class CALLER, class OUT, class CRITERIA>
bool goodOnes (CALLER *caller, OUT &perm, CRITERIA criteria)
 get a permutation which passes a selection criteria

Private Attributes

Combination< std::vector< unsigned int * > > * m_comb
 combination
COLL * m_coll
 collection
std::vector< unsigned int * > m_index_for_comb
 indices of elements
std::vector< unsigned int * > m_index
bool m_first
 flag to check if first

Detailed Description

template<class COLL>
class AnalysisUtils::Permutation< COLL >

permutation

Definition at line 23 of file AnalysisPermutation.h.

Constructor & Destructor Documentation

◆ Permutation() [1/2]

template<class COLL>
AnalysisUtils::Permutation< COLL >::Permutation ( COLL * coll,
const unsigned int nElement )
inline

constructor

Parameters
collcollection

Definition at line 30 of file AnalysisPermutation.h.

31 : m_coll(coll), m_first(true)
32 {
33 // init indices
34 for (unsigned int i=0; i<coll->size(); ++i)
35 m_index_for_comb.push_back(new unsigned int(i));
36
38 }
std::vector< unsigned int * > m_index_for_comb
indices of elements
Combination< std::vector< unsigned int * > > * m_comb
combination
bool m_first
flag to check if first

◆ ~Permutation()

template<class COLL>
AnalysisUtils::Permutation< COLL >::~Permutation ( )
inline

destructor

Definition at line 42 of file AnalysisPermutation.h.

43 {
44 delete m_comb;
45
46 for (unsigned int i=0; i<m_index_for_comb.size(); ++i)
47 delete m_index_for_comb[i];
48 }

◆ Permutation() [2/2]

template<class COLL>
AnalysisUtils::Permutation< COLL >::Permutation ( const Permutation< COLL > & )
delete

Member Function Documentation

◆ get()

template<class COLL>
template<class OUT>
bool AnalysisUtils::Permutation< COLL >::get ( OUT & perm)
inline

get a permutation.

This method changes the sequence in increasing order and return true if succeeds. If the current sequence is the last permutation, return false

Parameters
perma vector for permutation

Definition at line 59 of file AnalysisPermutation.h.

60 {
61 // init returned vector
62 perm.clear();
63
64 // get combination if first
65 if (m_first)
66 {
67 m_first=false;
68 if (! m_comb->get(m_index)) return false;
69 std::sort(m_index.begin(), m_index.end());
70 }
71 else
72 {
73 // change sequence. if this is the last permutation. get next combination
74 if (! std::next_permutation (m_index.begin(), m_index.end()))
75 {
76 if (! m_comb->get(m_index)) return false;
77 std::sort(m_index.begin(), m_index.end());
78 }
79 }
80
81 // assign
84 for (; it!=itE; ++it)
85 perm.push_back((*m_coll)[**it]);
86
87 return true;
88 }
std::vector< unsigned int * > m_index
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.

◆ goodOnes()

template<class COLL>
template<class CALLER, class OUT, class CRITERIA>
bool AnalysisUtils::Permutation< COLL >::goodOnes ( CALLER * caller,
OUT & perm,
CRITERIA criteria )
inline

get a permutation which passes a selection criteria

Parameters
perma vector for permutation
criteriaa function pointer of selection criteria

Definition at line 95 of file AnalysisPermutation.h.

96 {
97 get(perm);
98
99 // check if this passes the criteria
100 if (criteria(caller,perm)) return true;
101
102 // if not, look for next combination
103 return goodOnes(caller, perm, criteria);
104 }
bool goodOnes(CALLER *caller, OUT &perm, CRITERIA criteria)
get a permutation which passes a selection criteria
bool get(OUT &perm)
get a permutation.

◆ operator=()

template<class COLL>
Permutation & AnalysisUtils::Permutation< COLL >::operator= ( const Permutation< COLL > & )
delete

Member Data Documentation

◆ m_coll

template<class COLL>
COLL* AnalysisUtils::Permutation< COLL >::m_coll
private

collection

Definition at line 113 of file AnalysisPermutation.h.

◆ m_comb

template<class COLL>
Combination<std::vector<unsigned int *> >* AnalysisUtils::Permutation< COLL >::m_comb
private

combination

Definition at line 110 of file AnalysisPermutation.h.

◆ m_first

template<class COLL>
bool AnalysisUtils::Permutation< COLL >::m_first
private

flag to check if first

Definition at line 120 of file AnalysisPermutation.h.

◆ m_index

template<class COLL>
std::vector<unsigned int *> AnalysisUtils::Permutation< COLL >::m_index
private

Definition at line 117 of file AnalysisPermutation.h.

◆ m_index_for_comb

template<class COLL>
std::vector<unsigned int *> AnalysisUtils::Permutation< COLL >::m_index_for_comb
private

indices of elements

Definition at line 116 of file AnalysisPermutation.h.


The documentation for this class was generated from the following file: