ATLAS Offline Software
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 
13 void
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 
44 void
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 }
DataVector::reserve
void reserve(size_type n)
Attempt to preallocate enough memory for a specified number of elements.
TBLArDigitContainer_p1::m_nSamples
std::vector< unsigned short > m_nSamples
Definition: TBLArDigitContainer_p1.h:23
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
LArDigit::samples
const std::vector< short > & samples() const
Definition: LArDigit.h:78
skel.it
it
Definition: skel.GENtoEVGEN.py:396
LArDigit::hardwareID
const HWIdentifier & hardwareID() const
Definition: LArDigit.h:66
Identifier::get_identifier32
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
HWIdentifier
Definition: HWIdentifier.h:13
Identifier32::get_compact
value_type get_compact() const
Get the compact id.
Definition: Identifier32.h:44
TBLArDigitContainer.h
LArDigit::nsamples
int nsamples() const
Definition: LArDigit.h:75
LArDigit
Liquid Argon digit base class.
Definition: LArDigit.h:25
lumiFormat.i
int i
Definition: lumiFormat.py:85
TBLArDigitContainer_p1::m_samples
std::vector< unsigned short > m_samples
Definition: TBLArDigitContainer_p1.h:24
TBLArDigitContainerCnv_p1.h
TBLArDigitContainerCnv_p1::persToTrans
virtual void persToTrans(const TBLArDigitContainer_p1 *pers, TBLArDigitContainer *trans, MsgStream &log) const override
Definition: TBLArDigitContainerCnv_p1.cxx:14
DataVector::clear
void clear()
Erase all the elements in the collection.
TBLArDigitContainer_p1::m_channelID
std::vector< unsigned int > m_channelID
Definition: TBLArDigitContainer_p1.h:21
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
CaloGain::CaloGain
CaloGain
Definition: CaloGain.h:11
TBLArDigitContainer_p1::m_gain
std::vector< unsigned char > m_gain
Definition: TBLArDigitContainer_p1.h:22
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
LArDigit::gain
CaloGain::CaloGain gain() const
Definition: LArDigit.h:72
TBLArDigitContainer_p1
Definition: TBLArDigitContainer_p1.h:17
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
TBLArDigitContainer_p1.h
TBLArDigitContainer
Gaudi Class ID.
Definition: TBLArDigitContainer.h:40
TBLArDigitContainerCnv_p1::transToPers
virtual void transToPers(const TBLArDigitContainer *trans, TBLArDigitContainer_p1 *pers, MsgStream &log) const override
Definition: TBLArDigitContainerCnv_p1.cxx:45
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.