ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
InnerDetector
InDetValidation
InDetTruthVertexValidation
Root
InDetVertexTruthMatchUtils.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
InDetTruthVertexValidation/InDetVertexTruthMatchUtils.h
"
6
#include "
xAODTracking/VertexContainer.h
"
7
8
namespace
InDetVertexTruthMatchUtils
{
9
10
namespace
{
11
12
bool
isHardScatterEvent(
const
ElementLink<xAOD::TruthEventBaseContainer>
& evlink ) {
13
//good link of type "TruthEvent" (not truthpileupevent) and the first one in the collection
14
return
( evlink.
isValid
() && (*evlink)->type() ==
xAOD::Type::TruthEvent
&& evlink.
index
() == 0 );
15
}
16
17
}
18
19
//find vertex with largest amount of hard-scatter tracks
20
const
xAOD::Vertex
*
bestHardScatterMatch
(
const
xAOD::VertexContainer
& vxContainer ) {
21
//accessors for decorations
22
xAOD::Vertex::ConstAccessor<int> nHSTrkDecor(
"nHSTrk"
);
23
24
std::vector<std::pair<const xAOD::Vertex*, size_t> > allMatches =
hardScatterMatches
( vxContainer );
25
26
int
bestNHSTrk = 0;
27
const
xAOD::Vertex
* best =
nullptr
;
28
for
(
auto
it : allMatches ) {
29
int
nHSTrk = nHSTrkDecor( *(it.first) );
30
if
( nHSTrk > bestNHSTrk ){
31
bestNHSTrk = nHSTrk;
32
best = it.first;
33
}
34
}
35
36
//if didn't find any matches will return 0
37
return
best;
38
}
39
40
//Find all hard scatter matches
41
const
std::vector<std::pair<const xAOD::Vertex*, size_t> >
hardScatterMatches
(
const
xAOD::VertexContainer
& vxContainer ) {
42
//accessors for decorations
43
xAOD::Vertex::ConstAccessor<std::vector<VertexTruthMatchInfo> > matchInfoDecor(
"TruthEventMatchingInfos"
);
44
45
//return vector
46
std::vector<std::pair<const xAOD::Vertex*, size_t> > result;
47
48
//loop and look
49
for
(
auto
vxit : vxContainer ) {
50
try
{
51
const
std::vector<VertexTruthMatchInfo> & info = matchInfoDecor( *vxit );
52
if
(!matchInfoDecor.isAvailable(*vxit)){
53
return
result;
54
}
55
for
(
size_t
i = 0; i < info.size(); ++i ) {
56
if
( isHardScatterEvent( std::get<0>(info[i]) ) ) {
57
result.emplace_back(vxit, i );
58
break
;
59
}
60
}
61
}
62
catch
(
SG::ExcBadAuxVar
&){
63
return
result;
64
}
65
66
}
67
return
result;
68
}
69
70
HardScatterType
classifyHardScatter
(
const
xAOD::VertexContainer
& vxContainer ) {
71
72
// return a vector of reco vertices with contributions from the hard-scatter
73
// if the second element in the pair is zero, it means tracks from the hard-scatter
74
// contribute more weight to that reco vertex than any other interaction
75
std::vector<std::pair<const xAOD::Vertex*, size_t> > matches =
hardScatterMatches
( vxContainer );
76
77
// information indicating whether a given reco vertex is:
78
// MATCHED, MERGED, SPLIT or FAKE
79
xAOD::Vertex::Decorator<VertexMatchType> matchTypeDecor(
"VertexMatchType"
);
80
81
if
( matches.empty() ) {
82
// No reco vertices with tracks from hard-scatter
83
return
NONE
;
84
}
else
if
( matches.size() == 1 ) {
85
// A single reco vertex has tracks from hard-scatter
86
const
VertexMatchType
&
type
= matchTypeDecor( *(matches[0].first) );
87
//check if the index in the matching info for HS is first, then can assign clean/lowpu based on match/merge
88
if
( matches[0].second == 0 &&
type
==
MATCHED
) {
89
// HS made largest contribution and vertex matched
90
return
CLEAN
;
91
}
else
if
( matches[0].second == 0 &&
type
==
MERGED
) {
92
// HS made largest contribution and vertex merged
93
return
LOWPU
;
94
}
else
{
95
// HS did not make largest contribution or vertex is fake or vertex is part of non-HS split pair
96
return
HIGHPU
;
97
}
98
99
}
else
{
100
// multiple reco vertices have tracks from hard-scatter
101
// count how many have hard-scatter tracks as largest contribution
102
int
num_main = 0;
103
const
xAOD::Vertex
* mainVtx =
nullptr
;
104
for
(
auto
it : matches ) {
105
if
( it.second == 0 )
// is hard-scatter the largest contribution?
106
{
107
num_main++;
108
mainVtx = it.first;
109
}
110
}
111
if
(num_main == 0 ) {
112
return
HIGHPU
;
113
}
else
if
(num_main == 1 ) {
114
const
VertexMatchType
&
type
= matchTypeDecor(*mainVtx);
115
if
(
type
==
MATCHED
)
116
return
CLEAN
;
117
else
if
(
type
==
MERGED
)
118
return
LOWPU
;
119
else
120
return
HIGHPU
;
121
}
else
{
122
return
HSSPLIT
;
123
}
124
}
125
126
return
NONE
;
127
}
128
129
}
ElementLink
ElementLink()
Default constructor.
InDetVertexTruthMatchUtils.h
VertexContainer.h
ElementLink::index
index_type index() const
Get the index of the element inside of its container.
Definition
A/AthLinks/ElementLink.h:164
ElementLink::isValid
bool isValid() const
Check if the element can be found.
SG::ExcBadAuxVar
Exception — Attempt to retrieve nonexistent aux data item.
Definition
Control/AthContainers/AthContainers/exceptions.h:59
InDetVertexTruthMatchUtils
Definition
InDetVertexTruthMatchUtils.h:11
InDetVertexTruthMatchUtils::hardScatterMatches
const std::vector< std::pair< const xAOD::Vertex *, size_t > > hardScatterMatches(const xAOD::VertexContainer &vxContainer)
Definition
InDetVertexTruthMatchUtils.cxx:41
InDetVertexTruthMatchUtils::HardScatterType
HardScatterType
Definition
InDetVertexTruthMatchUtils.h:30
InDetVertexTruthMatchUtils::HSSPLIT
@ HSSPLIT
Definition
InDetVertexTruthMatchUtils.h:34
InDetVertexTruthMatchUtils::HIGHPU
@ HIGHPU
Definition
InDetVertexTruthMatchUtils.h:33
InDetVertexTruthMatchUtils::NONE
@ NONE
Definition
InDetVertexTruthMatchUtils.h:35
InDetVertexTruthMatchUtils::LOWPU
@ LOWPU
Definition
InDetVertexTruthMatchUtils.h:32
InDetVertexTruthMatchUtils::CLEAN
@ CLEAN
Definition
InDetVertexTruthMatchUtils.h:31
InDetVertexTruthMatchUtils::VertexMatchType
VertexMatchType
Definition
InDetVertexTruthMatchUtils.h:20
InDetVertexTruthMatchUtils::MATCHED
@ MATCHED
Definition
InDetVertexTruthMatchUtils.h:21
InDetVertexTruthMatchUtils::MERGED
@ MERGED
Definition
InDetVertexTruthMatchUtils.h:22
InDetVertexTruthMatchUtils::bestHardScatterMatch
const xAOD::Vertex * bestHardScatterMatch(const xAOD::VertexContainer &vxContainer)
Definition
InDetVertexTruthMatchUtils.cxx:20
InDetVertexTruthMatchUtils::classifyHardScatter
HardScatterType classifyHardScatter(const xAOD::VertexContainer &vxContainer)
Definition
InDetVertexTruthMatchUtils.cxx:70
xAODType::TruthEvent
@ TruthEvent
The object is a truth event.
Definition
ObjectType.h:69
xAOD::VertexContainer
VertexContainer_v1 VertexContainer
Definition of the current "Vertex container version".
Definition
VertexContainer.h:14
xAOD::Vertex
Vertex_v1 Vertex
Define the latest version of the vertex class.
Definition
Event/xAOD/xAODTracking/xAODTracking/Vertex.h:16
type
Generated on
for ATLAS Offline Software by
1.17.0