ATLAS Offline Software
AthExParticlesCnv_p1.cxx
Go to the documentation of this file.
1 
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
22 #include "AthExParticlesCnv_p1.h"
23 
24 
25 void
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
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 }
DataVector::reserve
void reserve(size_type n)
Attempt to preallocate enough memory for a specified number of elements.
AthExParticles_p1
Definition: AthExParticles_p1.h:38
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
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.
ThinningDecisionBase.h
Hold thinning decisions for one container.
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
lumiFormat.i
int i
Definition: lumiFormat.py:92
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
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
AthExParticles.h
getThinningCache.h
Helpers to retrieve the current thinning cache from the event context.
AthExParticlesCnv_p1.h
SG::getThinningDecision
const SG::ThinningDecisionBase * getThinningDecision(const EventContext &ctx, const std::string &key)
Retrieve the current thinning decision for key.
Definition: getThinningCache.cxx:83
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
AthExParticle_p1
Definition: AthExParticles_p1.h:21
DEBUG
#define DEBUG
Definition: page_access.h:11
LArG4FSStartPointFilter.particles
list particles
Definition: LArG4FSStartPointFilter.py:84
AthExParticle
Definition: AthExParticle.h:24
AthExParticles_p1::m_particles
std::vector< AthExParticle_p1 > m_particles
Definition: AthExParticles_p1.h:61
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
AthExParticles
Definition: AthExParticles.h:37
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37