ATLAS Offline Software
Loading...
Searching...
No Matches
TBLArDigitContainerCnv_p1.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3*/
4
6//#include "LArRawEvent/LArDigitContainer.h"
8#include "Identifier/Identifier.h"
10
11
12
13void
15 TBLArDigitContainer* trans, MsgStream &log) const
16{
17 const unsigned nDigits=pers->m_channelID.size();
18 if (nDigits != pers->m_gain.size() || nDigits != pers->m_nSamples.size()) {
19 log << MSG::ERROR << "LArDigitContainer_p1 is inconsistent! " << std::endl;
20 return;
21 }
22
23 //LArDigit digit;
24 trans->clear();
25 trans->reserve(nDigits);
26 std::vector<unsigned short>::const_iterator sample_it=pers->m_samples.begin();
27
28 for (unsigned i=0;i<nDigits;i++) {
29 std::vector<unsigned short>::const_iterator sample_it_e =
30 sample_it+pers->m_nSamples[i];
31 std::vector<short> samples (sample_it,sample_it_e);
32 sample_it = sample_it_e;
33
34 auto transDig = std::make_unique<LArDigit>
35 (HWIdentifier(pers->m_channelID[i]),
36 static_cast<CaloGain::CaloGain>(pers->m_gain[i]),
37 std::move(samples));
38
39 trans->push_back (std::move(transDig));
40 }
41}
42
43
44void
46 TBLArDigitContainer_p1* pers, MsgStream &/*log*/) const
47{
48
49 unsigned int nDigits=trans->size();
50 pers->m_channelID.reserve(nDigits);
51 pers->m_gain.reserve(nDigits);
52 pers->m_nSamples.reserve(nDigits);
53 if (nDigits)
54 pers->m_samples.reserve(
55 (*(trans->begin()))->nsamples()
56 * nDigits);
57
60 //unsigned i=0;
61 for (;it!=it_e;++it) {
62 const LArDigit* transDigit=*it;
63 pers->m_channelID.push_back(transDigit->hardwareID().get_identifier32().get_compact());
64 pers->m_gain.push_back((unsigned char)transDigit->gain());
65 pers->m_nSamples.push_back(transDigit->nsamples());
66 pers->m_samples.insert (pers->m_samples.end(),
67 transDigit->samples().begin(),
68 transDigit->samples().end());
69 //std:: cout << "Working on channel "<< i++ << "(" << std::hex
70 // << transDigit->m_hardwareID.get_compact() <<std::dec << ")" <<std::endl;
71 }
72}
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
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 end() const noexcept
Return a const_iterator pointing past 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.
value_type get_compact() const
Get the compact id.
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
Liquid Argon digit base class.
Definition LArDigit.h:25
CaloGain::CaloGain gain() const
Definition LArDigit.h:72
const HWIdentifier & hardwareID() const
Definition LArDigit.h:66
int nsamples() const
Definition LArDigit.h:75
const std::vector< short > & samples() const
Definition LArDigit.h:78
virtual void persToTrans(const TBLArDigitContainer_p1 *pers, TBLArDigitContainer *trans, MsgStream &log) const override
virtual void transToPers(const TBLArDigitContainer *trans, TBLArDigitContainer_p1 *pers, MsgStream &log) const override
std::vector< unsigned int > m_channelID
std::vector< unsigned char > m_gain
std::vector< unsigned short > m_samples
std::vector< unsigned short > m_nSamples