ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
TruthParticleID
McParticleEventTPCnv
src
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
18
#include "
AtlasHepMC/GenParticle.h
"
19
#include "
GeneratorObjects/McEventCollection.h
"
20
21
// McParticleKernel includes
22
#include "
McParticleKernel/ITruthParticleCnvTool.h
"
23
24
// McParticleEvent includes
25
#include "
McParticleEvent/TruthParticle.h
"
26
#include "
McParticleEvent/TruthParticleContainer.h
"
27
#include "
McParticleEvent/TruthEtIsolationsContainer.h
"
28
29
// McParticleEventTPCnv includes
30
#include "
McParticleEventTPCnv/TruthParticleContainerCnv_p6.h
"
31
32
#include "
McParticleEvent/PileUpClassification.h
"
33
34
35
void
36
TruthParticleContainerCnv_p6::persToTrans
(
const
TruthParticleContainer_p6
* pers,
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>
54
ElementLink<McEventCollection>
genEventEL;
55
m_genEvtCnv
.persToTrans( &pers->
m_genEvent
,
56
&genEventEL,
57
msg
);
58
trans
->setGenEvent (genEventEL);
59
60
const
McEventCollection
* evt =
trans
->genEventLink().getStorableObjectPointer();
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.
69
PileUpClassification::PileuType_t
putype =
PileUpClassification::pileUpType
(evt,pers->
m_genEvent
.
m_elementIndex
);
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 !!
98
ElementLink<TruthEtIsolationsContainer>
etIsolEL;
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
110
void
111
TruthParticleContainerCnv_p6::transToPers
(
const
TruthParticleContainer
*
trans
,
112
TruthParticleContainer_p6
* pers,
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
140
#include "
RootTruthParticleCnvTool.h
"
141
T_TPCnv<TruthParticleContainer, TruthParticleContainer_p6>::T_TPCnv
()
142
{
143
m_cnvTool
=
new
RootTruthParticleCnvTool
;
144
}
145
146
147
T_TPCnv<TruthParticleContainer, TruthParticleContainer_p6>::~T_TPCnv
()
148
{
149
delete
m_cnvTool
;
150
}
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:54
GenParticle.h
ITruthParticleCnvTool.h
McEventCollection.h
TruthParticleContainer.h
TruthParticle.h
PileUpClassification.h
RootTruthParticleCnvTool.h
TruthEtIsolationsContainer.h
TruthParticleContainerCnv_p6.h
ElementLink_p3::m_elementIndex
INDEXTYPE m_elementIndex
Definition
ElementLink_p3.h:28
ElementLink
ElementLink implementation for ROOT usage.
Definition
A/AthLinks/ElementLink.h:40
McEventCollection
This defines the McEventCollection, which is really just an ObjectVector of McEvent objectsFile: Gene...
Definition
McEventCollection.h:31
PileUpClassification::PileuType_t
PileuType_t
define some Pile-up classification Important : this classification is copied in McParticleAlgs/python...
Definition
PileUpClassification.h:29
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
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
RootTruthParticleCnvTool
Definition
RootTruthParticleCnvTool.h:15
T_TPCnv< TruthParticleContainer, TruthParticleContainer_p6 >::T_TPCnv
T_TPCnv()
Definition
TruthParticleContainerCnv_p6.cxx:141
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
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
TruthParticleContainerCnv_p6::m_genEvtCnv
ElementLinkCnv_p3< ElementLink< McEventCollection > > m_genEvtCnv
Converter for the ElementLink<McEventCollection> data member.
Definition
TruthParticleContainerCnv_p6.h:79
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
TruthParticleContainerCnv_p6::m_etIsolCnv
ElementLinkCnv_p3< ElementLink< TruthEtIsolationsContainer > > m_etIsolCnv
Converter for the ElementLink<TruthEtIsolationsContainer> data member.
Definition
TruthParticleContainerCnv_p6.h:83
TruthParticleContainer_p6
Definition
TruthParticleContainer_p6.h:27
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_p6::m_etIsolations
ElementLinkInt_p3 m_etIsolations
The persistent pointer toward the TruthEtIsolations container the (transient) TruthParticleContainer ...
Definition
TruthParticleContainer_p6.h:71
TruthParticleContainer
Definition
PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticleContainer.h:42
trans
TH1F * trans(TH1F *h, bool t=false)
Definition
comparitor.cxx:199
error
Definition
IImpactPoint3dEstimator.h:72
msg
MsgStream & msg
Definition
testRead.cxx:32
Generated on
for ATLAS Offline Software by
1.17.0