ATLAS Offline Software
ParticleLinksCnv_p1.h
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 // 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 
29 template<class Container>
31  ParticleLinks<Container>,
32  ParticleLinks_p1
33  >
34 {
35 public:
41 
42 
44  virtual ~ParticleLinksCnv_p1(){;}
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 
68 template<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 
97 template<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 
TestSUSYToolsAlg.dl
dl
Definition: TestSUSYToolsAlg.py:81
SelectedParticles::SetBit
void SetBit(unsigned i, bool good=true)
Definition: SelectedParticles.cxx:19
ParticleLinksCnv_p1::persToTrans
virtual void persToTrans(const ParticleLinks_p1 *persObj, ParticleLinks< Container > *transObj, MsgStream &msg) const override
Definition: ParticleLinksCnv_p1.h:98
DataLinkCnv_p1.h
This file contains the class definition for the DataLinkCnv_p1 class and DataLinkVectorCnv_p1 class.
SelectedParticles::AllBits
const std::vector< unsigned > & AllBits() const
Definition: SelectedParticles.h:76
index
Definition: index.py:1
TPConverterConstBase::transToPers
virtual void transToPers(const TRANS *transObj, PERS *persObj, MsgStream &log) const =0
Convert transient representation to persistent one.
SelectedParticles::SetMaxBits
void SetMaxBits(unsigned maxbits)
Definition: SelectedParticles.cxx:39
ParticleLinksCnv_p1::ParticleLinksCnv_p1
ParticleLinksCnv_p1()
Definition: ParticleLinksCnv_p1.h:43
SelectedParticles.h
SelectedParticles::goodParticles
void goodParticles(std::vector< unsigned > &goodparts) const
Definition: SelectedParticles.cxx:121
ParticleLinksCnv_p1::base_class
T_AthenaPoolTPCnvConstBase< ParticleLinks< Container >, ParticleLinks_p1 > base_class
Definition: ParticleLinksCnv_p1.h:38
ParticleLinksCnv_p1::~ParticleLinksCnv_p1
virtual ~ParticleLinksCnv_p1()
Definition: ParticleLinksCnv_p1.h:44
ParticleLinksCnv_p1::m_dl
DataLinkCnv_p1< DataLink< Container > > m_dl
Definition: ParticleLinksCnv_p1.h:63
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
ParticleLinksCnv_p1
Definition: ParticleLinksCnv_p1.h:34
TPConverterConstBase::persToTrans
virtual void persToTrans(const PERS *persObj, TRANS *transObj, MsgStream &log) const =0
Convert persistent representation to transient one.
ParticleLinksCnv_p1::transToPers
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.
Definition: ParticleLinksCnv_p1.h:69
SelectedParticles_p1::m_bits
std::vector< unsigned > m_bits
Definition: SelectedParticles_p1.h:20
SelectedParticles::Set
void Set(const std::vector< unsigned > &onoffBits)
Definition: SelectedParticles.h:60
SelectedParticles
Definition: SelectedParticles.h:54
DEBUG
#define DEBUG
Definition: page_access.h:11
SelectedParticles_p1
Definition: SelectedParticles_p1.h:16
TPConverterConstBase
Definition: TPConverter.h:776
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
DataLinkCnv_p1
Definition: DataLinkCnv_p1.h:23