ATLAS Offline Software
InnerDetector
InDetMonitoring
InDetPerformanceMonitoring
src
IDPerfMuonRefitter.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2021 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 "
CxxUtils/checker_macros.h
"
25
#include "
StoreGate/ReadHandle.h
"
26
#include "GaudiKernel/IInterface.h"
27
28
29
//==================================================================================
30
// Public Methods
31
//==================================================================================
32
IDPerfMuonRefitter::IDPerfMuonRefitter
(
const
std::string&
name
,
33
ISvcLocator* pSvcLocator):
34
AthAlgorithm
(
name
, pSvcLocator),
35
m_TrackRefitter1(
""
),
36
m_TrackRefitter2(
""
),
37
m_N_Muons(0),
38
m_N_MuonsRefit(0),
39
m_N_MuonRefitFailures(0)
40
{
41
// Properties that are set from the python scripts.
42
declareProperty
(
"OutputTracksName"
,
m_outputTracksName
=
"IDMuonTracks"
);
43
declareProperty
(
"ReFitterTool1"
,
m_TrackRefitter1
,
"ToolHandle for track fitter implementation"
);
44
declareProperty
(
"ReFitterTool2"
,
m_TrackRefitter2
,
"ToolHandle for track fitter implementation"
);
45
46
}
47
48
49
IDPerfMuonRefitter::~IDPerfMuonRefitter
()
50
{}
51
52
53
StatusCode
IDPerfMuonRefitter::initialize
()
54
{
55
// Retrieve fitter
56
if
(
m_TrackRefitter1
.retrieve().isFailure()) {
57
ATH_MSG_FATAL
(
"Unable to retrieve "
<<
m_TrackRefitter1
);
58
return
StatusCode::FAILURE;
59
}
else
{
60
ATH_MSG_INFO
(
"Retrieved tool"
<<
m_TrackRefitter1
);
61
}
62
// Retrieve the second fitter
63
if
(
m_TrackRefitter2
.retrieve().isFailure()) {
64
ATH_MSG_FATAL
(
"Unable to retrieve "
<<
m_TrackRefitter2
);
65
return
StatusCode::FAILURE;
66
}
else
{
67
ATH_MSG_INFO
(
"Retrieved tool"
<<
m_TrackRefitter2
);
68
}
69
70
ATH_CHECK
(
m_muonContainerKey
.initialize() );
71
return
StatusCode::SUCCESS;
72
}
73
74
75
76
77
StatusCode
IDPerfMuonRefitter::execute
()
78
{
79
SG::ReadHandle<xAOD::MuonContainer>
pxMuonContainer (
m_muonContainerKey
);
80
TrackCollection
* muonTrks =
new
TrackCollection
(
SG::OWN_ELEMENTS
);
81
TrackCollection
* muonTrksRefit1 =
new
TrackCollection
(
SG::OWN_ELEMENTS
);
82
TrackCollection
* muonTrksRefit2 =
new
TrackCollection
(
SG::OWN_ELEMENTS
);
83
for
(
const
auto
muon
: *pxMuonContainer){
84
if
(!
muon
) {
85
ATH_MSG_WARNING
(
"CB Muons missing!"
);
86
continue
;
87
}
88
++
m_N_Muons
;
89
const
xAOD::TrackParticle
* idTP =
muon
->trackParticle(xAOD::Muon::InnerDetectorTrackParticle);
90
if
(!idTP) {
91
ATH_MSG_DEBUG
(
"ID TrackParticles missing! Skipping Muon"
);
92
continue
;
93
}
94
Trk::Track
* defaultMuonTrk{};
95
Trk::Track
* refit1MuonTrk{};
96
Trk::Track
* refit2MuonTrk{};
97
const
xAOD::Electron
*
eg
{};
98
StatusCode
fitStatus;
99
//save default and refit track parameters
100
if
( idTP->
track
() ) {
101
defaultMuonTrk =
new
Trk::Track
(*idTP->
track
());
102
//save tracks to storegrate /
103
muonTrks->
push_back
(defaultMuonTrk);
104
IegammaTrkRefitterTool::Cache
cache1{};
105
cache1.
electron
=
eg
;
106
fitStatus =
m_TrackRefitter1
->refitTrack( Gaudi::Hive::currentContext(),idTP->
track
(), cache1 );
107
++
m_N_MuonsRefit
;
108
if
(fitStatus == StatusCode::SUCCESS) {
109
refit1MuonTrk = cache1.refittedTrack.release();
110
muonTrksRefit1->
push_back
(refit1MuonTrk);
111
}
else
{
112
ATH_MSG_DEBUG
(
"Track Refit1 Failed. Skipping Muon"
);
113
++
m_N_MuonRefitFailures
;
114
continue
;
115
}
116
IegammaTrkRefitterTool::Cache
cache2{};
117
cache2.
electron
=
eg
;
118
fitStatus =
m_TrackRefitter2
->refitTrack(Gaudi::Hive::currentContext(),idTP->
track
(), cache2 );
119
if
(fitStatus == StatusCode::SUCCESS) {
120
refit2MuonTrk = cache2.refittedTrack.release();
121
muonTrksRefit2->
push_back
(refit2MuonTrk);
122
}
else
{
123
ATH_MSG_DEBUG
(
"Track Refit2 Failed. Skipping Muon"
);
124
continue
;
125
}
126
}
127
}
// End loop over muons
128
//Store information into storegate
129
StatusCode
sc
=
evtStore
()->record(muonTrks,
m_outputTracksName
,
false
);
130
if
(
sc
.isFailure()) {
131
ATH_MSG_WARNING
(
"Failed storing "
<<
m_outputTracksName
);
132
}
else
{
133
ATH_MSG_DEBUG
(
"Stored "
<< muonTrks->
size
() <<
" "
<<
m_outputTracksName
<<
" into StoreGate"
);
134
}
135
sc
=
evtStore
()->record(muonTrksRefit1,
m_outputTracksName
+
"Refit1"
,
false
);
136
if
(
sc
.isFailure()) {
137
ATH_MSG_WARNING
(
"Failed storing "
<<
m_outputTracksName
+
"Refit1"
);
138
}
else
{
139
ATH_MSG_DEBUG
(
"Stored "
<< muonTrksRefit1->
size
() <<
" "
<<
m_outputTracksName
+
"Refit1"
<<
" into StoreGate"
);
140
}
141
sc
=
evtStore
()->record(muonTrksRefit2,
m_outputTracksName
+
"Refit2"
,
false
);
142
if
(
sc
.isFailure()) {
143
ATH_MSG_WARNING
(
"Failed storing "
<<
m_outputTracksName
+
"Refit2"
);
144
}
else
{
145
ATH_MSG_DEBUG
(
"Stored "
<< muonTrksRefit2->
size
() <<
" "
<<
m_outputTracksName
+
"Refit2"
<<
" into StoreGate"
);
146
}
147
return
StatusCode::SUCCESS;
148
}
149
150
151
StatusCode
IDPerfMuonRefitter::finalize
()
152
{
153
ATH_MSG_INFO
(
"***************************************************"
);
154
ATH_MSG_INFO
(
"**************** IDPerfMuonRefitter ***************"
);
155
ATH_MSG_INFO
(
"***************************************************"
);
156
ATH_MSG_INFO
(
m_N_Muons
<<
"\t\t Muons inspected"
);
157
ATH_MSG_INFO
(
m_N_MuonsRefit
<<
"\t\t Muons refit"
);
158
ATH_MSG_INFO
(
m_N_MuonRefitFailures
<<
"\t\t Muons refit failures"
);
159
ATH_MSG_INFO
(
"***************************************************"
);
160
ATH_MSG_INFO
(
"***************************************************"
);
161
return
StatusCode::SUCCESS;
162
}
xAOD::muon
@ muon
Definition:
TrackingPrimitives.h:195
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition:
AthMsgStreamMacros.h:34
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition:
AthMsgStreamMacros.h:31
ParticleTest.eg
eg
Definition:
ParticleTest.py:29
Trk::Track
The ATLAS Track class.
Definition:
Tracking/TrkEvent/TrkTrack/TrkTrack/Track.h:73
Muon.h
SG::ReadHandle
Definition:
StoreGate/StoreGate/ReadHandle.h:70
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition:
AthCommonDataStore.h:145
IDPerfMuonRefitter::finalize
virtual StatusCode finalize()
Definition:
IDPerfMuonRefitter.cxx:151
xAOD::JetInput::Track
@ Track
Definition:
JetContainerInfo.h:61
IDPerfMuonRefitter::m_N_Muons
int m_N_Muons
Definition:
IDPerfMuonRefitter.h:47
IDPerfMuonRefitter::m_TrackRefitter1
ToolHandle< IegammaTrkRefitterTool > m_TrackRefitter1
The track refitter.
Definition:
IDPerfMuonRefitter.h:38
IDPerfMuonRefitter.h
AthenaPoolTestRead.sc
sc
Definition:
AthenaPoolTestRead.py:27
IDPerfMuonRefitter::m_muonContainerKey
SG::ReadHandleKey< xAOD::MuonContainer > m_muonContainerKey
Definition:
IDPerfMuonRefitter.h:52
IegammaTrkRefitterTool::Cache
Struct Holding the result to return and intermediate objects Things are owned by the EDM or the uniqu...
Definition:
IegammaTrkRefitterTool.h:39
AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition:
AthCommonDataStore.h:85
IDPerfMuonRefitter::initialize
virtual StatusCode initialize()
Definition:
IDPerfMuonRefitter.cxx:53
SG::OWN_ELEMENTS
@ OWN_ELEMENTS
this data object owns its elements
Definition:
OwnershipPolicy.h:17
TrackCollection
DataVector< Trk::Track > TrackCollection
This typedef represents a collection of Trk::Track objects.
Definition:
TrackCollection.h:19
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition:
PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
IDPerfMuonRefitter::m_TrackRefitter2
ToolHandle< IegammaTrkRefitterTool > m_TrackRefitter2
The track refitter.
Definition:
IDPerfMuonRefitter.h:41
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition:
AthMsgStreamMacros.h:29
TrackCollection.h
ATH_CHECK
#define ATH_CHECK
Definition:
AthCheckMacros.h:40
IDPerfMuonRefitter::IDPerfMuonRefitter
IDPerfMuonRefitter(const std::string &name, ISvcLocator *pSvcLocator)
Definition:
IDPerfMuonRefitter.cxx:32
DataVector< Trk::Track >
AthAlgorithm
Definition:
AthAlgorithm.h:47
IDPerfMuonRefitter::m_outputTracksName
std::string m_outputTracksName
Definition:
IDPerfMuonRefitter.h:44
IDPerfMuonRefitter::m_N_MuonsRefit
int m_N_MuonsRefit
Definition:
IDPerfMuonRefitter.h:48
IDPerfMuonRefitter::m_N_MuonRefitFailures
int m_N_MuonRefitFailures
Definition:
IDPerfMuonRefitter.h:49
name
std::string name
Definition:
Control/AthContainers/Root/debug.cxx:195
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
xAOD::Electron_v1
Definition:
Electron_v1.h:34
IDPerfMuonRefitter::~IDPerfMuonRefitter
~IDPerfMuonRefitter()
Definition:
IDPerfMuonRefitter.cxx:49
MuonContainer.h
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition:
AthMsgStreamMacros.h:32
IDPerfMuonRefitter::execute
virtual StatusCode execute()
Definition:
IDPerfMuonRefitter.cxx:77
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition:
TrackParticle_v1.h:43
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:805
ReadHandle.h
Handle class for reading from StoreGate.
checker_macros.h
Define macros for attributes used to control the static checker.
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
IegammaTrkRefitterTool::Cache::electron
const xAOD::Electron * electron
pointer to the Electron input
Definition:
IegammaTrkRefitterTool.h:49
Generated on Fri Jul 5 2024 21:17:20 for ATLAS Offline Software by
1.8.18