ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
InnerDetector
InDetEventCnv
InDetEventTPCnv
src
PixelClusterContainerCnv_p2.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 "Identifier/Identifier.h"
8
#include "
InDetPrepRawData/PixelCluster.h
"
9
#include "
InDetEventTPCnv/InDetPrepRawData/PixelCluster_p2.h
"
10
#include "
InDetEventTPCnv/PixelClusterContainer_p2.h
"
11
#include "
InDetEventTPCnv/InDetPrepRawData/InDetPRD_Collection_p2.h
"
12
#include "
InDetPrepRawData/PixelClusterContainer.h
"
13
#include "
InDetIdentifier/PixelID.h
"
14
#include "
InDetEventTPCnv/InDetPrepRawData/PixelClusterCnv_p2.h
"
15
#include "
InDetEventTPCnv/PixelClusterContainerCnv_p2.h
"
16
#include "
StoreGate/ReadCondHandle.h
"
17
#include "
StoreGate/StoreGateSvc.h
"
18
19
// Gaudi
20
#include "GaudiKernel/ISvcLocator.h"
21
#include "GaudiKernel/Bootstrap.h"
22
#include "GaudiKernel/Service.h"
23
#include "GaudiKernel/MsgStream.h"
24
25
void
PixelClusterContainerCnv_p2::transToPers
(
const
InDet::PixelClusterContainer* transCont,
InDet::PixelClusterContainer_p2
* persCont, MsgStream &log) {
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 PRD
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
44
// this is the id of the latest collection read in
45
// This starts from the base of the TRT identifiers
46
unsigned
int
idLast(0);
47
48
//
49
PixelClusterCnv_p2
chanCnv;
50
TRANS::const_iterator it_Coll = transCont->begin();
51
TRANS::const_iterator it_CollEnd = transCont->end();
52
unsigned
int
collIndex;
53
unsigned
int
chanBegin = 0;
54
unsigned
int
chanEnd = 0;
55
persCont->
m_collections
.resize(transCont->numberOfCollections());
56
// if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << " Preparing " << persCont->m_collections.size() << "Collections" << endmsg;
57
for
(collIndex = 0; it_Coll != it_CollEnd; ++collIndex, ++it_Coll) {
58
// Add in new collection
59
const
InDet::PixelClusterCollection& collection = (**it_Coll);
60
chanBegin = chanEnd;
61
chanEnd += collection.
size
();
62
InDet::InDetPRD_Collection_p2
& pcollection = persCont->
m_collections
[collIndex];
63
unsigned
int
deltaId = (collection.identifyHash()-idLast);
64
// unsigned int deltaId = (collection.identify().get_compact()-idLast)/IDJUMP;
65
// if(deltaId*IDJUMP != collection.identify().get_compact()-idLast )
66
// log << MSG::FATAL << "THere is a mistake in Identifiers of the collection" << endmsg;
67
// if(deltaId > 0xFFFF) {
68
// log << MSG::FATAL << "Fixme!!! This is too big, something needs to be done " << endmsg;
69
// }
70
// pcollection.m_idDelta = (unsigned short) deltaId;
71
// idLast = collection.identify().get_compact(); // then update the last identifier
72
pcollection.
m_hashId
= deltaId;
73
idLast=collection.identifyHash();
74
pcollection.
m_size
= collection.size();
75
// Add in channels
76
persCont->
m_rawdata
.resize(chanEnd);
77
log << MSG::VERBOSE <<
"Reading collections with "
<< collection.size() <<
"PRDs "
<<
endmsg
;
78
for
(
unsigned
int
i = 0; i < collection.size(); ++i) {
79
InDet::PixelCluster_p2
* pchan = &(persCont->
m_rawdata
[i + chanBegin]);
80
const
InDet::PixelCluster
* chan =
static_cast<
const
InDet::PixelCluster
*
>
(collection[i]);
81
chanCnv.
transToPers
(chan, pchan, log);
82
}
83
}
84
// if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << " *** Writing InDet::PixelClusterContainer" << endmsg;
85
}
86
87
void
PixelClusterContainerCnv_p2::persToTrans
(
const
InDet::PixelClusterContainer_p2
* 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
SG::ReadCondHandle<InDetDD::SiDetectorElementCollection>
pixelDetEleHandle(
m_pixelDetEleCollKey
);
107
elements = *pixelDetEleHandle;
108
if
(not pixelDetEleHandle.
isValid
() or elements==
nullptr
) {
109
log << MSG::FATAL <<
m_pixelDetEleCollKey
.fullKey() <<
" is not available."
<<
endmsg
;
110
return
;
111
}
112
}
113
114
InDet::PixelClusterCollection* coll =
nullptr
;
115
116
PixelClusterCnv_p2
chanCnv;
117
unsigned
int
collBegin(0);
118
// this is the id of the latest collection read in
119
// This starts from the base of the TRT identifiers
120
unsigned
int
idLast(0);
121
// if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << " Reading " << persCont->m_collections.size() << "Collections" << endmsg;
122
for
(
unsigned
int
icoll = 0; icoll < persCont->
m_collections
.size(); ++icoll) {
123
124
// Create trans collection - in NOT owner of PixelDriftCircle (SG::VIEW_ELEMENTS)
125
// IDet collection don't have the Ownership policy c'tor
126
const
InDet::InDetPRD_Collection_p2
& pcoll = persCont->
m_collections
[icoll];
127
idLast += pcoll.
m_hashId
;
128
// Identifier collID= Identifier(idLast);
129
IdentifierHash
collIDHash=
IdentifierHash
((
unsigned
int
) idLast);
130
Identifier
collID =
m_pixId
->wafer_id(collIDHash);
131
coll =
new
InDet::PixelClusterCollection(collIDHash);
132
coll->setIdentifier(
Identifier
(collID));
133
unsigned
int
nchans = pcoll.
m_size
;
134
coll->resize(nchans);
135
const
InDetDD::SiDetectorElement
* de = (elements==
nullptr
? nullptr : elements->
getDetectorElement
(collIDHash));
136
// Fill with channels:
137
// This is used to read the vector of errMat
138
// values and lenght of the value are specified in separate vectors
139
// if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "Reading collection with " << nchans << "Channels " << endmsg;
140
for
(
unsigned
int
ichan = 0; ichan < nchans; ++ ichan) {
141
const
InDet::PixelCluster_p2
* pchan = &(persCont->
m_rawdata
[ichan + collBegin]);
142
InDet::PixelCluster
* chan =
new
InDet::PixelCluster
();
143
chanCnv.
persToTrans
(pchan, chan, log);
144
chan->setDetectorElement(de);
145
// DC Bugfix: Set the hash index!
146
chan->setHashAndIndex(collIDHash, ichan);
147
(*coll)[ichan] = chan;
148
}
149
collBegin += pcoll.
m_size
;
150
151
// register the PRD collection in IDC with hash - faster addCollection
152
StatusCode
sc
= transCont->addCollection(coll, collIDHash);
153
if
(
sc
.isFailure()) {
154
throw
std::runtime_error(
"Failed to add collection to ID Container"
);
155
}
156
// if (log.level() <= MSG::DEBUG) {
157
// log << MSG::DEBUG << "AthenaPoolTPCnvIDCont::persToTrans, collection, hash_id/coll id = " << (int) collIDHash << " / " << collID << ", added to Identifiable container." << endmsg;
158
// }
159
}
160
161
// if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << " *** Reading InDet::PixelClusterContainer" << endmsg;
162
}
163
164
165
166
//================================================================
167
InDet::PixelClusterContainer*
PixelClusterContainerCnv_p2::createTransient
(
const
InDet::PixelClusterContainer_p2
* persObj, MsgStream& log) {
168
if
(!
m_isInitialized
) {
169
if
(this->
initialize
(log) != StatusCode::SUCCESS) {
170
log << MSG::FATAL <<
"Could not initialize PixelClusterContainerCnv_p2 "
<<
endmsg
;
171
}
172
}
173
if
(not
m_pixId
) {
174
log << MSG::FATAL <<
"nullptr for m_pixId in PixelClusterContainerCnv_p2::createTransient"
<<
endmsg
;
175
return
nullptr
;
176
}
177
std::unique_ptr<InDet::PixelClusterContainer> trans(std::make_unique<InDet::PixelClusterContainer>(
m_pixId
->wafer_hash_max()));
178
persToTrans
(persObj, trans.get(), log);
179
return
(trans.release());
180
}
181
182
183
StatusCode
PixelClusterContainerCnv_p2::initialize
(MsgStream&) {
184
// Do not initialize again:
185
m_isInitialized
=
true
;
186
187
// Get Storegate, ID helpers, and so on
188
SmartIF<StoreGateSvc> detStore{Gaudi::svcLocator()->service(
"DetectorStore"
)};
189
CHECK
( detStore.isValid() );
190
191
// Get the sct helper from the detector store
192
CHECK
( detStore->retrieve(
m_pixId
,
"PixelID"
) );
193
194
CHECK
(
m_pixelDetEleCollKey
.initialize(
m_useDetectorElement
));
195
196
return
StatusCode::SUCCESS;
197
}
198
199
void
PixelClusterContainerCnv_p2::setUseDetectorElement
(
const
bool
useDetectorElement) {
200
m_useDetectorElement
= useDetectorElement;
201
}
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_p2.h
PixelClusterContainerCnv_p2.h
PixelClusterContainer_p2.h
PixelCluster_p2.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_p2
Definition
PixelClusterContainer_p2.h:21
InDet::PixelClusterContainer_p2::m_collections
std::vector< InDet::InDetPRD_Collection_p2 > m_collections
Definition
PixelClusterContainer_p2.h:26
InDet::PixelClusterContainer_p2::m_rawdata
std::vector< InDet::PixelCluster_p2 > m_rawdata
Definition
PixelClusterContainer_p2.h:27
InDet::PixelCluster_p2
Definition
PixelCluster_p2.h:17
InDet::PixelCluster
Definition
InnerDetector/InDetRecEvent/InDetPrepRawData/InDetPrepRawData/PixelCluster.h:49
PixelClusterCnv_p2
Definition
PixelClusterCnv_p2.h:27
PixelClusterCnv_p2::transToPers
void transToPers(const InDet::PixelCluster *, InDet::PixelCluster_p2 *, MsgStream &)
Definition
PixelClusterCnv_p2.cxx:73
PixelClusterCnv_p2::persToTrans
void persToTrans(const InDet::PixelCluster_p2 *, InDet::PixelCluster *, MsgStream &)
Definition
PixelClusterCnv_p2.cxx:67
PixelClusterContainerCnv_p2::persToTrans
virtual void persToTrans(const InDet::PixelClusterContainer_p2 *persCont, InDet::PixelClusterContainer *transCont, MsgStream &log)
Definition
PixelClusterContainerCnv_p2.cxx:87
PixelClusterContainerCnv_p2::m_isInitialized
bool m_isInitialized
Definition
PixelClusterContainerCnv_p2.h:43
PixelClusterContainerCnv_p2::createTransient
virtual InDet::PixelClusterContainer * createTransient(const InDet::PixelClusterContainer_p2 *persObj, MsgStream &log)
Definition
PixelClusterContainerCnv_p2.cxx:167
PixelClusterContainerCnv_p2::transToPers
virtual void transToPers(const InDet::PixelClusterContainer *transCont, InDet::PixelClusterContainer_p2 *persCont, MsgStream &log)
Definition
PixelClusterContainerCnv_p2.cxx:25
PixelClusterContainerCnv_p2::m_pixId
const PixelID * m_pixId
Definition
PixelClusterContainerCnv_p2.h:40
PixelClusterContainerCnv_p2::m_useDetectorElement
bool m_useDetectorElement
Definition
PixelClusterContainerCnv_p2.h:42
PixelClusterContainerCnv_p2::initialize
StatusCode initialize(MsgStream &log)
Definition
PixelClusterContainerCnv_p2.cxx:183
PixelClusterContainerCnv_p2::m_pixelDetEleCollKey
SG::ReadCondHandleKey< InDetDD::SiDetectorElementCollection > m_pixelDetEleCollKey
Definition
PixelClusterContainerCnv_p2.h:41
PixelClusterContainerCnv_p2::setUseDetectorElement
void setUseDetectorElement(const bool useDetectorElement)
Definition
PixelClusterContainerCnv_p2.cxx:199
SG::ReadCondHandle
Definition
ReadCondHandle.h:40
SG::ReadCondHandle::isValid
bool isValid()
Definition
ReadCondHandle.h:205
Identifier
Definition
IdentifierFieldParser.cxx:14
initialize
void initialize()
Definition
run_EoverP.cxx:894
Generated on
for ATLAS Offline Software by
1.17.0