ATLAS Offline Software
TruthParticleContainerCnv_p6.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_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
18 #include "AtlasHepMC/GenParticle.h"
20 
21 // McParticleKernel includes
23 
24 // McParticleEvent includes
28 
29 // McParticleEventTPCnv includes
31 
33 
34 
35 void
37  TruthParticleContainer* trans,
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>
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 !!
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 
110 void
113  MsgStream& msg ) const
114 {
115  msg << MSG::DEBUG
116  << "Creating persistent state of TruthParticleContainer..."
117  << endmsg;
118 
119  // convert the ElementLink<McEventCollection>
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>
131  &pers->m_etIsolations,
132  msg );
133 
134  return;
135 }
136 
137 
138 
139 
142 {
143  m_cnvTool = new RootTruthParticleCnvTool;
144 }
145 
146 
148 {
149  delete m_cnvTool;
150 }
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.
ElementLinkCnv_p3::persToTrans
void persToTrans(const PersLink_t &pers, Link_t &trans, MsgStream &log) const
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_p6::m_etIsolations
ElementLinkInt_p3 m_etIsolations
The persistent pointer toward the TruthEtIsolations container the (transient) TruthParticleContainer ...
Definition: TruthParticleContainer_p6.h:71
TruthParticleContainer.h
RootTruthParticleCnvTool
Definition: RootTruthParticleCnvTool.h:15
PileUpClassification::PileuType_t
PileuType_t
define some Pile-up classification Important : this classification is copied in McParticleAlgs/python...
Definition: PileUpClassification.h:29
LArG4FSStartPointFilter.evt
evt
Definition: LArG4FSStartPointFilter.py:42
TruthParticleContainerCnv_p6::m_cnvTool
ITruthParticleCnvTool * m_cnvTool
Pointer to the IAlgTool providing the conversion from a McEventCollection to a TruthParticleContainer...
Definition: TruthParticleContainerCnv_p6.h:75
TruthParticleContainer_p6
Definition: TruthParticleContainer_p6.h:27
TruthParticleContainer
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticleContainer.h:42
GenParticle.h
TruthParticleContainer_p6::m_genEvent
ElementLinkInt_p3 m_genEvent
The persistent pointer toward the McEventCollection the (transient) TruthParticleContainer is proxyin...
Definition: TruthParticleContainer_p6.h:65
TruthParticleContainer::etIsolationsLink
const ElementLink< TruthEtIsolationsContainer > & etIsolationsLink() const
return the link to truth Et isolations.
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticleContainer.h:275
TruthEtIsolationsContainer.h
ElementLinkCnv_p3::transToPers
void transToPers(const Link_t &trans, PersLink_t &pers, const SG::ThinningCache *cache, MsgStream &log) const
TruthParticleContainerCnv_p6::m_genEvtCnv
ElementLinkCnv_p3< ElementLink< McEventCollection > > m_genEvtCnv
Converter for the ElementLink<McEventCollection> data member.
Definition: TruthParticleContainerCnv_p6.h:79
dqt_zlumi_pandas.err
err
Definition: dqt_zlumi_pandas.py:193
McEventCollection.h
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
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
TruthParticleContainerCnv_p6.h
TruthParticleContainerCnv_p6::persToTrans
virtual void persToTrans(const TruthParticleContainer_p6 *persObj, TruthParticleContainer *transObj, MsgStream &msg) const override
Method creating the transient representation of TruthParticleContainer from its persistent representa...
Definition: TruthParticleContainerCnv_p6.cxx:36
DEBUG
#define DEBUG
Definition: page_access.h:11
TruthParticleContainerCnv_p6::transToPers
virtual void transToPers(const TruthParticleContainer *transObj, TruthParticleContainer_p6 *persObj, MsgStream &msg) const override
Method creating the persistent representation TruthParticleContainer_p6 from its transient representa...
Definition: TruthParticleContainerCnv_p6.cxx:111
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
PileUpClassification::pileUpType
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.
Definition: PileUpClassification.cxx:75
TruthParticleContainerCnv_p6::m_etIsolCnv
ElementLinkCnv_p3< ElementLink< TruthEtIsolationsContainer > > m_etIsolCnv
Converter for the ElementLink<TruthEtIsolationsContainer> data member.
Definition: TruthParticleContainerCnv_p6.h:83
error
Definition: IImpactPoint3dEstimator.h:70
T_TPCnv
Definition: T_AthenaPoolTPConverter.h:17
PileUpClassification.h
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
PileUpClassification::findEventIterators
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.
Definition: PileUpClassification.cxx:8