ATLAS Offline Software
Loading...
Searching...
No Matches
LArDigitContainerCnv_p1.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
7#include "Identifier/Identifier.h"
9
10
11
12void
14 LArDigitContainer* trans, MsgStream &log) const
15{
16 const unsigned nDigits=pers->m_channelID.size();
17 if (nDigits != pers->m_gain.size() || nDigits != pers->m_nSamples.size()) {
18 log << MSG::ERROR << "LArDigitContainer_p1 is inconsistent! " << std::endl;
19 return;
20 }
21
22 //LArDigit digit;
23 trans->clear();
24 trans->reserve(nDigits);
25 std::vector<unsigned short>::const_iterator sample_it=pers->m_samples.begin();
26 std::vector<unsigned short>::const_iterator sample_it_e;
27
28 for (unsigned i=0;i<nDigits;i++) {
29 sample_it_e=sample_it+pers->m_nSamples[i];
30 std::vector<short> samples (sample_it,sample_it_e);
31
33 (CaloGain::CaloGain)pers->m_gain[i],
34 std::move(samples)));
35
36 sample_it = sample_it_e;
37
38
39 //std:: cout << "Working on channel "<< i << "(" << std::hex
40 // << pers->m_channelID[i] <<std::dec << ")" <<std::endl;
41 }
42}
43
44
45void
47 LArDigitContainer_p1* pers, MsgStream &/*log*/) const
48{
49
50 unsigned int nDigits=trans->size();
51 pers->m_channelID.reserve(nDigits);
52 pers->m_gain.reserve(nDigits);
53 pers->m_nSamples.reserve(nDigits);
54 if (nDigits)
55 pers->m_samples.reserve(
56 (*(trans->begin()))->nsamples()
57 * nDigits);
58
59 for (const LArDigit* transDigit : *trans) {
60 pers->m_channelID.push_back(transDigit->hardwareID().get_identifier32().get_compact());
61 pers->m_gain.push_back((unsigned char)transDigit->gain());
62 pers->m_nSamples.push_back(transDigit->samples().size());
63 pers->m_samples.insert (pers->m_samples.end(),
64 transDigit->samples().begin(),
65 transDigit->samples().end());
66 }
67}
68
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.
virtual void persToTrans(const LArDigitContainer_p1 *pers, LArDigitContainer *trans, MsgStream &log) const override
virtual void transToPers(const LArDigitContainer *trans, LArDigitContainer_p1 *pers, MsgStream &log) const override
std::vector< unsigned short > m_samples
std::vector< unsigned short > m_nSamples
std::vector< unsigned int > m_channelID
std::vector< unsigned char > m_gain
Container class for LArDigit.
Liquid Argon digit base class.
Definition LArDigit.h:25