ATLAS Offline Software
Loading...
Searching...
No Matches
LArSCDigitContainerCnv_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 LArSCDigitContainer* trans, MsgStream &log) const
15{
16 const unsigned nDigits=pers->m_channelID.size();
17 if (nDigits > 0 && (nDigits != pers->m_chan.size() || nDigits != pers->m_nSamples.size() || nDigits*pers->m_nSamples[0] != pers->m_bcids.size() || nDigits*pers->m_nSamples[0] != pers->m_samples.size())) {
18 log << MSG::ERROR << "LArSCDigitContainer_p1 is inconsistent! " << std::endl;
19 return;
20 }
21
22 trans->clear();
23 trans->reserve(nDigits);
24 std::vector<unsigned short>::const_iterator sample_it=pers->m_samples.begin();
25 std::vector<unsigned short>::const_iterator sample_it_e;
26
27 std::vector<unsigned short>::const_iterator bcid_it=pers->m_bcids.begin();
28 std::vector<unsigned short>::const_iterator bcid_it_e;
29
30 for (unsigned i=0;i<nDigits;i++) {
31 sample_it_e=sample_it+pers->m_nSamples[i];
32 std::vector<short> samples (sample_it,sample_it_e);
33
34 bcid_it_e=bcid_it+pers->m_nSamples[i];
35 std::vector<unsigned short> bcids (bcid_it,bcid_it_e);
36
38 pers->m_chan[i], pers->m_sourceId[i],
39 std::move(samples), std::move(bcids) ));
40
41 sample_it = sample_it_e;
42 bcid_it = bcid_it_e;
43
44 }
45}
46
47
48void
50 LArSCDigitContainer_p1* pers, MsgStream &/*log*/) const
51{
52
53 unsigned int nDigits=trans->size();
54 pers->m_channelID.reserve(nDigits);
55 pers->m_chan.reserve(nDigits);
56 pers->m_sourceId.reserve(nDigits);
57 pers->m_nSamples.reserve(nDigits);
58 if (nDigits) {
59 pers->m_samples.reserve(
60 (*(trans->begin()))->nsamples()
61 * nDigits);
62 pers->m_bcids.reserve(
63 (*(trans->begin()))->nsamples()
64 * nDigits);
65 }
66 for (const LArSCDigit* transDigit : *trans) {
67 pers->m_channelID.push_back(transDigit->hardwareID().get_identifier32().get_compact());
68 pers->m_chan.push_back(transDigit->Channel());
69 pers->m_sourceId.push_back(transDigit->SourceId());
70 pers->m_nSamples.push_back(transDigit->samples().size());
71 pers->m_samples.insert (pers->m_samples.end(),
72 transDigit->samples().begin(),
73 transDigit->samples().end());
74 pers->m_bcids.insert (pers->m_bcids.end(),
75 transDigit->BCId().begin(),
76 transDigit->BCId().end());
77 }
78}
79
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 LArSCDigitContainer_p1 *pers, LArSCDigitContainer *trans, MsgStream &log) const override
virtual void transToPers(const LArSCDigitContainer *trans, LArSCDigitContainer_p1 *pers, MsgStream &log) const override
std::vector< unsigned char > m_chan
std::vector< unsigned short > m_bcids
std::vector< unsigned short > m_samples
std::vector< unsigned int > m_channelID
std::vector< unsigned short > m_nSamples
std::vector< unsigned int > m_sourceId
Container class for LArSCDigit.
Base class for LArDigits taken by LATOME.
Definition LArSCDigit.h:19