ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Generators
GeneratorObjectsTPCnv
src
McEventCollectionCnv_p1.cxx
Go to the documentation of this file.
1
2
3
/*
4
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
5
*/
6
7
// McEventCollectionCnv_p1.cxx
8
// Implementation file for class McEventCollectionCnv_p1
9
// Author: S.Binet<binet@cern.ch>
11
12
13
// STL includes
14
#include <utility>
15
16
// GeneratorObjectsTPCnv includes
17
#include "
GeneratorObjectsTPCnv/McEventCollectionCnv_p1.h
"
18
#include "
GeneratorObjectsTPCnv/GenEventCnv_p1.h
"
19
#include "
HepMcDataPool.h
"
20
22
// Constructors
24
25
McEventCollectionCnv_p1::McEventCollectionCnv_p1
() :
26
Base_t
( )
27
{}
28
29
McEventCollectionCnv_p1::McEventCollectionCnv_p1
(
const
McEventCollectionCnv_p1
& rhs )
30
31
=
default
;
32
33
McEventCollectionCnv_p1
&
34
McEventCollectionCnv_p1::operator=
(
const
McEventCollectionCnv_p1
& rhs )
35
{
36
if
(
this
!= &rhs ) {
37
Base_t::operator=( rhs );
38
}
39
return
*
this
;
40
}
41
43
// Destructor
45
46
McEventCollectionCnv_p1::~McEventCollectionCnv_p1
()
47
=
default
;
48
49
50
void
McEventCollectionCnv_p1::persToTrans
(
const
McEventCollection_p1
* persObj,
51
McEventCollection
* transObj,
52
MsgStream&
msg
)
53
{
54
msg
<< MSG::DEBUG <<
"Loading McEventCollection from persistent state..."
55
<<
endmsg
;
56
57
// elements are managed by DataPool
58
transObj->
clear
(
SG::VIEW_ELEMENTS
);
59
60
HepMC::DataPool
datapool =
HepMC::DataPool
();
61
datapool.
evt
.reserve ( 20 );
62
datapool.
vtx
.reserve ( 1000 );
63
datapool.
part
.reserve( 1000 );
64
65
// create a T/P converter for the GenEvent class
66
GenEventCnv_p1
genEvtCnv;
67
genEvtCnv.
setDataPool
( &datapool );
68
69
const
std::size_t nEvts = persObj->size();
70
if
( datapool.
evt
.capacity() - datapool.
evt
.allocated() < nEvts ) {
71
datapool.
evt
.reserve( datapool.
evt
.allocated() + nEvts );
72
}
73
transObj->
reserve
( nEvts );
74
for
(
const
auto
& persEvt : *persObj) {
75
HepMC::GenEvent
* genEvt = datapool.
getGenEvent
();
76
genEvtCnv.
persToTrans
( &persEvt, genEvt,
msg
);
77
transObj->
push_back
( genEvt );
78
79
}
//> end loop over genEvents
80
81
msg
<< MSG::DEBUG <<
"Loaded McEventCollection from persistent state [OK]"
82
<<
endmsg
;
83
}
84
85
void
McEventCollectionCnv_p1::transToPers
(
const
McEventCollection
*,
86
McEventCollection_p1
*,
87
MsgStream&
msg
)
88
{
89
msg
<< MSG::DEBUG <<
"Creating persistent state of McEventCollection..."
90
<<
endmsg
;
91
92
msg
<< MSG::ERROR
93
<<
"This transient-to-persistent converter method has been RETIRED !!"
94
<<
endmsg
95
<<
"You are not supposed to end-up here ! Go away !"
96
<<
endmsg
;
97
98
throw
std::runtime_error(
"Retired McEventCollectionCnv_p1::transToPers() !!"
);
99
}
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:54
GenEventCnv_p1.h
HepMcDataPool.h
McEventCollectionCnv_p1.h
DataVector::reserve
void reserve(size_type n)
Attempt to preallocate enough memory for a specified number of elements.
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
DataVector::clear
void clear()
Erase all the elements in the collection.
GenEventCnv_p1
Definition
GenEventCnv_p1.h:34
GenEventCnv_p1::persToTrans
virtual void persToTrans(const GenEvent_p1 *persObj, HepMC::GenEvent *transObj, MsgStream &msg)
Destructor:
Definition
GenEventCnv_p1.cxx:36
GenEventCnv_p1::setDataPool
void setDataPool(HepMC::DataPool *pool)
reset the @ HepMC::DataPool pointer
Definition
GenEventCnv_p1.cxx:31
McEventCollectionCnv_p1
Definition
McEventCollectionCnv_p1.h:34
McEventCollectionCnv_p1::McEventCollectionCnv_p1
McEventCollectionCnv_p1()
Default constructor:
Definition
McEventCollectionCnv_p1.cxx:25
McEventCollectionCnv_p1::~McEventCollectionCnv_p1
virtual ~McEventCollectionCnv_p1()
Destructor.
McEventCollectionCnv_p1::Base_t
T_AthenaPoolTPCnvBase< McEventCollection, McEventCollection_p1 > Base_t
Definition
McEventCollectionCnv_p1.h:36
McEventCollectionCnv_p1::persToTrans
virtual void persToTrans(const McEventCollection_p1 *persObj, McEventCollection *transObj, MsgStream &msg)
Method creating the transient representation of McEventCollection from its persistent representation ...
Definition
McEventCollectionCnv_p1.cxx:50
McEventCollectionCnv_p1::transToPers
virtual void transToPers(const McEventCollection *transObj, McEventCollection_p1 *persObj, MsgStream &msg)
Method creating the persistent representation McEventCollection_p1 from its transient representation ...
Definition
McEventCollectionCnv_p1.cxx:85
McEventCollectionCnv_p1::operator=
McEventCollectionCnv_p1 & operator=(const McEventCollectionCnv_p1 &rhs)
Assignement operator.
Definition
McEventCollectionCnv_p1.cxx:34
McEventCollection_p1
Definition
McEventCollection_p1.h:24
McEventCollection
This defines the McEventCollection, which is really just an ObjectVector of McEvent objectsFile: Gene...
Definition
McEventCollection.h:31
HepMC::GenEvent
HepMC3::GenEvent GenEvent
Definition
GenEvent.h:39
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition
OwnershipPolicy.h:18
HepMC::DataPool
Definition
HepMcDataPool.h:23
HepMC::DataPool::evt
::DataPool< HepMC::GenEvent, ClearGenEvent > evt
Definition
HepMcDataPool.h:52
HepMC::DataPool::part
::DataPool< HepMC::GenParticle, ClearGenParticle > part
Definition
HepMcDataPool.h:73
HepMC::DataPool::getGenEvent
HepMC::GenEvent * getGenEvent()
Definition
HepMcDataPool.h:53
HepMC::DataPool::vtx
::DataPool< HepMC::GenVertex, ClearGenVertex > vtx
Definition
HepMcDataPool.h:62
msg
MsgStream & msg
Definition
testRead.cxx:32
Generated on
for ATLAS Offline Software by
1.17.0