ATLAS Offline Software
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$
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),
51  m_timeBinWidth (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 
102 void 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 
150 void 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 
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 
LArCompactSubsetVector::m_data
std::vector< float > m_data
The wave data.
Definition: LArCompactSubset.h:910
LArCompactSubset.h
A more compact way of storing shape/ofc data.
fitman.sz
sz
Definition: fitman.py:527
LAr2DWaveBase::nWaves
static const unsigned int nWaves
The number of different types of waves we store.
Definition: LAr2DWaveBase.h:52
LArCompactSubsetVector::setData
void setData(unsigned int which, unsigned int chan, size_t tbin, size_t chanSize, const LArVectorProxy &from)
Set wave data for a channel.
Definition: LArCompactSubset.cxx:177
LArCompactSubsetVector::m_nSamples
unsigned int m_nSamples
Number of samples per wave. 0 before any waves have been added.
Definition: LArCompactSubset.h:884
LArCompactSubsetVector::resize
void resize(size_t sz)
Change the size of the vector.
Definition: LArCompactSubset.cxx:64
LArCompactSubsetConstChannelProxy::m_chan
unsigned int m_chan
Channel index to which we're referring.
Definition: LArCompactSubset.h:166
LArCompactSubsetChannelProxy::m_subset_nc
LArCompactSubsetVector * m_subset_nc
Subset within which we live (non-const). Null for an invalid proxy.
Definition: LArCompactSubset.h:211
LArCompactSubsetVector::getData
LArVectorProxy getData(unsigned int which, unsigned int chan, size_t tbin) const
Retrieve wave data.
Definition: LArCompactSubset.cxx:122
LArCompactSubsetVector::m_slots
std::vector< int > m_slots
Map from channel indices to wave slots.
Definition: LArCompactSubset.h:905
ReadCellNoiseFromCool.chan
chan
Definition: ReadCellNoiseFromCool.py:52
LArCompactSubsetVector::nWaves
static const unsigned int nWaves
Number of wave types we store.
Definition: LArCompactSubset.h:533
LArCompactSubsetVector::m_timeOffset
float m_timeOffset
Time parameters.
Definition: LArCompactSubset.h:888
python.Utils.unixtools.which
def which(filename, env=os.environ)
UNIX-style which ---------------------------------------------------------—.
Definition: unixtools.py:39
WriteBchToCool.beg
beg
Definition: WriteBchToCool.py:69
LArCompactSubsetChannelProxy::assign
void assign(const LAr2DWaveBase &other)
Initialize the referenced data from a standalone object.
Definition: LArCompactSubset.cxx:27
LArCompactSubsetVector::shrink_to_fit
void shrink_to_fit()
Release any allocated but unused storage.
Definition: LArCompactSubset.cxx:85
LArCompactSubsetVector::resizeChanVec
void resizeChanVec(size_t febIndex, size_t sz)
Resize one channel vector.
Definition: LArCompactSubset.cxx:102
LArCompactSubsetVector::timeOffset
float timeOffset(unsigned int chan) const
Return the time offset for channel index CHAN.
LArCompactSubsetVector::m_timeBinWidth
float m_timeBinWidth
Definition: LArCompactSubset.h:889
LArCompactSubsetVector::end
iterator end()
End iterator.
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
LAr2DWaveBase
Per-channel class holding wave information in time bins.
Definition: LAr2DWaveBase.h:49
LArCompactSubsetVector::m_indices
std::vector< unsigned int > m_indices
Map from FEB indices to channel indices.
Definition: LArCompactSubset.h:899
LArCompactSubsetVector::LArCompactSubsetVector
LArCompactSubsetVector(size_t nfeb=0)
Constructor.
Definition: LArCompactSubset.cxx:47
LArCompactSubsetVector::timeBinWidth
float timeBinWidth(unsigned int chan) const
Return the time bin width for channel index CHAN.
LArCompactSubsetVector::setTimings
void setTimings(unsigned int chan, float timeOffset, float timeBinWidth)
Set timing information for a channel.
Definition: LArCompactSubset.cxx:150
calibdata.copy
bool copy
Definition: calibdata.py:27
LAr2DWaveBase.h
Per-channel class holding wave information in time bins.
LArCompactSubsetVector::m_febids
std::vector< FebId > m_febids
Vector of stored FebIds.
Definition: LArCompactSubset.h:894
LArCompactSubsetVector::m_chanSize
unsigned int m_chanSize
Number of time bins per channels. 0 before any waves have been added.
Definition: LArCompactSubset.h:881
LArVectorProxy
Proxy for accessing a range of float values like a vector.
Definition: LArVectorProxy.h:38