ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
InnerDetector
InDetMonitoring
InDetPerformanceMonitoring
src
IDPerfMuonRefitter.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
6
//==================================================================================
7
8
//==================================================================================
9
// Include files...
10
//==================================================================================
11
12
// This file's header
13
#include "
InDetPerformanceMonitoring/IDPerfMuonRefitter.h
"
14
15
16
// Need containers
17
#include "
xAODMuon/Muon.h
"
18
#include "
xAODMuon/MuonContainer.h
"
19
20
//Interface Headers
21
#include "
TrkTrack/TrackCollection.h
"
22
23
// ATLAS headers
24
#include "
StoreGate/ReadHandle.h
"
25
#include "GaudiKernel/IInterface.h"
26
27
28
//==================================================================================
29
// Public Methods
30
//==================================================================================
31
IDPerfMuonRefitter::IDPerfMuonRefitter
(
const
std::string& name,
32
ISvcLocator* pSvcLocator):
33
AthAlgorithm
(name, pSvcLocator),
34
m_TrackRefitter1
(
""
),
35
m_TrackRefitter2
(
""
),
36
m_N_Muons
(0),
37
m_N_MuonsRefit
(0),
38
m_N_MuonRefitFailures
(0)
39
{
40
// Properties that are set from the python scripts.
41
declareProperty
(
"OutputTracksName"
,
m_outputTracksName
=
"IDMuonTracks"
);
42
declareProperty
(
"ReFitterTool1"
,
m_TrackRefitter1
,
"ToolHandle for track fitter implementation"
);
43
declareProperty
(
"ReFitterTool2"
,
m_TrackRefitter2
,
"ToolHandle for track fitter implementation"
);
44
45
}
46
47
48
IDPerfMuonRefitter::~IDPerfMuonRefitter
()
49
{}
50
51
52
StatusCode
IDPerfMuonRefitter::initialize
()
53
{
54
// Retrieve fitter
55
if
(
m_TrackRefitter1
.retrieve().isFailure()) {
56
ATH_MSG_FATAL
(
"Unable to retrieve "
<<
m_TrackRefitter1
);
57
return
StatusCode::FAILURE;
58
}
else
{
59
ATH_MSG_INFO
(
"Retrieved tool"
<<
m_TrackRefitter1
);
60
}
61
// Retrieve the second fitter
62
if
(
m_TrackRefitter2
.retrieve().isFailure()) {
63
ATH_MSG_FATAL
(
"Unable to retrieve "
<<
m_TrackRefitter2
);
64
return
StatusCode::FAILURE;
65
}
else
{
66
ATH_MSG_INFO
(
"Retrieved tool"
<<
m_TrackRefitter2
);
67
}
68
69
ATH_CHECK
(
m_muonContainerKey
.initialize() );
70
return
StatusCode::SUCCESS;
71
}
72
73
74
75
76
StatusCode
IDPerfMuonRefitter::execute
(
const
EventContext& ctx)
77
{
78
SG::ReadHandle<xAOD::MuonContainer>
pxMuonContainer (
m_muonContainerKey
, ctx);
79
TrackCollection
* muonTrks =
new
TrackCollection
(
SG::OWN_ELEMENTS
);
80
TrackCollection
* muonTrksRefit1 =
new
TrackCollection
(
SG::OWN_ELEMENTS
);
81
TrackCollection
* muonTrksRefit2 =
new
TrackCollection
(
SG::OWN_ELEMENTS
);
82
for
(
const
auto
muon : *pxMuonContainer){
83
if
(!muon) {
84
ATH_MSG_WARNING
(
"CB Muons missing!"
);
85
continue
;
86
}
87
++
m_N_Muons
;
88
const
xAOD::TrackParticle
* idTP = muon->trackParticle(xAOD::Muon::TrackParticleType::InnerDetectorTrackParticle);
89
if
(!idTP) {
90
ATH_MSG_DEBUG
(
"ID TrackParticles missing! Skipping Muon"
);
91
continue
;
92
}
93
Trk::Track
* defaultMuonTrk{};
94
Trk::Track
* refit1MuonTrk{};
95
Trk::Track
* refit2MuonTrk{};
96
const
xAOD::Electron
* eg{};
97
StatusCode fitStatus;
98
//save default and refit track parameters
99
if
( idTP->
track
() ) {
100
defaultMuonTrk =
new
Trk::Track
(*idTP->
track
());
101
//save tracks to storegrate /
102
muonTrks->
push_back
(defaultMuonTrk);
103
IegammaTrkRefitterTool::Cache
cache1{};
104
cache1.
electron
=eg;
105
fitStatus =
m_TrackRefitter1
->refitTrack( ctx,idTP->
track
(), cache1 );
106
++
m_N_MuonsRefit
;
107
if
(fitStatus == StatusCode::SUCCESS) {
108
refit1MuonTrk = cache1.
refittedTrack
.release();
109
muonTrksRefit1->
push_back
(refit1MuonTrk);
110
}
else
{
111
ATH_MSG_DEBUG
(
"Track Refit1 Failed. Skipping Muon"
);
112
++
m_N_MuonRefitFailures
;
113
continue
;
114
}
115
IegammaTrkRefitterTool::Cache
cache2{};
116
cache2.
electron
=eg;
117
fitStatus =
m_TrackRefitter2
->refitTrack(ctx,idTP->
track
(), cache2 );
118
if
(fitStatus == StatusCode::SUCCESS) {
119
refit2MuonTrk = cache2.
refittedTrack
.release();
120
muonTrksRefit2->
push_back
(refit2MuonTrk);
121
}
else
{
122
ATH_MSG_DEBUG
(
"Track Refit2 Failed. Skipping Muon"
);
123
continue
;
124
}
125
}
126
}
// End loop over muons
127
//Store information into storegate
128
StatusCode
sc
=
evtStore
()->record(muonTrks,
m_outputTracksName
,
false
);
129
if
(
sc
.isFailure()) {
130
ATH_MSG_WARNING
(
"Failed storing "
<<
m_outputTracksName
);
131
}
else
{
132
ATH_MSG_DEBUG
(
"Stored "
<< muonTrks->
size
() <<
" "
<<
m_outputTracksName
<<
" into StoreGate"
);
133
}
134
sc
=
evtStore
()->record(muonTrksRefit1,
m_outputTracksName
+
"Refit1"
,
false
);
135
if
(
sc
.isFailure()) {
136
ATH_MSG_WARNING
(
"Failed storing "
<<
m_outputTracksName
+
"Refit1"
);
137
}
else
{
138
ATH_MSG_DEBUG
(
"Stored "
<< muonTrksRefit1->
size
() <<
" "
<<
m_outputTracksName
+
"Refit1"
<<
" into StoreGate"
);
139
}
140
sc
=
evtStore
()->record(muonTrksRefit2,
m_outputTracksName
+
"Refit2"
,
false
);
141
if
(
sc
.isFailure()) {
142
ATH_MSG_WARNING
(
"Failed storing "
<<
m_outputTracksName
+
"Refit2"
);
143
}
else
{
144
ATH_MSG_DEBUG
(
"Stored "
<< muonTrksRefit2->
size
() <<
" "
<<
m_outputTracksName
+
"Refit2"
<<
" into StoreGate"
);
145
}
146
return
StatusCode::SUCCESS;
147
}
148
149
150
StatusCode
IDPerfMuonRefitter::finalize
()
151
{
152
ATH_MSG_INFO
(
"***************************************************"
);
153
ATH_MSG_INFO
(
"**************** IDPerfMuonRefitter ***************"
);
154
ATH_MSG_INFO
(
"***************************************************"
);
155
ATH_MSG_INFO
(
m_N_Muons
<<
"\t\t Muons inspected"
);
156
ATH_MSG_INFO
(
m_N_MuonsRefit
<<
"\t\t Muons refit"
);
157
ATH_MSG_INFO
(
m_N_MuonRefitFailures
<<
"\t\t Muons refit failures"
);
158
ATH_MSG_INFO
(
"***************************************************"
);
159
ATH_MSG_INFO
(
"***************************************************"
);
160
return
StatusCode::SUCCESS;
161
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition
AthMsgStreamMacros.h:34
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
MuonContainer.h
Muon.h
IDPerfMuonRefitter.h
sc
static Double_t sc
Definition
LArPhysWaveHECTool.cxx:37
ReadHandle.h
Handle class for reading from StoreGate.
TrackCollection.h
TrackCollection
DataVector< Trk::Track > TrackCollection
This typedef represents a collection of Trk::Track objects.
Definition
TrackCollection.h:19
AthAlgorithm::AthAlgorithm
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition
AthAlgorithm.cxx:10
AthCommonAlgorithm< Gaudi::Algorithm >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition
AthCommonDataStore.h:145
AthCommonAlgorithm< Gaudi::Algorithm >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
Definition
AthCommonDataStore.h:85
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
IDPerfMuonRefitter::m_TrackRefitter2
ToolHandle< IegammaTrkRefitterTool > m_TrackRefitter2
The track refitter.
Definition
IDPerfMuonRefitter.h:41
IDPerfMuonRefitter::m_N_MuonsRefit
int m_N_MuonsRefit
Definition
IDPerfMuonRefitter.h:48
IDPerfMuonRefitter::initialize
virtual StatusCode initialize()
Definition
IDPerfMuonRefitter.cxx:52
IDPerfMuonRefitter::execute
virtual StatusCode execute(const EventContext &ctx)
Execute method.
Definition
IDPerfMuonRefitter.cxx:76
IDPerfMuonRefitter::m_N_Muons
int m_N_Muons
Definition
IDPerfMuonRefitter.h:47
IDPerfMuonRefitter::m_muonContainerKey
SG::ReadHandleKey< xAOD::MuonContainer > m_muonContainerKey
Definition
IDPerfMuonRefitter.h:52
IDPerfMuonRefitter::~IDPerfMuonRefitter
~IDPerfMuonRefitter()
Definition
IDPerfMuonRefitter.cxx:48
IDPerfMuonRefitter::m_outputTracksName
std::string m_outputTracksName
Definition
IDPerfMuonRefitter.h:44
IDPerfMuonRefitter::finalize
virtual StatusCode finalize()
Definition
IDPerfMuonRefitter.cxx:150
IDPerfMuonRefitter::IDPerfMuonRefitter
IDPerfMuonRefitter(const std::string &name, ISvcLocator *pSvcLocator)
Definition
IDPerfMuonRefitter.cxx:31
IDPerfMuonRefitter::m_TrackRefitter1
ToolHandle< IegammaTrkRefitterTool > m_TrackRefitter1
The track refitter.
Definition
IDPerfMuonRefitter.h:38
IDPerfMuonRefitter::m_N_MuonRefitFailures
int m_N_MuonRefitFailures
Definition
IDPerfMuonRefitter.h:49
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
Trk::Track
The ATLAS Track class.
Definition
Tracking/TrkEvent/TrkTrack/TrkTrack/Track.h:73
xAOD::TrackParticle_v1::track
const Trk::Track * track() const
Returns a pointer (which can be NULL) to the Trk::Track which was used to make this TrackParticle.
Definition
TrackParticle_v1.cxx:756
SG::OWN_ELEMENTS
@ OWN_ELEMENTS
this data object owns its elements
Definition
OwnershipPolicy.h:17
xAOD::TrackParticle
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Definition
Event/xAOD/xAODTracking/xAODTracking/TrackParticle.h:13
xAOD::Electron
Electron_v1 Electron
Definition of the current "egamma version".
Definition
Event/xAOD/xAODEgamma/xAODEgamma/Electron.h:17
IegammaTrkRefitterTool::Cache
Struct Holding the result to return and intermediate objects Things are owned by the EDM or the uniqu...
Definition
IegammaTrkRefitterTool.h:39
IegammaTrkRefitterTool::Cache::refittedTrack
std::unique_ptr< Trk::Track > refittedTrack
Pointer to the refitted track.
Definition
IegammaTrkRefitterTool.h:41
IegammaTrkRefitterTool::Cache::electron
const xAOD::Electron * electron
pointer to the Electron input
Definition
IegammaTrkRefitterTool.h:49
Generated on
for ATLAS Offline Software by
1.17.0