ATLAS Offline Software
Loading...
Searching...
No Matches
ParticleLinksCnv_p1.h
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// ParticleLinksCnv_p1.h
8// Header file for class ParticleLinksCnv_p1, handles transient<->persistent ParticleLinks
9// Template class, must be inherited by the class handling instantiations of ParticleLinks
10// see ParticleBaseLinksCnv_p1
11//
12// Author: S. Protopopescu <serban@bnl.gov>
14#ifndef PARTICLEEVENTTPCNV_PARTICLELINKSCNV_P1_H
15#define PARTICLEEVENTTPCNV_PARTICLELINKSCNV_P1_H 1
16
17// AthenaPoolCnvSvc includes
18//#include "AthenaPoolCnvSvc/T_AthenaPoolTPConverter.h" (in DataLinkCnv_p1.h)
20#include "AthLinks/DataLink.h"
21#include "GaudiKernel/MsgStream.h"
25#include <string>
26#include <iostream>
27
28
29template<class Container>
31 ParticleLinks<Container>,
32 ParticleLinks_p1
33 >
34{
35public:
41
42
45
47 // Conversion methods:
49
50 virtual
51 void persToTrans( const ParticleLinks_p1* persObj,
52 ParticleLinks<Container>* transObj,
53 MsgStream &msg ) const override;
54
58 virtual
59 void transToPers( const ParticleLinks<Container>* transObj,
60 ParticleLinks_p1* persObj,
61 MsgStream &msg ) const override;
62 private:
64};
65
66#ifndef __REFLEX__
67
68template<class Container>
70 ParticleLinks_p1* persObj,
71 MsgStream &msg ) const {
72 msg<< MSG::DEBUG<<typeid(*transObj).name()<<" called"<<endmsg;
73 //std::cout<<">>> ParticleLinksCnv_p1 "<<typeid(*transObj).name()<<" called"<<std::endl;
74 if(transObj->size()==0) return;
75 SelectedParticles selparts; SelectedParticles_p1 selparts_p1;
76
77 typedef ParticleLinks<Container> Links;
78 selparts.SetMaxBits(transObj->size());
79 typename Links::const_iterator ilItr = transObj->begin();
80 typename Links::const_iterator ilEnd = transObj->end();
81 for(; ilItr != ilEnd; ++ilItr) {
82 selparts.SetBit((*ilItr).index());
83 }
84
85 std::string container_name=(&(*transObj)[0])->dataID();
86 msg<< MSG::DEBUG<<"Container name="<<container_name<<endmsg;
87 selparts_p1.m_bits=selparts.AllBits();
88 persObj->setSelectedParticles_p1(selparts_p1);
89 DataLink<Container> dl(container_name);
90 DataLink_p1 dl_p1;
91 m_dl.transToPers(&dl,&dl_p1,msg);
92 persObj->setDataLink_p1(dl_p1);
93 msg << MSG::DEBUG << "Created SelectedParticles, persistent state of "<<typeid(*transObj).name()<<endmsg;
94
95}
96
97template<class Container>
99 ParticleLinks<Container>* transObj,
100 MsgStream &msg ) const {
102 const DataLink_p1* dl_p1=persObj->dl_p1();
103 m_dl.persToTrans(dl_p1,&dl,msg);
104 dl.toTransient();
105 //const Container *particles=dl.cptr();
106 const SelectedParticles_p1* selparts_p1=persObj->sel();
107 //typename Container::const_iterator ipItr = particles->begin();
108 //typename Container::const_iterator ipEnd = particles->end();
109 SelectedParticles selparts;
110 selparts.Set (selparts_p1->m_bits);
111 //SelectedParticles selparts(m_bits);
112 std::vector<unsigned> goodparts;
113 selparts.goodParticles (goodparts);
114 transObj->reserve(goodparts.size());
115 for (unsigned index : goodparts) {
116 transObj->emplace_back (dl.key(), index);
117 }
118
119 msg << MSG::DEBUG << "Loading "<<typeid(*transObj).name()<<"from SelectedParticles"<<endmsg;
120}
121
122#endif // not __REFLEX__
123
124
125#endif // !PARTICLEEVENTTPCNV_PARTICLELINKSCNV_P1_H
126
#define endmsg
This file contains the class definition for the DataLinkCnv_p1 class and DataLinkVectorCnv_p1 class.
TPConverterConstBase< TRANS, PERS > T_AthenaPoolTPCnvConstBase
T_AthenaPoolTPCnvConstBase< ParticleLinks< Container >, ParticleLinks_p1 > base_class
DataLinkCnv_p1< DataLink< Container > > m_dl
virtual void transToPers(const ParticleLinks< Container > *transObj, ParticleLinks_p1 *persObj, MsgStream &msg) const override
Method creating the persistent representation Decay_p1 from its transient representation Decay.
virtual void persToTrans(const ParticleLinks_p1 *persObj, ParticleLinks< Container > *transObj, MsgStream &msg) const override
std::vector< unsigned > m_bits
void SetMaxBits(unsigned maxbits)
void Set(const std::vector< unsigned > &onoffBits)
void SetBit(unsigned i, bool good=true)
const std::vector< unsigned > & AllBits() const
void goodParticles(std::vector< unsigned > &goodparts) const
virtual void transToPers(const TRANS *transObj, PERS *persObj, MsgStream &log) const =0
Convert transient representation to persistent one.
virtual void persToTrans(const PERS *persObj, TRANS *transObj, MsgStream &log) const =0
Convert persistent representation to transient one.
Definition index.py:1
MsgStream & msg
Definition testRead.cxx:32