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();
77 for (collIndex = 0, it_Coll=transCont->begin(); it_Coll != it_CollEnd; ++collIndex, ++it_Coll) {
79 const InDet::TRT_DriftCircleCollection& collection = (**it_Coll);
81 chanEnd += collection.
size();
83 unsigned int deltaId = (collection.identifyHash()-idLast);
86 idLast = collection.identifyHash();
87 pcollection.
m_size = collection.size();
90 for (
unsigned int i = 0; i < collection.size(); ++i) {
94 persCont->
m_prdDeltaId[i+chanBegin]=chan->identify().get_identifier32().get_compact()-collection.identify().get_identifier32().get_compact();
119 elements = (*trtDetEleHandle)->getElements();
120 if (not trtDetEleHandle.
isValid() or elements==
nullptr) {
126 InDet::TRT_DriftCircleCollection* coll =
nullptr;
129 unsigned int collBegin(0);
132 unsigned int idLast(0);
134 for (
unsigned int icoll = 0; icoll < persCont->
m_collections.size(); ++icoll) {
144 coll =
new InDet::TRT_DriftCircleCollection(collIDHash);
145 coll->setIdentifier(collID);
146 unsigned int nchans = pcoll.
m_size;
147 coll->resize(nchans);
153 for (
unsigned int ichan = 0; ichan < nchans; ++ ichan) {
157 std::vector<Identifier> rdoList(1);
168 chan->setHashAndIndex(collIDHash,ichan);
169 (*coll)[ichan] = chan;
171 collBegin += pcoll.
m_size;
174 StatusCode
sc = transCont->addCollection(coll, collIDHash);
175 if (
sc.isFailure()) {
176 throw std::runtime_error(
"Failed to add collection to ID Container");
190 if (this->
initialize(log) != StatusCode::SUCCESS) {
191 log << MSG::FATAL <<
"Could not initialize TRT_DriftCircleContainerCnv_p2 " <<
endmsg;
195 std::unique_ptr<InDet::TRT_DriftCircleContainer> trans(std::make_unique<InDet::TRT_DriftCircleContainer>(
m_trtId->straw_layer_hash_max()));
197 return(trans.release());
208 SmartIF<StoreGateSvc> detStore{Gaudi::svcLocator()->service(
"DetectorStore")};
209 CHECK( detStore.isValid() );
216 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.