ATLAS Offline Software
Loading...
Searching...
No Matches
LArCompactSubset.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3*/
4
5// $Id$
12
13
16#include <cstdlib>
17#include <cassert>
18
19
20//=========================================================================
21
22
28{
29 size_t chanSize = other.waveSize(0);
30 m_subset_nc->setTimings (m_chan, other.timeOffset(), other.timeBinWidth());
31 for (unsigned int which = 0; which < LAr2DWaveBase::nWaves; ++which) {
32 assert (chanSize == other.waveSize(which));
33 for (unsigned int tbin = 0; tbin < chanSize; tbin++)
34 m_subset_nc->setData (which, m_chan, tbin, chanSize,
35 other.wave(which, tbin));
36 }
37}
38
39
40//==========================================================================
41
42
48 : m_chanSize (0),
49 m_nSamples (0),
50 m_timeOffset (0),
52 m_febids (nfeb),
53 m_indices (nfeb+1)
54{
55}
56
57
65{
66 size_t oldsz = m_febids.size();
67 m_febids.resize (sz);
68 m_indices.resize (sz+1);
69
70 if (sz >= oldsz) {
71 for (size_t j = oldsz+1; j < sz+1; j++)
72 m_indices[j] = m_indices[oldsz];
73 }
74 else {
75 abort();
76 // Unimplemented.
77 }
78}
79
80
86{
87 std::vector<float> tmp_data (m_data);
88 m_data.swap (tmp_data);
89
90 std::vector<int> tmp_slots (m_slots);
91 m_slots.swap (tmp_slots);
92}
93
94
102void LArCompactSubsetVector::resizeChanVec (size_t febIndex, size_t sz)
103{
104 assert (m_indices[febIndex+1] == m_indices.back());
105 size_t cursz = m_indices[febIndex+1] - m_indices[febIndex];
106 if (sz == cursz) return;
107 int newend = m_indices[febIndex] + sz;
108 for (size_t j = febIndex+1; j < m_indices.size(); j++)
109 m_indices[j] = newend;
110 m_slots.resize (m_slots.size() + (sz - cursz) * m_chanSize, -1);
111}
112
113
114
123 unsigned int chan,
124 size_t tbin) const
125{
126 assert (which < nWaves);
127 int slot = m_slots[chan * m_chanSize + tbin];
128 const float* beg = nullptr;
129 const float* end = nullptr;
130 if (slot >= 0) {
131 size_t nsamp = m_nSamples;
132 const float* chanstart = &m_data[slot * nWaves * nsamp];
133 beg = chanstart + which * nsamp;
134 end = beg + nsamp;
135 }
136 return LArVectorProxy (beg, end);
137}
138
139
150void LArCompactSubsetVector::setTimings (unsigned int /*chan*/,
151 float timeOffset,
152 float timeBinWidth)
153{
154 if (m_data.empty()) {
157 }
158 else {
159 assert (m_timeOffset == timeOffset);
160 assert (m_timeBinWidth == timeBinWidth);
161 }
162}
163
164
177void LArCompactSubsetVector::setData (unsigned int which,
178 unsigned int chan,
179 size_t tbin,
180 size_t chanSize,
181 const LArVectorProxy& from)
182{
183 assert (which < nWaves);
184
185 if (m_chanSize == 0 &&
186 m_nSamples == 0)
187 {
188 m_chanSize = chanSize;
189 m_nSamples = from.size();
190 m_slots.resize (m_indices.back() * m_chanSize, -1);
191 }
192 else {
193 assert (m_chanSize == chanSize);
194 assert (m_nSamples == from.size());
195 }
196
197 int slot = m_slots[chan * m_chanSize + tbin];
198 if (slot < 0) {
199 slot = m_data.size() / (nWaves * m_nSamples);
200 m_data.resize ((slot+1) * (nWaves * m_nSamples));
201 m_slots[chan * m_chanSize + tbin] = slot;
202 }
203
204 std::copy (from.begin(), from.end(),
205 &m_data[(slot * nWaves + which) * m_nSamples]);
206}
207
208
Per-channel class holding wave information in time bins.
A more compact way of storing shape/ofc data.
Per-channel class holding wave information in time bins.
static const unsigned int nWaves
The number of different types of waves we store.
LArCompactSubsetVector * m_subset_nc
Subset within which we live (non-const). Null for an invalid proxy.
void assign(const LAr2DWaveBase &other)
Initialize the referenced data from a standalone object.
unsigned int m_chan
Channel index to which we're referring.
std::vector< int > m_slots
Map from channel indices to wave slots.
float timeBinWidth(unsigned int chan) const
Return the time bin width for channel index CHAN.
float m_timeOffset
Time parameters.
void shrink_to_fit()
Release any allocated but unused storage.
std::vector< float > m_data
The wave data.
void resize(size_t sz)
Change the size of the vector.
void setData(unsigned int which, unsigned int chan, size_t tbin, size_t chanSize, const LArVectorProxy &from)
Set wave data for a channel.
unsigned int m_chanSize
Number of time bins per channels. 0 before any waves have been added.
std::vector< FebId > m_febids
Vector of stored FebIds.
std::vector< unsigned int > m_indices
Map from FEB indices to channel indices.
void resizeChanVec(size_t febIndex, size_t sz)
Resize one channel vector.
iterator end()
End iterator.
float timeOffset(unsigned int chan) const
Return the time offset for channel index CHAN.
static const unsigned int nWaves
Number of wave types we store.
LArVectorProxy getData(unsigned int which, unsigned int chan, size_t tbin) const
Retrieve wave data.
unsigned int m_nSamples
Number of samples per wave. 0 before any waves have been added.
void setTimings(unsigned int chan, float timeOffset, float timeBinWidth)
Set timing information for a channel.
LArCompactSubsetVector(size_t nfeb=0)
Constructor.
Proxy for accessing a range of float values like a vector.