ATLAS Offline Software
CopyTrackRecordCollection.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 
8 CopyTrackRecordCollection::CopyTrackRecordCollection(const std::string &name, ISvcLocator *pSvcLocator)
9  : AthReentrantAlgorithm(name, pSvcLocator) { }
10 
12 {
13  ATH_MSG_DEBUG("Initializing...");
14 
15  // Check that collection name is not empty
16  if (m_collectionName.empty()) {
17  ATH_MSG_ERROR("CaloCalibrationHitContainer collection name should not be empty");
18  return StatusCode::FAILURE;
19  }
20 
21  // Check and initialize keys
22  ATH_CHECK( m_signalInputKey.initialize() );
23  ATH_MSG_VERBOSE("Initialized ReadHandleKey: " << m_signalInputKey);
24  ATH_CHECK( m_outputKey.initialize() );
25  ATH_MSG_VERBOSE("Initialized WriteHandleKey: " << m_outputKey);
26 
27  return StatusCode::SUCCESS;
28 }
29 
30 StatusCode CopyTrackRecordCollection::execute(const EventContext& ctx) const
31 {
32  ATH_MSG_DEBUG("execute() begin");
33 
34  // Reading the input containers
35  ATH_MSG_VERBOSE("Retrieving input containers");
36 
38  if (!signalContainer.isValid()) {
39  ATH_MSG_ERROR("Could not get signal TrackRecordCollection container " << signalContainer.name() << " from store " << signalContainer.store());
40  return StatusCode::FAILURE;
41  }
42  ATH_MSG_DEBUG("Found signal TrackRecordCollection container " << signalContainer.name() << " in store " << signalContainer.store());
43 
44  // Creating output RDO container
46  ATH_CHECK(outputContainer.record(std::make_unique<TrackRecordCollection>(m_collectionName)));
47  if (!outputContainer.isValid()) {
48  ATH_MSG_ERROR("Could not record output TrackRecordCollection container " << outputContainer.name() << " to store " << outputContainer.store());
49  return StatusCode::FAILURE;
50  }
51  ATH_MSG_DEBUG("Recorded output TrackRecordCollection container " << outputContainer.name() << " in store " << outputContainer.store());
52 
53  // Copy signal TrackRecords
54  for (const TrackRecord &record : *signalContainer) {
55  outputContainer->push_back(TrackRecord(record));
56  }
57 
58  ATH_MSG_DEBUG("execute() end");
59  return StatusCode::SUCCESS;
60 }
CopyTrackRecordCollection::m_signalInputKey
SG::ReadHandleKey< TrackRecordCollection > m_signalInputKey
Definition: CopyTrackRecordCollection.h:21
CopyTrackRecordCollection::initialize
virtual StatusCode initialize() override
Definition: CopyTrackRecordCollection.cxx:11
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
SG::VarHandleBase::name
const std::string & name() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleBase.cxx:75
CopyTrackRecordCollection::m_outputKey
SG::WriteHandleKey< TrackRecordCollection > m_outputKey
Definition: CopyTrackRecordCollection.h:22
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
CopyTrackRecordCollection::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: CopyTrackRecordCollection.cxx:30
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
SG::VarHandleBase::store
std::string store() const
Return the name of the store holding the object we are proxying.
Definition: StoreGate/src/VarHandleBase.cxx:376
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
SG::WriteHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
TrackRecord
Definition: TrackRecord.h:12
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
CopyTrackRecordCollection::m_collectionName
Gaudi::Property< std::string > m_collectionName
Definition: CopyTrackRecordCollection.h:24
CopyTrackRecordCollection.h
CopyTrackRecordCollection::CopyTrackRecordCollection
CopyTrackRecordCollection(const std::string &name, ISvcLocator *pSvcLocator)
Definition: CopyTrackRecordCollection.cxx:8
AtlasHitsVector::push_back
void push_back(const T &t)
Definition: AtlasHitsVector.h:145