ATLAS Offline Software
Loading...
Searching...
No Matches
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
19#include "HepMcDataPool.h"
20
22// Constructors
24
28
30
31= default;
32
35{
36 if ( this != &rhs ) {
37 Base_t::operator=( rhs );
38 }
39 return *this;
40}
41
43// Destructor
45
47= default;
48
49
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
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
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}
#define endmsg
void reserve(unsigned int size)
Set the desired capacity.
unsigned int capacity()
return capacity of pool OK
unsigned int allocated()
return size already allocated OK
void reserve(size_type n)
Attempt to preallocate enough memory for a specified number of elements.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
void clear()
Erase all the elements in the collection.
virtual void persToTrans(const GenEvent_p1 *persObj, HepMC::GenEvent *transObj, MsgStream &msg)
Destructor:
void setDataPool(HepMC::DataPool *pool)
reset the @ HepMC::DataPool pointer
McEventCollectionCnv_p1()
Default constructor:
virtual ~McEventCollectionCnv_p1()
Destructor.
T_AthenaPoolTPCnvBase< McEventCollection, McEventCollection_p1 > Base_t
virtual void persToTrans(const McEventCollection_p1 *persObj, McEventCollection *transObj, MsgStream &msg)
Method creating the transient representation of McEventCollection from its persistent representation ...
virtual void transToPers(const McEventCollection *transObj, McEventCollection_p1 *persObj, MsgStream &msg)
Method creating the persistent representation McEventCollection_p1 from its transient representation ...
McEventCollectionCnv_p1 & operator=(const McEventCollectionCnv_p1 &rhs)
Assignement operator.
This defines the McEventCollection, which is really just an ObjectVector of McEvent objectsFile: Gene...
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
GenPartPool_t part
an arena of HepMC::GenParticle for efficient object instantiation
HepMC::GenEvent * getGenEvent()
GenVtxPool_t vtx
an arena of HepMC::GenVertex for efficient object instantiation
GenEvtPool_t evt
an arena of HepMC::GenEvent for efficient object instantiation
MsgStream & msg
Definition testRead.cxx:32