ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Event
xAOD
xAODTruthAthenaPool
src
xAODTruthVertexAuxContainerCnv_v1.cxx
Go to the documentation of this file.
1
//
2
// Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
//
4
5
// Local include(s).
6
#include "
xAODTruthVertexAuxContainerCnv_v1.h
"
7
8
// Gaudi/Athena include(s).
9
#include "
AthContainers/tools/copyAuxStoreThinned.h
"
10
#include "GaudiKernel/MsgStream.h"
11
#include "
TruthUtils/MagicNumbers.h
"
12
13
// EDM include(s):
14
#include "
xAODTruth/versions/TruthVertexContainer_v1.h
"
15
#include "
xAODTruth/TruthVertexContainer.h
"
16
17
// System include(s):
18
#include <cassert>
19
#include <stdexcept>
20
21
void
xAODTruthVertexAuxContainerCnv_v1::persToTrans
(
22
const
xAOD::TruthVertexAuxContainer_v1
* oldObj,
23
xAOD::TruthVertexAuxContainer
* newObj, MsgStream&)
const
{
24
25
// Some security checks.
26
assert(oldObj !=
nullptr
);
27
assert(newObj !=
nullptr
);
28
29
// Clear the transient object:
30
newObj->
resize
(0);
31
32
// Copy the payload of the v1 object into the latest one by misusing
33
// the thinning code a bit.
34
SG::copyAuxStoreThinned
(*oldObj, *newObj,
nullptr
);
35
//
36
// And now fix up the status and barcode variables in the new object...
37
//
38
// Set up interface containers on top of them:
39
xAOD::TruthVertexContainer_v1
oldInt;
40
for
(
size_t
i = 0; i < oldObj->
size
(); ++i ) {
41
oldInt.
push_back
(
new
xAOD::TruthVertex_v1
() );
42
}
43
oldInt.setStore( oldObj );
44
45
xAOD::TruthVertexContainer
newInt;
46
for
(
size_t
i = 0; i < newObj->
size
(); ++i ) {
47
newInt.
push_back
(
new
xAOD::TruthVertex
() );
48
}
49
newInt.setStore( newObj );
50
51
unsigned
int
index
{0};
52
static
const
SG::AuxElement::Accessor<int> idAcc (
"id"
);
53
static
const
SG::AuxElement::Accessor<int> barcodeAcc (
"barcode"
);
54
// Loop over the interface objects, and do the conversion with their help:
55
for
(
const
xAOD::TruthVertex_v1
* oldVtx : oldInt ) {
56
const
int
oldID = (idAcc.isAvailable (*oldVtx)) ? idAcc(*oldVtx) : 1000;
57
const
int
oldBarcode = (barcodeAcc.isAvailable (*oldVtx)) ? barcodeAcc(*oldVtx) :
HepMC::INVALID_VERTEX_ID
;
58
xAOD::TruthVertex
* newVtx = newInt.
at
(
index
);
59
// convert "old" id + barcode to "new" status values
60
newVtx->
setStatus
(
HepMC::new_vertex_status_from_old
(oldID, oldBarcode));
61
// The old barcode is still a unique identifier
62
newVtx->
setUid
(oldBarcode);
63
// This should be fine in the case that we are not mixing use of
64
// xAOD::Truth with containers linking to HepMC Truth in the same
65
// classes.
66
++
index
;
67
}
68
return
;
69
}
70
74
void
xAODTruthVertexAuxContainerCnv_v1::transToPers
(
75
const
xAOD::TruthVertexAuxContainer
*,
xAOD::TruthVertexAuxContainer_v1
*,
76
MsgStream& log)
const
{
77
78
static
const
char
*
const
ERRORMSG =
79
"Somebody called xAODTruthVertexAuxContainerCnv_v1::transToPers"
;
80
log << MSG::ERROR << ERRORMSG <<
endmsg
;
81
throw
std::runtime_error(ERRORMSG);
82
return
;
83
}
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:54
MagicNumbers.h
TruthVertexContainer.h
TruthVertexContainer_v1.h
DataVector::at
const T * at(size_type n) const
Access an element, as an rvalue.
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
xAODTruthVertexAuxContainerCnv_v1::persToTrans
virtual void persToTrans(const xAOD::TruthVertexAuxContainer_v1 *oldObj, xAOD::TruthVertexAuxContainer *newObj, MsgStream &log) const override
Function converting from the old type to the current one.
Definition
xAODTruthVertexAuxContainerCnv_v1.cxx:21
xAODTruthVertexAuxContainerCnv_v1::transToPers
virtual void transToPers(const xAOD::TruthVertexAuxContainer *, xAOD::TruthVertexAuxContainer_v1 *, MsgStream &log) const override
Dummy function inherited from the base class.
Definition
xAODTruthVertexAuxContainerCnv_v1.cxx:74
xAOD::AuxContainerBase::resize
virtual bool resize(size_t size) override
Resize the arrays to a given size.
Definition
AuxContainerBase.cxx:530
xAOD::AuxContainerBase::size
virtual size_t size() const override
Get the size of the container.
Definition
AuxContainerBase.cxx:455
xAOD::TruthVertexAuxContainer_v1
Auxiliary store for the truth vertices.
Definition
TruthVertexAuxContainer_v1.h:31
xAOD::TruthVertex_v1
Class describing a truth vertex in the MC record.
Definition
TruthVertex_v1.h:37
xAOD::TruthVertex_v1::setStatus
void setStatus(int value)
Set the vertex status.
xAOD::TruthVertex_v1::setUid
void setUid(int value)
Set the vertex unique ID.
copyAuxStoreThinned.h
Helper to copy an aux store while applying thinning.
HepMC::new_vertex_status_from_old
int new_vertex_status_from_old(const int oldStatus, const int barcode)
Get vertex status in the new scheme from the barcode and status in the old scheme.
Definition
MagicNumbers.h:373
HepMC::INVALID_VERTEX_ID
constexpr int INVALID_VERTEX_ID
Definition
MagicNumbers.h:59
SG::copyAuxStoreThinned
void copyAuxStoreThinned(const SG::IConstAuxStore &orig, SG::IAuxStore ©, const SG::ThinningInfo *info)
Helper to copy an aux store while applying thinning.
index
Definition
index.py:1
xAOD::TruthVertexContainer_v1
DataVector< TruthVertex_v1 > TruthVertexContainer_v1
Definition
TruthVertexContainer_v1.h:20
xAOD::TruthVertexAuxContainer
TruthVertexAuxContainer_v2 TruthVertexAuxContainer
Declare the latest version of the truth vertex auxiliary container.
Definition
TruthVertexAuxContainer.h:15
xAOD::TruthVertex
TruthVertex_v1 TruthVertex
Typedef to implementation.
Definition
TruthVertex.h:15
xAOD::TruthVertexContainer
TruthVertexContainer_v1 TruthVertexContainer
Declare the latest version of the truth vertex container.
Definition
TruthVertexContainer.h:17
xAODTruthVertexAuxContainerCnv_v1.h
Generated on
for ATLAS Offline Software by
1.17.0