1 // This file's extension implies that it's C, but it's really -*- C++ -*-.
4 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
7 // $Id: CaloCellPrefetchIterator.icc,v 1.2 2008-08-02 14:57:07 ssnyder Exp $
10 * @file CaloEvent/CaloCellPrefetchIterator.icc
11 * @author scott snyder
13 * @brief To iterate over @c CaloCell's, prefetching the detector description.
17 //****************************************************************************
20 namespace CaloEvent_detail {
24 * @brief Return the current parameter (will always be 1).
26 template <class T, class TAG>
28 typename paramholder<T, TAG>::param_t
29 paramholder<T, TAG>::getParameter() const
36 * @brief Move to the next weight (a no-op).
38 template <class T, class TAG>
40 void paramholder<T, TAG>::next()
46 * @brief Fetch the next weight from the iterator (a no-op).
48 template <class T, class TAG>
50 void paramholder<T, TAG>::fetch (const T& /*it*/)
56 * @brief Return the current parameter.
60 typename paramholder<T, NavigationTokenIteratorTag>::param_t
61 paramholder<T, NavigationTokenIteratorTag>::getParameter() const
68 * @brief Move to the next weight.
72 void paramholder<T, NavigationTokenIteratorTag>::next()
74 m_param = m_next_param;
79 * @brief Fetch the next weight from the iterator.
83 void paramholder<T, NavigationTokenIteratorTag>::fetch (const T& it)
85 m_next_param = it.getParameter();
89 } // namespace CaloEvent_detail
92 //****************************************************************************
97 * @param begin Underlying begin iterator.
98 * @param end Underlying end iterator.
101 CaloCellPrefetchIterator<T>::CaloCellPrefetchIterator
102 (const base_iterator& begin,
103 const base_iterator& end)
113 * @brief Constructor, from a container.
114 * @param cont Container over which to iterate.
117 template <class CONTAINER>
118 CaloCellPrefetchIterator<T>::CaloCellPrefetchIterator
119 (const CONTAINER& cont)
120 : m_it (cont.begin()),
128 * @brief Move to the next element.
130 * Returns true if more elements, false otherwise.
131 * This should be called before processing the first element.
135 bool CaloCellPrefetchIterator<T>::next()
137 // Are we at the end (use the saved result of the comparison).
141 // Move to the next cell/weight.
142 m_cellp = m_next_cellp;
143 paramholder::next ();
145 // Is the iterator (now pointing at the next element) at the end?
147 // No, fetch the contents of the next element.
148 m_next_cellp = *m_it;
149 paramholder::fetch (m_it);
150 // And prefetch the DDE.
151 __builtin_prefetch (m_next_cellp->caloDDE());
152 // Bump the iterator.
156 // This is the last element. Remember that for next time.
166 * @brief Dereference the iterator.
170 const CaloCell* CaloCellPrefetchIterator<T>::operator*() const
177 * @brief Initialize before first use.
180 void CaloCellPrefetchIterator<T>::init()
184 m_next_cellp = *m_it;
185 paramholder::fetch (m_it);