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