ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
MuonSpectrometer
MuonCnv
MuonEventAthenaPool
src
RpcPadContainerCnv_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
5
#include "
RpcPadContainerCnv_p1.h
"
6
7
#include "
MuonRDO/RpcPad.h
"
8
#include "
MuonRDO/RpcPadContainer.h
"
9
#include "
MuonEventAthenaPool/RpcPad_p1.h
"
10
#include "
MuonEventAthenaPool/RpcPadContainer_p1.h
"
11
#include "
RpcPadCnv_p1.h
"
12
#include "GaudiKernel/Bootstrap.h"
13
#include "GaudiKernel/StatusCode.h"
14
#include "GaudiKernel/Service.h"
15
#include "GaudiKernel/MsgStream.h"
16
#include "
StoreGate/StoreGateSvc.h
"
17
#include "
AthAllocators/DataPool.h
"
18
#include "
StoreGate/ReadCondHandle.h
"
19
20
RpcPadContainerCnv_p1::RpcPadContainerCnv_p1
() :
21
m_isInitialized
(false),
22
m_rpcCabKey
(
"RpcCablingCondData"
) {
23
}
24
25
26
StatusCode
RpcPadContainerCnv_p1::initialize
(MsgStream &log) {
27
28
m_isInitialized
=
true
;
29
30
StatusCode
sc
=
m_rpcCabKey
.initialize();
31
32
log << MSG::DEBUG <<
"Converter initialized."
<<
endmsg
;
33
34
return
sc
;
35
}
36
37
void
RpcPadContainerCnv_p1::transToPers
(
const
RpcPadContainer
* transCont,
RpcPadContainer_p1
* persCont, MsgStream &log)
38
{
39
40
typedef
RpcPadContainer
TRANS
;
41
42
RpcPadCnv_p1
cnv;
43
TRANS::const_iterator
it_Coll = transCont->
begin
();
44
TRANS::const_iterator
it_CollEnd = transCont->
end
();
45
unsigned
int
collIndex;
46
47
int
numColl = transCont->
numberOfCollections
();
48
persCont->resize(numColl); log << MSG::DEBUG <<
" Preparing "
<< persCont->size() <<
"Collections"
<<
endmsg
;
49
50
for
(collIndex = 0; it_Coll != it_CollEnd; ++collIndex, ++it_Coll) {
51
// Add in new collection
52
RpcPad_p1
* pcoll = &( (*persCont)[collIndex] );
53
cnv.
transToPers
( &(**it_Coll), pcoll , log);
54
}
55
log << MSG::DEBUG <<
" *** Writing RpcPadContainer ***"
<<
endmsg
;
56
}
57
58
void
RpcPadContainerCnv_p1::persToTrans
(
const
RpcPadContainer_p1
* persCont,
RpcPadContainer
* transCont, MsgStream &log)
59
{
60
SG::ReadCondHandle<RpcCablingCondData>
rpcCab(
m_rpcCabKey
, Gaudi::Hive::currentContext());
61
const
RpcCablingCondData
* rpcCabling=*rpcCab;
62
if
(!rpcCab.
isValid
()||!rpcCabling) {
63
log << MSG::FATAL <<
m_rpcCabKey
.fullKey() <<
" is not available."
<<
endmsg
;
64
return
;
65
}
66
RpcPadCnv_p1
cnv;
67
68
log << MSG::DEBUG <<
" Reading "
<< persCont->size() <<
"Collections"
<<
endmsg
;
69
for
(
unsigned
int
icoll = 0; icoll < persCont->size(); ++icoll) {
70
71
RpcPad
* coll =
new
RpcPad
;
72
cnv.
persToTrans
( &( (*persCont)[icoll]), coll, log);
73
74
int
temp = rpcCabling->operator()(coll->
identify
());
75
if
(temp==-1) {
76
coll->
m_idHash
=
IdentifierHash
();
77
log<<MSG::WARNING<<
"get_hash failed - nothing else we can try!"
<<
endmsg
;
78
}
else
{
79
coll->
m_idHash
= temp;
80
}
81
82
// another check - see if already added
83
const
auto
*ptr = transCont->
indexFindPtr
(coll->
identifyHash
());
84
if
(ptr!=
nullptr
) {
85
log << MSG::WARNING<<
"Collection with hash="
<<coll->
identifyHash
()<<
" already exists in container (with "
<<ptr->size()<<
" elements). "
86
<<
"Will therefore DISCARD this collection which has "
<<coll->
size
()<<
" elements)!"
<<
endmsg
;
87
delete
coll;
88
}
else
{
89
StatusCode
sc
= transCont->
addCollection
(coll, coll->
identifyHash
());
90
if
(
sc
.isFailure()) {
91
log << MSG::WARNING<<
"Could not add collection with hash="
<<coll->
identifyHash
()
92
<<
" to IDC which has hash max of "
<<transCont->
size
()<<
" (PadHashFunction gives "
<<rpcCabling->
max
()<<
")"
<<
endmsg
;
93
throw
std::runtime_error(
"Failed to add collection to ID Container. Hash = "
+std::to_string(coll->
identifyHash
()));
94
}
95
}
96
}
97
98
log << MSG::DEBUG <<
" *** Reading RpcPadContainer"
<<
endmsg
;
99
}
100
101
102
103
//================================================================
104
RpcPadContainer
*
RpcPadContainerCnv_p1::createTransient
(
const
RpcPadContainer_p1
* persObj, MsgStream& log)
105
{
106
if
(!
m_isInitialized
) {
107
if
(this->
initialize
(log) != StatusCode::SUCCESS) {
108
log << MSG::FATAL <<
"Could not initialize RpcPadContainerCnv_p1 "
<<
endmsg
;
109
return
nullptr
;
110
}
111
}
112
SG::ReadCondHandle<RpcCablingCondData>
rpcCab(
m_rpcCabKey
, Gaudi::Hive::currentContext());
113
const
RpcCablingCondData
* rpcCabling=*rpcCab;
114
if
(!rpcCab.
isValid
()||!rpcCabling) {
115
log << MSG::FATAL <<
m_rpcCabKey
.fullKey() <<
" is not available."
<<
endmsg
;
116
return
nullptr
;
117
}
118
std::unique_ptr<RpcPadContainer> trans(
new
RpcPadContainer
(rpcCabling->
max
()));
119
persToTrans
(persObj, trans.get(), log);
120
return
(trans.release());
121
}
122
123
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:54
DataPool.h
sc
static Double_t sc
Definition
LArPhysWaveHECTool.cxx:37
RpcPadContainer
Athena::TPCnvVers::Old Athena::TPCnvVers::Current Athena::TPCnvVers::Old Athena::TPCnvVers::Current Athena::TPCnvVers::Old Athena::TPCnvVers::Current Athena::TPCnvVers::Current Athena::TPCnvVers::Current Athena::TPCnvVers::Current RpcPadContainer
Definition
MuonEventAthenaPoolTPCnv.cxx:156
ReadCondHandle.h
RpcPadCnv_p1.h
RpcPadContainerCnv_p1.h
RpcPadContainer.h
RpcPadContainer_p1.h
RpcPad.h
RpcPad_p1.h
StoreGateSvc.h
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
IdentifiableContainerMT::const_iterator
Definition
IdentifiableContainerMT.h:81
IdentifiableContainerMT::end
const_iterator end() const
return const_iterator for end of container
Definition
IdentifiableContainerMT.h:247
IdentifiableContainerMT::numberOfCollections
virtual size_t numberOfCollections() const override final
return number of collections
Definition
IdentifiableContainerMT.h:215
IdentifiableContainerMT::indexFindPtr
virtual const T * indexFindPtr(IdentifierHash hashId) const override final
return pointer on the found entry or null if out of range using hashed index - fast version,...
Definition
IdentifiableContainerMT.h:297
IdentifiableContainerMT::size
size_t size() const
Duplicate of fullSize for backwards compatability.
Definition
IdentifiableContainerMT.h:208
IdentifiableContainerMT::addCollection
virtual StatusCode addCollection(const T *coll, IdentifierHash hashId) override final
insert collection into container with id hash if IDC should not take ownership of collection,...
Definition
IdentifiableContainerMT.h:305
IdentifiableContainerMT::begin
const_iterator begin() const
return const_iterator for first entry
Definition
IdentifiableContainerMT.h:241
IdentifierHash
This is a "hash" representation of an Identifier.
Definition
IdentifierHash.h:25
RpcCablingCondData
Definition
RpcCablingCondData.h:23
RpcCablingCondData::max
int max() const
Definition
RpcCablingCondData.cxx:127
RpcPadCnv_p1
Definition
RpcPadCnv_p1.h:26
RpcPadCnv_p1::persToTrans
virtual void persToTrans(const RpcPad_p1 *persColl, RpcPad *transColl, MsgStream &log)
Converts vector of PERS::value_type objects to vector of TRANS::value_type objects,...
Definition
RpcPadCnv_p1.cxx:28
RpcPadCnv_p1::transToPers
virtual void transToPers(const RpcPad *transColl, RpcPad_p1 *persColl, MsgStream &log)
Converts vector of TRANS::value_type objects to vector of PERS::value_type objects,...
Definition
RpcPadCnv_p1.cxx:12
RpcPadContainerCnv_p1::initialize
StatusCode initialize(MsgStream &log)
Definition
RpcPadContainerCnv_p1.cxx:26
RpcPadContainerCnv_p1::m_rpcCabKey
SG::ReadCondHandleKey< RpcCablingCondData > m_rpcCabKey
Definition
RpcPadContainerCnv_p1.h:36
RpcPadContainerCnv_p1::createTransient
virtual RpcPadContainer * createTransient(const RpcPadContainer_p1 *persObj, MsgStream &log) override
Definition
RpcPadContainerCnv_p1.cxx:104
RpcPadContainerCnv_p1::RpcPadContainerCnv_p1
RpcPadContainerCnv_p1()
Definition
RpcPadContainerCnv_p1.cxx:20
RpcPadContainerCnv_p1::m_isInitialized
bool m_isInitialized
Definition
RpcPadContainerCnv_p1.h:35
RpcPadContainerCnv_p1::TRANS
RpcPadContainer TRANS
Definition
RpcPadContainerCnv_p1.h:28
RpcPadContainerCnv_p1::transToPers
virtual void transToPers(const TRANS *transCont, PERS *persCont, MsgStream &log) override
Definition
RpcPadContainerCnv_p1.cxx:37
RpcPadContainerCnv_p1::persToTrans
virtual void persToTrans(const PERS *persCont, TRANS *transCont, MsgStream &log) override
Definition
RpcPadContainerCnv_p1.cxx:58
RpcPadContainer_p1
Definition
RpcPadContainer_p1.h:19
RpcPadContainer
Use IdentifiableContainer with RpcPad.
Definition
RpcPadContainer.h:23
RpcPad_p1
Definition
RpcPad_p1.h:14
RpcPad
Definition
RpcPad.h:21
RpcPad::identify
Identifier identify() const
Definition
RpcPad.h:100
RpcPad::identifyHash
IdentifierHash identifyHash() const
Returns the OFFLINE identifier hash for this collection.
Definition
RpcPad.h:103
RpcPad::m_idHash
IdentifierHash m_idHash
Definition
RpcPad.h:128
SG::ReadCondHandle
Definition
ReadCondHandle.h:40
SG::ReadCondHandle::isValid
bool isValid()
Definition
ReadCondHandle.h:205
initialize
void initialize()
Definition
run_EoverP.cxx:894
Generated on
for ATLAS Offline Software by
1.17.0