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