7#include "Identifier/Identifier.h"
9#include "GaudiKernel/GaudiException.h"
19 void writeTwoBits(std::vector<unsigned char>&
vec,
const unsigned idx,
const unsigned char val) {
20 const auto qr=std::div(idx,4);
21 const unsigned char maskval=(
val&0x3) << 2*qr.rem;
22 vec[qr.quot]|=maskval;
26 unsigned char readTwoBits(
const std::vector<unsigned char>&
vec,
const unsigned idx) {
27 const auto qr=std::div(idx,4);
28 const unsigned char&
v=
vec[qr.quot];
29 return (v>>2*qr.rem) & 0x3;
47 const unsigned nMaxChannels=4*(pers->
m_gain.size());
54 std::vector<short>::const_iterator samplesIt=pers->
m_samples.begin();
55 for(
unsigned idx=0;idx<nMaxChannels;idx++) {
56 const unsigned char gain=readTwoBits(pers->
m_gain,idx);
59 std::vector<short>::const_iterator samplesIt_e=samplesIt+pers->
m_nSamples;
60 std::vector<short> samples(samplesIt,samplesIt_e);
65 samplesIt=samplesIt_e;
75 const unsigned int nChannels=trans->
size();
83 const unsigned hashMax=
m_idHelper->channelHashMax();
86 pers->
m_gain.assign(hashMax/4,0);
90 std::vector<const LArDigit*> digitsvsHash(hashMax,
nullptr);
91 for (
const LArDigit* transDigit : *trans) {
94 log << MSG::ERROR <<
"Encountered LArDigit Container with varying numbers of ADC samples" <<
endmsg;
95 throw GaudiException(
"Encountered LArDigit Container with varying numbers of ADC samples",
96 "LArDigitContainerCnv_p2",StatusCode::FAILURE);
98 digitsvsHash[
h]=transDigit;
102 std::vector<short>::iterator writeIt=pers->
m_samples.begin();
103 std::vector<const LArDigit*>::const_iterator it=digitsvsHash.begin();
104 std::vector<const LArDigit*>::const_iterator it_e=digitsvsHash.end();
105 for (;it!=it_e;++it,++idx) {
112 writeIt=std::copy(dig->
samples().begin(),dig->
samples().end(),writeIt);
std::vector< size_t > vec
Header file for AthHistogramAlgorithm.
a typed memory pool that saves time spent allocation small object.
void reserve(unsigned int size)
Set the desired capacity.
pointer nextElementPtr()
obtain the next available element in pool by pointer pool is resized if its limit has been reached On...
void reserve(size_type n)
Attempt to preallocate enough memory for a specified number of elements.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
void clear()
Erase all the elements in the collection.
This is a "hash" representation of an Identifier.
virtual void persToTrans(const LArDigitContainer_p2 *pers, LArDigitContainer *trans, MsgStream &log) const override
LArDigitContainerCnv_p2(const LArOnlineID_Base *idHelper)
virtual void transToPers(const LArDigitContainer *trans, LArDigitContainer_p2 *pers, MsgStream &log) const override
const LArOnlineID_Base * m_idHelper
std::vector< unsigned char > m_gain
std::vector< short > m_samples
Container class for LArDigit.
Liquid Argon digit base class.
CaloGain::CaloGain gain() const
const std::vector< short > & samples() const
Helper for the Liquid Argon Calorimeter cell identifiers.
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts