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