ATLAS Offline Software
Loading...
Searching...
No Matches
TRT_DriftCircleContainerCnv_p0.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 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#include <iostream>
21#include <sstream>
22
23//================================================================
24
25
26StatusCode TRT_DriftCircleContainerCnv_p0::initialize(MsgStream &log ) {
27
28 log << MSG::INFO << "TRT_DriftCircleContainerCnv::initialize()" << endmsg;
29
30 SmartIF<StoreGateSvc> detStore{Gaudi::svcLocator()->service("DetectorStore")};
31 CHECK( detStore.isValid() );
32
33 CHECK( detStore->retrieve(m_trtId, "TRT_ID") );
34 // Initialize readCondHandle key
35 CHECK(m_trtDetEleContKey.initialize());
36 MSG_DEBUG(log,"Converter initialized.");
37
38 return StatusCode::SUCCESS;
39}
40
41
42
43
44InDet::TRT_DriftCircleContainer* TRT_DriftCircleContainerCnv_p0::createTransient(TRT_DriftCircleContainer_p0* persObj, MsgStream& log) {
45
46 std::unique_ptr<InDet::TRT_DriftCircleContainer> trans(std::make_unique<InDet::TRT_DriftCircleContainer>(m_trtId->straw_layer_hash_max()) );
47 MSG_DEBUG(log,"Read PRD vector, size " << persObj->size());
48
50 const InDetDD::TRT_DetElementCollection* elements(trtDetEleHandle->getElements());
51 if (not trtDetEleHandle.isValid() or elements==nullptr) {
52 log << MSG::FATAL << m_trtDetEleContKey.fullKey() << " is not available." << endmsg;
53 return trans.release();
54 }
55
56 for (InDet::TRT_DriftCircleCollection* dcColl : *persObj) {
57 // Add detElem to each drift circle
58 IdentifierHash collHash = dcColl->identifyHash();
59 const InDetDD::TRT_BaseElement * de = elements->getDetectorElement(collHash);
60 MSG_DEBUG(log,"Set TRT_DriftCircle detector element to "<< de);
61
62 InDet::TRT_DriftCircleCollection::iterator itColl = dcColl->begin();
63 InDet::TRT_DriftCircleCollection::iterator lastColl = dcColl->end();
64 for (int num = 0; itColl != lastColl; ++itColl, ++num) {
65 MSG_DEBUG(log,"PRD " << num);
66 (*itColl)->m_detEl = de;
67 }
68
69 StatusCode sc= trans ? trans->addCollection(dcColl, collHash): StatusCode::FAILURE;
70 if (sc.isSuccess()){
71 MSG_VERBOSE(log,"TRT_DriftCircleContainer successfully added to Container !");
72 } else {
73 log << MSG::ERROR << "Failed to add TRT_DriftCircleContainer to container" << endmsg;
74 return nullptr;
75 }
76 }
77 return(trans.release());
78}
79
#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:17
#define MSG_DEBUG(log, x)
Definition MsgUtil.h:15
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