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