9#include "Identifier/Identifier.h"
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"
42 using TRANS = InDet::SCT_ClusterContainer;
46 unsigned int idLast(0);
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;
58 if (this->
initialize(log) != StatusCode::SUCCESS) {
59 log << MSG::FATAL <<
"Could not initialize SCT_ClusterContainerCnv_p2 " <<
endmsg;
65 persCont->
m_collections.resize(transCont->numberOfCollections());
70 for ( it_Coll=transCont->begin(); it_Coll != it_CollEnd; ++it_Coll) {
71 const InDet::SCT_ClusterCollection& collection = (**it_Coll);
72 totSize+=collection.size();
79 for (collIndex = 0, it_Coll=transCont->begin(); it_Coll != it_CollEnd; ++collIndex, ++it_Coll) {
81 const InDet::SCT_ClusterCollection& collection = (**it_Coll);
83 chanEnd += collection.
size();
85 unsigned int deltaId = (collection.identifyHash()-idLast);
88 idLast=collection.identifyHash();
89 pcollection.
m_size = collection.size();
92 for (
unsigned int i = 0; i < collection.size(); ++i) {
97 persCont->
m_prdDeltaId[i+chanBegin]=
m_sctId->calc_offset(collection.identify(), chan->identify() );
106 if (this->
initialize(log) != StatusCode::SUCCESS) {
107 log << MSG::FATAL <<
"Could not initialize SCT_ClusterContainerCnv_p3 from persToTrans" <<
endmsg;
129 elements = sctDetEleHandle1.
cptr();
135 elements = sctDetEleHandle2.
cptr();
137 log << MSG::FATAL <<
"No valid SCT detector element collection keys available." <<
endmsg;
143 InDet::SCT_ClusterCollection* coll =
nullptr;
147 unsigned int collBegin(0);
150 unsigned int idLast(0);
152 for (
unsigned int icoll = 0; icoll < persCont->
m_collections.size(); ++icoll) {
161 coll =
new InDet::SCT_ClusterCollection(collIDHash);
163 unsigned int nchans = pcoll.
m_size;
164 coll->resize(nchans);
170 for (
unsigned int ichan = 0; ichan < nchans; ++ ichan) {
180 chan->setHashAndIndex(collIDHash,ichan);
181 (*coll)[ichan] = chan;
183 collBegin += pcoll.
m_size;
186 StatusCode
sc = transCont->addCollection(coll, collIDHash);
187 if (
sc.isFailure()) {
188 throw std::runtime_error(
"Failed to add collection to ID Container");
202 if (this->
initialize(log) != StatusCode::SUCCESS) {
203 log << MSG::FATAL <<
"Could not initialize SCT_ClusterContainerCnv_p3 " <<
endmsg;
206 std::unique_ptr<InDet::SCT_ClusterContainer> trans(std::make_unique<InDet::SCT_ClusterContainer>(
m_sctId->wafer_hash_max()));
208 return(trans.release());
217 SmartIF<StoreGateSvc> detStore{Gaudi::svcLocator()->service(
"DetectorStore")};
218 CHECK( detStore.isValid() );
226 return StatusCode::SUCCESS;
Helpers for checking error return status codes and reporting errors.
#define CHECK(...)
Evaluate an expression and check for errors.
This is an Identifier helper class for the SCT subdetector.
size_type size() const noexcept
This is a "hash" representation of an Identifier.
Class to hold the SiDetectorElement objects to be put in the detector store.
const SiDetectorElement * getDetectorElement(const IdentifierHash &hash) const
Class to hold geometrical description of a silicon detector element.
std::vector< InDet::SCT_Cluster_p3 > m_rawdata
std::vector< Identifier::diff_type > m_prdDeltaId
std::vector< InDet::InDetPRD_Collection_p2 > m_collections
void transToPers(const InDet::SCT_Cluster *, InDet::SCT_Cluster_p3 *, MsgStream &)
InDet::SCT_Cluster createSCT_Cluster(const InDet::SCT_Cluster_p3 *persObj, Identifier clusId, const InDetDD::SiDetectorElement *detEl, MsgStream &log)
virtual void transToPers(const InDet::SCT_ClusterContainer *transCont, InDet::SCT_ClusterContainer_p3 *persCont, MsgStream &log)
virtual InDet::SCT_ClusterContainer * createTransient(const InDet::SCT_ClusterContainer_p3 *persObj, MsgStream &log)
SG::ReadCondHandleKey< InDetDD::SiDetectorElementCollection > m_ITkStripDetEleCollKey
virtual void persToTrans(const InDet::SCT_ClusterContainer_p3 *persCont, InDet::SCT_ClusterContainer *transCont, MsgStream &log)
StatusCode initialize(MsgStream &log)
bool m_useDetectorElement
SG::ReadCondHandleKey< InDetDD::SiDetectorElementCollection > m_SCTDetEleCollKey
void setIdHelper(const SCT_ID *sct_id)
void setUseDetectorElement(const bool useDetectorElement)
This is an Identifier helper class for the SCT subdetector.
Exception — Can't retrieve CondCont from ReadCondHandle.
const_pointer_type cptr()