ATLAS Offline Software
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 
12 void
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 
45 void
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 
DataVector::reserve
void reserve(size_type n)
Attempt to preallocate enough memory for a specified number of elements.
Identifier32
Definition: Identifier32.h:25
LArDigitContainerCnv_p1.h
LArDigitContainer_p1::m_samples
std::vector< unsigned short > m_samples
Definition: LArDigitContainer_p1.h:19
LArDigitContainer_p1::m_channelID
std::vector< unsigned int > m_channelID
Definition: LArDigitContainer_p1.h:16
HWIdentifier
Definition: HWIdentifier.h:13
LArDigit
Liquid Argon digit base class.
Definition: LArDigit.h:25
lumiFormat.i
int i
Definition: lumiFormat.py:92
01SubmitToGrid.samples
samples
Definition: 01SubmitToGrid.py:58
DataVector::clear
void clear()
Erase all the elements in the collection.
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
LArDigitContainer_p1.h
LArDigitContainer.h
CaloGain::CaloGain
CaloGain
Definition: CaloGain.h:11
LArDigitContainerCnv_p1::persToTrans
virtual void persToTrans(const LArDigitContainer_p1 *pers, LArDigitContainer *trans, MsgStream &log) const override
Definition: LArDigitContainerCnv_p1.cxx:13
LArDigitContainer_p1
Definition: LArDigitContainer_p1.h:12
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
LArDigitContainer_p1::m_nSamples
std::vector< unsigned short > m_nSamples
Definition: LArDigitContainer_p1.h:18
LArDigitContainerCnv_p1::transToPers
virtual void transToPers(const LArDigitContainer *trans, LArDigitContainer_p1 *pers, MsgStream &log) const override
Definition: LArDigitContainerCnv_p1.cxx:46
LArDigitContainer
Container class for LArDigit.
Definition: LArDigitContainer.h:24
LArDigitContainer_p1::m_gain
std::vector< unsigned char > m_gain
Definition: LArDigitContainer_p1.h:17
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.