ATLAS Offline Software
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Attributes | List of all members
LArCompactSubsetVector Class Reference

This acts like a vector of FEB ID / channel vector pairs. More...

#include <LArCompactSubset.h>

Collaboration diagram for LArCompactSubsetVector:

Classes

class  const_iterator
 const_iterator class. More...
 
class  iterator
 Iterator class. More...
 

Public Types

typedef unsigned int FebId
 Type for FEB IDs. Would be better to get this from somewhere common... More...
 

Public Member Functions

 LArCompactSubsetVector (size_t nfeb=0)
 Constructor. More...
 
size_t size () const
 Return the size of this vector. More...
 
LArCompactSubsetFebPair operator[] (size_t i)
 Vector indexing. More...
 
const LArCompactSubsetConstFebPair operator[] (size_t i) const
 Vector indexing. More...
 
iterator begin ()
 Begin iterator. More...
 
iterator end ()
 End iterator. More...
 
const_iterator begin () const
 Begin iterator. More...
 
const_iterator end () const
 End iterator. More...
 
void resize (size_t sz)
 Change the size of the vector. More...
 
void shrink_to_fit ()
 Release any allocated but unused storage. More...
 
FebIdfebIdRef (size_t febIndex)
 Return a reference to a FEB ID variable. More...
 
const FebIdfebIdRef (size_t febIndex) const
 Return a reference to a FEB ID variable. More...
 
size_t febSize (unsigned int febIndex) const
 Return the number of channels for a given FEB index. More...
 
unsigned int chanIndex (unsigned int febIndex) const
 Return the index of the first channel for a FEB index. More...
 
void resizeChanVec (size_t febIndex, size_t sz)
 Resize one channel vector. More...
 
size_t getChanSize () const
 Return the number of time bins used in this subset. More...
 
size_t getSize (unsigned int chan) const
 Return the number of time bins for channel index CHAN. More...
 
float timeOffset (unsigned int chan) const
 Return the time offset for channel index CHAN. More...
 
float timeBinWidth (unsigned int chan) const
 Return the time bin width for channel index CHAN. More...
 
LArVectorProxy getData (unsigned int which, unsigned int chan, size_t tbin) const
 Retrieve wave data. More...
 
void setTimings (unsigned int chan, float timeOffset, float timeBinWidth)
 Set timing information for a channel. More...
 
void setData (unsigned int which, unsigned int chan, size_t tbin, size_t chanSize, const LArVectorProxy &from)
 Set wave data for a channel. More...
 

Static Public Member Functions

template<class T , class OTHERIT , class COPIER >
static void copySubset (OTHERIT otherBeg, OTHERIT otherEnd, LArCompactSubsetVector &to, COPIER copier)
 Helper used by LArConditionsSubset::assign. More...
 

Static Public Attributes

static const unsigned int nWaves = 2
 Number of wave types we store. More...
 

Private Attributes

unsigned int m_chanSize
 Number of time bins per channels. 0 before any waves have been added. More...
 
unsigned int m_nSamples
 Number of samples per wave. 0 before any waves have been added. More...
 
float m_timeOffset
 Time parameters. More...
 
float m_timeBinWidth
 
std::vector< FebIdm_febids
 Vector of stored FebIds. More...
 
std::vector< unsigned int > m_indices
 Map from FEB indices to channel indices. More...
 
std::vector< int > m_slots
 Map from channel indices to wave slots. More...
 
std::vector< float > m_data
 The wave data. More...
 

Detailed Description

This acts like a vector of FEB ID / channel vector pairs.

This is also the class which contains all the data.

Definition at line 529 of file LArCompactSubset.h.

Member Typedef Documentation

◆ FebId

typedef unsigned int LArCompactSubsetVector::FebId

Type for FEB IDs. Would be better to get this from somewhere common...

Definition at line 536 of file LArCompactSubset.h.

Constructor & Destructor Documentation

◆ LArCompactSubsetVector()

LArCompactSubsetVector::LArCompactSubsetVector ( size_t  nfeb = 0)

Constructor.

Parameters
nfebInitial number of FEBs to allocate.

Definition at line 47 of file LArCompactSubset.cxx.

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 }

Member Function Documentation

◆ begin() [1/2]

iterator LArCompactSubsetVector::begin ( )

Begin iterator.

◆ begin() [2/2]

const_iterator LArCompactSubsetVector::begin ( ) const

Begin iterator.

◆ chanIndex()

unsigned int LArCompactSubsetVector::chanIndex ( unsigned int  febIndex) const

Return the index of the first channel for a FEB index.

Parameters
febIndexThe index of the FEB to query.

If febIndex is the number of FEBs, then this returns the total number of channels.

◆ copySubset()

template<class T , class OTHERIT , class COPIER >
static void LArCompactSubsetVector::copySubset ( OTHERIT  otherBeg,
OTHERIT  otherEnd,
LArCompactSubsetVector to,
COPIER  copier 
)
static

Helper used by LArConditionsSubset::assign.

Parameters
otherBegStart of the range to copy.
otherEndEnd of the range to copy.
toThe subset to which to copy.
copierHelper to copy a single payload object.

◆ end() [1/2]

iterator LArCompactSubsetVector::end ( )

End iterator.

◆ end() [2/2]

const_iterator LArCompactSubsetVector::end ( ) const

End iterator.

◆ febIdRef() [1/2]

FebId& LArCompactSubsetVector::febIdRef ( size_t  febIndex)

Return a reference to a FEB ID variable.

Parameters
febIndexIndex of the desired FEB ID.

◆ febIdRef() [2/2]

const FebId& LArCompactSubsetVector::febIdRef ( size_t  febIndex) const

Return a reference to a FEB ID variable.

Parameters
febIndexIndex of the desired FEB ID.

◆ febSize()

size_t LArCompactSubsetVector::febSize ( unsigned int  febIndex) const

Return the number of channels for a given FEB index.

Parameters
febIndexThe index of the FEB to query.

◆ getChanSize()

size_t LArCompactSubsetVector::getChanSize ( ) const

Return the number of time bins used in this subset.

◆ getData()

LArVectorProxy LArCompactSubsetVector::getData ( unsigned int  which,
unsigned int  chan,
size_t  tbin 
) const

Retrieve wave data.

Parameters
whichThe wave type to retrieve.
chanThe index of the channel to retrieve.
tbinThe time bin index to retrieve.

Definition at line 122 of file LArCompactSubset.cxx.

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 }

◆ getSize()

size_t LArCompactSubsetVector::getSize ( unsigned int  chan) const

Return the number of time bins for channel index CHAN.

Parameters
chanThe channel index to query.

This is either the same as getChanSize(), or 0 if this channel is empty.

◆ operator[]() [1/2]

LArCompactSubsetFebPair LArCompactSubsetVector::operator[] ( size_t  i)

Vector indexing.

Parameters
iIndex to look up.

◆ operator[]() [2/2]

const LArCompactSubsetConstFebPair LArCompactSubsetVector::operator[] ( size_t  i) const

Vector indexing.

Parameters
iIndex to look up.

◆ resize()

void LArCompactSubsetVector::resize ( size_t  sz)

Change the size of the vector.

Parameters
szNew size.

Restriction: The size can only be increased.

Definition at line 64 of file LArCompactSubset.cxx.

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 }

◆ resizeChanVec()

void LArCompactSubsetVector::resizeChanVec ( size_t  febIndex,
size_t  sz 
)

Resize one channel vector.

Parameters
febIndexThe index of the vector to resize.
szThe new size of the vector.

Restriction: Only the last index may be resized.

Definition at line 102 of file LArCompactSubset.cxx.

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 }

◆ setData()

void LArCompactSubsetVector::setData ( unsigned int  which,
unsigned int  chan,
size_t  tbin,
size_t  chanSize,
const LArVectorProxy from 
)

Set wave data for a channel.

Parameters
whichWave type to set.
chanChannel index to set.
tbinTime bin index to set.
chanSizeNumber of time bins for this channel.
fromWave data.

We currently assume that all non-empty channels within a subset have the same number of time bins and samples. We'll trip an assertion if that's not the case.

Definition at line 177 of file LArCompactSubset.cxx.

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 }

◆ setTimings()

void LArCompactSubsetVector::setTimings ( unsigned int  chan,
float  timeOffset,
float  timeBinWidth 
)

Set timing information for a channel.

Parameters
chanChannel index to set.
timeOffsetTime offset to set.
timeBinWidthTime bin width to set.

We currently assume that all non-empty channels within a subset have the same values for these parameters. We'll trip an assertion if that's not the case.

Definition at line 150 of file LArCompactSubset.cxx.

153 {
154  if (m_data.empty()) {
157  }
158  else {
159  assert (m_timeOffset == timeOffset);
160  assert (m_timeBinWidth == timeBinWidth);
161  }
162 }

◆ shrink_to_fit()

void LArCompactSubsetVector::shrink_to_fit ( )

Release any allocated but unused storage.

Called by the P->T converter after conversion is complete.

Definition at line 85 of file LArCompactSubset.cxx.

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 }

◆ size()

size_t LArCompactSubsetVector::size ( ) const

Return the size of this vector.

◆ timeBinWidth()

float LArCompactSubsetVector::timeBinWidth ( unsigned int  chan) const

Return the time bin width for channel index CHAN.

Parameters
chanThe channel index to query.

We currently assume that this is the same for all channels, so CHAN is ignored.

◆ timeOffset()

float LArCompactSubsetVector::timeOffset ( unsigned int  chan) const

Return the time offset for channel index CHAN.

Parameters
chanThe channel index to query.

We currently assume that this is the same for all channels, so CHAN is ignored.

Member Data Documentation

◆ m_chanSize

unsigned int LArCompactSubsetVector::m_chanSize
private

Number of time bins per channels. 0 before any waves have been added.

Definition at line 881 of file LArCompactSubset.h.

◆ m_data

std::vector<float> LArCompactSubsetVector::m_data
private

The wave data.

Definition at line 910 of file LArCompactSubset.h.

◆ m_febids

std::vector<FebId> LArCompactSubsetVector::m_febids
private

Vector of stored FebIds.

Definition at line 894 of file LArCompactSubset.h.

◆ m_indices

std::vector<unsigned int> LArCompactSubsetVector::m_indices
private

Map from FEB indices to channel indices.

Definition at line 899 of file LArCompactSubset.h.

◆ m_nSamples

unsigned int LArCompactSubsetVector::m_nSamples
private

Number of samples per wave. 0 before any waves have been added.

Definition at line 884 of file LArCompactSubset.h.

◆ m_slots

std::vector<int> LArCompactSubsetVector::m_slots
private

Map from channel indices to wave slots.

Definition at line 905 of file LArCompactSubset.h.

◆ m_timeBinWidth

float LArCompactSubsetVector::m_timeBinWidth
private

Definition at line 889 of file LArCompactSubset.h.

◆ m_timeOffset

float LArCompactSubsetVector::m_timeOffset
private

Time parameters.

We assume that these are the same for all non-empty channels within a subset.

Definition at line 888 of file LArCompactSubset.h.

◆ nWaves

const unsigned int LArCompactSubsetVector::nWaves = 2
static

Number of wave types we store.

Definition at line 533 of file LArCompactSubset.h.


The documentation for this class was generated from the following files:
LArCompactSubsetVector::m_data
std::vector< float > m_data
The wave data.
Definition: LArCompactSubset.h:910
fitman.sz
sz
Definition: fitman.py:527
LArCompactSubsetVector::m_nSamples
unsigned int m_nSamples
Number of samples per wave. 0 before any waves have been added.
Definition: LArCompactSubset.h:884
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
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.
LArCompactSubsetVector::m_indices
std::vector< unsigned int > m_indices
Map from FEB indices to channel indices.
Definition: LArCompactSubset.h:899
LArCompactSubsetVector::timeBinWidth
float timeBinWidth(unsigned int chan) const
Return the time bin width for channel index CHAN.
calibdata.copy
bool copy
Definition: calibdata.py:27
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