ATLAS Offline Software
Loading...
Searching...
No Matches
TruthParticleContainerCnv_p6.cxx
Go to the documentation of this file.
1
2
3/*
4 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
5*/
6
7// TruthParticleContainerCnv_p6.cxx
8// Implementation file for class TruthParticleContainerCnv_p6
9// Author: S.Binet<binet@cern.ch>
11
12// STL includes
13
14// Framework includes
15#include "GaudiKernel/MsgStream.h"
16
17// HepMC includes
20
21// McParticleKernel includes
23
24// McParticleEvent includes
28
29// McParticleEventTPCnv includes
31
33
34
35void
38 MsgStream& msg ) const
39{
40 msg << MSG::DEBUG
41 << "Loading TruthParticleContainer from persistent state..."
42 << endmsg;
43
44 if ( 0 == m_cnvTool ) {
45 msg << MSG::ERROR
46 << "NULL pointer to ITruthParticleCnvTool !!"
47 << endmsg
48 << "Can't create *ANY* TruthParticleContainer !!"
49 << endmsg;
50 throw std::runtime_error("NULL pointer to ITruthParticleCnvTool !!");
51 }
52
53 // convert the ElementLink<McEventCollection>
55 m_genEvtCnv.persToTrans( &pers->m_genEvent,
56 &genEventEL,
57 msg );
58 trans->setGenEvent (genEventEL);
59
61 if ( 0 == evt ) {
62 const std::string error("NULL pointer to McEventCollection !!");
63 msg << MSG::ERROR << error
64 << endmsg;
65 throw std::runtime_error(error);
66 }
67
68 // retrieve the pileup type of this container : it is the same as the GenEvent it is linked to.
70 // retrieve all GenEvent corresponding to this pile-up type :
71 size_t firstEvt, lastEvt;
72 PileUpClassification::findEventIterators(putype, evt, firstEvt, lastEvt);
73 msg << MSG::DEBUG << " Converting pile-up type = "<< putype << " from McEventCollection index "<< firstEvt << " to "<< lastEvt << endmsg;
74 // loop on the GenEvent to fill the container.
75 for( ; firstEvt != lastEvt; firstEvt++){
76
77 if ( !m_cnvTool->convert( evt,
78 firstEvt,
79 trans ).isSuccess() ) {
80 msg << MSG::ERROR
81 << "Problem converting HepMC::GenEvent ["
82 << trans->genEventLink().dataID() << "]["
83 << firstEvt << "]"
84 << " to TruthParticleContainer !"
85 << endmsg;
86 throw std::runtime_error("No TruthParticleContainer created !!");
87 }
88 }
89
90 if ( !trans->genEventLink().isValid() ) {
91 const std::string err = "ElementLink to McEventCollection is not valid !";
92 msg << MSG::ERROR << err << endmsg;
93 throw std::runtime_error(err);
94 }
95
96 // convert the ElementLink<TruthEtIsolationsContainer>
97 // this needs to be done *AFTER* the GenEvent->TPContainer conversion !!
99 m_etIsolCnv.persToTrans( &pers->m_etIsolations,
100 &etIsolEL,
101 msg );
102 trans->setEtIsolations (etIsolEL);
103
104 msg << MSG::DEBUG
105 << "Loaded TruthParticleContainer from persistent state [OK]"
106 << endmsg;
107 return;
108}
109
110void
113 MsgStream& msg ) const
114{
115 msg << MSG::DEBUG
116 << "Creating persistent state of TruthParticleContainer..."
117 << endmsg;
118
119 // convert the ElementLink<McEventCollection>
120 m_genEvtCnv.transToPers( &trans->genEventLink(),
121 &pers->m_genEvent,
122 msg );
123
124 if ( !trans->genEventLink().isValid() ) {
125 msg << MSG::WARNING
126 << "Transient ElementLink is NOT valid !!" << endmsg;
127 }
128
129 // convert the ElementLink<TruthEtIsolationsContainer>
130 m_etIsolCnv.transToPers( &trans->etIsolationsLink(),
131 &pers->m_etIsolations,
132 msg );
133
134 return;
135}
136
137
138
139
145
146
#define endmsg
This defines the McEventCollection, which is really just an ObjectVector of McEvent objectsFile: Gene...
PileuType_t
define some Pile-up classification Important : this classification is copied in McParticleAlgs/python...
static void findEventIterators(PileuType_t putype, McEventCollection::const_iterator &fEvt, McEventCollection::const_iterator &lEvt)
Find interval [fEvt,lEvt] containing all GenEvents of type putype from the McEventCollection.
static PileuType_t pileUpType(const McEventCollection *evts, size_t evtIndex)
Return the type of pile-up event of the GenEvent number evtIndex in the McEventCollection.
virtual void persToTrans(const TruthParticleContainer_p6 *persObj, TruthParticleContainer *transObj, MsgStream &msg) const override
Method creating the transient representation of TruthParticleContainer from its persistent representa...
virtual void transToPers(const TruthParticleContainer *transObj, TruthParticleContainer_p6 *persObj, MsgStream &msg) const override
Method creating the persistent representation TruthParticleContainer_p6 from its transient representa...
ElementLinkCnv_p3< ElementLink< McEventCollection > > m_genEvtCnv
Converter for the ElementLink<McEventCollection> data member.
ITruthParticleCnvTool * m_cnvTool
Pointer to the IAlgTool providing the conversion from a McEventCollection to a TruthParticleContainer...
ElementLinkCnv_p3< ElementLink< TruthEtIsolationsContainer > > m_etIsolCnv
Converter for the ElementLink<TruthEtIsolationsContainer> data member.
ElementLinkInt_p3 m_genEvent
The persistent pointer toward the McEventCollection the (transient) TruthParticleContainer is proxyin...
ElementLinkInt_p3 m_etIsolations
The persistent pointer toward the TruthEtIsolations container the (transient) TruthParticleContainer ...
const ElementLink< McEventCollection > & genEventLink() const
Retrieve the HepMC::GenEvent this TruthParticleContainer is proxying, as a link.
void setGenEvent(const ElementLink< McEventCollection > &genEvent)
Setup the persistent pointer toward the HepMC::GenEvent this TruthParticleContainer is proxying.
void setEtIsolations(const ElementLink< TruthEtIsolationsContainer > &etIsolations)
Setup the persistent pointer toward the TruthEtIsolations.
const ElementLink< TruthEtIsolationsContainer > & etIsolationsLink() const
return the link to truth Et isolations.
MsgStream & msg
Definition testRead.cxx:32