ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
CombinationsGen Class Reference

#include <CombinationsGen.h>

Collaboration diagram for CombinationsGen:

Public Member Functions

 CombinationsGen (unsigned int n, unsigned int k)
 
std::pair< std::vector< unsigned int >, bool > next ()
 

Private Attributes

bool m_more
 
bool m_invalid
 
std::string m_bitmask
 

Detailed Description

Definition at line 20 of file CombinationsGen.h.

Constructor & Destructor Documentation

◆ CombinationsGen()

CombinationsGen::CombinationsGen ( unsigned int  n,
unsigned int  k 
)
inline

Definition at line 22 of file CombinationsGen.h.

22  :
23  m_more{true}, m_invalid{false}{
24 
25  if (k<=n){
26  m_bitmask = std::string(k, 1);
27  m_bitmask.resize(n, 0);
28  } else {
29  m_invalid = true;
30  }
31  }

Member Function Documentation

◆ next()

std::pair<std::vector<unsigned int>, bool> CombinationsGen::next ( )
inline

Definition at line 33 of file CombinationsGen.h.

33  {
34 
35  std::vector<unsigned int> comb;
36  if (m_invalid){return {comb, false};}
37 
38  if(not m_more){return {comb, false};}
39 
40  for(std::size_t i = 0; i < m_bitmask.size(); ++i){
41  if(m_bitmask[i]){comb.push_back(i);}
42  }
43  m_more = std::prev_permutation(m_bitmask.begin(), m_bitmask.end());
44  return {comb, true};
45  }

Member Data Documentation

◆ m_bitmask

std::string CombinationsGen::m_bitmask
private

Definition at line 50 of file CombinationsGen.h.

◆ m_invalid

bool CombinationsGen::m_invalid
private

Definition at line 49 of file CombinationsGen.h.

◆ m_more

bool CombinationsGen::m_more
private

Definition at line 48 of file CombinationsGen.h.


The documentation for this class was generated from the following file:
CombinationsGen::m_more
bool m_more
Definition: CombinationsGen.h:48
lumiFormat.i
int i
Definition: lumiFormat.py:85
beamspotman.n
n
Definition: beamspotman.py:731
CombinationsGen::m_invalid
bool m_invalid
Definition: CombinationsGen.h:49
CombinationsGen::m_bitmask
std::string m_bitmask
Definition: CombinationsGen.h:50
fitman.k
k
Definition: fitman.py:528