11#include "Identifier/Identifier.h"
18#include "GaudiKernel/ISvcLocator.h"
19#include "GaudiKernel/Bootstrap.h"
20#include "GaudiKernel/StatusCode.h"
21#include "GaudiKernel/Service.h"
22#include "GaudiKernel/MsgStream.h"
51 using TRANS = InDet::TRT_DriftCircleContainer;
55 unsigned int idLast(0);
59 TRANS::const_iterator it_Coll = transCont->begin();
60 TRANS::const_iterator it_CollEnd = transCont->end();
61 unsigned int collIndex;
62 unsigned int chanBegin = 0;
63 unsigned int chanEnd = 0;
65 persCont->
m_collections.resize(transCont->numberOfCollections());
70 for ( it_Coll=transCont->begin(); it_Coll != it_CollEnd; ++it_Coll) {
71 const InDet::TRT_DriftCircleCollection& 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::TRT_DriftCircleCollection& 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]=chan->identify().get_identifier32().get_compact()-collection.identify().get_identifier32().get_compact();
132 elements = (*trtDetEleHandle)->getElements();
133 if (not trtDetEleHandle.
isValid() or elements==
nullptr) {
139 InDet::TRT_DriftCircleCollection* coll =
nullptr;
142 unsigned int collBegin(0);
145 unsigned int idLast(0);
147 for (
unsigned int icoll = 0; icoll < persCont->
m_collections.size(); ++icoll) {
157 coll =
new InDet::TRT_DriftCircleCollection(collIDHash);
158 coll->setIdentifier(collID);
159 unsigned int nchans = pcoll.
m_size;
160 coll->resize(nchans);
166 for (
unsigned int ichan = 0; ichan < nchans; ++ ichan) {
170 std::vector<Identifier> rdoList(1);
181 chan->setHashAndIndex(collIDHash,ichan);
182 (*coll)[ichan] = chan;
184 collBegin += pcoll.
m_size;
187 StatusCode
sc = transCont->addCollection(coll, collIDHash);
188 if (
sc.isFailure()) {
189 throw std::runtime_error(
"Failed to add collection to ID Container");
203 if (this->
initialize(log) != StatusCode::SUCCESS) {
204 log << MSG::FATAL <<
"Could not initialize TRT_DriftCircleContainerCnv_p2 " <<
endmsg;
208 std::unique_ptr<InDet::TRT_DriftCircleContainer> trans(std::make_unique<InDet::TRT_DriftCircleContainer>(
m_trtId->straw_layer_hash_max()));
210 return(trans.release());
221 SmartIF<StoreGateSvc> detStore{Gaudi::svcLocator()->service(
"DetectorStore")};
222 CHECK( detStore.isValid() );
229 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 TRT subdetector.
size_type size() const noexcept
value_type get_compact() const
Get the compact id.
This is a "hash" representation of an Identifier.
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
Virtual base class of TRT readout elements.
Class to hold collection of TRT detector elements.
const TRT_BaseElement * getDetectorElement(const IdentifierHash &hash) const
std::vector< unsigned short > m_prdDeltaId
std::vector< InDet::InDetPRD_Collection_p2 > m_collections
std::vector< InDet::TRT_DriftCircle_p2 > m_rawdata
InDet::TRT_DriftCircle createTRT_DriftCircle(const InDet::TRT_DriftCircle_p2 *persObj, Identifier clusId, std::vector< Identifier > &&rdoList, const InDetDD::TRT_BaseElement *detEl, MsgStream &log)
void transToPers(const InDet::TRT_DriftCircle *transObj, InDet::TRT_DriftCircle_p2 *persObj, MsgStream &log)
StatusCode initialize(MsgStream &log)
void setIdHelper(const TRT_ID *trt_id)
SG::ReadCondHandleKey< InDetDD::TRT_DetElementContainer > m_trtDetEleContKey
bool m_useDetectorElement
virtual InDet::TRT_DriftCircleContainer * createTransient(const InDet::TRT_DriftCircleContainer_p2 *persObj, MsgStream &log)
virtual void transToPers(const InDet::TRT_DriftCircleContainer *transCont, InDet::TRT_DriftCircleContainer_p2 *persCont, MsgStream &log)
virtual void persToTrans(const InDet::TRT_DriftCircleContainer_p2 *persCont, InDet::TRT_DriftCircleContainer *transCont, MsgStream &log)
void setUseDetectorElement(const bool useDetectorElement)
This is an Identifier helper class for the TRT subdetector.