ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
InnerDetector
InDetEventCnv
InDetEventTPCnv
src
InDetPrepRawData
PixelClusterContainerCnv_p1.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
// Athena
6
#include "
AthenaKernel/errorcheck.h
"
7
#include "
InDetPrepRawData/PixelCluster.h
"
8
#include "
InDetPrepRawData/PixelClusterContainer.h
"
9
#include "
InDetEventTPCnv/InDetPrepRawData/PixelCluster_p1.h
"
10
#include "
InDetEventTPCnv/InDetPrepRawData/InDetPRD_Container_p1.h
"
11
#include "
InDetIdentifier/PixelID.h
"
12
#include "
InDetEventTPCnv/InDetPrepRawData/PixelClusterCnv_p1.h
"
13
#include "
InDetEventTPCnv/InDetPrepRawData/PixelClusterContainerCnv_p1.h
"
14
#include "
StoreGate/ReadCondHandle.h
"
15
#include "
StoreGate/StoreGateSvc.h
"
16
17
// Gaudi
18
#include "GaudiKernel/ISvcLocator.h"
19
#include "GaudiKernel/Bootstrap.h"
20
#include "GaudiKernel/StatusCode.h"
21
#include "GaudiKernel/Service.h"
22
#include "GaudiKernel/MsgStream.h"
23
24
void
InDet::PixelClusterContainerCnv_p1::transToPers
(
const
InDet::PixelClusterContainer* transCont,
InDet::InDetPRD_Container_p1
* persCont, MsgStream &log)
25
{
26
27
// The transient model has a container holding collections and the
28
// collections hold channels.
29
//
30
// The persistent model flattens this so that the persistent
31
// container has two vectors:
32
// 1) all collections, and
33
// 2) all RDO
34
//
35
// The persistent collections, then only maintain indexes into the
36
// container's vector of all channels.
37
//
38
// So here we loop over all collection and add their channels
39
// to the container's vector, saving the indexes in the
40
// collection.
41
42
using
TRANS
= InDet::PixelClusterContainer;
43
using
CONV =
ITPConverterFor<Trk::PrepRawData>
;
44
45
PixelClusterCnv_p1
chanCnv;
46
TRANS::const_iterator it_Coll = transCont->begin();
47
TRANS::const_iterator it_CollEnd = transCont->end();
48
unsigned
int
collIndex;
49
unsigned
int
chanBegin = 0;
50
unsigned
int
chanEnd = 0;
51
persCont->
m_collections
.resize(transCont->numberOfCollections());
52
53
for
(collIndex = 0; it_Coll != it_CollEnd; ++collIndex, ++it_Coll) {
54
// Add in new collection
55
const
InDet::PixelClusterCollection& collection = (**it_Coll);
56
chanBegin = chanEnd;
57
chanEnd += collection.
size
();
58
InDet::InDetPRD_Collection_p1
& pcollection = persCont->
m_collections
[collIndex];
59
pcollection.
m_id
= collection.identify().get_compact();
60
pcollection.
m_hashId
= (
unsigned
int) collection.identifyHash();
61
pcollection.
m_begin
= chanBegin;
62
pcollection.
m_end
= chanEnd;
63
// Add in channels
64
persCont->
m_PRD
.resize(chanEnd);
65
for
(
unsigned
int
i = 0; i < collection.size(); ++i) {
66
const
InDet::PixelCluster
* chan = collection[i];
67
persCont->
m_PRD
[i + chanBegin] =
toPersistent
((CONV**)
nullptr
, chan, log );
68
}
69
}
70
}
71
72
void
InDet::PixelClusterContainerCnv_p1::persToTrans
(
const
InDet::InDetPRD_Container_p1
* persCont, InDet::PixelClusterContainer* transCont, MsgStream &log)
73
{
74
75
// The transient model has a container holding collections and the
76
// collections hold channels.
77
//
78
// The persistent model flattens this so that the persistent
79
// container has two vectors:
80
// 1) all collections, and
81
// 2) all channels
82
//
83
// The persistent collections then only maintain indices into the
84
// container's vector of all channels.
85
//
86
// So here we loop over all collection and extract their channels
87
// from the vector.
88
89
//see: coverity issue 22632, elements is unused. Left here to highlight this.
90
//const InDetDD::SiDetectorElementCollection* elements(nullptr);
91
if
(
m_useDetectorElement
) {
92
SG::ReadCondHandle<InDetDD::SiDetectorElementCollection>
pixelDetEleHandle(
m_pixelDetEleCollKey
);
93
const
InDetDD::SiDetectorElementCollection
* theseElements = *pixelDetEleHandle;
94
if
(not pixelDetEleHandle.
isValid
() or theseElements==
nullptr
) {
95
log << MSG::FATAL <<
m_pixelDetEleCollKey
.fullKey() <<
" is not available."
<<
endmsg
;
96
return
;
97
}
98
}
99
100
InDet::PixelClusterCollection* coll =
nullptr
;
101
102
PixelClusterCnv_p1
chanCnv;
103
using
CONV =
ITPConverterFor<Trk::PrepRawData>
;
104
105
for
(
unsigned
int
icoll = 0; icoll < persCont->
m_collections
.size(); ++icoll) {
106
107
// Create trans collection - is NOT owner of PixelCluster (SG::VIEW_ELEMENTS)
108
// IDet collection don't have the Ownership policy c'tor
109
const
InDet::InDetPRD_Collection_p1
& pcoll = persCont->
m_collections
[icoll];
110
IdentifierHash
collIDHash(
IdentifierHash
(pcoll.
m_hashId
));
111
coll =
new
InDet::PixelClusterCollection(collIDHash);
112
coll->setIdentifier(
Identifier
(pcoll.
m_id
));
113
unsigned
int
nchans = pcoll.
m_end
- pcoll.
m_begin
;
114
coll->resize(nchans);
115
const
InDetDD::SiDetectorElement
* de =
nullptr
;
//elements is nullptr, so this is also
116
// Fill with channels
117
for
(
unsigned
int
ichan = 0; ichan < nchans; ++ ichan) {
118
const
TPObjRef
pchan = persCont->
m_PRD
[ichan + pcoll.
m_begin
];
119
InDet::PixelCluster
* chan =
dynamic_cast<
InDet::PixelCluster
*
>
(
createTransFromPStore
((CONV**)
nullptr
, pchan, log ) );
120
if
(chan){
121
chan->m_detEl = de;
122
(*coll)[ichan] = chan;
123
}
else
{
124
log << MSG::WARNING <<
"Cast to InDet::PixelCluster* failed in PixelClusterContainerCnv_p1"
<<
endmsg
;
125
}
126
}
127
128
// register the rdo collection in IDC with hash - faster addCollection
129
StatusCode
sc
= transCont->addCollection(coll, collIDHash);
130
if
(
sc
.isFailure()) {
131
throw
std::runtime_error(
"Failed to add collection to ID Container"
);
132
}
133
134
}
135
136
}
137
138
139
140
//================================================================
141
InDet::PixelClusterContainer*
InDet::PixelClusterContainerCnv_p1::createTransient
(
const
InDet::InDetPRD_Container_p1
* persObj, MsgStream& log)
142
{
143
if
(!
m_isInitialized
) {
144
if
(this->
initialize
(log) != StatusCode::SUCCESS) {
145
log << MSG::FATAL <<
"Could not initialize PixelClusterContainerCnv_p1 "
<<
endmsg
;
146
return
nullptr
;
147
}
148
}
149
if
(not
m_pixId
) {
150
log << MSG::FATAL <<
"PixelID helper is null in PixelClusterContainerCnv_p1::createTransient"
<<
endmsg
;
151
return
nullptr
;
152
}
153
std::unique_ptr<InDet::PixelClusterContainer> trans(std::make_unique<InDet::PixelClusterContainer>(
m_pixId
->wafer_hash_max()));
154
persToTrans
(persObj, trans.get(), log);
155
return
(trans.release());
156
}
157
158
StatusCode
InDet::PixelClusterContainerCnv_p1::initialize
(MsgStream&) {
159
// Do not initialize again:
160
m_isInitialized
=
true
;
161
162
// get StoreGate service
163
CHECK
(
m_storeGate
.retrieve() );
164
165
// get DetectorStore service
166
SmartIF<StoreGateSvc> detStore{Gaudi::svcLocator()->service(
"DetectorStore"
)};
167
CHECK
( detStore.isValid() );
168
169
// Get the pixel helper from the detector store
170
CHECK
( detStore->retrieve(
m_pixId
,
"PixelID"
) );
171
172
CHECK
(
m_pixelDetEleCollKey
.initialize(
m_useDetectorElement
));
173
174
return
StatusCode::SUCCESS;
175
}
176
177
// Method for test/PixelClusterContainerCnv_p1_test.cxx
178
void
InDet::PixelClusterContainerCnv_p1::setUseDetectorElement
(
const
bool
useDetectorElement) {
179
m_useDetectorElement
= useDetectorElement;
180
}
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
InDetPRD_Container_p1.h
PixelClusterContainer.h
PixelCluster.h
sc
static Double_t sc
Definition
LArPhysWaveHECTool.cxx:37
PixelClusterCnv_p1.h
PixelClusterContainerCnv_p1.h
PixelCluster_p1.h
PixelID.h
This is an Identifier helper class for the Pixel subdetector.
ReadCondHandle.h
StoreGateSvc.h
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::SiDetectorElementCollection
Class to hold the SiDetectorElement objects to be put in the detector store.
Definition
SiDetectorElementCollection.h:27
InDetDD::SiDetectorElement
Class to hold geometrical description of a silicon detector element.
Definition
SiDetectorElement.h:109
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::PixelClusterContainerCnv_p1::transToPers
virtual void transToPers(const TRANS *transCont, PERS *persCont, MsgStream &log)
Definition
PixelClusterContainerCnv_p1.cxx:24
InDet::PixelClusterContainerCnv_p1::createTransient
virtual InDet::PixelClusterContainer * createTransient(const InDet::InDetPRD_Container_p1 *persObj, MsgStream &log)
Definition
PixelClusterContainerCnv_p1.cxx:141
InDet::PixelClusterContainerCnv_p1::TRANS
InDet::PixelClusterContainer TRANS
Definition
PixelClusterContainerCnv_p1.h:32
InDet::PixelClusterContainerCnv_p1::m_storeGate
ServiceHandle< StoreGateSvc > m_storeGate
Definition
PixelClusterContainerCnv_p1.h:40
InDet::PixelClusterContainerCnv_p1::setUseDetectorElement
void setUseDetectorElement(const bool useDetectorElement)
Definition
PixelClusterContainerCnv_p1.cxx:178
InDet::PixelClusterContainerCnv_p1::m_isInitialized
bool m_isInitialized
Definition
PixelClusterContainerCnv_p1.h:43
InDet::PixelClusterContainerCnv_p1::initialize
StatusCode initialize(MsgStream &log)
Definition
PixelClusterContainerCnv_p1.cxx:158
InDet::PixelClusterContainerCnv_p1::m_useDetectorElement
bool m_useDetectorElement
Definition
PixelClusterContainerCnv_p1.h:42
InDet::PixelClusterContainerCnv_p1::m_pixelDetEleCollKey
SG::ReadCondHandleKey< InDetDD::SiDetectorElementCollection > m_pixelDetEleCollKey
Definition
PixelClusterContainerCnv_p1.h:41
InDet::PixelClusterContainerCnv_p1::m_pixId
const PixelID * m_pixId
Definition
PixelClusterContainerCnv_p1.h:39
InDet::PixelClusterContainerCnv_p1::persToTrans
virtual void persToTrans(const PERS *persCont, TRANS *transCont, MsgStream &log)
Definition
PixelClusterContainerCnv_p1.cxx:72
InDet::PixelCluster
Definition
InnerDetector/InDetRecEvent/InDetPrepRawData/InDetPrepRawData/PixelCluster.h:49
PixelClusterCnv_p1
Definition
PixelClusterCnv_p1.h:23
SG::ReadCondHandle
Definition
ReadCondHandle.h:40
SG::ReadCondHandle::isValid
bool isValid()
Definition
ReadCondHandle.h:205
TPObjRef
This class is an object reference used in Athena persistent data model.
Definition
TPObjRef.h:20
Identifier
Definition
IdentifierFieldParser.cxx:14
initialize
void initialize()
Definition
run_EoverP.cxx:894
Generated on
for ATLAS Offline Software by
1.17.0