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"
41 using TRANS = InDet::SCT_ClusterContainer;
45 unsigned int idLast(0);
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;
57 if (this->
initialize(log) != StatusCode::SUCCESS) {
58 log << MSG::FATAL <<
"Could not initialize SCT_ClusterContainerCnv_p2 " <<
endmsg;
64 persCont->
m_collections.resize(transCont->numberOfCollections());
69 for ( it_Coll=transCont->begin(); it_Coll != it_CollEnd; ++it_Coll) {
70 const InDet::SCT_ClusterCollection& collection = (**it_Coll);
71 totSize+=collection.size();
78 for (collIndex = 0, it_Coll=transCont->begin(); it_Coll != it_CollEnd; ++collIndex, ++it_Coll) {
80 const InDet::SCT_ClusterCollection& collection = (**it_Coll);
82 chanEnd += collection.
size();
84 unsigned int deltaId = (collection.identifyHash()-idLast);
87 idLast=collection.identifyHash();
88 pcollection.
m_size = collection.size();
91 for (
unsigned int i = 0; i < collection.size(); ++i) {
96 persCont->
m_prdDeltaId[i+chanBegin]=
m_sctId->calc_offset(collection.identify(), chan->identify() );
105 if (this->
initialize(log) != StatusCode::SUCCESS) {
106 log << MSG::FATAL <<
"Could not initialize SCT_ClusterContainerCnv_p3 from persToTrans" <<
endmsg;
128 elements = sctDetEleHandle1.
cptr();
134 elements = sctDetEleHandle2.
cptr();
136 log << MSG::FATAL <<
"No valid SCT detector element collection keys available." <<
endmsg;
142 InDet::SCT_ClusterCollection* coll =
nullptr;
146 unsigned int collBegin(0);
149 unsigned int idLast(0);
151 for (
unsigned int icoll = 0; icoll < persCont->
m_collections.size(); ++icoll) {
160 coll =
new InDet::SCT_ClusterCollection(collIDHash);
162 unsigned int nchans = pcoll.
m_size;
163 coll->resize(nchans);
169 for (
unsigned int ichan = 0; ichan < nchans; ++ ichan) {
179 chan->setHashAndIndex(collIDHash,ichan);
180 (*coll)[ichan] = chan;
182 collBegin += pcoll.
m_size;
185 StatusCode
sc = transCont->addCollection(coll, collIDHash);
186 if (
sc.isFailure()) {
187 throw std::runtime_error(
"Failed to add collection to ID Container");
201 if (this->
initialize(log) != StatusCode::SUCCESS) {
202 log << MSG::FATAL <<
"Could not initialize SCT_ClusterContainerCnv_p3 " <<
endmsg;
205 std::unique_ptr<InDet::SCT_ClusterContainer> trans(std::make_unique<InDet::SCT_ClusterContainer>(
m_sctId->wafer_hash_max()));
207 return(trans.release());
216 SmartIF<StoreGateSvc> detStore{Gaudi::svcLocator()->service(
"DetectorStore")};
217 CHECK( detStore.isValid() );
225 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()