ATLAS Offline Software
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
HLT::ComboIteratorTopo Class Reference

#include <ComboIterator.h>

Inheritance diagram for HLT::ComboIteratorTopo:
Collaboration diagram for HLT::ComboIteratorTopo:

Public Member Functions

 ComboIteratorTopo (const std::vector< TEVec > &tes, const TrigNavStructure *nav, HLT::te_id_type topoSpan)
 
bool rewind ()
 Rewind method, resetting the iterator to the first element. More...
 
TEVecoperator* ()
 Unary * operator, used to recover the current combination. More...
 
bool isValid () const
 Validity check for the iterator. More...
 
TEVeccombination ()
 Accessor method for the current combination. More...
 
ComboIteratoroperator++ (int)
 Post increment operator. More...
 
ComboIteratoroperator++ ()
 Pre increment operator. More...
 

Protected Member Functions

virtual bool overlaps (const TriggerElement *t1, const TriggerElement *t2) const
 Method used to test overlaps between two TEs. More...
 
bool overlaps (const TriggerElement *t1, const TEVec &teVec, int idx=-1) const
 Method used to test overlaps between a TE and a vector of TEs. More...
 
bool incrementByOne (int pos, bool &ok)
 Private increment method. More...
 
bool increment (int pos)
 Private increment method. More...
 
bool reset (int pos)
 Private reset method. More...
 
void invalidate ()
 Method used to invalidate the current combination. More...
 
void print () const
 Debug dump to std::cout. More...
 

Protected Attributes

TEVec m_comb
 Current combination of TEs. More...
 
std::vector< int > m_idx
 Vector of indexes keeping track of the loop over combinations. More...
 
std::vector< TEVecm_tes
 Vector of vectors of TEs to be combined. More...
 
bool m_valid
 Validity status variable. More...
 
const TrigNavStructurem_nav
 Pointer to the navigation service. More...
 

Private Member Functions

void traverseUntilSeedsTopo (const TriggerElement *start, std::set< const TriggerElement * > &topos) const
 

Private Attributes

HLT::te_id_type m_spanId
 

Detailed Description

Definition at line 173 of file ComboIterator.h.

Constructor & Destructor Documentation

◆ ComboIteratorTopo()

HLT::ComboIteratorTopo::ComboIteratorTopo ( const std::vector< TEVec > &  tes,
const TrigNavStructure nav,
HLT::te_id_type  topoSpan 
)

Definition at line 199 of file ComboIterator.cxx.

201  : ComboIterator(tes, nav),
202  m_spanId(topoSpan) {
203  rewind();
204 }

Member Function Documentation

◆ combination()

TEVec& HLT::ComboIterator::combination ( )
inlinevirtualinherited

Accessor method for the current combination.

Implements HLT::ComboIteratorBase.

Definition at line 98 of file ComboIterator.h.

98 { return m_comb; }

◆ increment()

bool HLT::ComboIterator::increment ( int  pos)
protectedinherited

Private increment method.

Definition at line 69 of file ComboIterator.cxx.

70 {
71  if (!isValid()) return false;
72 
73  bool ok = false;
74  while (!ok) if (!incrementByOne(pos, ok)) return false;
75 
76  return ok;
77 }

◆ incrementByOne()

bool HLT::ComboIterator::incrementByOne ( int  pos,
bool &  ok 
)
protectedinherited

Private increment method.

Definition at line 80 of file ComboIterator.cxx.

81 {
82  // cout << "increment1 " << pos << endl;
83 
84  if (pos >= (int)m_comb.size() || pos < 0) return false;
85 
86  ok = false;
87 
88  // If we're at the end of the vector for this element, ...
89  if (m_idx[pos] == (int)m_tes[pos].size() - 1) {
90 
91  // ... if it's the first (innermost-loop) one, we're done...
92  if (pos == 0) return false;
93 
94  // ... otherwise increment the previous element by one...
95  if (!increment(pos - 1)) return false;
96 
97  // ... reset this one...
98  if (!reset(pos)) return false;
99 
100  // ... and increment it (from reset to valid).
101  if (!increment(pos)) return false;
102  }
103  else {
104  // else it's just the normal case,
105 
106  m_idx [pos]++;
107  m_comb[pos] = m_tes[pos][m_idx[pos]];
108  }
109 
110  ok = !overlaps(m_comb[pos], m_comb, pos);
111  // cout << "after increment (pos=" << pos << ", ok=" << ok << ")" << endl; print();
112 
113  return true;
114 }

◆ invalidate()

void HLT::ComboIterator::invalidate ( )
protectedinherited

Method used to invalidate the current combination.

Definition at line 189 of file ComboIterator.cxx.

190 {
191  // cout << "-------------------------------" << endl;
192  // cout << "Invalidate!" << endl;
193  // cout << "-------------------------------" << endl;
194  m_valid = false;
195  m_comb.clear();
196 }

◆ isValid()

bool HLT::ComboIterator::isValid ( ) const
inlinevirtualinherited

Validity check for the iterator.

Returns
result of the validity check; returns false if iterator is at end, true otherwise.

Implements HLT::ComboIteratorBase.

Definition at line 95 of file ComboIterator.h.

95 { return m_valid; }

◆ operator*()

TEVec& HLT::ComboIterator::operator* ( )
inlinevirtualinherited

Unary * operator, used to recover the current combination.

Implements HLT::ComboIteratorBase.

Definition at line 90 of file ComboIterator.h.

90 { return combination(); }

◆ operator++() [1/2]

HLT::ComboIterator & HLT::ComboIterator::operator++ ( )
virtualinherited

Pre increment operator.

Implements HLT::ComboIteratorBase.

Definition at line 58 of file ComboIterator.cxx.

59 {
60  if (!increment((int)m_comb.size() - 1)) invalidate();
61  // cout << "vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv" << endl;
62  // print();
63  // cout << "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" << endl;
64 
65  return *this;
66 }

◆ operator++() [2/2]

ComboIterator& HLT::ComboIterator::operator++ ( int  )
inlinevirtualinherited

Post increment operator.

Implements HLT::ComboIteratorBase.

Definition at line 101 of file ComboIterator.h.

101 { return operator++(); }

◆ overlaps() [1/2]

bool HLT::ComboIterator::overlaps ( const TriggerElement t1,
const TEVec teVec,
int  idx = -1 
) const
protectedinherited

Method used to test overlaps between a TE and a vector of TEs.

Returns
result of the overlap test; returns true if the TE corresponds to the same RoI as one of the TEs in the vector, false otherwise.
Parameters
t1TE to check.
teVecTE vector to check.
idxoptional integer parameter, limiting the check over the 0..idx-1 range of the vector.

Definition at line 146 of file ComboIterator.cxx.

148 {
149  if (idx < 0) idx = teVec.size();
150 
151  for (int i = 0; i < idx; i++) {
152  if (!teVec[i]) return false;
153  if (overlaps(te1, teVec[i])) return true;
154  }
155 
156  return false;
157 }

◆ overlaps() [2/2]

bool HLT::ComboIteratorTopo::overlaps ( const TriggerElement t1,
const TriggerElement t2 
) const
protectedvirtual

Method used to test overlaps between two TEs.

Returns
result of the overlap test; returns true if the two TEs correspond to the same RoI, false otherwise.
Parameters
t1first TE to check.
t2second TE to check.

Reimplemented from HLT::ComboIterator.

Definition at line 228 of file ComboIterator.cxx.

228  {
229  if ( HLT::ComboIterator::overlaps(t1, t2) == true ) return true;
230 
231  // if above returned true it means TEs are from the same RoI, combiation is uninteresting
232  // if false it may still be uninteresting because it is joined by topo TE
233 
234  std::set<const TriggerElement*> te1span;
235  traverseUntilSeedsTopo(t1, te1span);
236  if ( te1span.empty() ) // empty set can not be from the same combination
237  return true;
238 
239  std::set<const TriggerElement*> te2span;
240  traverseUntilSeedsTopo(t2, te2span);
241  if ( te2span.empty() )
242  return true;
243  /*
244  for ( auto te : te1span )
245  cout << " t1 span TES " << te << " " << te->getId() << endl;
246  cout << endl;
247  for ( auto te : te2span )
248  cout << " t2 span TES " << te << " " << te->getId() << endl;
249  */
250  std::vector<const TriggerElement*> intersection;
251  std::set_intersection(te1span.begin(), te1span.end(), te2span.begin(), te2span.end(),
252  std::back_inserter(intersection));
253 
254  if ( not intersection.empty() )
255  return false; // there is genuine topo join, the pair is interesting
256  return true;
257 
258 }

◆ print()

void HLT::ComboIterator::print ( ) const
protectedinherited

Debug dump to std::cout.

Definition at line 170 of file ComboIterator.cxx.

171 {
172  cout << endl;
173  cout << "TEs:" << endl;
174  cout << "{" << endl;
175  for (unsigned int i = 0; i < m_tes.size(); i++) {
176  cout << " [ ";
177  for (unsigned int j = 0; j < m_tes[i].size(); j++) cout << m_tes[i][j] << " ";
178  cout << "]" << endl;
179  }
180  cout << "}" << endl << endl << "Comb = [ ";
181  for (unsigned int i = 0; i < m_comb.size(); i++) cout << m_comb[i] << " ";
182  cout << "]" << endl << "Idxs = [ ";
183  for (unsigned int i = 0; i < m_idx.size(); i++) cout << m_idx[i] << " ";
184  cout << "]" << endl;
185  cout << (isValid() ? "Valid" : "Invalid") << endl << endl;
186 }

◆ reset()

bool HLT::ComboIterator::reset ( int  pos)
protectedinherited

Private reset method.

Definition at line 117 of file ComboIterator.cxx.

118 {
119  // cout << "Reset : " << pos << endl;
120 
121  if (pos >= (int)m_comb.size() || pos < 0) return false;
122 
123  m_comb[pos] = 0;
124  m_idx [pos] = -1;
125 
126 
127  // Find the previous element of the same type (if any), and get its index
128  // in the vector of TEs of this type...
129 
130  for (unsigned int j = pos; j > 0; j--) {
131 
132  if (!m_comb[j - 1]) continue;
133 
134  // Find the TE of the same type with the highest index
135  if (m_comb[j - 1]->getId() == m_tes[pos][0]->getId()) {
136  m_idx[pos] = m_idx[j - 1];
137  break;
138  }
139  }
140 
141  // cout << "reset to index = " << m_idx[pos] << endl;
142  return 1;
143 }

◆ rewind()

bool HLT::ComboIterator::rewind ( )
virtualinherited

Rewind method, resetting the iterator to the first element.

Implements HLT::ComboIteratorBase.

Definition at line 27 of file ComboIterator.cxx.

28 {
29  m_comb.clear();
30  m_idx.clear();
31 
32  // cout << "Construct" << endl;
33 
34  for (unsigned int i = 0; i < m_tes.size(); i++) {
35 
36  if (m_tes[i].size() == 0) {
37  invalidate();
38  return 0;
39  }
40 
41  m_comb.push_back(0);
42  m_idx.push_back(-1);
43 
44  if (!reset(i) || !increment(i)) {
45  invalidate();
46  return 0;
47  }
48  }
49 
50  // cout << "After setup: " << endl;
51  // cout << "vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv" << endl;
52  // print();
53  // cout << "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" << endl;
54  return isValid();
55 }

◆ traverseUntilSeedsTopo()

void HLT::ComboIteratorTopo::traverseUntilSeedsTopo ( const TriggerElement start,
std::set< const TriggerElement * > &  topos 
) const
private

Definition at line 206 of file ComboIterator.cxx.

206  {
207 
209  for ( auto successor : successors ) {
210  if ( successor->getActiveState() == true and successor->getId() == m_spanId ) {
211  topos.insert(successor);
212  }
213  }
214  if ( not topos.empty() )
215  return;
216 
217  // we need to digg deeper
219  for ( auto predecessor : predecessors ) {
220  // this next line is disabled because the predecessors of the L1Topo simulation output TE are exactly of type RoI-node (after discussion with Tomasz)
221  // if ( HLT::TrigNavStructure::isRoINode(predecessor) ) continue;
222  traverseUntilSeedsTopo(predecessor, topos);
223  if ( not topos.empty() )
224  return;
225  }
226 }

Member Data Documentation

◆ m_comb

TEVec HLT::ComboIterator::m_comb
protectedinherited

Current combination of TEs.

Definition at line 140 of file ComboIterator.h.

◆ m_idx

std::vector<int> HLT::ComboIterator::m_idx
protectedinherited

Vector of indexes keeping track of the loop over combinations.

Definition at line 143 of file ComboIterator.h.

◆ m_nav

const TrigNavStructure* HLT::ComboIterator::m_nav
protectedinherited

Pointer to the navigation service.

Definition at line 152 of file ComboIterator.h.

◆ m_spanId

HLT::te_id_type HLT::ComboIteratorTopo::m_spanId
private

Definition at line 183 of file ComboIterator.h.

◆ m_tes

std::vector<TEVec> HLT::ComboIterator::m_tes
protectedinherited

Vector of vectors of TEs to be combined.

Definition at line 146 of file ComboIterator.h.

◆ m_valid

bool HLT::ComboIterator::m_valid
protectedinherited

Validity status variable.

Definition at line 149 of file ComboIterator.h.


The documentation for this class was generated from the following files:
HLT::ComboIterator::operator++
ComboIterator & operator++()
Pre increment operator.
Definition: ComboIterator.cxx:58
HLT::ComboIterator::invalidate
void invalidate()
Method used to invalidate the current combination.
Definition: ComboIterator.cxx:189
HLT::ComboIterator::combination
TEVec & combination()
Accessor method for the current combination.
Definition: ComboIterator.h:98
HLT::ComboIterator::m_comb
TEVec m_comb
Current combination of TEs.
Definition: ComboIterator.h:140
mergePhysValFiles.start
start
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:14
ALFA_EventTPCnv_Dict::t1
std::vector< ALFA_RawDataCollection_p1 > t1
Definition: ALFA_EventTPCnvDict.h:43
HLT::ComboIterator::incrementByOne
bool incrementByOne(int pos, bool &ok)
Private increment method.
Definition: ComboIterator.cxx:80
HLT::ComboIterator::reset
bool reset(int pos)
Private reset method.
Definition: ComboIterator.cxx:117
intersection
std::vector< std::string > intersection(std::vector< std::string > &v1, std::vector< std::string > &v2)
Definition: compareFlatTrees.cxx:25
HLT::TrigNavStructure::getDirectSuccessors
static const std::vector< TriggerElement * > & getDirectSuccessors(const TriggerElement *te)
returns list of direct predecessors (nodes I seed)
Definition: TrigNavStructure.cxx:124
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
HLT::ComboIterator::increment
bool increment(int pos)
Private increment method.
Definition: ComboIterator.cxx:69
HLT::TrigNavStructure::getDirectPredecessors
static const std::vector< TriggerElement * > & getDirectPredecessors(const TriggerElement *te)
returns list of direct predecessors (nodes seeding me)
Definition: TrigNavStructure.cxx:120
lumiFormat.i
int i
Definition: lumiFormat.py:85
HLT::ComboIteratorTopo::traverseUntilSeedsTopo
void traverseUntilSeedsTopo(const TriggerElement *start, std::set< const TriggerElement * > &topos) const
Definition: ComboIterator.cxx:206
HLT::ComboIterator::overlaps
virtual bool overlaps(const TriggerElement *t1, const TriggerElement *t2) const
Method used to test overlaps between two TEs.
Definition: ComboIterator.cxx:160
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
ALFA_EventTPCnv_Dict::t2
std::vector< ALFA_RawDataContainer_p1 > t2
Definition: ALFA_EventTPCnvDict.h:44
HLT::ComboIterator::m_tes
std::vector< TEVec > m_tes
Vector of vectors of TEs to be combined.
Definition: ComboIterator.h:146
HLT::ComboIterator::m_valid
bool m_valid
Validity status variable.
Definition: ComboIterator.h:149
HLT::ComboIterator::ComboIterator
ComboIterator(const std::vector< TEVec > &tes, const TrigNavStructure *nav)
Constructor; gets a vector of TE vectors and a pointer to Navigation as arguments.
Definition: ComboIterator.cxx:15
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
HLT::ComboIterator::m_idx
std::vector< int > m_idx
Vector of indexes keeping track of the loop over combinations.
Definition: ComboIterator.h:143
HLT::ComboIteratorTopo::m_spanId
HLT::te_id_type m_spanId
Definition: ComboIterator.h:183
set_intersection
Set * set_intersection(Set *set1, Set *set2)
Perform an intersection of two sets.
HLT::ComboIterator::rewind
bool rewind()
Rewind method, resetting the iterator to the first element.
Definition: ComboIterator.cxx:27
HLT::ComboIterator::isValid
bool isValid() const
Validity check for the iterator.
Definition: ComboIterator.h:95