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-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"
17
#include "
AthenaKernel/getThinningCache.h
"
18
#include "
AthenaKernel/ThinningDecisionBase.h
"
19
20
// AthExThinning includes
21
#include "
AthExThinning/AthExParticles.h
"
22
#include "
AthExParticlesCnv_p1.h
"
23
24
25
void
26
AthExParticlesCnv_p1::persToTransWithKey
(
const
AthExParticles_p1
* persObj,
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
53
void
54
AthExParticlesCnv_p1::transToPersWithKey
(
const
AthExParticles
* transObj,
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 =
64
SG::getThinningDecision
(key);
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
}
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:61
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:54
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:26
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