ATLAS Offline Software
TBADCRawContCnv_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 "TBEvent/TBADCRawCont.h"
7 #include "Identifier/Identifier.h"
9 
10 
11 
12 void
14  TBADCRawCont* trans, MsgStream &/*log*/) const
15 {
16 
17  const unsigned nADCRaws = pers->m_adc.size();
18 
19  // clear the trans contained and reserve space for the new scints
20  trans->clear();
21  trans->reserve(nADCRaws);
22 
23  // copy all the scints from the pers to the trans
24  for (unsigned nADCRawNow=0; nADCRawNow<nADCRaws; nADCRawNow++) {
25  TBADCRaw * ADCRaw = new TBADCRaw();
26 
27  // fill in the scint properties
28  ADCRaw -> setADC( pers->m_adc[nADCRawNow] );
29  ADCRaw -> setDetectorName( pers->m_tbDetectorName[nADCRawNow] );
30  ADCRaw -> setOverflow( pers->m_overflow[nADCRawNow] );
31 
32  // fill the container with the scint object
33  trans->push_back(ADCRaw);
34  }
35 
36 }
37 
38 
39 void
41  TBADCRawCont_p1* pers, MsgStream &/*log*/) const
42 {
43 
44  const unsigned nADCRaws = trans->size();
45 
46  pers -> m_adc.reserve(nADCRaws);
47  pers -> m_tbDetectorName.reserve(nADCRaws);
48  pers -> m_overflow.reserve(nADCRaws);
49 
50  // iterators for the container
51  TBADCRawCont::const_iterator ADCRawIt = trans->begin();
52  TBADCRawCont::const_iterator ADCRawIt_e = trans->end();
53 
54  // copy all the scints from the trans to the pers
55  for (; ADCRawIt!=ADCRawIt_e; ++ADCRawIt) {
56  const TBADCRaw * ADCRaw = * ADCRawIt;
57 
58  pers -> m_adc.push_back( ADCRaw->getADC() );
59  pers -> m_tbDetectorName.push_back( ADCRaw->getDetectorName() );
60  pers -> m_overflow.push_back( ADCRaw->isOverflow() );
61 
62  }
63 
64 }
65 
DataVector::reserve
void reserve(size_type n)
Attempt to preallocate enough memory for a specified number of elements.
TBADCRawCont_p1
Definition: TBADCRawCont_p1.h:15
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
TBADCRaw
Definition: TBADCRaw.h:21
TBADCRawContCnv_p1.h
TBADCRawCont.h
TBADCRawCont_p1::m_overflow
std::vector< bool > m_overflow
Definition: TBADCRawCont_p1.h:24
TBBeamDetector::getDetectorName
const std::string & getDetectorName() const
Definition: TBBeamDetector.h:61
TBADCRawCont_p1.h
DataVector::clear
void clear()
Erase all the elements in the collection.
TBADCRawCont_p1::m_adc
std::vector< signal_type > m_adc
Definition: TBADCRawCont_p1.h:21
TBADCRawContCnv_p1::transToPers
virtual void transToPers(const TBADCRawCont *trans, TBADCRawCont_p1 *pers, MsgStream &log) const override
Definition: TBADCRawContCnv_p1.cxx:40
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
TBADCRawCont_p1::m_tbDetectorName
std::vector< std::string > m_tbDetectorName
Definition: TBADCRawCont_p1.h:23
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
TBADCRaw::getADC
signal_type getADC() const
Definition: TBADCRaw.h:35
TBBeamDetector::isOverflow
bool isOverflow() const
Definition: TBBeamDetector.h:64
TBADCRawCont
Definition: TBADCRawCont.h:20
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.
TBADCRawContCnv_p1::persToTrans
virtual void persToTrans(const TBADCRawCont_p1 *pers, TBADCRawCont *trans, MsgStream &log) const override
Definition: TBADCRawContCnv_p1.cxx:13