ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
HeavyIonPhys
HIEventUtils
Root
HIVertexSelectionTool.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
6
#include "
HIEventUtils/HIVertexSelectionTool.h
"
7
#include "
xAODTracking/TrackParticleContainer.h
"
8
#include "
AsgMessaging/Check.h
"
9
10
using
std::string;
11
12
HI::HIVertexSelectionTool::HIVertexSelectionTool(
const
string
& name )
13
:
asg
::AsgTool(
name
)
14
, m_accept(
"HIVertexSelection"
)
15
#ifndef XAOD_STANDALONE
16
// we don't want to give the tool a name in rootcore
17
, m_trkSelTool(
"InDet::InDetTrackSelectionTool"
, this )
18
#endif
// XAOD_STANDALONE
19
{
20
declareProperty(
"RequirePrimary"
, m_requirePrimary,
"Require the vertex to have type PriVtx"
);
21
declareProperty(
"MaxAbsZ"
, m_maxAbsZ,
"Maximum absolute value of the vertex z position"
);
22
declareProperty(
"TrackSelectionTool"
, m_trkSelTool,
"Track selection tool"
);
23
declareProperty(
"MinNTrk"
, m_minNtrk,
"Minimum number of associated tracks passing selection"
);
24
declareProperty(
"MinRmsPt"
, m_minRmsPt,
"Minimum RMS pt [MeV] of associated tracks passing selection"
);
25
}
26
27
HI::HIVertexSelectionTool::~HIVertexSelectionTool
() =
default
;
28
29
StatusCode
HI::HIVertexSelectionTool::initialize
()
30
{
31
ATH_MSG_INFO
(
"Initializing vertex selection tool."
);
32
ATH_CHECK
(
asg::AsgTool::initialize
() );
33
34
35
if
(
m_requirePrimary
) {
36
ATH_MSG_INFO
(
"Requiring vertex to be a primary vertex"
);
37
m_accept
.addCut(
"type"
,
"Whether the vertex satisfies the requirement to be a primary vertex"
);
38
}
39
else
{
40
ATH_MSG_INFO
(
"NOT requiring vertex to be a primary vertex"
);
41
}
42
43
if
(
m_maxAbsZ
> 0.) {
44
ATH_MSG_INFO
(
"Maximum |z| = "
<<
m_maxAbsZ
<<
" mm"
);
45
m_accept
.addCut(
"z"
,
"Whether the vertex's |z| is in an allowed range"
);
46
}
47
48
if
(
m_minNtrk
>= 0) {
49
m_checkTracks
=
true
;
50
ATH_MSG_INFO
(
"Minimum Ntrk = "
<<
m_minNtrk
);
51
m_accept
.addCut(
"ntrk"
,
"Whether the vertex has the minimum number of tracks"
);
52
}
53
if
(
m_minRmsPt
>= 0.) {
54
m_checkTracks
=
true
;
55
ATH_MSG_INFO
(
"Minimum RMS track pt = "
<<
m_minRmsPt
<<
" MeV"
);
56
m_accept
.addCut(
"pt"
,
"Whether the vertex's tracks RMS pt is sufficient"
);
57
}
58
59
60
return
StatusCode::SUCCESS;
61
}
62
63
StatusCode
HI::HIVertexSelectionTool::finalize
()
64
{
65
ATH_MSG_INFO
(
"Finalizing vertex selection tool."
);
66
return
StatusCode::SUCCESS;
67
}
68
69
//R.Longo 13-10-2019 - Replacing PATCore/TAccept (inherited from 21.0 HI-equalization)
70
const
asg::AcceptInfo
&
HI::HIVertexSelectionTool::getAcceptInfo
()
const
71
{
72
// return the current TAccept object by reference. This allows users to avoid copying it.
73
return
m_accept
;
74
}
75
76
asg::AcceptData
HI::HIVertexSelectionTool::accept
(
const
xAOD::IParticle
* )
const
77
{
78
asg::AcceptData
acceptData (&
m_accept
);
79
ATH_MSG_ERROR
(
"Vertex selection tool should not be passed an IParticle."
);
80
throw
std::invalid_argument(
"Vertex selection tool given an IParticle."
);
81
return
acceptData;
82
}
83
84
asg::AcceptData
HI::HIVertexSelectionTool::accept
(
const
xAOD::Vertex
& vtx )
const
85
{
86
asg::AcceptData
acceptData (&
m_accept
);
87
88
if
(!
m_requirePrimary
|| vtx.
vertexType
() ==
xAOD::VxType::PriVtx
) {
89
acceptData.
setCutResult
(
"type"
,
true
);
90
}
91
if
(
m_maxAbsZ
< 0. || std::fabs( vtx.
z
() ) <
m_maxAbsZ
) {
92
acceptData.
setCutResult
(
"z"
,
true
);
93
}
94
if
(
m_checkTracks
) {
95
bool
countTracks =
m_minNtrk
>= 0;
96
bool
countPt =
m_minRmsPt
>= 0.;
97
int
nPassed = 0;
// cumulative total number of tracks passed
98
double
sumPtSq = 0.;
// cumulative total of pt^2 of tracks passed
99
for
(
const
auto
& track : vtx.
trackParticleLinks
() ) {
100
if
( !track.isValid() )
continue
;
101
if
( !
m_trkSelTool
->accept( **track, &vtx ) )
continue
;
102
103
if
(countTracks) {
104
nPassed++;
105
if
(nPassed >=
m_minNtrk
) {
106
acceptData.
setCutResult
(
"ntrk"
,
true
);
107
countTracks =
false
;
// stop bothering to count
108
}
109
}
110
if
(countPt) {
111
auto
pt = (*track)->pt();
112
sumPtSq += pt*pt;
113
if
(sumPtSq >=
m_minRmsPt
*
m_minRmsPt
) {
114
acceptData.
setCutResult
(
"pt"
,
true
);
115
countPt =
false
;
// stop evaluating pt
116
}
117
}
118
119
if
(!countTracks && !countPt)
break
;
// don't run through tracks we don't need to check
120
}
// end loop over tracks
121
}
122
123
return
acceptData;
124
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
Check.h
TrackParticleContainer.h
HIVertexSelectionTool.h
HI::HIVertexSelectionTool::accept
virtual asg::AcceptData accept(const xAOD::IParticle *) const override
The main accept method: the actual cuts are applied here.
Definition
HIVertexSelectionTool.cxx:76
HI::HIVertexSelectionTool::getAcceptInfo
virtual const asg::AcceptInfo & getAcceptInfo() const override
Declare the interface ID for this pure-virtual interface class to the Athena framework.
Definition
HIVertexSelectionTool.cxx:70
HI::HIVertexSelectionTool::initialize
virtual StatusCode initialize() override
Definition
HIVertexSelectionTool.cxx:29
HI::HIVertexSelectionTool::m_maxAbsZ
double m_maxAbsZ
maximum |z| position of the vertex
Definition
HIVertexSelectionTool.h:42
HI::HIVertexSelectionTool::m_trkSelTool
ToolHandle< InDet::IInDetTrackSelectionTool > m_trkSelTool
track selection tool which can be optionally used for N_trk and sum pt cuts
Definition
HIVertexSelectionTool.h:44
HI::HIVertexSelectionTool::~HIVertexSelectionTool
ASG_TOOL_CLASS2(HIVertexSelectionTool, IAsgSelectionTool, HI::IHIVertexSelectionTool) public ~HIVertexSelectionTool()
HI::HIVertexSelectionTool::m_accept
asg::AcceptInfo m_accept
Definition
HIVertexSelectionTool.h:38
HI::HIVertexSelectionTool::m_minNtrk
int m_minNtrk
Definition
HIVertexSelectionTool.h:45
HI::HIVertexSelectionTool::m_checkTracks
bool m_checkTracks
Definition
HIVertexSelectionTool.h:47
HI::HIVertexSelectionTool::finalize
virtual StatusCode finalize() override
Definition
HIVertexSelectionTool.cxx:63
HI::HIVertexSelectionTool::m_requirePrimary
bool m_requirePrimary
require the vertex to be of type PriVtx
Definition
HIVertexSelectionTool.h:41
HI::HIVertexSelectionTool::m_minRmsPt
double m_minRmsPt
Definition
HIVertexSelectionTool.h:46
asg::AcceptData
Definition
AcceptData.h:31
asg::AcceptData::setCutResult
void setCutResult(const std::string &cutName, bool cutResult)
Set the result of a cut, based on the cut name (safer).
Definition
AcceptData.h:135
asg::AcceptInfo
Definition
AcceptInfo.h:28
asg::AsgTool::initialize
virtual StatusCode initialize()
Dummy implementation of the initialisation function.
Definition
AsgTool.h:133
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition
Event/xAOD/xAODBase/xAODBase/IParticle.h:41
xAOD::Vertex_v1::z
float z() const
Returns the z position.
xAOD::Vertex_v1::trackParticleLinks
const TrackParticleLinks_t & trackParticleLinks() const
Get all the particles associated with the vertex.
xAOD::Vertex_v1::vertexType
VxType::VertexType vertexType() const
The type of the vertex.
asg
Definition
DataHandleTestTool.h:28
extractSporadic.name
name
Definition
extractSporadic.py:101
xAOD::VxType::PriVtx
@ PriVtx
Primary vertex.
Definition
TrackingPrimitives.h:590
xAOD::Vertex
Vertex_v1 Vertex
Define the latest version of the vertex class.
Definition
Event/xAOD/xAODTracking/xAODTracking/Vertex.h:16
Generated on
for ATLAS Offline Software by
1.17.0