ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
TestBeam
TBTPCnv
src
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
5
#include "
TBTPCnv/TBMWPCContCnv_p1.h
"
6
#include "
TBEvent/TBMWPCCont.h
"
7
#include "Identifier/Identifier.h"
8
#include "
TBTPCnv/TBMWPCCont_p1.h
"
9
10
11
12
void
13
TBMWPCContCnv_p1::persToTrans
(
const
TBMWPCCont_p1
* pers,
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
68
void
69
TBMWPCContCnv_p1::transToPers
(
const
TBMWPCCont
* trans,
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
TBMWPCContCnv_p1.h
TBMWPCCont.h
TBMWPCCont_p1.h
DataVector< TBMWPC >::const_iterator
DataModel_detail::const_iterator< DataVector > const_iterator
Definition
DataVector.h:838
DataVector::reserve
void reserve(size_type n)
Attempt to preallocate enough memory for a specified number of elements.
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
DataVector::clear
void clear()
Erase all the elements in the collection.
TBBeamDetector::isOverflow
bool isOverflow() const
Definition
TBBeamDetector.h:65
TBBeamDetector::getDetectorName
const std::string & getDetectorName() const
Definition
TBBeamDetector.h:62
TBMWPCContCnv_p1::transToPers
virtual void transToPers(const TBMWPCCont *trans, TBMWPCCont_p1 *pers, MsgStream &log) const override
Definition
TBMWPCContCnv_p1.cxx:69
TBMWPCContCnv_p1::persToTrans
virtual void persToTrans(const TBMWPCCont_p1 *pers, TBMWPCCont *trans, MsgStream &log) const override
Definition
TBMWPCContCnv_p1.cxx:13
TBMWPCCont_p1
Definition
TBMWPCCont_p1.h:15
TBMWPCCont_p1::m_clusterSize_c
std::vector< std::vector< float > > m_clusterSize_c
Definition
TBMWPCCont_p1.h:26
TBMWPCCont_p1::m_isX
std::vector< bool > m_isX
Definition
TBMWPCCont_p1.h:23
TBMWPCCont_p1::m_overflow
std::vector< bool > m_overflow
Definition
TBMWPCCont_p1.h:41
TBMWPCCont_p1::m_cErr
std::vector< std::vector< float > > m_cErr
Definition
TBMWPCCont_p1.h:21
TBMWPCCont_p1::m_tbDetectorName
std::vector< std::string > m_tbDetectorName
Definition
TBMWPCCont_p1.h:40
TBMWPCCont_p1::m_cPos
std::vector< std::vector< float > > m_cPos
Definition
TBMWPCCont_p1.h:20
TBMWPCCont_p1::m_cPosOverflow
std::vector< std::vector< unsigned > > m_cPosOverflow
Definition
TBMWPCCont_p1.h:37
TBMWPCCont
"TBEvent/TBMWPCCont.h"
Definition
TBMWPCCont.h:17
TBMWPC
Definition
TBMWPC.h:30
TBMWPC::getCErr
const std::vector< float > & getCErr() const
Definition
TBMWPC.h:67
TBMWPC::isCPosOverflow
const std::vector< bool > & isCPosOverflow() const
Definition
TBMWPC.h:78
TBMWPC::isX
bool isX() const
Definition
TBMWPC.h:69
TBMWPC::getCPos
const std::vector< float > & getCPos() const
Definition
TBMWPC.h:65
TBMWPC::getClusterSizeC
const std::vector< float > & getClusterSizeC() const
Get cluster size for c-direction.
Definition
TBMWPC.h:74
Generated on
for ATLAS Offline Software by
1.17.0