ATLAS Offline Software
Loading...
Searching...
No Matches
TRT_DriftCircleContainerCnv_p0.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
9#include "MsgUtil.h"
11
12// Gaudi
13#include "GaudiKernel/ISvcLocator.h"
14#include "GaudiKernel/Bootstrap.h"
15#include "GaudiKernel/StatusCode.h"
16#include "GaudiKernel/Service.h"
17#include "GaudiKernel/MsgStream.h"
18
19#include <string>
20
21//================================================================
22
23
24StatusCode TRT_DriftCircleContainerCnv_p0::initialize(MsgStream &log ) {
25
26 log << MSG::INFO << "TRT_DriftCircleContainerCnv::initialize()" << endmsg;
27
28 SmartIF<StoreGateSvc> detStore{Gaudi::svcLocator()->service("DetectorStore")};
29 CHECK( detStore.isValid() );
30
31 CHECK( detStore->retrieve(m_trtId, "TRT_ID") );
32 // Initialize readCondHandle key
33 CHECK(m_trtDetEleContKey.initialize());
34 MSG_DEBUG(log,"Converter initialized.");
35
36 return StatusCode::SUCCESS;
37}
38
39
40
41
42InDet::TRT_DriftCircleContainer* TRT_DriftCircleContainerCnv_p0::createTransient(TRT_DriftCircleContainer_p0* persObj, MsgStream& log) {
43
44 auto trans = std::make_unique<InDet::TRT_DriftCircleContainer>(m_trtId->straw_layer_hash_max());
45 MSG_DEBUG(log,"Read PRD vector, size " << persObj->size());
46
48 const InDetDD::TRT_DetElementCollection* elements(trtDetEleHandle->getElements());
49 if (not trtDetEleHandle.isValid() or elements==nullptr) {
50 log << MSG::FATAL << m_trtDetEleContKey.fullKey() << " is not available." << endmsg;
51 return trans.release();
52 }
53
54 for (InDet::TRT_DriftCircleCollection* dcColl : *persObj) {
55 // Add detElem to each drift circle
56 IdentifierHash collHash = dcColl->identifyHash();
57 const InDetDD::TRT_BaseElement * de = elements->getDetectorElement(collHash);
58 MSG_DEBUG(log,"Set TRT_DriftCircle detector element to "<< de);
59
60 InDet::TRT_DriftCircleCollection::iterator itColl = dcColl->begin();
61 InDet::TRT_DriftCircleCollection::iterator lastColl = dcColl->end();
62 for (int num = 0; itColl != lastColl; ++itColl, ++num) {
63 MSG_DEBUG(log,"PRD " << num);
64 (*itColl)->m_detEl = de;
65 }
66
67 StatusCode sc = trans->addCollection(dcColl, collHash);
68 if (sc.isSuccess()){
69 MSG_VERBOSE(log,"TRT_DriftCircleContainer successfully added to Container !");
70 } else {
71 log << MSG::ERROR << "Failed to add TRT_DriftCircleContainer to container" << endmsg;
72 return nullptr;
73 }
74 }
75 return(trans.release());
76}
77
#define endmsg
Helpers for checking error return status codes and reporting errors.
#define CHECK(...)
Evaluate an expression and check for errors.
static Double_t sc
#define MSG_VERBOSE(log, x)
Definition MsgUtil.h:18
#define MSG_DEBUG(log, x)
Definition MsgUtil.h:16
DataVector< Trk::PrepRawDataCollection< InDet::TRT_DriftCircle > > TRT_DriftCircleContainer_p0
This is an Identifier helper class for the TRT subdetector.
size_type size() const noexcept
Returns the number of elements in the collection.
This is a "hash" representation of an Identifier.
Virtual base class of TRT readout elements.
Class to hold collection of TRT detector elements.
const TRT_BaseElement * getDetectorElement(const IdentifierHash &hash) const
virtual InDet::TRT_DriftCircleContainer * createTransient(const TRT_DriftCircleContainer_p0 *, MsgStream &) override
SG::ReadCondHandleKey< InDetDD::TRT_DetElementContainer > m_trtDetEleContKey