Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
athena
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Peter Sherwood
athena
Commits
688fa977
Commit
688fa977
authored
4 years ago
by
Christos Anastopoulos
Browse files
Options
Downloads
Patches
Plain Diff
ATLASRECTS-5680 : Try to fix memory leak
parent
22a54b1d
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
InnerDetector/InDetRecTools/InDetSecVxFinderTool/src/JetFitterTrackSelectorTool.cxx
+158
-158
158 additions, 158 deletions
...s/InDetSecVxFinderTool/src/JetFitterTrackSelectorTool.cxx
with
158 additions
and
158 deletions
InnerDetector/InDetRecTools/InDetSecVxFinderTool/src/JetFitterTrackSelectorTool.cxx
+
158
−
158
View file @
688fa977
/*
/*
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
*/
*/
#include
"InDetSecVxFinderTool/JetFitterTrackSelectorTool.h"
#include
"InDetSecVxFinderTool/JetFitterTrackSelectorTool.h"
using
namespace
InDet
;
using
namespace
InDet
;
JetFitterTrackSelectorTool
::
JetFitterTrackSelectorTool
(
const
std
::
string
&
t
,
const
std
::
string
&
n
,
const
IInterface
*
p
)
JetFitterTrackSelectorTool
::
JetFitterTrackSelectorTool
(
const
std
::
string
&
t
,
const
std
::
string
&
n
,
const
IInterface
*
p
)
:
AthAlgTool
(
t
,
n
,
p
)
:
AthAlgTool
(
t
,
n
,
p
)
{
{
declareInterface
<
JetFitterTrackSelectorTool
>
(
this
);
declareInterface
<
JetFitterTrackSelectorTool
>
(
this
);
}
}
JetFitterTrackSelectorTool
::~
JetFitterTrackSelectorTool
()
{}
JetFitterTrackSelectorTool
::~
JetFitterTrackSelectorTool
()
{}
StatusCode
JetFitterTrackSelectorTool
::
initialize
()
{
StatusCode
JetFitterTrackSelectorTool
::
initialize
()
{
if
(
AlgTool
::
initialize
().
isFailure
()
)
{
if
(
AlgTool
::
initialize
().
isFailure
()
)
{
msg
(
MSG
::
ERROR
)
<<
" Unable to initialize the AlgTool"
<<
endmsg
;
msg
(
MSG
::
ERROR
)
<<
" Unable to initialize the AlgTool"
<<
endmsg
;
return
StatusCode
::
FAILURE
;
return
StatusCode
::
FAILURE
;
}
}
if
(
m_trkFilter
.
retrieve
().
isFailure
()
)
{
if
(
m_trkFilter
.
retrieve
().
isFailure
()
)
{
msg
(
MSG
::
ERROR
)
<<
" Unable to retrieve InDet::InDetDetailedTrackSelectorTool"
<<
endmsg
;
msg
(
MSG
::
ERROR
)
<<
" Unable to retrieve InDet::InDetDetailedTrackSelectorTool"
<<
endmsg
;
return
StatusCode
::
FAILURE
;
return
StatusCode
::
FAILURE
;
}
}
if
(
m_jetFitterUtils
.
retrieve
().
isFailure
()
)
{
if
(
m_jetFitterUtils
.
retrieve
().
isFailure
()
)
{
msg
(
MSG
::
ERROR
)
<<
" Unable to retrieve InDet::InDetJetFitterUtils/InDetJetFitterUtils"
<<
endmsg
;
msg
(
MSG
::
ERROR
)
<<
" Unable to retrieve InDet::InDetJetFitterUtils/InDetJetFitterUtils"
<<
endmsg
;
return
StatusCode
::
FAILURE
;
return
StatusCode
::
FAILURE
;
}
}
if
(
m_extrapolator
.
retrieve
().
isFailure
()
)
{
if
(
m_extrapolator
.
retrieve
().
isFailure
()
)
{
msg
(
MSG
::
ERROR
)
<<
" Unable to retrieve Trk::Extrapolator/InDetExtrapolator"
<<
endmsg
;
msg
(
MSG
::
ERROR
)
<<
" Unable to retrieve Trk::Extrapolator/InDetExtrapolator"
<<
endmsg
;
return
StatusCode
::
FAILURE
;
return
StatusCode
::
FAILURE
;
}
}
return
StatusCode
::
SUCCESS
;
return
StatusCode
::
SUCCESS
;
}
}
StatusCode
JetFitterTrackSelectorTool
::
finalize
()
{
StatusCode
JetFitterTrackSelectorTool
::
finalize
()
{
msg
(
MSG
::
INFO
)
<<
"Finalize successful"
<<
endmsg
;
msg
(
MSG
::
INFO
)
<<
"Finalize successful"
<<
endmsg
;
return
StatusCode
::
SUCCESS
;
return
StatusCode
::
SUCCESS
;
}
}
const
Trk
::
SelectedTracksInJet
*
JetFitterTrackSelectorTool
::
doTrackSelection
(
const
xAOD
::
Vertex
&
primaryVertex
,
const
Trk
::
SelectedTracksInJet
*
JetFitterTrackSelectorTool
::
doTrackSelection
(
const
xAOD
::
Vertex
&
primaryVertex
,
const
TLorentzVector
&
jetMomentum
,
const
TLorentzVector
&
jetMomentum
,
const
std
::
vector
<
const
xAOD
::
IParticle
*>
&
inputTracks
)
const
{
const
std
::
vector
<
const
xAOD
::
IParticle
*>
&
inputTracks
)
const
{
// perform the track selection
// perform the track selection
// step 1, apply a track filter like "InDet::InDetDetailedTrackSelectorTool"
// step 1, apply a track filter like "InDet::InDetDetailedTrackSelectorTool"
// step 2, calculate the compatibility of filtered tracks with primary vertex
// step 2, calculate the compatibility of filtered tracks with primary vertex
// use this to deduce primaryTracks and secondaryTracks
// use this to deduce primaryTracks and secondaryTracks
ATH_MSG_DEBUG
(
"Doing track selection on "
<<
inputTracks
.
size
()
<<
" tracks ... "
);
ATH_MSG_DEBUG
(
"Doing track selection on "
<<
inputTracks
.
size
()
<<
" tracks ... "
);
// We need to use normal pointers instead of smart pointers since the code breaks.
// We need to use normal pointers instead of smart pointers since the code breaks.
// We have to fix this issue in the future
// We have to fix this issue in the future
// if ( m_selectedTracks != nullptr ) delete m_selectedTracks; // May this break the code?
// if ( m_selectedTracks != nullptr ) delete m_selectedTracks; // May this break the code?
Trk
::
SelectedTracksInJet
*
selectedTracks
=
new
Trk
::
SelectedTracksInJet
();
Trk
::
SelectedTracksInJet
*
selectedTracks
=
new
Trk
::
SelectedTracksInJet
();
// Vectors of Trk::ITrackLink to be given to m_selectedTracks once we understand if they are primary of secondary tracks
// Vectors of Trk::ITrackLink to be given to m_selectedTracks once we understand if they are primary of secondary tracks
std
::
vector
<
const
Trk
::
ITrackLink
*
>
primaryTrackLinks
;
std
::
vector
<
const
Trk
::
ITrackLink
*
>
primaryTrackLinks
;
std
::
vector
<
const
Trk
::
ITrackLink
*
>
secondaryTrackLinks
;
std
::
vector
<
const
Trk
::
ITrackLink
*
>
secondaryTrackLinks
;
// Running on input tracks
// Running on input tracks
std
::
vector
<
const
xAOD
::
IParticle
*>::
const_iterator
trk_iter
=
inputTracks
.
begin
();
std
::
vector
<
const
xAOD
::
IParticle
*>::
const_iterator
trk_iter
=
inputTracks
.
begin
();
std
::
vector
<
const
xAOD
::
IParticle
*>::
const_iterator
trk_end
=
inputTracks
.
end
();
std
::
vector
<
const
xAOD
::
IParticle
*>::
const_iterator
trk_end
=
inputTracks
.
end
();
int
counter
=
0
;
int
counter
=
0
;
for
(
;
trk_iter
!=
trk_end
;
trk_iter
++
)
{
for
(
;
trk_iter
!=
trk_end
;
trk_iter
++
)
{
// Convert xAOD::IParticle to xAOD::TrackParticle
// Convert xAOD::IParticle to xAOD::TrackParticle
const
xAOD
::
TrackParticle
*
tmp
=
dynamic_cast
<
const
xAOD
::
TrackParticle
*
>
(
*
trk_iter
);
const
xAOD
::
TrackParticle
*
tmp
=
dynamic_cast
<
const
xAOD
::
TrackParticle
*
>
(
*
trk_iter
);
// Apply track filter
// Apply track filter
if
(
m_trkFilter
->
decision
(
*
tmp
,
&
primaryVertex
)
==
false
)
continue
;
if
(
m_trkFilter
->
decision
(
*
tmp
,
&
primaryVertex
)
==
false
)
continue
;
// Compute compatibility and understand track type
// Compute compatibility and understand track type
// 0: extrapolation of MeasuredPerigee failed
// 0: extrapolation of MeasuredPerigee failed
// 1: primary
// 1: primary
// 2: secondary
// 2: secondary
int
type
=
computeTrackCompatibility
(
primaryVertex
,
jetMomentum
,
*
tmp
);
int
type
=
computeTrackCompatibility
(
primaryVertex
,
jetMomentum
,
*
tmp
);
// Create Trk::ITrackLink collections to be given to selected tracks
// Create Trk::ITrackLink collections to be given to selected tracks
ElementLink
<
xAOD
::
TrackParticleContainer
>
linkTP
;
ElementLink
<
xAOD
::
TrackParticleContainer
>
linkTP
;
linkTP
.
setElement
(
tmp
);
linkTP
.
setElement
(
tmp
);
Trk
::
LinkToXAODTrackParticle
*
link
=
new
Trk
::
LinkToXAODTrackParticle
(
linkTP
);
Trk
::
LinkToXAODTrackParticle
*
link
=
new
Trk
::
LinkToXAODTrackParticle
(
linkTP
);
if
(
type
==
1
)
primaryTrackLinks
.
push_back
(
link
);
if
(
type
==
1
)
primaryTrackLinks
.
push_back
(
link
);
else
if
(
type
==
2
)
secondaryTrackLinks
.
push_back
(
link
);
else
if
(
type
==
2
)
secondaryTrackLinks
.
push_back
(
link
);
else
continue
;
else
continue
;
// How many tracks we are selecting
// How many tracks we are selecting
counter
++
;
counter
++
;
}
}
ATH_MSG_DEBUG
(
" Total of selected tracks: "
<<
counter
);
ATH_MSG_DEBUG
(
" Total of selected tracks: "
<<
counter
);
selectedTracks
->
setPrimaryTrackLinks
(
primaryTrackLinks
);
selectedTracks
->
setPrimaryTrackLinks
(
primaryTrackLinks
);
selectedTracks
->
setSecondaryTrackLinks
(
secondaryTrackLinks
);
selectedTracks
->
setSecondaryTrackLinks
(
secondaryTrackLinks
);
return
selectedTracks
;
return
selectedTracks
;
}
}
int
JetFitterTrackSelectorTool
::
computeTrackCompatibility
(
const
xAOD
::
Vertex
&
primaryVertex
,
int
JetFitterTrackSelectorTool
::
computeTrackCompatibility
(
const
xAOD
::
Vertex
&
primaryVertex
,
const
TLorentzVector
&
jetMomentum
,
const
TLorentzVector
&
jetMomentum
,
const
xAOD
::
TrackParticle
&
track
)
const
{
const
xAOD
::
TrackParticle
&
track
)
const
{
// Decorators for tracks
// Decorators for tracks
SG
::
AuxElement
::
Decorator
<
float
>
compatibilityDecorator
(
"TrackCompatibility"
);
SG
::
AuxElement
::
Decorator
<
float
>
compatibilityDecorator
(
"TrackCompatibility"
);
// Recomputing Perigee w.r.t PV
// Recomputing Perigee w.r.t PV
Trk
::
PerigeeSurface
mySurface
(
primaryVertex
.
position
()
);
Trk
::
PerigeeSurface
mySurface
(
primaryVertex
.
position
()
);
const
Trk
::
TrackParameters
*
myMeasuredPerigee
=
m_extrapolator
->
extrapolate
(
track
,
mySurface
);
std
::
unique_ptr
<
const
Trk
::
TrackParameters
>
myMeasuredPerigee
(
m_extrapolator
->
extrapolate
(
track
,
mySurface
)
)
;
if
(
myMeasuredPerigee
==
nullptr
)
{
if
(
!
myMeasuredPerigee
)
{
ATH_MSG_DEBUG
(
" Extrapolation to primary vertex failed. Skipping track "
);
ATH_MSG_DEBUG
(
" Extrapolation to primary vertex failed. Skipping track "
);
compatibilityDecorator
(
track
)
=
0.
;
compatibilityDecorator
(
track
)
=
0.
;
return
0
;
return
0
;
}
}
// Prepare for using jetFitterUtils (for the computation of the compatibility)
// Prepare for using jetFitterUtils (for the computation of the compatibility)
// Is this conrvertion really necessary?
// Is this conrvertion really necessary?
Trk
::
RecVertex
primaryVertexRecVertex
(
primaryVertex
.
position
(),
Trk
::
RecVertex
primaryVertexRecVertex
(
primaryVertex
.
position
(),
primaryVertex
.
covariancePosition
(),
primaryVertex
.
covariancePosition
(),
primaryVertex
.
numberDoF
(),
primaryVertex
.
numberDoF
(),
primaryVertex
.
chiSquared
());
primaryVertex
.
chiSquared
());
Amg
::
Vector3D
jetMomSpatial
(
jetMomentum
.
X
(),
jetMomentum
.
Y
(),
jetMomentum
.
Z
()
);
Amg
::
Vector3D
jetMomSpatial
(
jetMomentum
.
X
(),
jetMomentum
.
Y
(),
jetMomentum
.
Z
()
);
double
compatibilityValue
=
m_jetFitterUtils
->
compatibility
(
*
myMeasuredPerigee
,
primaryVertexRecVertex
).
first
;
double
compatibilityValue
=
m_jetFitterUtils
->
compatibility
(
*
myMeasuredPerigee
,
primaryVertexRecVertex
).
first
;
compatibilityValue
=
fabs
(
compatibilityValue
)
*
m_jetFitterUtils
->
get3DLifetimeSignOfTrack
(
*
myMeasuredPerigee
,
compatibilityValue
=
fabs
(
compatibilityValue
)
*
m_jetFitterUtils
->
get3DLifetimeSignOfTrack
(
*
myMeasuredPerigee
,
jetMomSpatial
,
jetMomSpatial
,
primaryVertexRecVertex
);
primaryVertexRecVertex
);
// Decorate
// Decorate
ATH_MSG_DEBUG
(
"compatibilityValue = "
<<
compatibilityValue
);
ATH_MSG_DEBUG
(
"compatibilityValue = "
<<
compatibilityValue
);
compatibilityDecorator
(
track
)
=
compatibilityValue
;
compatibilityDecorator
(
track
)
=
compatibilityValue
;
// Understand if primary or secondary track particle
// Understand if primary or secondary track particle
double
cutCompatibilityPVforPosTracks
=
m_cutCompatibilityPrimaryVertexForPositiveLifetimeTracks
;
double
cutCompatibilityPVforPosTracks
=
m_cutCompatibilityPrimaryVertexForPositiveLifetimeTracks
;
double
cutCompatibilityPVforNegTracks
=
m_cutCompatibilityPrimaryVertexForNegativeLifetimeTracks
;
double
cutCompatibilityPVforNegTracks
=
m_cutCompatibilityPrimaryVertexForNegativeLifetimeTracks
;
if
(
m_revertFromPositiveToNegativeTags
)
{
if
(
m_revertFromPositiveToNegativeTags
)
{
cutCompatibilityPVforNegTracks
=
m_cutCompatibilityPrimaryVertexForPositiveLifetimeTracks
;
cutCompatibilityPVforNegTracks
=
m_cutCompatibilityPrimaryVertexForPositiveLifetimeTracks
;
cutCompatibilityPVforPosTracks
=
m_cutCompatibilityPrimaryVertexForNegativeLifetimeTracks
;
cutCompatibilityPVforPosTracks
=
m_cutCompatibilityPrimaryVertexForNegativeLifetimeTracks
;
}
}
if
(
(
compatibilityValue
<
0
&&
if
(
(
compatibilityValue
<
0
&&
TMath
::
Prob
(
fabs
(
compatibilityValue
),
2
)
<
cutCompatibilityPVforNegTracks
)
||
TMath
::
Prob
(
fabs
(
compatibilityValue
),
2
)
<
cutCompatibilityPVforNegTracks
)
||
(
compatibilityValue
>=
0
&&
(
compatibilityValue
>=
0
&&
TMath
::
Prob
(
fabs
(
compatibilityValue
),
2
)
<
cutCompatibilityPVforPosTracks
)
)
TMath
::
Prob
(
fabs
(
compatibilityValue
),
2
)
<
cutCompatibilityPVforPosTracks
)
)
return
2
;
return
2
;
else
return
1
;
else
return
1
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment