ATLAS Offline Software
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 
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
36  MSG_DEBUG(log,"Converter initialized.");
37 
38  return StatusCode::SUCCESS;
39 }
40 
41 
42 
43 
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 
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
python.Constants.FATAL
int FATAL
Definition: Control/AthenaCommon/python/Constants.py:19
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
TRT_ID::straw_layer_hash_max
size_type straw_layer_hash_max(void) const
Definition: TRT_ID.h:920
TRT_ID.h
This is an Identifier helper class for the TRT subdetector. This class is a factory for creating comp...
SG::ReadCondHandle::isValid
bool isValid()
Definition: ReadCondHandle.h:206
ReadCondHandle.h
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
TRT_DriftCircleContainerCnv_p0::m_trtDetEleContKey
SG::ReadCondHandleKey< InDetDD::TRT_DetElementContainer > m_trtDetEleContKey
Definition: TRT_DriftCircleContainerCnv_p0.h:24
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
TRT_DriftCircleContainerCnv_p0.h
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
TRT_DriftCircleContainerCnv_p0::m_trtId
const TRT_ID * m_trtId
Definition: TRT_DriftCircleContainerCnv_p0.h:23
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
trigbs_pickEvents.num
num
Definition: trigbs_pickEvents.py:76
InDet::TRT_DriftCircleContainer
Trk::PrepRawDataContainer< TRT_DriftCircleCollection > TRT_DriftCircleContainer
Definition: TRT_DriftCircleContainer.h:27
TRT_BaseElement.h
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
errorcheck.h
Helpers for checking error return status codes and reporting errors.
InDet::TRT_DriftCircleCollection
Trk::PrepRawDataCollection< TRT_DriftCircle > TRT_DriftCircleCollection
Definition: TRT_DriftCircleCollection.h:26
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
TRT_DriftCircleContainerCnv_p0::createTransient
virtual InDet::TRT_DriftCircleContainer * createTransient(const TRT_DriftCircleContainer_p0 *, MsgStream &) override
Definition: TRT_DriftCircleContainerCnv_p0.h:38
MSG_VERBOSE
#define MSG_VERBOSE(log, x)
Definition: MsgUtil.h:17
InDetDD::TRT_DetElementCollection::getDetectorElement
const TRT_BaseElement * getDetectorElement(const IdentifierHash &hash) const
Definition: TRT_DetElementCollection.cxx:11
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
MSG_DEBUG
#define MSG_DEBUG(log, x)
Definition: MsgUtil.h:15
InDetDD::TRT_DetElementContainer::getElements
const TRT_DetElementCollection * getElements() const
Definition: TRT_DetElementContainer.cxx:29
TRT_DriftCircleContainerCnv_p0::initialize
StatusCode initialize(MsgStream &log)
Definition: TRT_DriftCircleContainerCnv_p0.cxx:26
InDetDD::TRT_DetElementCollection
Class to hold collection of TRT detector elements.
Definition: TRT_DetElementCollection.h:28
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
InDetDD::TRT_BaseElement
Definition: TRT_BaseElement.h:57
MsgUtil.h