ATLAS Offline Software
ProductGen.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
6 #include "./ProductGen.h"
7 #include <algorithm>
8 
9 
11 
12 ProductGen::ProductGen(const std::vector<std::size_t>& ends):
13  m_ends(ends), m_counters(ends.size(), 0), m_ncounters(ends.size()){
14 
15  if (!m_ends.empty()){
16  m_done = false;
17  for(auto& i : m_ends){
18  if(i < 1) {
19  m_done = true;
20  break;
21  } else {
22  i -= 1;
23  }
24  }
25  }
26 
27 }
28 
29 
30 std::vector<std::size_t> ProductGen::next() {
31 
32  if(m_done){return std::vector<std::size_t>();}
33 
34  auto result = std::vector<std::size_t>(m_counters);
35  m_done = atEnd();
36  for(std::size_t i = 0; i < m_ncounters; ++i){
37 
38  if(m_counters[i] == m_ends[i]){
39  m_counters[i] = 0;
40  } else {
41  m_counters[i] += 1;
42  break;
43  }
44  }
45  return result;
46 }
ProductGen::ProductGen
ProductGen()
Definition: ProductGen.cxx:10
get_generator_info.result
result
Definition: get_generator_info.py:21
ProductGen.h
ProductGen::m_counters
std::vector< std::size_t > m_counters
Definition: ProductGen.h:23
ProductGen::atEnd
bool atEnd()
Definition: ProductGen.h:26
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
ProductGen::m_done
bool m_done
Definition: ProductGen.h:25
lumiFormat.i
int i
Definition: lumiFormat.py:92
ProductGen::m_ncounters
std::size_t m_ncounters
Definition: ProductGen.h:24
ProductGen::next
std::vector< std::size_t > next()
Definition: ProductGen.cxx:30
ProductGen::m_ends
std::vector< std::size_t > m_ends
Definition: ProductGen.h:22