ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
AthenaExamples
AthExThinning
src
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"
18
#include "
AthenaKernel/getThinningCache.h
"
19
#include "
AthenaKernel/ThinningDecisionBase.h
"
20
21
// AthExThinning includes
22
#include "
AthExThinning/AthExParticles.h
"
23
#include "
AthExParticlesCnv_p1.h
"
24
25
26
void
27
AthExParticlesCnv_p1::persToTransWithKey
(
const
AthExParticles_p1
* persObj,
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
54
void
55
AthExParticlesCnv_p1::transToPersWithKey
(
const
AthExParticles
* transObj,
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 =
65
SG::getThinningDecision
(key);
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
}
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:54
AthExParticlesCnv_p1.h
AthExParticles.h
ThinningDecisionBase.h
Hold thinning decisions for one container.
AthExParticle_p1
Definition
AthExParticles_p1.h:21
AthExParticle
Definition
AthExParticle.h:24
AthExParticlesCnv_p1::transToPersWithKey
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...
Definition
AthExParticlesCnv_p1.cxx:55
AthExParticlesCnv_p1::persToTransWithKey
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...
Definition
AthExParticlesCnv_p1.cxx:27
AthExParticles_p1
Definition
AthExParticles_p1.h:38
AthExParticles_p1::m_particles
std::vector< AthExParticle_p1 > m_particles
Definition
AthExParticles_p1.h:61
AthExParticles
Definition
AthExParticles.h:37
DataVector::reserve
void reserve(size_type n)
Attempt to preallocate enough memory for a specified number of elements.
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
SG::ThinningDecisionBase
Hold thinning decisions for one container.
Definition
ThinningDecisionBase.h:39
SG::ThinningDecisionBase::thinned
bool thinned(size_t ndx) const
Return true if element ndx should be thinned.
getThinningCache.h
Helpers to retrieve the current thinning cache from the event context.
SG::getThinningDecision
const SG::ThinningDecisionBase * getThinningDecision(const EventContext &ctx, const std::string &key)
Retrieve the current thinning decision for key.
Definition
getThinningCache.cxx:83
msg
MsgStream & msg
Definition
testRead.cxx:32
Generated on
for ATLAS Offline Software by
1.17.0