ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
InnerDetector
InDetEventCnv
InDetEventTPCnv
src
SCT_ClusterContainerCnv_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
#include "
InDetEventTPCnv/SCT_ClusterContainerCnv_p2.h
"
6
7
// Athena
8
#include "
AthenaKernel/errorcheck.h
"
9
#include "Identifier/Identifier.h"
10
#include "
InDetIdentifier/SCT_ID.h
"
11
#include "
InDetEventTPCnv/InDetPrepRawData/InDetPRD_Collection_p2.h
"
12
#include "
InDetEventTPCnv/InDetPrepRawData/SCT_Cluster_p2.h
"
13
#include "
InDetEventTPCnv/InDetPrepRawData/SCT_ClusterCnv_p2.h
"
14
#include "
InDetPrepRawData/SCT_Cluster.h
"
15
#include "
StoreGate/ReadCondHandle.h
"
16
#include "
StoreGate/StoreGateSvc.h
"
17
18
// Gaudi
19
#include "GaudiKernel/Bootstrap.h"
20
#include "GaudiKernel/ISvcLocator.h"
21
#include "GaudiKernel/MsgStream.h"
22
#include "GaudiKernel/Service.h"
23
#include "GaudiKernel/StatusCode.h"
24
25
void
SCT_ClusterContainerCnv_p2::transToPers
(
const
InDet::SCT_ClusterContainer* transCont,
InDet::SCT_ClusterContainer_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::SCT_ClusterContainer;
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
//SCT_ClusterCnv_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
56
//to retrieve the SCT_ID helper
57
if
(!
m_isInitialized
) {
58
if
(this->
initialize
(log) != StatusCode::SUCCESS) {
59
log << MSG::FATAL <<
"Could not initialize SCT_ClusterContainerCnv_p2 "
<<
endmsg
;
60
}
61
}
62
63
SCT_ClusterCnv_p2
chanCnv(
m_sctId
);
64
65
persCont->
m_collections
.resize(transCont->numberOfCollections());
66
67
// to avoid the inside-loop resize
68
int
totSize = 0;
69
//for ( ; it_Coll != it_CollEnd; it_Coll++) {
70
for
( it_Coll=transCont->begin(); it_Coll != it_CollEnd; ++it_Coll) {
71
const
InDet::SCT_ClusterCollection& collection = (**it_Coll);
72
totSize+=collection.size();
73
}
74
persCont->
m_rawdata
.resize(totSize);
75
persCont->
m_prdDeltaId
.resize(totSize);
76
77
// if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << " Preparing " << persCont->m_collections.size() << "Collections" << endmsg;
78
//for (collIndex = 0; it_Coll != it_CollEnd; ++collIndex, it_Coll++) {
79
for
(collIndex = 0, it_Coll=transCont->begin(); it_Coll != it_CollEnd; ++collIndex, ++it_Coll) {
80
// Add in new collection
81
const
InDet::SCT_ClusterCollection& collection = (**it_Coll);
82
chanBegin = chanEnd;
83
chanEnd += collection.
size
();
84
InDet::InDetPRD_Collection_p2
& pcollection = persCont->
m_collections
[collIndex];
85
unsigned
int
deltaId = (collection.identifyHash()-idLast);
86
87
pcollection.
m_hashId
= deltaId;
88
idLast=collection.identifyHash();
89
pcollection.
m_size
= collection.size();
90
// Add in channels
91
92
for
(
unsigned
int
i = 0; i < collection.size(); ++i) {
93
InDet::SCT_Cluster_p2
* pchan = &(persCont->
m_rawdata
[i + chanBegin]);
94
const
InDet::SCT_Cluster
* chan =
static_cast<
const
InDet::SCT_Cluster
*
>
(collection[i]);
95
chanCnv.
transToPers
(chan, pchan, log);
96
persCont->
m_prdDeltaId
[i+chanBegin]=
m_sctId
->calc_offset(collection.identify(), chan->identify() );
97
}
98
}
99
// if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << " *** Writing InDet::SCT_ClusterContainer" << endmsg;
100
}
101
102
void
SCT_ClusterContainerCnv_p2::persToTrans
(
const
InDet::SCT_ClusterContainer_p2
* persCont, InDet::SCT_ClusterContainer* transCont, MsgStream &log)
103
{
104
105
// The transient model has a container holding collections and the
106
// collections hold channels.
107
//
108
// The persistent model flattens this so that the persistent
109
// container has two vectors:
110
// 1) all collections, and
111
// 2) all channels
112
//
113
// The persistent collections, then only maintain indexes into the
114
// container's vector of all channels.
115
//
116
// So here we loop over all collection and extract their channels
117
// from the vector.
118
119
const
InDetDD::SiDetectorElementCollection
* elements(
nullptr
);
120
if
(
m_useDetectorElement
) {
121
SG::ReadCondHandle<InDetDD::SiDetectorElementCollection>
sctDetEleHandle(
m_SCTDetEleCollKey
);
122
elements = *sctDetEleHandle;
123
if
(not sctDetEleHandle.
isValid
() or elements==
nullptr
) {
124
log << MSG::FATAL <<
m_SCTDetEleCollKey
.fullKey() <<
" is not available."
<<
endmsg
;
125
return
;
126
}
127
}
128
129
InDet::SCT_ClusterCollection* coll =
nullptr
;
130
131
//SCT_ClusterCnv_p2 chanCnv;
132
SCT_ClusterCnv_p2
chanCnv(
m_sctId
);
133
unsigned
int
collBegin(0);
134
// this is the id of the latest collection read in
135
// This starts from the base of the TRT identifiers
136
unsigned
int
idLast(0);
137
// if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << " Reading " << persCont->m_collections.size() << "Collections" << endmsg;
138
for
(
unsigned
int
icoll = 0; icoll < persCont->
m_collections
.size(); ++icoll) {
139
140
// Create trans collection - in NOT owner of SCT_DriftCircle (SG::VIEW_ELEMENTS)
141
// IDet collection don't have the Ownership policy c'tor
142
const
InDet::InDetPRD_Collection_p2
& pcoll = persCont->
m_collections
[icoll];
143
idLast += pcoll.
m_hashId
;
144
// Identifier collID= Identifier(idLast);
145
IdentifierHash
collIDHash=
IdentifierHash
((
unsigned
int
) idLast);
146
Identifier
collID =
m_sctId
->wafer_id(collIDHash);
147
coll =
new
InDet::SCT_ClusterCollection(collIDHash);
148
coll->setIdentifier(
Identifier
(collID));
149
unsigned
int
nchans = pcoll.
m_size
;
150
coll->resize(nchans);
151
const
InDetDD::SiDetectorElement
* de = (elements==
nullptr
? nullptr : elements->
getDetectorElement
(collIDHash));
152
// Fill with channels:
153
// This is used to read the vector of errMat
154
// values and lenght of the value are specified in separate vectors
155
// if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "Reading collection with " << nchans << "Channels " << endmsg;
156
for
(
unsigned
int
ichan = 0; ichan < nchans; ++ ichan) {
157
const
InDet::SCT_Cluster_p2
* pchan = &(persCont->
m_rawdata
[ichan + collBegin]);
158
Identifier
clusId=
m_sctId
->strip_id_offset(coll->identify() , persCont->
m_prdDeltaId
[ichan + collBegin]);
159
InDet::SCT_Cluster
* chan =
new
InDet::SCT_Cluster
160
(chanCnv.
createSCT_Cluster
(pchan, clusId, de, log));
161
// chan->m_rdoList.resize(1);
162
// chan->m_rdoList[0]=chan->m_clusId;
163
//DC Bugfix: Set the idhash for this channel
164
chan->setHashAndIndex(collIDHash,ichan);
165
(*coll)[ichan] = chan;
166
}
167
collBegin += pcoll.
m_size
;
168
169
// register the PRD collection in IDC with hash - faster addCollection
170
StatusCode
sc
= transCont->addCollection(coll, collIDHash);
171
if
(
sc
.isFailure()) {
172
throw
std::runtime_error(
"Failed to add collection to ID Container"
);
173
}
174
// if (log.level() <= MSG::DEBUG) {
175
// log << MSG::DEBUG << "AthenaPoolTPCnvIDCont::persToTrans, collection, hash_id/coll id = " << (int) collIDHash << " / " << collID << ", added to Identifiable container." << endmsg;
176
// }
177
}
178
179
// if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << " *** Reading InDet::SCT_ClusterContainer" << endmsg;
180
}
181
182
183
184
//================================================================
185
InDet::SCT_ClusterContainer*
SCT_ClusterContainerCnv_p2::createTransient
(
const
InDet::SCT_ClusterContainer_p2
* persObj, MsgStream& log) {
186
// if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "SCT_ClusterContainerCnv_p2::createTransient called " << endmsg;
187
if
(!
m_isInitialized
) {
188
if
(this->
initialize
(log) != StatusCode::SUCCESS) {
189
log << MSG::FATAL <<
"Could not initialize SCT_ClusterContainerCnv_p2 "
<<
endmsg
;
190
}
191
}
192
std::unique_ptr<InDet::SCT_ClusterContainer> trans(std::make_unique<InDet::SCT_ClusterContainer>(
m_sctId
->wafer_hash_max()));
193
persToTrans
(persObj, trans.get(), log);
194
return
(trans.release());
195
}
196
197
198
StatusCode
SCT_ClusterContainerCnv_p2::initialize
(MsgStream&) {
199
// Do not initialize again:
200
m_isInitialized
=
true
;
201
202
// Get Storegate, ID helpers, and so on
203
SmartIF<StoreGateSvc> detStore{Gaudi::svcLocator()->service(
"DetectorStore"
)};
204
CHECK
( detStore.isValid() );
205
206
// Get the sct helper from the detector store
207
CHECK
( detStore->retrieve(
m_sctId
,
"SCT_ID"
) );
208
209
CHECK
(
m_SCTDetEleCollKey
.initialize(
m_useDetectorElement
));
210
211
return
StatusCode::SUCCESS;
212
}
213
214
// Methods for test/SCT_ClusterContainerCnv_p2_test.cxx
215
void
SCT_ClusterContainerCnv_p2::setIdHelper
(
const
SCT_ID
* sct_id) {
216
m_sctId
= sct_id;
217
}
218
219
void
SCT_ClusterContainerCnv_p2::setUseDetectorElement
(
const
bool
useDetectorElement) {
220
m_useDetectorElement
= useDetectorElement;
221
}
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
sc
static Double_t sc
Definition
LArPhysWaveHECTool.cxx:37
ReadCondHandle.h
SCT_ClusterCnv_p2.h
SCT_ClusterContainerCnv_p2.h
SCT_Cluster.h
SCT_Cluster_p2.h
SCT_ID.h
This is an Identifier helper class for the SCT subdetector.
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::SCT_ClusterContainer_p2
Definition
SCT_ClusterContainer_p2.h:23
InDet::SCT_ClusterContainer_p2::m_prdDeltaId
std::vector< Identifier::diff_type > m_prdDeltaId
Definition
SCT_ClusterContainer_p2.h:32
InDet::SCT_ClusterContainer_p2::m_rawdata
std::vector< InDet::SCT_Cluster_p2 > m_rawdata
Definition
SCT_ClusterContainer_p2.h:29
InDet::SCT_ClusterContainer_p2::m_collections
std::vector< InDet::InDetPRD_Collection_p2 > m_collections
Definition
SCT_ClusterContainer_p2.h:28
InDet::SCT_Cluster_p2
Definition
SCT_Cluster_p2.h:18
InDet::SCT_Cluster
Definition
SCT_Cluster.h:34
SCT_ClusterCnv_p2
Definition
SCT_ClusterCnv_p2.h:29
SCT_ClusterCnv_p2::transToPers
void transToPers(const InDet::SCT_Cluster *, InDet::SCT_Cluster_p2 *, MsgStream &)
Definition
SCT_ClusterCnv_p2.cxx:74
SCT_ClusterCnv_p2::createSCT_Cluster
InDet::SCT_Cluster createSCT_Cluster(const InDet::SCT_Cluster_p2 *persObj, Identifier clusId, const InDetDD::SiDetectorElement *detEl, MsgStream &log)
Definition
SCT_ClusterCnv_p2.cxx:25
SCT_ClusterContainerCnv_p2::m_SCTDetEleCollKey
SG::ReadCondHandleKey< InDetDD::SiDetectorElementCollection > m_SCTDetEleCollKey
Definition
SCT_ClusterContainerCnv_p2.h:42
SCT_ClusterContainerCnv_p2::setIdHelper
void setIdHelper(const SCT_ID *sct_id)
Definition
SCT_ClusterContainerCnv_p2.cxx:215
SCT_ClusterContainerCnv_p2::m_isInitialized
bool m_isInitialized
Definition
SCT_ClusterContainerCnv_p2.h:44
SCT_ClusterContainerCnv_p2::transToPers
virtual void transToPers(const InDet::SCT_ClusterContainer *transCont, InDet::SCT_ClusterContainer_p2 *persCont, MsgStream &log)
Definition
SCT_ClusterContainerCnv_p2.cxx:25
SCT_ClusterContainerCnv_p2::initialize
StatusCode initialize(MsgStream &log)
Definition
SCT_ClusterContainerCnv_p2.cxx:198
SCT_ClusterContainerCnv_p2::setUseDetectorElement
void setUseDetectorElement(const bool useDetectorElement)
Definition
SCT_ClusterContainerCnv_p2.cxx:219
SCT_ClusterContainerCnv_p2::m_useDetectorElement
bool m_useDetectorElement
Definition
SCT_ClusterContainerCnv_p2.h:43
SCT_ClusterContainerCnv_p2::persToTrans
virtual void persToTrans(const InDet::SCT_ClusterContainer_p2 *persCont, InDet::SCT_ClusterContainer *transCont, MsgStream &log)
Definition
SCT_ClusterContainerCnv_p2.cxx:102
SCT_ClusterContainerCnv_p2::createTransient
virtual InDet::SCT_ClusterContainer * createTransient(const InDet::SCT_ClusterContainer_p2 *persObj, MsgStream &log)
Definition
SCT_ClusterContainerCnv_p2.cxx:185
SCT_ClusterContainerCnv_p2::m_sctId
const SCT_ID * m_sctId
Definition
SCT_ClusterContainerCnv_p2.h:41
SCT_ID
This is an Identifier helper class for the SCT subdetector.
Definition
SCT_ID.h:68
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