ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
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 More...
 
 ~Permutation ()
 destructor More...
 
 Permutation (const Permutation &)=delete
 
Permutationoperator= (const Permutation &)=delete
 
template<class OUT >
bool get (OUT &perm)
 get a permutation. More...
 
template<class CALLER , class OUT , class CRITERIA >
bool goodOnes (CALLER *caller, OUT &perm, CRITERIA criteria)
 get a permutation which passes a selection criteria More...
 

Private Attributes

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

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  }

◆ ~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
82  std::vector<unsigned int *>::const_iterator it = m_index.begin();
83  std::vector<unsigned int *>::const_iterator itE = m_index.end();
84  for (; it!=itE; ++it)
85  perm.push_back((*m_coll)[**it]);
86 
87  return true;
88  }

◆ 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  }

◆ 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:
AnalysisUtils::Combination::get
bool get(OUT &comb)
get a combination.
Definition: AnalysisCombination.h:43
AnalysisUtils::Permutation::m_index
std::vector< unsigned int * > m_index
Definition: AnalysisPermutation.h:117
skel.it
it
Definition: skel.GENtoEVGEN.py:396
TruthTest.itE
itE
Definition: TruthTest.py:25
AnalysisUtils::Permutation::m_first
bool m_first
flag to check if first
Definition: AnalysisPermutation.h:120
lumiFormat.i
int i
Definition: lumiFormat.py:85
AnalysisUtils::Permutation::get
bool get(OUT &perm)
get a permutation.
Definition: AnalysisPermutation.h:59
Combination
AnalysisUtils::Permutation::m_index_for_comb
std::vector< unsigned int * > m_index_for_comb
indices of elements
Definition: AnalysisPermutation.h:116
AnalysisUtils::Permutation::m_comb
Combination< std::vector< unsigned int * > > * m_comb
combination
Definition: AnalysisPermutation.h:110
AnalysisUtils::Permutation::goodOnes
bool goodOnes(CALLER *caller, OUT &perm, CRITERIA criteria)
get a permutation which passes a selection criteria
Definition: AnalysisPermutation.h:95
std::sort
void sort(typename std::reverse_iterator< DataModel_detail::iterator< DVL > > beg, typename std::reverse_iterator< DataModel_detail::iterator< DVL > > end, const Compare &comp)
Specialization of sort for DataVector/List.
Definition: DVL_algorithms.h:623
AnalysisUtils::Permutation::m_coll
COLL * m_coll
collection
Definition: AnalysisPermutation.h:113