ATLAS Offline Software
LArRawSCContainerCnv_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  LArRawSCContainer* trans, MsgStream &log) const
15 {
16  const unsigned nDigits=pers->m_channelID.size();
17  if (nDigits != pers->m_chan.size() || nDigits != pers->m_nEnergies.size()) {
18  log << MSG::ERROR << "LArRawSCContainer_p1 is inconsistent! " << std::endl;
19  return;
20  }
21 
22  trans->clear();
23  trans->reserve(nDigits);
24  std::vector<int>::const_iterator en_it=pers->m_energies.begin();
25  std::vector<int>::const_iterator en_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  std::vector<bool>::const_iterator satur_it=pers->m_satur.begin();
31  std::vector<bool>::const_iterator satur_it_e;
32 
33  for (unsigned i=0;i<nDigits;i++) {
34  en_it_e=en_it+pers->m_nEnergies[i];
35  std::vector<int> energies (en_it,en_it_e);
36 
37  bcid_it_e=bcid_it+pers->m_nEnergies[i];
38  std::vector<unsigned short> bcids (bcid_it,bcid_it_e);
39 
40  satur_it_e=satur_it+pers->m_nEnergies[i];
41  std::vector<bool> satur (satur_it,satur_it_e);
42 
44  pers->m_chan[i],
45  pers->m_sourceId[i],
46  std::move(energies),
47  std::move(bcids),
48  std::move(satur)));
49 
50  en_it = en_it_e;
51  bcid_it = bcid_it_e;
52  satur_it = satur_it_e;
53 
54  }
55 }
56 
57 
58 void
60  LArRawSCContainer_p1* pers, MsgStream &/*log*/) const
61 {
62 
63  unsigned int nDigits=trans->size();
64  pers->m_channelID.reserve(nDigits);
65  pers->m_chan.reserve(nDigits);
66  pers->m_sourceId.reserve(nDigits);
67  pers->m_nEnergies.reserve(nDigits);
68  if (nDigits) {
69  pers->m_energies.reserve(
70  (*(trans->begin()))->nsamples()
71  * nDigits);
72  pers->m_bcids.reserve(
73  (*(trans->begin()))->nsamples()
74  * nDigits);
75  pers->m_satur.reserve(
76  (*(trans->begin()))->nsamples()
77  * nDigits);
78  }
79  for (const LArRawSC* transDigit : *trans) {
80  pers->m_channelID.push_back(transDigit->hardwareID().get_identifier32().get_compact());
81  pers->m_chan.push_back(transDigit->chan());
82  pers->m_sourceId.push_back(transDigit->SourceId());
83  pers->m_nEnergies.push_back(transDigit->energies().size());
84  pers->m_energies.insert (pers->m_energies.end(),
85  transDigit->energies().begin(),
86  transDigit->energies().end());
87  pers->m_bcids.insert (pers->m_bcids.end(),
88  transDigit->bcids().begin(),
89  transDigit->bcids().end());
90  pers->m_satur.insert (pers->m_satur.end(),
91  transDigit->satur().begin(),
92  transDigit->satur().end());
93  }
94 }
95 
DataVector::reserve
void reserve(size_type n)
Attempt to preallocate enough memory for a specified number of elements.
LArRawSC
Liquid Argon SuperCell raw data.
Definition: LArRawSC.h:19
Identifier32
Definition: Identifier32.h:25
LArRawSCContainerCnv_p1::transToPers
virtual void transToPers(const LArRawSCContainer *trans, LArRawSCContainer_p1 *pers, MsgStream &log) const override
Definition: LArRawSCContainerCnv_p1.cxx:59
LArRawSCContainer_p1::m_chan
std::vector< unsigned short > m_chan
Definition: LArRawSCContainer_p1.h:17
LArRawSCContainer_p1::m_sourceId
std::vector< unsigned int > m_sourceId
Definition: LArRawSCContainer_p1.h:18
LArRawSCContainer.h
LArRawSCContainer
Container class for LArRawSC.
Definition: LArRawSCContainer.h:17
LArRawSCContainer_p1
Definition: LArRawSCContainer_p1.h:12
LArRawSCContainerCnv_p1.h
LArRawSCContainer_p1::m_energies
std::vector< int > m_energies
Definition: LArRawSCContainer_p1.h:20
HWIdentifier
Definition: HWIdentifier.h:13
lumiFormat.i
int i
Definition: lumiFormat.py:85
LArRawSCContainerCnv_p1::persToTrans
virtual void persToTrans(const LArRawSCContainer_p1 *pers, LArRawSCContainer *trans, MsgStream &log) const override
Definition: LArRawSCContainerCnv_p1.cxx:13
LArRawSCContainer_p1::m_satur
std::vector< bool > m_satur
Definition: LArRawSCContainer_p1.h:22
DataVector::clear
void clear()
Erase all the elements in the collection.
LArRawSCContainer_p1::m_bcids
std::vector< unsigned short > m_bcids
Definition: LArRawSCContainer_p1.h:21
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
LArRawSCContainer_p1::m_channelID
std::vector< unsigned int > m_channelID
Definition: LArRawSCContainer_p1.h:16
LArRawSCContainer_p1.h
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
LArRawSCContainer_p1::m_nEnergies
std::vector< unsigned short > m_nEnergies
Definition: LArRawSCContainer_p1.h:19
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.