2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
5 * @file LArRawConditions/LArCompactSubset.icc
6 * @author scott snyder <snyder@bnl.gov>
8 * @brief A more compact way of storing shape/ofc data.
13 //=========================================================================
17 * @brief Default constructor. Makes an invalid proxy.
20 LArCompactSubsetConstChannelProxy::LArCompactSubsetConstChannelProxy()
29 * @brief chan The channel index we reference.
30 * @brief subset The subset object within which we live.
33 LArCompactSubsetConstChannelProxy::LArCompactSubsetConstChannelProxy
35 const LArCompactSubsetVector& subset)
43 * @brief Test to see if the proxy is valid.
46 bool LArCompactSubsetConstChannelProxy::isValid() const
53 * @brief Return the time offset for this channel.
56 float LArCompactSubsetConstChannelProxy::timeOffset() const
58 return m_subset->timeOffset (m_chan);
63 * @brief Return the time bin width for this channel.
66 float LArCompactSubsetConstChannelProxy::timeBinWidth() const
68 return m_subset->timeBinWidth (m_chan);
73 * @brief Return the number of time bins for this channel.
76 size_t LArCompactSubsetConstChannelProxy::getSize () const
78 return m_subset->getSize (m_chan);
83 * @brief Return one set of wave data from this channel.
84 * @param which Index of the wave type to return.
85 * @param tbin Time bin index.
89 LArCompactSubsetConstChannelProxy::getData (unsigned int which,
92 return m_subset->getData (which, m_chan, tbin);
97 * @brief Return number of shape time bins.
100 size_t LArCompactSubsetConstChannelProxy::shapeSize() const
102 return m_subset->getSize (m_chan);
107 * @brief Return number of shape derivative time bins.
110 size_t LArCompactSubsetConstChannelProxy::shapeDerSize() const
112 return m_subset->getSize (m_chan);
117 * @brief Return shape data.
118 * @param tbin Time bin index.
121 ILArShape::ShapeRef_t
122 LArCompactSubsetConstChannelProxy::shape (size_t tbin) const
124 return m_subset->getData (0, m_chan, tbin);
129 * @brief Return shape derivative data.
130 * @param tbin Time bin index.
133 ILArShape::ShapeRef_t
134 LArCompactSubsetConstChannelProxy::shapeDer (size_t tbin) const
136 return m_subset->getData (1, m_chan, tbin);
141 * @brief Return number of time bins for OFC A coefficients.
145 LArCompactSubsetConstChannelProxy::OFC_aSize () const
147 return m_subset->getSize (m_chan);
152 * @brief Return number of time bins for OFC B coefficients.
156 LArCompactSubsetConstChannelProxy::OFC_bSize () const
158 return m_subset->getSize (m_chan);
163 * @brief Return OFC A coefficients.
164 * @param tbin Time bin index.
168 LArCompactSubsetConstChannelProxy::OFC_a (size_t tbin) const
170 return m_subset->getData (0, m_chan, tbin);
175 * @brief Return OFC B coefficients.
176 * @param tbin Time bin index.
180 LArCompactSubsetConstChannelProxy::OFC_b (size_t tbin) const
182 return m_subset->getData (1, m_chan, tbin);
187 * @brief Default constructor. Makes an invalid proxy.
190 LArCompactSubsetChannelProxy::LArCompactSubsetChannelProxy()
191 : m_subset_nc (nullptr)
197 * @brief Constructor.
198 * @brief chan The channel index we reference.
199 * @brief subset The subset object within which we live.
202 LArCompactSubsetChannelProxy::LArCompactSubsetChannelProxy
204 LArCompactSubsetVector& subset)
205 : LArCompactSubsetConstChannelProxy (chan, subset),
206 m_subset_nc (&subset)
212 * @brief Initialize the referenced data from a standalone object.
213 * @param other The object from which to initialize.
216 LArCompactSubsetChannelProxy&
217 LArCompactSubsetChannelProxy::operator= (const LAr2DWaveBase& other)
224 //=========================================================================
228 * @brief Constructor.
229 * @param p Pointer to a channel proxy.
232 LArCompactSubsetChannelPointer::LArCompactSubsetChannelPointer
233 (const LArCompactSubsetChannelProxy* p)
234 : LArCompactSubsetChannelProxy (*p)
240 * @brief `Dereference' the pointer.
243 LArCompactSubsetChannelProxy
244 LArCompactSubsetChannelPointer::operator*() const
251 * @brief Test for a valid pointer.
254 LArCompactSubsetChannelPointer::operator bool() const
260 //=========================================================================
264 * @brief Default constructor.
267 LArCompactSubsetChannelVector::const_iterator::const_iterator()
275 * @brief Constructor from channel index and subset reference.
278 LArCompactSubsetChannelVector::const_iterator::const_iterator
279 (unsigned int chan, const LArCompactSubsetVector& subset)
287 * @brief Iterator increment.
290 LArCompactSubsetChannelVector::const_iterator&
291 LArCompactSubsetChannelVector::const_iterator::operator++()
299 * @brief Iterator dereference.
300 * Yields a channel proxy.
303 LArCompactSubsetConstChannelProxy
304 LArCompactSubsetChannelVector::const_iterator::operator*() const
306 return LArCompactSubsetConstChannelProxy (m_chan, *m_subset);
311 * @brief Iterator equality test.
314 bool LArCompactSubsetChannelVector::const_iterator::operator==
315 (const const_iterator& other) const
317 return m_chan == other.m_chan;
322 * @brief Iterator inequality test.
325 bool LArCompactSubsetChannelVector::const_iterator::operator!=
326 (const const_iterator& other) const
328 return m_chan != other.m_chan;
333 * @brief Adjust iterator backwards.
334 * @param delta Amount by which to adjust.
337 LArCompactSubsetChannelVector::const_iterator
338 LArCompactSubsetChannelVector::const_iterator::operator-
341 return const_iterator (m_chan - delta, *m_subset);
346 * @brief Iterator difference.
347 * @param other Other iterator for difference.
351 LArCompactSubsetChannelVector::const_iterator::operator-
352 (const const_iterator& other) const
354 return m_chan - other.m_chan;
359 * @brief Constructor.
360 * @param febIndex FEB index with which we're associated.
361 * @param subset Subset within which we live.
364 LArCompactSubsetChannelVector::LArCompactSubsetChannelVector
365 (size_t febIndex, LArCompactSubsetVector* subset)
366 : m_febIndex (febIndex),
373 * @brief Return the size of this vector (number of channels for this FEB).
376 size_t LArCompactSubsetChannelVector::size() const
378 return m_subset->febSize (m_febIndex);
383 * @brief Vector indexing. Returns a channel proxy.
384 * @param i Channel index within the vector.
387 LArCompactSubsetChannelProxy
388 LArCompactSubsetChannelVector::operator[] (size_t i)
390 unsigned int chan = m_subset->chanIndex (m_febIndex) + i;
391 assert (chan <= m_subset->chanIndex (m_febIndex+1));
392 return LArCompactSubsetChannelProxy (chan, *m_subset);
397 * @brief Vector indexing. Returns a channel proxy.
398 * @param i Channel index within the vector.
401 LArCompactSubsetConstChannelProxy
402 LArCompactSubsetChannelVector::operator[] (size_t i) const
404 unsigned int chan = m_subset->chanIndex (m_febIndex) + i;
405 assert (chan <= m_subset->chanIndex (m_febIndex+1));
406 return LArCompactSubsetConstChannelProxy (chan, *m_subset);
411 * @brief Begin iterator.
414 LArCompactSubsetChannelVector::const_iterator
415 LArCompactSubsetChannelVector::begin() const
417 return const_iterator (m_subset->chanIndex (m_febIndex), *m_subset);
422 * @brief End iterator.
425 LArCompactSubsetChannelVector::const_iterator
426 LArCompactSubsetChannelVector::end() const
428 return const_iterator (m_subset->chanIndex (m_febIndex+1), *m_subset);
433 * @brief Resize this vector.
434 * @param sz The desired new size.
436 * Restriction: Only the vector associated with the last FEB index
437 * in the subset may be resized.
440 void LArCompactSubsetChannelVector::resize (size_t sz)
442 m_subset->resizeChanVec (m_febIndex, sz);
448 * @brief Constructor.
449 * @param febIndex FEB index with which we're associated.
450 * @param subset Subset within which we live.
453 LArCompactSubsetConstChannelVector::LArCompactSubsetConstChannelVector
454 (size_t febIndex, const LArCompactSubsetVector* subset)
455 : m_febIndex (febIndex),
462 * @brief Return the size of this vector (number of channels for this FEB).
465 size_t LArCompactSubsetConstChannelVector::size() const
467 return m_subset->febSize (m_febIndex);
472 * @brief Vector indexing. Returns a channel proxy.
473 * @param i Channel index within the vector.
476 LArCompactSubsetConstChannelProxy
477 LArCompactSubsetConstChannelVector::operator[] (size_t i) const
479 unsigned int chan = m_subset->chanIndex (m_febIndex) + i;
480 assert (chan <= m_subset->chanIndex (m_febIndex+1));
481 return LArCompactSubsetConstChannelProxy (chan, *m_subset);
485 //=========================================================================
489 * @brief Default constructor. Makes an invalid `pointer'.
492 LArCompactSubsetChannelVectorPointer::
493 LArCompactSubsetChannelVectorPointer()
494 : LArCompactSubsetChannelVector (0, 0)
500 * @brief Constructor.
501 * @param p Pointer to a channel vector proxy.
504 LArCompactSubsetChannelVectorPointer::LArCompactSubsetChannelVectorPointer
505 (const LArCompactSubsetChannelVector* p)
506 : LArCompactSubsetChannelVector (*p)
512 * @brief `Dereference' the pointer.
515 LArCompactSubsetChannelVector
516 LArCompactSubsetChannelVectorPointer::operator*()
518 return LArCompactSubsetChannelVector (m_febIndex, m_subset);
523 * @brief `Dereference' the pointer.
526 LArCompactSubsetConstChannelVector
527 LArCompactSubsetChannelVectorPointer::operator*() const
529 return LArCompactSubsetConstChannelVector (m_febIndex, m_subset);
534 * @brief `Dereference' the pointer.
537 const LArCompactSubsetChannelVector*
538 LArCompactSubsetChannelVectorPointer::operator->() const
544 //=========================================================================
548 * @brief Constructor.
549 * @param febIndex The index of the pair.
550 * @param subset The subset within which we live.
553 LArCompactSubsetFebPair::LArCompactSubsetFebPair
555 LArCompactSubsetVector& subset)
556 : first (subset.febIdRef (febIndex)),
557 second (febIndex, &subset)
563 * @brief Constructor.
564 * @param febIndex The index of the pair.
565 * @param subset The subset within which we live.
568 LArCompactSubsetConstFebPair::LArCompactSubsetConstFebPair
570 const LArCompactSubsetVector& subset)
571 : first (subset.febIdRef (febIndex)),
572 second (febIndex, &subset)
577 //=========================================================================
581 * @brief Constructor.
582 * @param febIndex The FEB index to which we point.
583 * @param subset The subset within which we live.
586 LArCompactSubsetVector::iterator::iterator (size_t febIndex,
587 LArCompactSubsetVector& subset)
588 : m_febIndex (febIndex),
594 * @brief `Dereference' the iterator.
597 LArCompactSubsetFebPair
598 LArCompactSubsetVector::iterator::operator*()
600 return LArCompactSubsetFebPair (m_febIndex, m_subset);
605 * @brief Compare iterators for equality.
609 LArCompactSubsetVector::iterator::operator== (const iterator& other) const
611 return m_febIndex == other.m_febIndex;
616 * @brief Compare iterators for inequality.
620 LArCompactSubsetVector::iterator::operator!= (const iterator& other) const
622 return m_febIndex != other.m_febIndex;
627 * @brief Advance iterator.
630 LArCompactSubsetVector::iterator&
631 LArCompactSubsetVector::iterator::operator++()
639 * @brief Adjust iterator.
640 * @param delta Amount by which to advance the iterator.
643 LArCompactSubsetVector::iterator
644 LArCompactSubsetVector::iterator::operator+ (size_t delta)
646 return iterator (m_febIndex + delta, m_subset);
651 * @brief Iterator difference.
652 * @param other Other iterator for difference.
655 LArCompactSubsetVector::iterator::difference_type
656 LArCompactSubsetVector::iterator::operator- (const iterator& other)
658 return m_febIndex - other.m_febIndex;
663 * @brief Constructor.
664 * @param febIndex The FEB index to which we point.
665 * @param subset The subset within which we live.
668 LArCompactSubsetVector::const_iterator::const_iterator (size_t febIndex,
669 const LArCompactSubsetVector& subset)
670 : m_febIndex (febIndex),
676 * @brief `Dereference' the iterator.
679 LArCompactSubsetConstFebPair
680 LArCompactSubsetVector::const_iterator::operator*()
682 return LArCompactSubsetConstFebPair (m_febIndex, m_subset);
687 * @brief Compare iterators for equality.
691 LArCompactSubsetVector::const_iterator::operator== (const const_iterator& other) const
693 return m_febIndex == other.m_febIndex;
698 * @brief Compare iterators for inequality.
702 LArCompactSubsetVector::const_iterator::operator!= (const const_iterator& other) const
704 return m_febIndex != other.m_febIndex;
709 * @brief Advance iterator.
712 LArCompactSubsetVector::const_iterator&
713 LArCompactSubsetVector::const_iterator::operator++()
721 * @brief Adjust iterator.
722 * @param delta Amount by which to advance the iterator.
725 LArCompactSubsetVector::const_iterator
726 LArCompactSubsetVector::const_iterator::operator+ (size_t delta) const
728 return const_iterator (m_febIndex + delta, m_subset);
733 * @brief Iterator difference.
734 * @param other Other iterator for difference.
737 LArCompactSubsetVector::const_iterator::difference_type
738 LArCompactSubsetVector::const_iterator::operator- (const const_iterator& other) const
740 return m_febIndex - other.m_febIndex;
745 * @brief Return the size of this vector.
748 size_t LArCompactSubsetVector::size() const
750 return m_febids.size();
755 * @brief Vector indexing.
756 * @param i Index to look up.
759 LArCompactSubsetFebPair
760 LArCompactSubsetVector::operator[] (size_t i)
762 assert (i < m_febids.size());
763 return LArCompactSubsetFebPair (i, *this);
768 * @brief Vector indexing.
769 * @param i Index to look up.
772 const LArCompactSubsetConstFebPair
773 LArCompactSubsetVector::operator[] (size_t i) const
775 assert (i < m_febids.size());
776 return LArCompactSubsetConstFebPair (i, *(LArCompactSubsetVector*)this);
781 * @brief Begin iterator.
784 LArCompactSubsetVector::iterator LArCompactSubsetVector::begin()
786 return iterator (0, *this);
791 * @brief End iterator.
794 LArCompactSubsetVector::iterator LArCompactSubsetVector::end()
796 return iterator (m_febids.size(), *this);
801 * @brief Begin iterator.
804 LArCompactSubsetVector::const_iterator LArCompactSubsetVector::begin() const
806 return const_iterator (0, *this);
811 * @brief End iterator.
814 LArCompactSubsetVector::const_iterator LArCompactSubsetVector::end() const
816 return const_iterator (m_febids.size(), *this);
821 * @brief Return a reference to a FEB ID variable.
822 * @param febIndex Index of the desired FEB ID.
825 LArCompactSubsetVector::FebId&
826 LArCompactSubsetVector::febIdRef (size_t febIndex)
828 return m_febids[febIndex];
833 * @brief Return a reference to a FEB ID variable.
834 * @param febIndex Index of the desired FEB ID.
837 const LArCompactSubsetVector::FebId&
838 LArCompactSubsetVector::febIdRef (size_t febIndex) const
840 return m_febids[febIndex];
845 * @brief Return the number of channels for a given FEB index.
846 * @param febIndex The index of the FEB to query.
849 size_t LArCompactSubsetVector::febSize (unsigned int febIndex) const
851 assert (febIndex+1 < m_indices.size());
852 return m_indices[febIndex+1] - m_indices[febIndex];
857 * @brief Return the index of the first channel for a FEB index.
858 * @param febIndex The index of the FEB to query.
860 * If febIndex is the number of FEBs, then this returns
861 * the total number of channels.
865 LArCompactSubsetVector::chanIndex (unsigned int febIndex) const
867 assert (febIndex < m_indices.size());
868 return m_indices[febIndex];
873 * @brief Return the number of time bins used in this subset.
876 size_t LArCompactSubsetVector::getChanSize() const
883 * @brief Return the number of time bins for channel index CHAN.
884 * @param chan The channel index to query.
886 * This is either the same as getChanSize(), or 0 if this channel
890 size_t LArCompactSubsetVector::getSize (unsigned int chan) const
894 int slot = m_slots[chan * m_chanSize];
902 * @brief Return the time offset for channel index CHAN.
903 * @param chan The channel index to query.
905 * We currently assume that this is the same for all channels,
906 * so CHAN is ignored.
909 float LArCompactSubsetVector::timeOffset (unsigned int /*chan*/) const
916 * @brief Return the time bin width for channel index CHAN.
917 * @param chan The channel index to query.
919 * We currently assume that this is the same for all channels,
920 * so CHAN is ignored.
923 float LArCompactSubsetVector::timeBinWidth (unsigned int /*chan*/) const
925 return m_timeBinWidth;
930 * @brief Helper used by LArConditionsSubset::assign.
931 * @param otherBeg Start of the range to copy.
932 * @param otherEnd End of the range to copy.
933 * @param to The subset to which to copy.
934 * @param copier Helper to copy a single payload object.
936 template <class T, class OTHERIT, class COPIER>
937 void LArCompactSubsetVector::copySubset (OTHERIT otherBeg,
939 LArCompactSubsetVector& to,
942 to.resize (otherEnd - otherBeg);
944 for (; otherBeg != otherEnd; ++otherBeg, ++ndx) {
945 to[ndx].first = (*otherBeg).first;
946 unsigned int nChannels = (*otherBeg).second.size();
947 to[ndx].second.resize(nChannels);
948 for (size_t i = 0; i < nChannels; i++) {
950 copier ((*otherBeg).second[i], tmp);
951 to[ndx].second[i] = tmp;