ATLAS Offline Software
Loading...
Searching...
No Matches
LArCompactSubset.icc
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4/**
5 * @file LArRawConditions/LArCompactSubset.icc
6 * @author scott snyder <snyder@bnl.gov>
7 * @date Apr, 2011
8 * @brief A more compact way of storing shape/ofc data.
9 *
10 */
11
12
13//=========================================================================
14
15
16/**
17 * @brief Default constructor. Makes an invalid proxy.
18 */
19inline
20LArCompactSubsetConstChannelProxy::LArCompactSubsetConstChannelProxy()
21 : m_chan (0),
22 m_subset (nullptr)
23{
24}
25
26
27/**
28 * @brief Constructor.
29 * @brief chan The channel index we reference.
30 * @brief subset The subset object within which we live.
31 */
32inline
33LArCompactSubsetConstChannelProxy::LArCompactSubsetConstChannelProxy
34 (unsigned int chan,
35 const LArCompactSubsetVector& subset)
36 : m_chan (chan),
37 m_subset (&subset)
38{
39}
40
41
42/**
43 * @brief Test to see if the proxy is valid.
44 */
45inline
46bool LArCompactSubsetConstChannelProxy::isValid() const
47{
48 return m_subset != 0;
49}
50
51
52/**
53 * @brief Return the time offset for this channel.
54 */
55inline
56float LArCompactSubsetConstChannelProxy::timeOffset() const
57{
58 return m_subset->timeOffset (m_chan);
59}
60
61
62/**
63 * @brief Return the time bin width for this channel.
64 */
65inline
66float LArCompactSubsetConstChannelProxy::timeBinWidth() const
67{
68 return m_subset->timeBinWidth (m_chan);
69}
70
71
72/**
73 * @brief Return the number of time bins for this channel.
74 */
75inline
76size_t LArCompactSubsetConstChannelProxy::getSize () const
77{
78 return m_subset->getSize (m_chan);
79}
80
81
82/**
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.
86 */
87inline
88LArVectorProxy
89LArCompactSubsetConstChannelProxy::getData (unsigned int which,
90 size_t tbin) const
91{
92 return m_subset->getData (which, m_chan, tbin);
93}
94
95
96/**
97 * @brief Return number of shape time bins.
98 */
99inline
100size_t LArCompactSubsetConstChannelProxy::shapeSize() const
101{
102 return m_subset->getSize (m_chan);
103}
104
105
106/**
107 * @brief Return number of shape derivative time bins.
108 */
109inline
110size_t LArCompactSubsetConstChannelProxy::shapeDerSize() const
111{
112 return m_subset->getSize (m_chan);
113}
114
115
116/**
117 * @brief Return shape data.
118 * @param tbin Time bin index.
119 */
120inline
121ILArShape::ShapeRef_t
122LArCompactSubsetConstChannelProxy::shape (size_t tbin) const
123{
124 return m_subset->getData (0, m_chan, tbin);
125}
126
127
128/**
129 * @brief Return shape derivative data.
130 * @param tbin Time bin index.
131 */
132inline
133ILArShape::ShapeRef_t
134LArCompactSubsetConstChannelProxy::shapeDer (size_t tbin) const
135{
136 return m_subset->getData (1, m_chan, tbin);
137}
138
139
140/**
141 * @brief Return number of time bins for OFC A coefficients.
142 */
143inline
144size_t
145LArCompactSubsetConstChannelProxy::OFC_aSize () const
146{
147 return m_subset->getSize (m_chan);
148}
149
150
151/**
152 * @brief Return number of time bins for OFC B coefficients.
153 */
154inline
155size_t
156LArCompactSubsetConstChannelProxy::OFC_bSize () const
157{
158 return m_subset->getSize (m_chan);
159}
160
161
162/**
163 * @brief Return OFC A coefficients.
164 * @param tbin Time bin index.
165 */
166inline
167ILArOFC::OFCRef_t
168LArCompactSubsetConstChannelProxy::OFC_a (size_t tbin) const
169{
170 return m_subset->getData (0, m_chan, tbin);
171}
172
173
174/**
175 * @brief Return OFC B coefficients.
176 * @param tbin Time bin index.
177 */
178inline
179ILArOFC::OFCRef_t
180LArCompactSubsetConstChannelProxy::OFC_b (size_t tbin) const
181{
182 return m_subset->getData (1, m_chan, tbin);
183}
184
185
186/**
187 * @brief Default constructor. Makes an invalid proxy.
188 */
189inline
190LArCompactSubsetChannelProxy::LArCompactSubsetChannelProxy()
191 : m_subset_nc (nullptr)
192{
193}
194
195
196/**
197 * @brief Constructor.
198 * @brief chan The channel index we reference.
199 * @brief subset The subset object within which we live.
200 */
201inline
202LArCompactSubsetChannelProxy::LArCompactSubsetChannelProxy
203 (unsigned int chan,
204 LArCompactSubsetVector& subset)
205 : LArCompactSubsetConstChannelProxy (chan, subset),
206 m_subset_nc (&subset)
207{
208}
209
210
211/**
212 * @brief Initialize the referenced data from a standalone object.
213 * @param other The object from which to initialize.
214 */
215inline
216LArCompactSubsetChannelProxy&
217LArCompactSubsetChannelProxy::operator= (const LAr2DWaveBase& other)
218{
219 assign (other);
220 return *this;
221}
222
223
224//=========================================================================
225
226
227/**
228 * @brief Constructor.
229 * @param p Pointer to a channel proxy.
230 */
231inline
232LArCompactSubsetChannelPointer::LArCompactSubsetChannelPointer
233 (const LArCompactSubsetChannelProxy* p)
234 : LArCompactSubsetChannelProxy (*p)
235{
236}
237
238
239/**
240 * @brief `Dereference' the pointer.
241 */
242inline
243LArCompactSubsetChannelProxy
244LArCompactSubsetChannelPointer::operator*() const
245{
246 return *this;
247}
248
249
250/**
251 * @brief Test for a valid pointer.
252 */
253inline
254LArCompactSubsetChannelPointer::operator bool() const
255{
256 return isValid();
257}
258
259
260//=========================================================================
261
262
263/**
264 * @brief Default constructor.
265 */
266inline
267LArCompactSubsetChannelVector::const_iterator::const_iterator()
268 : m_chan(0),
269 m_subset(0)
270{
271}
272
273
274/**
275 * @brief Constructor from channel index and subset reference.
276 */
277inline
278LArCompactSubsetChannelVector::const_iterator::const_iterator
279 (unsigned int chan, const LArCompactSubsetVector& subset)
280 : m_chan (chan),
281 m_subset (&subset)
282{
283}
284
285
286/**
287 * @brief Iterator increment.
288 */
289inline
290LArCompactSubsetChannelVector::const_iterator&
291LArCompactSubsetChannelVector::const_iterator::operator++()
292{
293 ++m_chan;
294 return *this;
295}
296
297
298/**
299 * @brief Iterator dereference.
300 * Yields a channel proxy.
301 */
302inline
303LArCompactSubsetConstChannelProxy
304LArCompactSubsetChannelVector::const_iterator::operator*() const
305{
306 return LArCompactSubsetConstChannelProxy (m_chan, *m_subset);
307}
308
309
310/**
311 * @brief Iterator equality test.
312 */
313inline
314bool LArCompactSubsetChannelVector::const_iterator::operator==
315 (const const_iterator& other) const
316{
317 return m_chan == other.m_chan;
318}
319
320
321/**
322 * @brief Iterator inequality test.
323 */
324inline
325bool LArCompactSubsetChannelVector::const_iterator::operator!=
326 (const const_iterator& other) const
327{
328 return m_chan != other.m_chan;
329}
330
331
332/**
333* @brief Adjust iterator backwards.
334* @param delta Amount by which to adjust.
335*/
336inline
337LArCompactSubsetChannelVector::const_iterator
338LArCompactSubsetChannelVector::const_iterator::operator-
339 (size_t delta) const
340{
341 return const_iterator (m_chan - delta, *m_subset);
342}
343
344
345/**
346 * @brief Iterator difference.
347 * @param other Other iterator for difference.
348 */
349inline
350long
351LArCompactSubsetChannelVector::const_iterator::operator-
352 (const const_iterator& other) const
353{
354 return m_chan - other.m_chan;
355}
356
357
358/**
359 * @brief Constructor.
360 * @param febIndex FEB index with which we're associated.
361 * @param subset Subset within which we live.
362 */
363inline
364LArCompactSubsetChannelVector::LArCompactSubsetChannelVector
365 (size_t febIndex, LArCompactSubsetVector* subset)
366 : m_febIndex (febIndex),
367 m_subset (subset)
368{
369}
370
371
372/**
373 * @brief Return the size of this vector (number of channels for this FEB).
374 */
375inline
376size_t LArCompactSubsetChannelVector::size() const
377{
378 return m_subset->febSize (m_febIndex);
379}
380
381
382/**
383 * @brief Vector indexing. Returns a channel proxy.
384 * @param i Channel index within the vector.
385 */
386inline
387LArCompactSubsetChannelProxy
388LArCompactSubsetChannelVector::operator[] (size_t i)
389{
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);
393}
394
395
396/**
397 * @brief Vector indexing. Returns a channel proxy.
398 * @param i Channel index within the vector.
399 */
400inline
401LArCompactSubsetConstChannelProxy
402LArCompactSubsetChannelVector::operator[] (size_t i) const
403{
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);
407}
408
409
410/**
411 * @brief Begin iterator.
412 */
413inline
414LArCompactSubsetChannelVector::const_iterator
415LArCompactSubsetChannelVector::begin() const
416{
417 return const_iterator (m_subset->chanIndex (m_febIndex), *m_subset);
418}
419
420
421/**
422 * @brief End iterator.
423 */
424inline
425LArCompactSubsetChannelVector::const_iterator
426LArCompactSubsetChannelVector::end() const
427{
428 return const_iterator (m_subset->chanIndex (m_febIndex+1), *m_subset);
429}
430
431
432/**
433 * @brief Resize this vector.
434 * @param sz The desired new size.
435 *
436 * Restriction: Only the vector associated with the last FEB index
437 * in the subset may be resized.
438 */
439inline
440void LArCompactSubsetChannelVector::resize (size_t sz)
441{
442 m_subset->resizeChanVec (m_febIndex, sz);
443}
444
445
446
447/**
448 * @brief Constructor.
449 * @param febIndex FEB index with which we're associated.
450 * @param subset Subset within which we live.
451 */
452inline
453LArCompactSubsetConstChannelVector::LArCompactSubsetConstChannelVector
454 (size_t febIndex, const LArCompactSubsetVector* subset)
455 : m_febIndex (febIndex),
456 m_subset (subset)
457{
458}
459
460
461/**
462 * @brief Return the size of this vector (number of channels for this FEB).
463 */
464inline
465size_t LArCompactSubsetConstChannelVector::size() const
466{
467 return m_subset->febSize (m_febIndex);
468}
469
470
471/**
472 * @brief Vector indexing. Returns a channel proxy.
473 * @param i Channel index within the vector.
474 */
475inline
476LArCompactSubsetConstChannelProxy
477LArCompactSubsetConstChannelVector::operator[] (size_t i) const
478{
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);
482}
483
484
485//=========================================================================
486
487
488/**
489 * @brief Default constructor. Makes an invalid `pointer'.
490 */
491inline
492LArCompactSubsetChannelVectorPointer::
493LArCompactSubsetChannelVectorPointer()
494 : LArCompactSubsetChannelVector (0, 0)
495{
496}
497
498
499/**
500 * @brief Constructor.
501 * @param p Pointer to a channel vector proxy.
502 */
503inline
504LArCompactSubsetChannelVectorPointer::LArCompactSubsetChannelVectorPointer
505 (const LArCompactSubsetChannelVector* p)
506 : LArCompactSubsetChannelVector (*p)
507{
508}
509
510
511/**
512 * @brief `Dereference' the pointer.
513 */
514inline
515LArCompactSubsetChannelVector
516LArCompactSubsetChannelVectorPointer::operator*()
517{
518 return LArCompactSubsetChannelVector (m_febIndex, m_subset);
519}
520
521
522/**
523 * @brief `Dereference' the pointer.
524 */
525inline
526LArCompactSubsetConstChannelVector
527LArCompactSubsetChannelVectorPointer::operator*() const
528{
529 return LArCompactSubsetConstChannelVector (m_febIndex, m_subset);
530}
531
532
533/**
534 * @brief `Dereference' the pointer.
535 */
536inline
537const LArCompactSubsetChannelVector*
538LArCompactSubsetChannelVectorPointer::operator->() const
539{
540 return this;
541}
542
543
544//=========================================================================
545
546
547/**
548 * @brief Constructor.
549 * @param febIndex The index of the pair.
550 * @param subset The subset within which we live.
551 */
552inline
553LArCompactSubsetFebPair::LArCompactSubsetFebPair
554 (size_t febIndex,
555 LArCompactSubsetVector& subset)
556 : first (subset.febIdRef (febIndex)),
557 second (febIndex, &subset)
558{
559}
560
561
562/**
563 * @brief Constructor.
564 * @param febIndex The index of the pair.
565 * @param subset The subset within which we live.
566 */
567inline
568LArCompactSubsetConstFebPair::LArCompactSubsetConstFebPair
569 (size_t febIndex,
570 const LArCompactSubsetVector& subset)
571 : first (subset.febIdRef (febIndex)),
572 second (febIndex, &subset)
573{
574}
575
576
577//=========================================================================
578
579
580/**
581 * @brief Constructor.
582 * @param febIndex The FEB index to which we point.
583 * @param subset The subset within which we live.
584 */
585inline
586LArCompactSubsetVector::iterator::iterator (size_t febIndex,
587 LArCompactSubsetVector& subset)
588 : m_febIndex (febIndex),
589 m_subset (subset)
590{
591}
592
593/**
594 * @brief `Dereference' the iterator.
595 */
596inline
597LArCompactSubsetFebPair
598LArCompactSubsetVector::iterator::operator*()
599{
600 return LArCompactSubsetFebPair (m_febIndex, m_subset);
601}
602
603
604/**
605 * @brief Compare iterators for equality.
606 */
607inline
608bool
609LArCompactSubsetVector::iterator::operator== (const iterator& other) const
610{
611 return m_febIndex == other.m_febIndex;
612}
613
614
615/**
616 * @brief Compare iterators for inequality.
617 */
618inline
619bool
620LArCompactSubsetVector::iterator::operator!= (const iterator& other) const
621{
622 return m_febIndex != other.m_febIndex;
623}
624
625
626/**
627 * @brief Advance iterator.
628 */
629inline
630LArCompactSubsetVector::iterator&
631LArCompactSubsetVector::iterator::operator++()
632{
633 ++m_febIndex;
634 return *this;
635}
636
637
638/**
639 * @brief Adjust iterator.
640 * @param delta Amount by which to advance the iterator.
641 */
642inline
643LArCompactSubsetVector::iterator
644LArCompactSubsetVector::iterator::operator+ (size_t delta)
645{
646 return iterator (m_febIndex + delta, m_subset);
647}
648
649
650/**
651 * @brief Iterator difference.
652 * @param other Other iterator for difference.
653 */
654inline
655LArCompactSubsetVector::iterator::difference_type
656LArCompactSubsetVector::iterator::operator- (const iterator& other)
657{
658 return m_febIndex - other.m_febIndex;
659}
660
661
662/**
663 * @brief Constructor.
664 * @param febIndex The FEB index to which we point.
665 * @param subset The subset within which we live.
666 */
667inline
668LArCompactSubsetVector::const_iterator::const_iterator (size_t febIndex,
669 const LArCompactSubsetVector& subset)
670 : m_febIndex (febIndex),
671 m_subset (subset)
672{
673}
674
675/**
676 * @brief `Dereference' the iterator.
677 */
678inline
679LArCompactSubsetConstFebPair
680LArCompactSubsetVector::const_iterator::operator*()
681{
682 return LArCompactSubsetConstFebPair (m_febIndex, m_subset);
683}
684
685
686/**
687 * @brief Compare iterators for equality.
688 */
689inline
690bool
691LArCompactSubsetVector::const_iterator::operator== (const const_iterator& other) const
692{
693 return m_febIndex == other.m_febIndex;
694}
695
696
697/**
698 * @brief Compare iterators for inequality.
699 */
700inline
701bool
702LArCompactSubsetVector::const_iterator::operator!= (const const_iterator& other) const
703{
704 return m_febIndex != other.m_febIndex;
705}
706
707
708/**
709 * @brief Advance iterator.
710 */
711inline
712LArCompactSubsetVector::const_iterator&
713LArCompactSubsetVector::const_iterator::operator++()
714{
715 ++m_febIndex;
716 return *this;
717}
718
719
720/**
721 * @brief Adjust iterator.
722 * @param delta Amount by which to advance the iterator.
723 */
724inline
725LArCompactSubsetVector::const_iterator
726LArCompactSubsetVector::const_iterator::operator+ (size_t delta) const
727{
728 return const_iterator (m_febIndex + delta, m_subset);
729}
730
731
732/**
733 * @brief Iterator difference.
734 * @param other Other iterator for difference.
735 */
736inline
737LArCompactSubsetVector::const_iterator::difference_type
738LArCompactSubsetVector::const_iterator::operator- (const const_iterator& other) const
739{
740 return m_febIndex - other.m_febIndex;
741}
742
743
744/**
745 * @brief Return the size of this vector.
746 */
747inline
748size_t LArCompactSubsetVector::size() const
749{
750 return m_febids.size();
751}
752
753
754/**
755 * @brief Vector indexing.
756 * @param i Index to look up.
757 */
758inline
759LArCompactSubsetFebPair
760LArCompactSubsetVector::operator[] (size_t i)
761{
762 assert (i < m_febids.size());
763 return LArCompactSubsetFebPair (i, *this);
764}
765
766
767/**
768 * @brief Vector indexing.
769 * @param i Index to look up.
770 */
771inline
772const LArCompactSubsetConstFebPair
773LArCompactSubsetVector::operator[] (size_t i) const
774{
775 assert (i < m_febids.size());
776 return LArCompactSubsetConstFebPair (i, *(LArCompactSubsetVector*)this);
777}
778
779
780/**
781 * @brief Begin iterator.
782 */
783inline
784LArCompactSubsetVector::iterator LArCompactSubsetVector::begin()
785{
786 return iterator (0, *this);
787}
788
789
790/**
791 * @brief End iterator.
792 */
793inline
794LArCompactSubsetVector::iterator LArCompactSubsetVector::end()
795{
796 return iterator (m_febids.size(), *this);
797}
798
799
800/**
801 * @brief Begin iterator.
802 */
803inline
804LArCompactSubsetVector::const_iterator LArCompactSubsetVector::begin() const
805{
806 return const_iterator (0, *this);
807}
808
809
810/**
811 * @brief End iterator.
812 */
813inline
814LArCompactSubsetVector::const_iterator LArCompactSubsetVector::end() const
815{
816 return const_iterator (m_febids.size(), *this);
817}
818
819
820/**
821 * @brief Return a reference to a FEB ID variable.
822 * @param febIndex Index of the desired FEB ID.
823 */
824inline
825LArCompactSubsetVector::FebId&
826LArCompactSubsetVector::febIdRef (size_t febIndex)
827{
828 return m_febids[febIndex];
829}
830
831
832/**
833 * @brief Return a reference to a FEB ID variable.
834 * @param febIndex Index of the desired FEB ID.
835 */
836inline
837const LArCompactSubsetVector::FebId&
838LArCompactSubsetVector::febIdRef (size_t febIndex) const
839{
840 return m_febids[febIndex];
841}
842
843
844/**
845 * @brief Return the number of channels for a given FEB index.
846 * @param febIndex The index of the FEB to query.
847 */
848inline
849size_t LArCompactSubsetVector::febSize (unsigned int febIndex) const
850{
851 assert (febIndex+1 < m_indices.size());
852 return m_indices[febIndex+1] - m_indices[febIndex];
853}
854
855
856/**
857 * @brief Return the index of the first channel for a FEB index.
858 * @param febIndex The index of the FEB to query.
859 *
860 * If febIndex is the number of FEBs, then this returns
861 * the total number of channels.
862 */
863inline
864unsigned int
865LArCompactSubsetVector::chanIndex (unsigned int febIndex) const
866{
867 assert (febIndex < m_indices.size());
868 return m_indices[febIndex];
869}
870
871
872/**
873 * @brief Return the number of time bins used in this subset.
874 */
875inline
876size_t LArCompactSubsetVector::getChanSize() const
877{
878 return m_chanSize;
879}
880
881
882/**
883 * @brief Return the number of time bins for channel index CHAN.
884 * @param chan The channel index to query.
885 *
886 * This is either the same as getChanSize(), or 0 if this channel
887 * is empty.
888 */
889inline
890size_t LArCompactSubsetVector::getSize (unsigned int chan) const
891{
892 if (m_chanSize == 0)
893 return 0;
894 int slot = m_slots[chan * m_chanSize];
895 if (slot >= 0)
896 return m_chanSize;
897 return 0;
898}
899
900
901/**
902 * @brief Return the time offset for channel index CHAN.
903 * @param chan The channel index to query.
904 *
905 * We currently assume that this is the same for all channels,
906 * so CHAN is ignored.
907 */
908inline
909float LArCompactSubsetVector::timeOffset (unsigned int /*chan*/) const
910{
911 return m_timeOffset;
912}
913
914
915/**
916 * @brief Return the time bin width for channel index CHAN.
917 * @param chan The channel index to query.
918 *
919 * We currently assume that this is the same for all channels,
920 * so CHAN is ignored.
921 */
922inline
923float LArCompactSubsetVector::timeBinWidth (unsigned int /*chan*/) const
924{
925 return m_timeBinWidth;
926}
927
928
929/**
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.
935 */
936template <class T, class OTHERIT, class COPIER>
937void LArCompactSubsetVector::copySubset (OTHERIT otherBeg,
938 OTHERIT otherEnd,
939 LArCompactSubsetVector& to,
940 COPIER copier)
941{
942 to.resize (otherEnd - otherBeg);
943 size_t ndx = 0;
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++) {
949 T tmp;
950 copier ((*otherBeg).second[i], tmp);
951 to[ndx].second[i] = tmp;
952 }
953 }
954}