2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
5 #ifndef CALORINGERTOOLS_CALORINGERREADERJETUTILS_ICC
6 #define CALORINGERTOOLS_CALORINGERREADERJETUTILS_ICC
10 #include "GaudiKernel/StatusCode.h"
11 #include "GaudiKernel/ToolHandle.h"
13 // Interface includes:
14 #include "CaloRingerTools/ICaloRingsBuilder.h"
17 #include "xAODCaloEvent/CaloClusterContainer.h"
18 #include "xAODCaloRings/CaloRingsContainer.h"
19 #include "xAODCaloRings/RingSetContainer.h"
20 #include "xAODCaloRings/CaloRingsAuxContainer.h"
21 #include "xAODCaloRings/RingSetAuxContainer.h"
22 #include "xAODCaloRings/tools/getCaloRingsDecorator.h"
25 #include "CaloRingerTools/ICaloRingerInputReader.h"
29 // =====================================================================================
30 template<typename container_t>
31 StatusCode BuildCaloRingsJetFctor<container_t>::prepareJetToLoopFor( std::size_t nParticles ) {
32 // Call overridden method
33 ATH_CHECK( base_t::prepareJetToLoopFor( nParticles ) );
34 // Make the decorator key
35 m_decor = new decor_t( m_decorKey );
36 return StatusCode::SUCCESS;
39 // =====================================================================================
40 template<typename container_t>
41 void BuildCaloRingsJetFctor<container_t>::checkJetRelease() {
42 // Call overridden method
43 base_t::checkJetRelease();
44 if ( m_part_counter == m_part_size ) {
45 delete m_decor; m_decor = nullptr;
49 // =====================================================================================
50 template<typename container_t>
51 void BuildCaloRingsJetFctor<container_t>::displayLoopingMessage() const {
52 if (msgLvl(MSG::DEBUG)) {
53 msg() << MSG::DEBUG << " ---------- Reading "
59 // =====================================================================================
60 template< typename container_t >
61 void BuildCaloRingsJetFctor<container_t>::operator() ( const particle_t *part )
64 auto ringsELReader = xAOD::getCaloRingsReader();
65 const xAOD::CaloRingsLinks *caloRingsLinks(nullptr);
68 caloRingsLinks = &(ringsELReader(*part));
69 } catch ( const std::exception &e) {
70 ATH_MSG_DEBUG("Couldn't retrieve CaloRingsELVec. Reason: " << e.what());
73 incrementCounter(); displayLoopingMessage();
75 // Make CaloRings ElementLink Holder:
76 xAOD::CaloRingsLinks clRingsLinks;
78 // The CaloRings ElementLink:
79 ElementLink<xAOD::CaloRingsContainer> ringsEL;
81 if (m_builder->execute( *part, ringsEL ).isFailure()){
82 throw std::runtime_error("Error while executing CaloRings builder.");
86 clRingsLinks.push_back( ringsEL );
90 // Decorate particle with CaloRings:
91 m_decor->operator()( *part ) = clRingsLinks;
97 // =====================================================================================
98 template<typename container_t>
99 StatusCode BuildCaloRingsJetFctor<container_t>::initialize()
101 ATH_CHECK( m_decorKey.initialize() );
102 m_decorKey.owner()->declare(m_decorKey);
103 return StatusCode::SUCCESS;
107 } // namespace Ringer
109 #endif // CALORINGERTOOLS_RINGERREADERUTILS_ICC
111 // vim: filetype=cpp: