ATLAS Offline Software
Loading...
Searching...
No Matches
TBMWPCContCnv_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
7#include "Identifier/Identifier.h"
9
10
11
12void
14 TBMWPCCont* trans, MsgStream &/*log*/) const
15{
16
17 const unsigned nTBMWPCs = pers->m_cPos.size();
18
19 // clear the trans contained and reserve space for the new MWPCs
20 trans->clear();
21 trans->reserve(nTBMWPCs);
22
23 // copy all the MWPCs from the pers to the trans
24 for (unsigned nTBMWPCNow=0; nTBMWPCNow<nTBMWPCs; nTBMWPCNow++) {
25 TBMWPC * MWPC = new TBMWPC();
26
27 MWPC -> setCPos( pers->m_cPos[nTBMWPCNow] );
28 MWPC -> setCErr( pers->m_cErr[nTBMWPCNow] );
29 MWPC -> setXchambers( pers->m_isX[nTBMWPCNow] );
30 MWPC -> setClusterSizeC( pers->m_clusterSize_c[nTBMWPCNow] );
31
32
33
34
35 // ------------------------------------------------------------------------------------------------
36 // for some reason a stright forward definition of m_cPosOverflow as
37 // std::vector < std::vector<bool> > m_cPosOverflow;
38 // does not work. perhaps due to the fact that std::vector<bool> is nonconforming (not
39 // really a vector of bool). instead we defined
40 // std::vector < std::vector<unsigned> > m_cPosOverflow;
41 // and now need to convert the bool constituents of the vectors to unsigned
42 // ------------------------------------------------------------------------------------------------
43 unsigned nBools = pers->m_cPosOverflow[nTBMWPCNow].size(); //length of the vector of bool in TBMWPC
44 std::vector<bool> cPosOverflowNow; //defines length
45 cPosOverflowNow.reserve(nBools);
46
47 for (unsigned nBoolNow=0; nBoolNow<nBools; nBoolNow++) {
48 if(pers->m_cPosOverflow[nTBMWPCNow][nBoolNow])
49 cPosOverflowNow.push_back(true);
50 else
51 cPosOverflowNow.push_back(false);
52 }
53 MWPC -> setCPosOverflow( cPosOverflowNow );
54 // ------------------------------------------------------------------------------------------------
55
56
57
58 MWPC -> setDetectorName( pers->m_tbDetectorName[nTBMWPCNow] );
59 MWPC -> setOverflow( pers->m_overflow[nTBMWPCNow] );
60
61 // fill the container with the MWPC object
62 trans->push_back(MWPC);
63 }
64
65}
66
67
68void
70 TBMWPCCont_p1* pers, MsgStream &/*log*/) const
71{
72
73 const unsigned nTBMWPCs = trans->size();
74
75 pers -> m_cPos.reserve(nTBMWPCs);
76 pers -> m_cErr.reserve(nTBMWPCs);
77 pers -> m_isX.reserve(nTBMWPCs);
78 pers -> m_clusterSize_c.reserve(nTBMWPCs);
79 pers -> m_cPosOverflow.reserve(nTBMWPCs);
80 pers -> m_tbDetectorName.reserve(nTBMWPCs);
81 pers -> m_overflow.reserve(nTBMWPCs);
82
83
84 // iterators for the container
85 TBMWPCCont::const_iterator MWPCIt = trans->begin();
86 TBMWPCCont::const_iterator MWPCIt_e = trans->end();
87
88 // copy all the MWPCs from the trans to the pers
89 for (; MWPCIt!=MWPCIt_e; ++MWPCIt) {
90 const TBMWPC * MWPC = * MWPCIt;
91
92 // fill in the MWPC properties
93 pers -> m_cPos.push_back( MWPC->getCPos() );
94 pers -> m_cErr.push_back( MWPC->getCErr() );
95 pers -> m_isX.push_back( MWPC->isX() );
96 pers -> m_clusterSize_c.push_back( MWPC->getClusterSizeC() );
97
98 // ------------------------------------------------------------------------------------------------
99 // for some reason a stright forward definition of m_cPosOverflow as
100 // std::vector < std::vector<bool> > m_cPosOverflow;
101 // does not work. perhaps due to the fact that std::vector<bool> is nonconforming (not
102 // really a vector of bool variables, but some ). instead we defined
103 // std::vector < std::vector<unsigned> > m_cPosOverflow;
104 // and now need to convert the bool constituents of the vectors to unsigned
105 // ------------------------------------------------------------------------------------------------
106 unsigned nBools = MWPC->isCPosOverflow().size(); //length of the vector of bool in TBMWPC
107 std::vector<unsigned> cPosOverflowNow(nBools); //defines length and initializes to zero
108
109 for (unsigned nBoolNow=0; nBoolNow<nBools; nBoolNow++) {
110 if(MWPC->isCPosOverflow()[nBoolNow])
111 cPosOverflowNow[nBoolNow] = 1;
112 }
113 pers -> m_cPosOverflow.push_back( std::move(cPosOverflowNow) );
114 // ------------------------------------------------------------------------------------------------
115
116 pers -> m_tbDetectorName.push_back( MWPC->getDetectorName() );
117 pers -> m_overflow.push_back( MWPC->isOverflow() );
118 }
119
120}
121
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.
bool isOverflow() const
const std::string & getDetectorName() const
virtual void transToPers(const TBMWPCCont *trans, TBMWPCCont_p1 *pers, MsgStream &log) const override
virtual void persToTrans(const TBMWPCCont_p1 *pers, TBMWPCCont *trans, MsgStream &log) const override
std::vector< std::vector< float > > m_clusterSize_c
std::vector< bool > m_isX
std::vector< bool > m_overflow
std::vector< std::vector< float > > m_cErr
std::vector< std::string > m_tbDetectorName
std::vector< std::vector< float > > m_cPos
std::vector< std::vector< unsigned > > m_cPosOverflow
"TBEvent/TBMWPCCont.h"
Definition TBMWPCCont.h:17
const std::vector< float > & getCErr() const
Definition TBMWPC.h:67
const std::vector< bool > & isCPosOverflow() const
Definition TBMWPC.h:78
bool isX() const
Definition TBMWPC.h:69
const std::vector< float > & getCPos() const
Definition TBMWPC.h:65
const std::vector< float > & getClusterSizeC() const
Get cluster size for c-direction.
Definition TBMWPC.h:74