ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
InnerDetector
InDetEventCnv
InDetEventTPCnv
src
InDetPrepRawData
TRT_DriftCircleContainerCnv_p1.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
InDetPrepRawData/TRT_DriftCircle.h
"
6
#include "
InDetPrepRawData/TRT_DriftCircleContainer.h
"
7
#include "
InDetEventTPCnv/InDetPrepRawData/TRT_DriftCircle_p1.h
"
8
#include "
InDetEventTPCnv/InDetPrepRawData/InDetPRD_Container_p1.h
"
9
#include "
InDetIdentifier/TRT_ID.h
"
10
#include "
TRT_ReadoutGeometry/TRT_DetectorManager.h
"
11
#include "
InDetEventTPCnv/InDetPrepRawData/TRT_DriftCircleCnv_p1.h
"
12
#include "
InDetEventTPCnv/InDetPrepRawData/TRT_DriftCircleContainerCnv_p1.h
"
13
#include "
AthenaKernel/errorcheck.h
"
14
15
// Gaudi
16
#include "GaudiKernel/ISvcLocator.h"
17
#include "GaudiKernel/Bootstrap.h"
18
#include "GaudiKernel/StatusCode.h"
19
#include "GaudiKernel/Service.h"
20
#include "GaudiKernel/MsgStream.h"
21
22
// Athena
23
#include "
StoreGate/StoreGateSvc.h
"
24
25
26
27
#include "
AthAllocators/DataPool.h
"
28
29
void
InDet::TRT_DriftCircleContainerCnv_p1::transToPers
(
const
InDet::TRT_DriftCircleContainer* transCont,
InDet::InDetPRD_Container_p1
* persCont, MsgStream &log)
30
{
31
32
// The transient model has a container holding collections and the
33
// collections hold channels.
34
//
35
// The persistent model flattens this so that the persistent
36
// container has two vectors:
37
// 1) all collections, and
38
// 2) all RDO
39
//
40
// The persistent collections, then only maintain indexes into the
41
// container's vector of all channels.
42
//
43
// So here we loop over all collection and add their channels
44
// to the container's vector, saving the indexes in the
45
// collection.
46
47
using
TRANS
= InDet::TRT_DriftCircleContainer;
48
using
CONV =
ITPConverterFor<Trk::PrepRawData>
;
49
50
TRT_DriftCircleCnv_p1
chanCnv;
51
TRANS::const_iterator it_Coll = transCont->begin();
52
TRANS::const_iterator it_CollEnd = transCont->end();
53
unsigned
int
collIndex;
54
unsigned
int
chanBegin = 0;
55
unsigned
int
chanEnd = 0;
56
persCont->
m_collections
.resize(transCont->numberOfCollections());
57
// if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << " Preparing " << persCont->m_collections.size() << "Collections" << endmsg;
58
59
for
(collIndex = 0; it_Coll != it_CollEnd; ++collIndex, ++it_Coll) {
60
// Add in new collection
61
const
InDet::TRT_DriftCircleCollection& collection = (**it_Coll);
62
chanBegin = chanEnd;
63
chanEnd += collection.
size
();
64
InDet::InDetPRD_Collection_p1
& pcollection = persCont->
m_collections
[collIndex];
65
pcollection.
m_id
= collection.identify().get_compact();
66
pcollection.
m_hashId
= (
unsigned
int) collection.identifyHash();
67
pcollection.
m_begin
= chanBegin;
68
pcollection.
m_end
= chanEnd;
69
// Add in channels
70
persCont->
m_PRD
.resize(chanEnd);
71
for
(
unsigned
int
i = 0; i < collection.size(); ++i) {
72
const
InDet::TRT_DriftCircle
* chan = collection[i];
73
persCont->
m_PRD
[i + chanBegin] =
toPersistent
((CONV**)
nullptr
, chan, log );
74
}
75
}
76
// if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << " *** Writing TRT_DriftCircleContainer ***" << endmsg;
77
}
78
79
void
InDet::TRT_DriftCircleContainerCnv_p1::persToTrans
(
const
InDet::InDetPRD_Container_p1
* persCont, InDet::TRT_DriftCircleContainer* transCont, MsgStream &log)
80
{
81
82
// The transient model has a container holding collections and the
83
// collections hold channels.
84
//
85
// The persistent model flattens this so that the persistent
86
// container has two vectors:
87
// 1) all collections, and
88
// 2) all channels
89
//
90
// The persistent collections, then only maintain indexes into the
91
// container's vector of all channels.
92
//
93
// So here we loop over all collection and extract their channels
94
// from the vector.
95
96
97
InDet::TRT_DriftCircleCollection* coll =
nullptr
;
98
99
TRT_DriftCircleCnv_p1
chanCnv;
100
using
CONV =
ITPConverterFor<Trk::PrepRawData>
;
101
102
// if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << " Reading " << persCont->m_collections.size() << "Collections" << endmsg;
103
for
(
unsigned
int
icoll = 0; icoll < persCont->
m_collections
.size(); ++icoll) {
104
105
// Create trans collection - is NOT owner of TRT_DriftCircle (SG::VIEW_ELEMENTS)
106
// IDet collection don't have the Ownership policy c'tor
107
const
InDet::InDetPRD_Collection_p1
& pcoll = persCont->
m_collections
[icoll];
108
//Identifier collID(Identifier(pcoll.m_id));
109
IdentifierHash
collIDHash(
IdentifierHash
(pcoll.
m_hashId
));
110
coll =
new
InDet::TRT_DriftCircleCollection(collIDHash);
111
coll->setIdentifier(
Identifier
(pcoll.
m_id
));
112
unsigned
int
nchans = pcoll.
m_end
- pcoll.
m_begin
;
113
coll->resize(nchans);
114
const
InDetDD::TRT_BaseElement
* de =
m_trtMgr
->getElement(collIDHash);
115
// Fill with channels
116
for
(
unsigned
int
ichan = 0; ichan < nchans; ++ ichan) {
117
const
TPObjRef
pchan = persCont->
m_PRD
[ichan + pcoll.
m_begin
];
118
InDet::TRT_DriftCircle
* chan =
dynamic_cast<
InDet::TRT_DriftCircle
*
>
(
createTransFromPStore
((CONV**)
nullptr
, pchan, log ) );
119
if
(chan) {
120
chan->m_detEl = de;
121
(*coll)[ichan] = chan;
122
}
123
}
124
125
// register the rdo collection in IDC with hash - faster addCollection
126
StatusCode
sc
= transCont->addCollection(coll, collIDHash);
127
if
(
sc
.isFailure()) {
128
throw
std::runtime_error(
"Failed to add collection to ID Container"
);
129
}
130
// if (log.level() <= MSG::DEBUG) {
131
// log << MSG::DEBUG << "AthenaPoolTPCnvIDCont::persToTrans, collection, hash_id/coll id = " << (int) collIDHash << " / " <<
132
// collID.get_compact() << ", added to Identifiable container." << endmsg;
133
// }
134
}
135
136
// if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << " *** Reading TRT_DriftCircleContainer" << endmsg;
137
}
138
139
140
141
//================================================================
142
InDet::TRT_DriftCircleContainer*
InDet::TRT_DriftCircleContainerCnv_p1::createTransient
(
const
InDet::InDetPRD_Container_p1
* persObj, MsgStream& log) {
143
if
(!
m_isInitialized
) {
144
if
(this->
initialize
(log) != StatusCode::SUCCESS) {
145
log << MSG::FATAL <<
"Could not initialize TRT_DriftCircleContainerCnv_p1 "
<<
endmsg
;
146
}
147
}
148
std::unique_ptr<InDet::TRT_DriftCircleContainer> trans(std::make_unique<InDet::TRT_DriftCircleContainer>(
m_trtId
->module_hash_max()));
149
persToTrans
(persObj, trans.get(), log);
150
return
(trans.release());
151
}
152
153
StatusCode
InDet::TRT_DriftCircleContainerCnv_p1::initialize
(MsgStream &
/*log*/
) {
154
// Do not initialize again:
155
m_isInitialized
=
true
;
156
157
SmartIF<StoreGateSvc> detStore{Gaudi::svcLocator()->service(
"DetectorStore"
)};
158
CHECK
( detStore.isValid() );
159
CHECK
( detStore->retrieve(
m_trtId
,
"TRT_ID"
) );
160
CHECK
( detStore->retrieve(
m_trtMgr
) );
161
return
StatusCode::SUCCESS;
162
}
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:54
errorcheck.h
Helpers for checking error return status codes and reporting errors.
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition
Control/AthenaKernel/AthenaKernel/errorcheck.h:422
DataPool.h
InDetPRD_Container_p1.h
sc
static Double_t sc
Definition
LArPhysWaveHECTool.cxx:37
StoreGateSvc.h
TRT_DetectorManager.h
TRT_DriftCircleCnv_p1.h
TRT_DriftCircleContainerCnv_p1.h
TRT_DriftCircleContainer.h
TRT_DriftCircle.h
TRT_DriftCircle_p1.h
TRT_ID.h
This is an Identifier helper class for the TRT subdetector.
DataVector< PrepRawDataT >::size
size_type size() const noexcept
ITPConverterFor
Common base class for all TP converters, specialized for a given transient type.
Definition
TPConverter.h:37
TPPolyCnvBase< TRANS, TRANS, PERS >::createTransFromPStore
CNV::Trans_t * createTransFromPStore(CNV **cnv, const TPObjRef &ref, MsgStream &log) const
Definition
TPConverter.h:172
TPPolyCnvBase< TRANS, TRANS, PERS >::toPersistent
TPObjRef toPersistent(CNV **cnv, const typename CNV::TransBase_t *transObj, MsgStream &log) const
Definition
TPConverter.h:119
IdentifierHash
This is a "hash" representation of an Identifier.
Definition
IdentifierHash.h:25
InDetDD::TRT_BaseElement
Virtual base class of TRT readout elements.
Definition
TRT_BaseElement.h:56
InDet::InDetPRD_Collection_p1
Definition
InDetPRD_Collection_p1.h:11
InDet::InDetPRD_Collection_p1::m_begin
unsigned int m_begin
Definition
InDetPRD_Collection_p1.h:41
InDet::InDetPRD_Collection_p1::m_id
unsigned int m_id
Definition
InDetPRD_Collection_p1.h:32
InDet::InDetPRD_Collection_p1::m_hashId
unsigned int m_hashId
Definition
InDetPRD_Collection_p1.h:38
InDet::InDetPRD_Collection_p1::m_end
unsigned int m_end
Definition
InDetPRD_Collection_p1.h:44
InDet::InDetPRD_Container_p1
Definition
InDetPRD_Container_p1.h:14
InDet::InDetPRD_Container_p1::m_PRD
std::vector< TPObjRef > m_PRD
Definition
InDetPRD_Container_p1.h:20
InDet::InDetPRD_Container_p1::m_collections
std::vector< InDet::InDetPRD_Collection_p1 > m_collections
Definition
InDetPRD_Container_p1.h:19
InDet::TRT_DriftCircleContainerCnv_p1::m_trtMgr
const InDetDD::TRT_DetectorManager * m_trtMgr
Definition
TRT_DriftCircleContainerCnv_p1.h:41
InDet::TRT_DriftCircleContainerCnv_p1::createTransient
virtual InDet::TRT_DriftCircleContainer * createTransient(const InDet::InDetPRD_Container_p1 *persObj, MsgStream &log)
Definition
TRT_DriftCircleContainerCnv_p1.cxx:142
InDet::TRT_DriftCircleContainerCnv_p1::m_trtId
const TRT_ID * m_trtId
Definition
TRT_DriftCircleContainerCnv_p1.h:40
InDet::TRT_DriftCircleContainerCnv_p1::m_isInitialized
bool m_isInitialized
Definition
TRT_DriftCircleContainerCnv_p1.h:42
InDet::TRT_DriftCircleContainerCnv_p1::persToTrans
virtual void persToTrans(const PERS *persCont, TRANS *transCont, MsgStream &log)
Definition
TRT_DriftCircleContainerCnv_p1.cxx:79
InDet::TRT_DriftCircleContainerCnv_p1::transToPers
virtual void transToPers(const TRANS *transCont, PERS *persCont, MsgStream &log)
Definition
TRT_DriftCircleContainerCnv_p1.cxx:29
InDet::TRT_DriftCircleContainerCnv_p1::initialize
StatusCode initialize(MsgStream &log)
Definition
TRT_DriftCircleContainerCnv_p1.cxx:153
InDet::TRT_DriftCircleContainerCnv_p1::TRANS
InDet::TRT_DriftCircleContainer TRANS
Definition
TRT_DriftCircleContainerCnv_p1.h:31
InDet::TRT_DriftCircle
Definition
TRT_DriftCircle.h:32
TPObjRef
This class is an object reference used in Athena persistent data model.
Definition
TPObjRef.h:20
TRT_DriftCircleCnv_p1
Definition
TRT_DriftCircleCnv_p1.h:25
Identifier
Definition
IdentifierFieldParser.cxx:14
initialize
void initialize()
Definition
run_EoverP.cxx:894
Generated on
for ATLAS Offline Software by
1.17.0