ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
InnerDetector
InDetEventCnv
InDetEventTPCnv
src
PixelClusterContainerCnv_p3.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
#include "
InDetEventTPCnv/PixelClusterContainerCnv_p3.h
"
6
7
// Athena
8
#include "
AthenaKernel/errorcheck.h
"
9
#include "Identifier/Identifier.h"
10
#include "
InDetIdentifier/PixelID.h
"
11
#include "
InDetEventTPCnv/InDetPrepRawData/InDetPRD_Collection_p2.h
"
12
#include "
InDetEventTPCnv/PixelClusterContainer_p3.h
"
13
#include "
InDetEventTPCnv/InDetPrepRawData/PixelCluster_p3.h
"
14
#include "
InDetEventTPCnv/InDetPrepRawData/PixelClusterCnv_p3.h
"
15
#include "
InDetPrepRawData/PixelCluster.h
"
16
#include "
InDetPrepRawData/PixelClusterContainer.h
"
17
#include "
StoreGate/ReadCondHandle.h
"
18
#include "
StoreGate/StoreGateSvc.h
"
19
20
// Gaudi
21
#include "GaudiKernel/Bootstrap.h"
22
#include "GaudiKernel/ISvcLocator.h"
23
#include "GaudiKernel/MsgStream.h"
24
#include "GaudiKernel/Service.h"
25
#include "GaudiKernel/StatusCode.h"
26
27
void
PixelClusterContainerCnv_p3::transToPers
(
const
InDet::PixelClusterContainer* transCont,
InDet::PixelClusterContainer_p3
* persCont, MsgStream &log) {
28
29
// The transient model has a container holding collections and the
30
// collections hold channels.
31
//
32
// The persistent model flattens this so that the persistent
33
// container has two vectors:
34
// 1) all collections, and
35
// 2) all PRD
36
//
37
// The persistent collections, then only maintain indexes into the
38
// container's vector of all channels.
39
//
40
// So here we loop over all collection and add their channels
41
// to the container's vector, saving the indexes in the
42
// collection.
43
44
using
TRANS = InDet::PixelClusterContainer;
45
46
// this is the id of the latest collection read in
47
// This starts from the base of the TRT identifiers
48
unsigned
int
idLast(0);
49
50
//
51
//PixelClusterCnv_p3 chanCnv;
52
if
(!
m_isInitialized
) {
53
if
(this->
initialize
(log) != StatusCode::SUCCESS) {
54
log << MSG::FATAL <<
"Could not initialize PixelClusterContainerCnv_p3 "
<<
endmsg
;
55
}
56
}
57
PixelClusterCnv_p3
chanCnv(
m_pixId
);
58
59
TRANS::const_iterator it_Coll = transCont->begin();
60
TRANS::const_iterator it_CollEnd = transCont->end();
61
unsigned
int
collIndex;
62
unsigned
int
chanBegin = 0;
63
unsigned
int
chanEnd = 0;
64
persCont->
m_collections
.resize(transCont->numberOfCollections());
65
// if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << " Preparing " << persCont->m_collections.size() << "Collections" << endmsg;
66
for
(collIndex = 0; it_Coll != it_CollEnd; ++collIndex, ++it_Coll) {
67
// Add in new collection
68
const
InDet::PixelClusterCollection& collection = (**it_Coll);
69
chanBegin = chanEnd;
70
chanEnd += collection.
size
();
71
InDet::InDetPRD_Collection_p2
& pcollection = persCont->
m_collections
[collIndex];
72
unsigned
int
deltaId = (collection.identifyHash()-idLast);
73
74
pcollection.
m_hashId
= deltaId;
75
idLast=collection.identifyHash();
76
pcollection.
m_size
= collection.size();
77
// Add in channels
78
persCont->
m_rawdata
.resize(chanEnd);
79
for
(
unsigned
int
i = 0; i < collection.size(); ++i) {
80
InDet::PixelCluster_p3
* pchan = &(persCont->
m_rawdata
[i + chanBegin]);
81
const
InDet::PixelCluster
* chan =
static_cast<
const
InDet::PixelCluster
*
>
(collection[i]);
82
chanCnv.
transToPers
(chan, pchan, log);
83
}
84
}
85
}
86
87
void
PixelClusterContainerCnv_p3::persToTrans
(
const
InDet::PixelClusterContainer_p3
* persCont, InDet::PixelClusterContainer* transCont, MsgStream &log)
88
{
89
90
// The transient model has a container holding collections and the
91
// collections hold channels.
92
//
93
// The persistent model flattens this so that the persistent
94
// container has two vectors:
95
// 1) all collections, and
96
// 2) all channels
97
//
98
// The persistent collections, then only maintain indexes into the
99
// container's vector of all channels.
100
//
101
// So here we loop over all collection and extract their channels
102
// from the vector.
103
104
const
InDetDD::SiDetectorElementCollection
* elements(
nullptr
);
105
if
(
m_useDetectorElement
) {
106
try
{
107
SG::ReadCondHandle<InDetDD::SiDetectorElementCollection>
pixelDetEleHandle1(
m_pixelDetEleCollKey
);
108
elements = pixelDetEleHandle1.
cptr
();
109
}
catch
(
const
SG::ExcNoCondCont
& e) {
110
log << MSG::DEBUG <<
m_pixelDetEleCollKey
<<
" is not available - probably RUN4, trying "
<<
m_pixelITkEleCollKey
<<
" instead."
<<
endmsg
;
111
// If the first key fails, try the second key
112
try
{
113
SG::ReadCondHandle<InDetDD::SiDetectorElementCollection>
pixelDetEleHandle2(
m_pixelITkEleCollKey
);
114
elements = pixelDetEleHandle2.
cptr
();
115
}
catch
(
const
SG::ExcNoCondCont
& e) {
116
log << MSG::FATAL <<
"No valid Pixel detector element collection keys available."
<<
endmsg
;
117
return
;
118
}
119
}
120
}
121
122
InDet::PixelClusterCollection* coll =
nullptr
;
123
124
//PixelClusterCnv_p3 chanCnv;
125
PixelClusterCnv_p3
chanCnv(
m_pixId
);
126
unsigned
int
collBegin(0);
127
// this is the id of the latest collection read in
128
// This starts from the base of the TRT identifiers
129
unsigned
int
idLast(0);
130
// if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << " Reading " << persCont->m_collections.size() << "Collections" << endmsg;
131
for
(
unsigned
int
icoll = 0; icoll < persCont->
m_collections
.size(); ++icoll) {
132
133
// Create trans collection - in NOT owner of PixelDriftCircle (SG::VIEW_ELEMENTS)
134
// IDet collection don't have the Ownership policy c'tor
135
const
InDet::InDetPRD_Collection_p2
& pcoll = persCont->
m_collections
[icoll];
136
idLast += pcoll.
m_hashId
;
137
// Identifier collID= Identifier(idLast);
138
IdentifierHash
collIDHash=
IdentifierHash
((
unsigned
int
) idLast);
139
Identifier
collID =
m_pixId
->wafer_id(collIDHash);
140
coll =
new
InDet::PixelClusterCollection(collIDHash);
141
coll->setIdentifier(
Identifier
(collID));
142
unsigned
int
nchans = pcoll.
m_size
;
143
coll->resize(nchans);
144
const
InDetDD::SiDetectorElement
* de = (elements==
nullptr
? nullptr : elements->
getDetectorElement
(collIDHash));
145
// Fill with channels:
146
// This is used to read the vector of errMat
147
// values and lenght of the value are specified in separate vectors
148
// if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "Reading collection with " << nchans << "Channels " << endmsg;
149
for
(
unsigned
int
ichan = 0; ichan < nchans; ++ ichan) {
150
const
InDet::PixelCluster_p3
* pchan = &(persCont->
m_rawdata
[ichan + collBegin]);
151
// In preparation for 64-bit ids, set the initial cluster
152
// id to the wafer id. Actual cluster id will be set in
153
// the converter from diff.
154
InDet::PixelCluster
* chan =
new
InDet::PixelCluster
155
(chanCnv.
createPixelCluster
(pchan, collID, de, log));
156
// DC Bugfix: Set the hash index!
157
chan->setHashAndIndex(collIDHash, ichan);
158
(*coll)[ichan] = chan;
159
}
160
collBegin += pcoll.
m_size
;
161
162
// register the PRD collection in IDC with hash - faster addCollection
163
StatusCode
sc
= transCont->addCollection(coll, collIDHash);
164
if
(
sc
.isFailure()) {
165
throw
std::runtime_error(
"Failed to add collection to ID Container"
);
166
}
167
// if (log.level() <= MSG::DEBUG) {
168
// log << MSG::DEBUG << "AthenaPoolTPCnvIDCont::persToTrans, collection, hash_id/coll id = " << (int) collIDHash << " / " << collID << ", added to Identifiable container." << endmsg;
169
// }
170
}
171
172
// if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << " *** Reading InDet::PixelClusterContainer" << endmsg;
173
}
174
175
176
177
//================================================================
178
InDet::PixelClusterContainer*
PixelClusterContainerCnv_p3::createTransient
(
const
InDet::PixelClusterContainer_p3
* persObj, MsgStream& log) {
179
// if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "PixelClusterContainerCnv_p3::createTransient called " << endmsg;
180
if
(!
m_isInitialized
) {
181
if
(this->
initialize
(log) != StatusCode::SUCCESS) {
182
log << MSG::FATAL <<
"Could not initialize PixelClusterContainerCnv_p3 "
<<
endmsg
;
183
}
184
}
185
if
(not
m_pixId
) {
186
log << MSG::FATAL <<
"nullptr for m_pixId in PixelClusterContainerCnv_p3::createTransient"
<<
endmsg
;
187
return
nullptr
;
188
}
189
std::unique_ptr<InDet::PixelClusterContainer> trans(std::make_unique<InDet::PixelClusterContainer>(
m_pixId
->wafer_hash_max()));
190
persToTrans
(persObj, trans.get(), log);
191
return
(trans.release());
192
}
193
194
195
StatusCode
PixelClusterContainerCnv_p3::initialize
(MsgStream&) {
196
// Do not initialize again:
197
m_isInitialized
=
true
;
198
199
// Get Storegate, ID helpers, and so on
200
SmartIF<StoreGateSvc> detStore{Gaudi::svcLocator()->service(
"DetectorStore"
)};
201
CHECK
( detStore.isValid() );
202
203
// Get the Pixel helper from the detector store
204
CHECK
( detStore->retrieve(
m_pixId
,
"PixelID"
) );
205
206
CHECK
(
m_pixelDetEleCollKey
.initialize(
m_useDetectorElement
));
207
CHECK
(
m_pixelITkEleCollKey
.initialize(
m_useDetectorElement
));
208
209
return
StatusCode::SUCCESS;
210
}
211
212
void
PixelClusterContainerCnv_p3::setUseDetectorElement
(
const
bool
useDetectorElement) {
213
m_useDetectorElement
= useDetectorElement;
214
}
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_Collection_p2.h
PixelClusterContainer.h
PixelCluster.h
sc
static Double_t sc
Definition
LArPhysWaveHECTool.cxx:37
PixelClusterCnv_p3.h
PixelClusterContainerCnv_p3.h
PixelClusterContainer_p3.h
PixelCluster_p3.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
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::SiDetectorElementCollection::getDetectorElement
const SiDetectorElement * getDetectorElement(const IdentifierHash &hash) const
Definition
SiDetectorElementCollection.cxx:9
InDetDD::SiDetectorElement
Class to hold geometrical description of a silicon detector element.
Definition
SiDetectorElement.h:109
InDet::InDetPRD_Collection_p2
Definition
InDetPRD_Collection_p2.h:11
InDet::InDetPRD_Collection_p2::m_hashId
unsigned short m_hashId
Definition
InDetPRD_Collection_p2.h:35
InDet::InDetPRD_Collection_p2::m_size
unsigned short m_size
Definition
InDetPRD_Collection_p2.h:40
InDet::PixelClusterContainer_p3
Definition
PixelClusterContainer_p3.h:21
InDet::PixelClusterContainer_p3::m_collections
std::vector< InDet::InDetPRD_Collection_p2 > m_collections
Definition
PixelClusterContainer_p3.h:26
InDet::PixelClusterContainer_p3::m_rawdata
std::vector< InDet::PixelCluster_p3 > m_rawdata
Definition
PixelClusterContainer_p3.h:27
InDet::PixelCluster_p3
Definition
PixelCluster_p3.h:18
InDet::PixelCluster
Definition
InnerDetector/InDetRecEvent/InDetPrepRawData/InDetPrepRawData/PixelCluster.h:49
PixelClusterCnv_p3
Definition
PixelClusterCnv_p3.h:29
PixelClusterCnv_p3::createPixelCluster
InDet::PixelCluster createPixelCluster(const InDet::PixelCluster_p3 *persObj, const Identifier &waferId, const InDetDD::SiDetectorElement *delEl, MsgStream &log)
Definition
PixelClusterCnv_p3.cxx:29
PixelClusterCnv_p3::transToPers
void transToPers(const InDet::PixelCluster *, InDet::PixelCluster_p3 *, MsgStream &)
Definition
PixelClusterCnv_p3.cxx:127
PixelClusterContainerCnv_p3::transToPers
virtual void transToPers(const InDet::PixelClusterContainer *transCont, InDet::PixelClusterContainer_p3 *persCont, MsgStream &log)
Definition
PixelClusterContainerCnv_p3.cxx:27
PixelClusterContainerCnv_p3::m_pixelITkEleCollKey
SG::ReadCondHandleKey< InDetDD::SiDetectorElementCollection > m_pixelITkEleCollKey
Definition
PixelClusterContainerCnv_p3.h:46
PixelClusterContainerCnv_p3::setUseDetectorElement
void setUseDetectorElement(const bool useDetectorElement)
Definition
PixelClusterContainerCnv_p3.cxx:212
PixelClusterContainerCnv_p3::initialize
StatusCode initialize(MsgStream &log)
Definition
PixelClusterContainerCnv_p3.cxx:195
PixelClusterContainerCnv_p3::m_useDetectorElement
bool m_useDetectorElement
Definition
PixelClusterContainerCnv_p3.h:47
PixelClusterContainerCnv_p3::m_pixelDetEleCollKey
SG::ReadCondHandleKey< InDetDD::SiDetectorElementCollection > m_pixelDetEleCollKey
Definition
PixelClusterContainerCnv_p3.h:45
PixelClusterContainerCnv_p3::createTransient
virtual InDet::PixelClusterContainer * createTransient(const InDet::PixelClusterContainer_p3 *persObj, MsgStream &log)
Definition
PixelClusterContainerCnv_p3.cxx:178
PixelClusterContainerCnv_p3::persToTrans
virtual void persToTrans(const InDet::PixelClusterContainer_p3 *persCont, InDet::PixelClusterContainer *transCont, MsgStream &log)
Definition
PixelClusterContainerCnv_p3.cxx:87
PixelClusterContainerCnv_p3::m_isInitialized
bool m_isInitialized
Definition
PixelClusterContainerCnv_p3.h:48
PixelClusterContainerCnv_p3::m_pixId
const PixelID * m_pixId
Definition
PixelClusterContainerCnv_p3.h:44
SG::ExcNoCondCont
Exception — Can't retrieve CondCont from ReadCondHandle.
Definition
Control/StoreGate/StoreGate/exceptions.h:330
SG::ReadCondHandle
Definition
ReadCondHandle.h:40
SG::ReadCondHandle::cptr
const_pointer_type cptr()
Definition
ReadCondHandle.h:67
Identifier
Definition
IdentifierFieldParser.cxx:14
initialize
void initialize()
Definition
run_EoverP.cxx:894
Generated on
for ATLAS Offline Software by
1.17.0