ATLAS Offline Software
McEventCollectionCnv_p1.cxx
Go to the documentation of this file.
1 
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 
26  Base_t( )
27 {}
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 
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 
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 }
DataVector::reserve
void reserve(size_type n)
Attempt to preallocate enough memory for a specified number of elements.
McEventCollectionCnv_p1
Definition: McEventCollectionCnv_p1.h:43
McEventCollectionCnv_p1::McEventCollectionCnv_p1
McEventCollectionCnv_p1()
Default constructor:
Definition: McEventCollectionCnv_p1.cxx:25
HepMC::DataPool
Definition: HepMcDataPool.h:81
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition: OwnershipPolicy.h:18
TPConverterBase
Definition: TPConverter.h:738
McEventCollectionCnv_p1::~McEventCollectionCnv_p1
virtual ~McEventCollectionCnv_p1()
Destructor.
HepMcDataPool.h
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
HepMC::DataPool::evt
GenEvtPool_t evt
an arena of HepMC::GenEvent for efficient object instantiation
Definition: HepMcDataPool.h:140
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
GenEventCnv_p1.h
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
HepMC::DataPool::vtx
GenVtxPool_t vtx
an arena of HepMC::GenVertex for efficient object instantiation
Definition: HepMcDataPool.h:144
McEventCollection
This defines the McEventCollection, which is really just an ObjectVector of McEvent objects.
Definition: McEventCollection.h:33
DataVector::clear
void clear()
Erase all the elements in the collection.
GenEventCnv_p1
Definition: GenEventCnv_p1.h:45
GenEventCnv_p1::setDataPool
void setDataPool(HepMC::DataPool *pool)
reset the @ HepMC::DataPool pointer
Definition: GenEventCnv_p1.cxx:31
GenEventCnv_p1::persToTrans
virtual void persToTrans(const GenEvent_p1 *persObj, HepMC::GenEvent *transObj, MsgStream &msg)
Destructor:
Definition: GenEventCnv_p1.cxx:36
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
DEBUG
#define DEBUG
Definition: page_access.h:11
McEventCollectionCnv_p1::operator=
McEventCollectionCnv_p1 & operator=(const McEventCollectionCnv_p1 &rhs)
Assignement operator.
Definition: McEventCollectionCnv_p1.cxx:34
McEventCollection_p1
Definition: McEventCollection_p1.h:24
HepMC::DataPool::getGenEvent
HepMC::GenEvent * getGenEvent()
Definition: HepMcDataPool.h:150
McEventCollectionCnv_p1.h
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
HepMC::DataPool::part
GenPartPool_t part
an arena of HepMC::GenParticle for efficient object instantiation
Definition: HepMcDataPool.h:148