ATLAS Offline Software
Loading...
Searching...
No Matches
AthExParticlesCnv_p1.cxx
Go to the documentation of this file.
1
2
3/*
4 Copyright (C) 2002-2019 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
15// Framework includes
16#include "GaudiKernel/MsgStream.h"
19
20// AthExThinning includes
23
24
25void
27 AthExParticles* transObj,
28 const std::string& /*key*/,
29 MsgStream &msg ) const
30{
31 msg << MSG::DEBUG
32 << "Loading Particles from persistent state..."
33 << endmsg;
34
35 const std::vector<AthExParticle_p1>& particles = persObj->m_particles;
36 const std::size_t nMax = particles.size();
37 transObj->reserve( nMax );
38
39 for (const AthExParticle_p1& p : particles) {
40 transObj->push_back( std::make_unique<AthExParticle>( p.m_px,
41 p.m_py,
42 p.m_pz,
43 p.m_ene ) );
44 }
45
46 msg << MSG::DEBUG
47 << "Loaded Particles from persistent state [OK]"
48 << endmsg;
49 return;
50}
51
52
53void
55 AthExParticles_p1* persObj,
56 const std::string& key,
57 MsgStream &msg ) const
58{
59 msg << MSG::DEBUG
60 << "Creating persistent state of Particles..."
61 << endmsg;
62
63 const SG::ThinningDecisionBase* dec =
65
66 for ( unsigned int i = 0; i != transObj->size(); ++i ) {
67 if (dec && dec->thinned(i)) continue;
68 const AthExParticle * p = (*transObj)[i];
69 if ( 0 == p ) {
70 std::cerr << "## skipping element [" << i << "] ##" << std::endl;
71 continue;
72 }
73
74 persObj->m_particles.emplace_back( p->px(),
75 p->py(),
76 p->pz(),
77 p->e() );
78 }
79
80 msg << MSG::DEBUG
81 << "Created persistent state of Particles [OK]"
82 << endmsg;
83 return;
84}
#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