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);
95 idLast=collection.identifyHash();
96 pcollection.
m_size = collection.size();
101 for (
unsigned int i = 0; i < collection.size(); ++i) {
106 persCont->
m_prdDeltaId[i+chanBegin]=
m_sctId->calc_offset(collection.identify(), chan->identify() );
132 elements = *sctDetEleHandle;
133 if (not sctDetEleHandle.
isValid() or elements==
nullptr) {
139 InDet::SCT_ClusterCollection* coll =
nullptr;
143 unsigned int collBegin(0);
146 unsigned int idLast(0);
148 for (
unsigned int icoll = 0; icoll < persCont->
m_collections.size(); ++icoll) {
157 coll =
new InDet::SCT_ClusterCollection(collIDHash);
159 unsigned int nchans = pcoll.
m_size;
160 coll->resize(nchans);
166 for (
unsigned int ichan = 0; ichan < nchans; ++ ichan) {
174 chan->setHashAndIndex(collIDHash,ichan);
175 (*coll)[ichan] = chan;
177 collBegin += pcoll.
m_size;
180 StatusCode
sc = transCont->addCollection(coll, collIDHash);
181 if (
sc.isFailure()) {
182 throw std::runtime_error(
"Failed to add collection to ID Container");
198 if (this->
initialize(log) != StatusCode::SUCCESS) {
199 log << MSG::FATAL <<
"Could not initialize SCT_ClusterContainerCnv_p2 " <<
endmsg;
202 std::unique_ptr<InDet::SCT_ClusterContainer> trans(std::make_unique<InDet::SCT_ClusterContainer>(
m_sctId->wafer_hash_max()));
204 return(trans.release());
213 SmartIF<StoreGateSvc> detStore{Gaudi::svcLocator()->service(
"DetectorStore")};
214 CHECK( detStore.isValid() );
221 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< Identifier::diff_type > m_prdDeltaId
std::vector< InDet::SCT_Cluster_p2 > m_rawdata
std::vector< InDet::InDetPRD_Collection_p2 > m_collections
void transToPers(const InDet::SCT_Cluster *, InDet::SCT_Cluster_p2 *, MsgStream &)
InDet::SCT_Cluster createSCT_Cluster(const InDet::SCT_Cluster_p2 *persObj, Identifier clusId, const InDetDD::SiDetectorElement *detEl, MsgStream &log)
SG::ReadCondHandleKey< InDetDD::SiDetectorElementCollection > m_SCTDetEleCollKey
void setIdHelper(const SCT_ID *sct_id)
virtual void transToPers(const InDet::SCT_ClusterContainer *transCont, InDet::SCT_ClusterContainer_p2 *persCont, MsgStream &log)
StatusCode initialize(MsgStream &log)
void setUseDetectorElement(const bool useDetectorElement)
bool m_useDetectorElement
virtual void persToTrans(const InDet::SCT_ClusterContainer_p2 *persCont, InDet::SCT_ClusterContainer *transCont, MsgStream &log)
virtual InDet::SCT_ClusterContainer * createTransient(const InDet::SCT_ClusterContainer_p2 *persObj, MsgStream &log)
This is an Identifier helper class for the SCT subdetector.