7#include "Identifier/Identifier.h"
20#include "GaudiKernel/ISvcLocator.h"
21#include "GaudiKernel/Bootstrap.h"
22#include "GaudiKernel/Service.h"
23#include "GaudiKernel/MsgStream.h"
42 using TRANS = InDet::PixelClusterContainer;
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;
55 persCont->
m_collections.resize(transCont->numberOfCollections());
57 for (collIndex = 0; it_Coll != it_CollEnd; ++collIndex, ++it_Coll) {
59 const InDet::PixelClusterCollection& collection = (**it_Coll);
61 chanEnd += collection.
size();
63 unsigned int deltaId = (collection.identifyHash()-idLast);
73 idLast=collection.identifyHash();
74 pcollection.
m_size = collection.size();
77 log << MSG::VERBOSE <<
"Reading collections with " << collection.size() <<
"PRDs " <<
endmsg;
78 for (
unsigned int i = 0; i < collection.size(); ++i) {
107 elements = *pixelDetEleHandle;
108 if (not pixelDetEleHandle.
isValid() or elements==
nullptr) {
114 InDet::PixelClusterCollection* coll =
nullptr;
117 unsigned int collBegin(0);
120 unsigned int idLast(0);
122 for (
unsigned int icoll = 0; icoll < persCont->
m_collections.size(); ++icoll) {
131 coll =
new InDet::PixelClusterCollection(collIDHash);
133 unsigned int nchans = pcoll.
m_size;
134 coll->resize(nchans);
140 for (
unsigned int ichan = 0; ichan < nchans; ++ ichan) {
144 chan->setDetectorElement(de);
146 chan->setHashAndIndex(collIDHash, ichan);
147 (*coll)[ichan] = chan;
149 collBegin += pcoll.
m_size;
152 StatusCode
sc = transCont->addCollection(coll, collIDHash);
153 if (
sc.isFailure()) {
154 throw std::runtime_error(
"Failed to add collection to ID Container");
169 if (this->
initialize(log) != StatusCode::SUCCESS) {
170 log << MSG::FATAL <<
"Could not initialize PixelClusterContainerCnv_p2 " <<
endmsg;
174 log << MSG::FATAL <<
"nullptr for m_pixId in PixelClusterContainerCnv_p2::createTransient" <<
endmsg;
177 std::unique_ptr<InDet::PixelClusterContainer> trans(std::make_unique<InDet::PixelClusterContainer>(
m_pixId->wafer_hash_max()));
179 return(trans.release());
188 SmartIF<StoreGateSvc> detStore{Gaudi::svcLocator()->service(
"DetectorStore")};
189 CHECK( detStore.isValid() );
196 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 Pixel 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::InDetPRD_Collection_p2 > m_collections
std::vector< InDet::PixelCluster_p2 > m_rawdata
void transToPers(const InDet::PixelCluster *, InDet::PixelCluster_p2 *, MsgStream &)
void persToTrans(const InDet::PixelCluster_p2 *, InDet::PixelCluster *, MsgStream &)
virtual void persToTrans(const InDet::PixelClusterContainer_p2 *persCont, InDet::PixelClusterContainer *transCont, MsgStream &log)
virtual InDet::PixelClusterContainer * createTransient(const InDet::PixelClusterContainer_p2 *persObj, MsgStream &log)
virtual void transToPers(const InDet::PixelClusterContainer *transCont, InDet::PixelClusterContainer_p2 *persCont, MsgStream &log)
bool m_useDetectorElement
StatusCode initialize(MsgStream &log)
SG::ReadCondHandleKey< InDetDD::SiDetectorElementCollection > m_pixelDetEleCollKey
void setUseDetectorElement(const bool useDetectorElement)