ATLAS Offline Software
Loading...
Searching...
No Matches
xAODTrackParticleAuxContainerCnv.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
5// $Id: xAODTrackParticleAuxContainerCnv.cxx 791368 2017-01-05 08:55:07Z krasznaa $
6
7// System include(s):
8#include <exception>
9#include <memory>
10
11// ROOT include(s):
12#include <TClass.h>
13
14// Athena/Gaudi include(s):
17
18// Local include(s):
24
25// EDM include(s):
27
29xAODTrackParticleAuxContainerCnv( ISvcLocator* svcLoc )
31 m_compressorTool( "xAODMaker::TrackParticleCompressorTool/"
32 "xAODTrackParticleCompressorTool" ) {
33
34}
35
37
38 // Retrieve the compression tool:
39 CHECK( m_compressorTool.retrieve() );
40
41 // Call the base class's initialize:
43
44 // Return gracefully:
45 return StatusCode::SUCCESS;
46}
47
51 const std::string& key ) {
52
53 // Load the necessary ROOT class(es):
54 static char const* const NAME =
55 "std::vector<ElementLink<DataVector<Trk::Track> > >";
56 static TClass const* const cls = TClass::GetClass( NAME );
57 if( ! cls ) {
58 ATH_MSG_ERROR( "Couldn't load dictionary for type: " << NAME );
59 }
60
61 // This makes a copy of the container, with any thinning applied.
62 std::unique_ptr< xAOD::TrackParticleAuxContainer > result
64
65
66 // Create a helper object for the float compression:
68 for( size_t i = 0; i < result->size(); ++i ) {
69 helper.push_back( std::make_unique<xAOD::TrackParticle>() );
70 }
71 helper.setStore( result.get() );
72
73 // Compress the track particles' payload:
74 for( xAOD::TrackParticle* tp : helper ) {
75 // Check for possible compression errors:
76 if( ! m_compressorTool->compress( *tp ).isSuccess() ) {
77 REPORT_MESSAGE( MSG::ERROR )
78 << "Failed to compress track particle";
79 return nullptr;
80 }
81 }
82
83 // Return the thinned and compressed object:
84 return result.release();
85}
86
#define ATH_MSG_ERROR(x)
Helpers for checking error return status codes and reporting errors.
#define REPORT_MESSAGE(LVL)
Report a message.
#define CHECK(...)
Evaluate an expression and check for errors.
StatusCode initialize() override
Function initialising the converter.
virtual xAOD::TrackParticleAuxContainer * createPersistentWithKey(xAOD::TrackParticleAuxContainer *trans, const std::string &key) override
Function preparing the container to be written out.
xAODTrackParticleAuxContainerCnv(ISvcLocator *svcLoc)
Converter constructor.
ToolHandle< xAODMaker::ITrackParticleCompressorTool > m_compressorTool
Compressor tool for the track particles.
Helper to copy an object while applying thinning.
TrackParticle_v1 TrackParticle
Reference the current persistent version:
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container version".
TrackParticleAuxContainer_v5 TrackParticleAuxContainer
Definition of the current TrackParticle auxiliary container.
T_AthenaPoolAuxContainerCnv< xAOD::TrackParticleAuxContainer, xAODTrackParticleAuxContainerCnv_v4, xAODTrackParticleAuxContainerCnv_v3, xAODTrackParticleAuxContainerCnv_v2, xAODTrackParticleAuxContainerCnv_v1 > xAODTrackParticleAuxContainerCnvBase
Base class for the converter.