ATLAS Offline Software
Loading...
Searching...
No Matches
L1JetCopyAlgorithm.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
7
8//**********************************************************************
9
10template<typename T>
11L1JetCopyAlgorithm<T>::L1JetCopyAlgorithm( const std::string& name, ISvcLocator* pSvcLocator ) : AthReentrantAlgorithm(name,pSvcLocator){
12 declareProperty("JetInContainerName" ,m_jetInContainerKey="");
13 declareProperty("JetOutContainerName" ,m_jetOutContainerKey="");
14}
15
16template<typename T>
18
19 ATH_MSG_INFO(" Initializing " << name());
20 ATH_CHECK( m_jetInContainerKey.initialize() );
21 ATH_CHECK( m_jetOutContainerKey.initialize() );
22
23 return StatusCode::SUCCESS;
24}
25
26template<typename T>
28 ATH_MSG_INFO ("Finalizing " << name());
29 return StatusCode::SUCCESS;
30}
31
32//**********************************************************************
33
34template<typename T>
35StatusCode L1JetCopyAlgorithm<T>::execute(const EventContext& ctx) const {
36 SG::ReadHandle<JetContainer> inputJetsHandle(m_jetInContainerKey, ctx); // read handle
37 if (!inputJetsHandle.isValid() ) {
38 ATH_MSG_ERROR("evtStore() does not contain jet Collection with name "<< m_jetInContainerKey);
39 return StatusCode::FAILURE;
40 }
41
42 ATH_MSG_DEBUG("Shallow-copying "<<m_jetInContainerKey);
44
45 auto shallowcopy = xAOD::shallowCopyContainer(*inputJetsHandle);
46 std::unique_ptr<JetContainer> copiedjets(shallowcopy.first);
47 std::unique_ptr<xAOD::ShallowAuxContainer> shallowaux(shallowcopy.second);
48
49 if(copiedjets.get() == nullptr || shallowaux.get() == nullptr) {
50 ATH_MSG_ERROR("Failed to make shallow copy of "<<m_jetInContainerKey<<".");
51 return StatusCode::FAILURE;
52 }
53 ATH_CHECK( jetsOut.record(std::move(copiedjets), std::move(shallowaux)) );
54
55 return StatusCode::SUCCESS;
56}
57
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
An algorithm that can be simultaneously executed in multiple threads.
StatusCode initialize() override
SG::ReadHandleKey< JetContainer > m_jetInContainerKey
StatusCode execute(const EventContext &ctx) const override
StatusCode finalize() override
L1JetCopyAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
SG::WriteHandleKey< JetContainer > m_jetOutContainerKey
virtual bool isValid() override final
Can the handle be successfully dereferenced?
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
std::pair< std::unique_ptr< T >, std::unique_ptr< ShallowAuxContainer > > shallowCopyContainer(const T &cont, const EventContext &ctx)
Function making a shallow copy of a constant container.