ATLAS Offline Software
Loading...
Searching...
No Matches
AthExParticlesCnv_p1.cxx
Go to the documentation of this file.
1
2
3/*
4 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
5*/
6
7// AthExParticlesCnv_p1.cxx
8// Implementation file for class AthExParticlesCnv_p1
9// Author: S.Binet<binet@cern.ch>
11
12
13// STL includes
14#include <print>
15
16// Framework includes
17#include "GaudiKernel/MsgStream.h"
20
21// AthExThinning includes
24
25
26void
28 AthExParticles* transObj,
29 const std::string& /*key*/,
30 MsgStream &msg ) const
31{
32 msg << MSG::DEBUG
33 << "Loading Particles from persistent state..."
34 << endmsg;
35
36 const std::vector<AthExParticle_p1>& particles = persObj->m_particles;
37 const std::size_t nMax = particles.size();
38 transObj->reserve( nMax );
39
40 for (const AthExParticle_p1& p : particles) {
41 transObj->push_back( std::make_unique<AthExParticle>( p.m_px,
42 p.m_py,
43 p.m_pz,
44 p.m_ene ) );
45 }
46
47 msg << MSG::DEBUG
48 << "Loaded Particles from persistent state [OK]"
49 << endmsg;
50 return;
51}
52
53
54void
56 AthExParticles_p1* persObj,
57 const std::string& key,
58 MsgStream &msg ) const
59{
60 msg << MSG::DEBUG
61 << "Creating persistent state of Particles..."
62 << endmsg;
63
64 const SG::ThinningDecisionBase* dec =
66
67 for ( unsigned int i = 0; i != transObj->size(); ++i ) {
68 if (dec && dec->thinned(i)) continue;
69 const AthExParticle * p = (*transObj)[i];
70 if ( 0 == p ) {
71 std::println (std::cerr, "## skipping element [{}] ##", i);
72 continue;
73 }
74
75 persObj->m_particles.emplace_back( p->px(),
76 p->py(),
77 p->pz(),
78 p->e() );
79 }
80
81 msg << MSG::DEBUG
82 << "Created persistent state of Particles [OK]"
83 << endmsg;
84 return;
85}
#define endmsg
Hold thinning decisions for one container.
virtual void transToPersWithKey(const AthExParticles *transObj, AthExParticles_p1 *persObj, const std::string &key, MsgStream &msg) const override
Method creating the persistent representation Particles_p1 from its transient representation Particle...
virtual void persToTransWithKey(const AthExParticles_p1 *persObj, AthExParticles *transObj, const std::string &key, MsgStream &msg) const override
Method creating the transient representation of Particles from its persistent representation Particle...
std::vector< AthExParticle_p1 > m_particles
void reserve(size_type n)
Attempt to preallocate enough memory for a specified number of elements.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
Hold thinning decisions for one container.
bool thinned(size_t ndx) const
Return true if element ndx should be thinned.
Helpers to retrieve the current thinning cache from the event context.
const SG::ThinningDecisionBase * getThinningDecision(const EventContext &ctx, const std::string &key)
Retrieve the current thinning decision for key.
MsgStream & msg
Definition testRead.cxx:32