ATLAS Offline Software
TimedHitPtrCollection.icc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include <algorithm>
6 #include <cassert>
7 template <class HIT>
8 void
9 TimedHitPtrCollection<HIT>::insert(const PileUpTimeEventIndex& timeEventIndex,
10  const AthenaHitsVector<HIT>* inputCollection) {
11  assert(inputCollection);
12  typename AthenaHitsVector<HIT>::const_iterator i(inputCollection->begin());
13  typename AthenaHitsVector<HIT>::const_iterator e(inputCollection->end());
14  while (i!=e) m_hits.push_back(TimedHitPtr<HIT>(timeEventIndex.time(), timeEventIndex.index(),*i++, timeEventIndex.type()));
15  if (m_sorted) {
16  m_sorted=false;
17  throw SortedException();
18  }
19 }
20 
21 template <class HIT>
22 void
23 TimedHitPtrCollection<HIT>::insert(float evtTime,
24  const AthenaHitsVector<HIT>* inputCollection) {
25  assert(inputCollection);
26  typename AthenaHitsVector<HIT>::const_iterator i(inputCollection->begin());
27  typename AthenaHitsVector<HIT>::const_iterator e(inputCollection->end());
28  while (i!=e) m_hits.push_back(TimedHitPtr<HIT>(evtTime, *i++));
29  if (m_sorted) {
30  m_sorted=false;
31  throw SortedException();
32  }
33 }
34 
35 
36  ///returns an iterator range with the hits of current detector element
37 template <class HIT>
38 bool
39 TimedHitPtrCollection<HIT>::nextDetectorElement(const_iterator& b, const_iterator& e) {
40  if (!m_sorted) sortVector();
41  b = m_currentHit;
42  while (m_currentHit != m_hits.end() && !(*b < *m_currentHit)) ++m_currentHit;
43  e = m_currentHit;
44  return (b != e);
45 }
46 
47 template <class HIT>
48 void
49 TimedHitPtrCollection<HIT>::sortVector() {
50  std::stable_sort(m_hits.begin(), m_hits.end());
51  m_currentHit = m_hits.begin();
52  m_sorted=true;
53 }
54