ATLAS Offline Software
TruthParticleContainerCnv_p5.cxx
Go to the documentation of this file.
1 
3 /*
4  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 // TruthParticleContainerCnv_p5.cxx
8 // Implementation file for class TruthParticleContainerCnv_p5
9 // Author: S.Binet<binet@cern.ch>
11 
12 // STL includes
13 
14 // Framework includes
15 #include "GaudiKernel/MsgStream.h"
16 
17 // HepMC includes
18 #include "AtlasHepMC/GenParticle.h"
20 
21 // McParticleKernel includes
23 
24 // McParticleEvent includes
28 
29 // McParticleEventTPCnv includes
31 
32 
33 void
35  TruthParticleContainer* trans,
36  MsgStream& msg ) const
37 {
38  msg << MSG::DEBUG
39  << "Loading TruthParticleContainer from persistent state..."
40  << endmsg;
41 
42  if ( 0 == m_cnvTool ) {
43  msg << MSG::ERROR
44  << "NULL pointer to ITruthParticleCnvTool !!"
45  << endmsg
46  << "Can't create *ANY* TruthParticleContainer !!"
47  << endmsg;
48  throw std::runtime_error("NULL pointer to ITruthParticleCnvTool !!");
49  }
50 
51  // convert the ElementLink<McEventCollection>
54  &genEventEL,
55  msg );
56  trans->setGenEvent (genEventEL);
57 
59  if ( 0 == evt ) {
60  const std::string error("NULL pointer to McEventCollection !!");
61  msg << MSG::ERROR << error
62  << endmsg;
63  throw std::runtime_error(error);
64  }
65 
66  if ( !m_cnvTool->convert( evt,
68  trans ).isSuccess() ) {
69  msg << MSG::ERROR
70  << "Problem converting HepMC::GenEvent ["
71  << pers->m_genEvent.m_contName << "]["
72  << pers->m_genEvent.m_elementIndex << "]"
73  << " to TruthParticleContainer !"
74  << endmsg;
75  throw std::runtime_error("No TruthParticleContainer created !!");
76  }
77 
78  if ( !trans->genEventLink().isValid() ) {
79  const std::string err = "ElementLink to McEventCollection is not valid !";
80  msg << MSG::ERROR << err << endmsg;
81  throw std::runtime_error(err);
82  }
83 
84  // convert the ElementLink<TruthEtIsolationsContainer>
85  // this needs to be done *AFTER* the GenEvent->TPContainer conversion !!
88  &etIsolEL,
89  msg );
90  trans->setEtIsolations (etIsolEL);
91 
92  msg << MSG::DEBUG
93  << "Loaded TruthParticleContainer from persistent state [OK]"
94  << endmsg;
95  return;
96 }
97 
98 void
101  MsgStream& msg ) const
102 {
103  msg << MSG::DEBUG
104  << "Creating persistent state of TruthParticleContainer..."
105  << endmsg;
106 
107  msg << MSG::ERROR
108  << "This transient-to-persistent converter method has been RETIRED !!"
109  << endmsg
110  << "You are not supposed to end-up here ! Go away !"
111  << endmsg;
112 
113  throw std::runtime_error( "Retired TruthParticleContainerCnv_p5::transToPers() !!" );
114 
115  return;
116 }
117 
118 
119 
120 
123 {
124  m_cnvTool = new RootTruthParticleCnvTool;
125 }
126 
127 
129 {
130  delete m_cnvTool;
131 }
TruthParticleContainerCnv_p5::m_etIsolCnv
ElementLinkCnv_p1< ElementLink< TruthEtIsolationsContainer > > m_etIsolCnv
Converter for the ElementLink<TruthEtIsolationsContainer> data member.
Definition: TruthParticleContainerCnv_p5.h:83
ITruthParticleCnvTool::convert
virtual StatusCode convert(const McEventCollection *mcEvts, const unsigned int genEvtIndex, TruthParticleContainer *mcParts, const ITruthParticleVisitor *visitor=0) const =0
Convert a McEventCollection into an TruthParticleContainer.
ITruthParticleCnvTool.h
TruthParticleContainer::setEtIsolations
void setEtIsolations(const ElementLink< TruthEtIsolationsContainer > &etIsolations)
Setup the persistent pointer toward the TruthEtIsolations.
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticleContainer.h:307
TruthParticleContainer_p5::m_genEvent
ElementLinkInt_p1 m_genEvent
The persistent pointer toward the McEventCollection the (transient) TruthParticleContainer is proxyin...
Definition: TruthParticleContainer_p5.h:45
TruthParticleContainer.h
RootTruthParticleCnvTool
Definition: RootTruthParticleCnvTool.h:15
LArG4FSStartPointFilter.evt
evt
Definition: LArG4FSStartPointFilter.py:42
TruthParticleContainerCnv_p5::m_cnvTool
ITruthParticleCnvTool * m_cnvTool
Pointer to the IAlgTool providing the conversion from a McEventCollection to a TruthParticleContainer...
Definition: TruthParticleContainerCnv_p5.h:75
TruthParticleContainer
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticleContainer.h:42
GenParticle.h
TruthParticleContainerCnv_p5::persToTrans
virtual void persToTrans(const TruthParticleContainer_p5 *persObj, TruthParticleContainer *transObj, MsgStream &msg) const override
Method creating the transient representation of TruthParticleContainer from its persistent representa...
Definition: TruthParticleContainerCnv_p5.cxx:34
TruthEtIsolationsContainer.h
dqt_zlumi_pandas.err
err
Definition: dqt_zlumi_pandas.py:182
McEventCollection.h
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
TruthParticleContainer_p5
Definition: TruthParticleContainer_p5.h:27
TruthParticleContainer::setGenEvent
void setGenEvent(const ElementLink< McEventCollection > &genEvent)
Setup the persistent pointer toward the HepMC::GenEvent this TruthParticleContainer is proxying.
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticleContainer.h:290
McEventCollection
This defines the McEventCollection, which is really just an ObjectVector of McEvent objects.
Definition: McEventCollection.h:33
TruthParticle.h
ElementLinkCnv_p1::persToTrans
void persToTrans(const PersLink_t &pers, Link_t &trans, MsgStream &log) const
TruthParticleContainer_p5::m_etIsolations
ElementLinkInt_p1 m_etIsolations
The persistent pointer toward the TruthEtIsolations container the (transient) TruthParticleContainer ...
Definition: TruthParticleContainer_p5.h:51
TruthParticleContainerCnv_p5.h
DEBUG
#define DEBUG
Definition: page_access.h:11
TruthParticleContainer::genEventLink
const ElementLink< McEventCollection > & genEventLink() const
Retrieve the HepMC::GenEvent this TruthParticleContainer is proxying, as a link.
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticleContainer.h:237
RootTruthParticleCnvTool.h
get_generator_info.error
error
Definition: get_generator_info.py:40
TruthParticleContainerCnv_p5::m_genEvtCnv
ElementLinkCnv_p1< ElementLink< McEventCollection > > m_genEvtCnv
Converter for the ElementLink<McEventCollection> data member.
Definition: TruthParticleContainerCnv_p5.h:79
error
Definition: IImpactPoint3dEstimator.h:70
TruthParticleContainerCnv_p5::transToPers
virtual void transToPers(const TruthParticleContainer *transObj, TruthParticleContainer_p5 *persObj, MsgStream &msg) const override
Method creating the persistent representation TruthParticleContainer_p5 from its transient representa...
Definition: TruthParticleContainerCnv_p5.cxx:99
T_TPCnv
Definition: T_AthenaPoolTPConverter.h:17
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7