ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Tracking
TrkValidation
TrkValAlgs
src
SingleTrackDiffAlg.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
7
// SingleTrackDiffAlg.cxx, (c) ATLAS Detector Software
9
10
#include "
TrkValAlgs/SingleTrackDiffAlg.h
"
11
// Gaudi
12
#include "GaudiKernel/MsgStream.h"
13
#include "GaudiKernel/SmartDataPtr.h"
14
// Trk
15
#include "
TrkTrack/TrackCollection.h
"
16
#include "
TrkTrack/Track.h
"
17
//#include "TrkParameters/Perigee.h"
18
//#include "TrkParameters/MeasuredPerigee.h"
19
//#include "TrkEventPrimitives/ErrorMatrix.h"
20
21
#include "
TrkValInterfaces/ITrackDiff.h
"
22
23
Trk::SingleTrackDiffAlg::SingleTrackDiffAlg
(
const
std::string& name, ISvcLocator* pSvcLocator):
24
AthAlgorithm
(name,pSvcLocator),
25
m_trackDiffTool
(
"Trk::TrackDiff/TrackDiff"
),
26
m_referenceTrackCollection
(
"simulatedTracks"
),
27
m_comparedTrackCollection
(
"Tracks"
)
28
29
{
30
declareProperty
(
"ReferenceTrackCollection"
,
m_referenceTrackCollection
,
"Name of the reference track collection"
);
31
declareProperty
(
"ComparedTrackCollection"
,
m_comparedTrackCollection
,
"Name of the track collection, which tracks will be compared"
);
32
declareProperty
(
"TrackDiffTool"
,
m_trackDiffTool
,
"Tool to compare two tracks"
);
33
34
}
35
36
Trk::SingleTrackDiffAlg::~SingleTrackDiffAlg
() =
default
;
37
38
StatusCode
Trk::SingleTrackDiffAlg::initialize
() {
39
msg
(MSG::INFO) <<
"SingleTrackDiffAlg initialize()"
<<
endmsg
;
40
41
42
// Get TrackDiff Tool
43
StatusCode
sc
=
m_trackDiffTool
.retrieve();
44
if
(
sc
.isFailure()) {
45
msg
(MSG::FATAL) <<
"Could not retrieve "
<<
m_trackDiffTool
<<
" (to compare tracks) "
<<
endmsg
;
46
return
sc
;
47
}
48
49
return
StatusCode::SUCCESS;
50
}
51
52
StatusCode
Trk::SingleTrackDiffAlg::execute
(
const
EventContext&
/*ctx*/
) {
53
if
(
msgLvl
(MSG::VERBOSE))
msg
(MSG::VERBOSE) <<
"SingleTrackDiffAlg execute() start"
<<
endmsg
;
54
55
StatusCode
sc
= StatusCode::SUCCESS;
56
57
const
TrackCollection
* referenceTracks =
nullptr
;
58
const
TrackCollection
* comparedTracks =
nullptr
;
59
// get reference collection
60
if
(!
m_referenceTrackCollection
.empty()) {
61
sc
=
evtStore
()->retrieve(referenceTracks,
m_referenceTrackCollection
);
62
if
(
sc
.isFailure()) {
63
msg
(MSG::ERROR) <<
"Reference tracks not found: "
<<
m_referenceTrackCollection
<<
endmsg
;
64
return
StatusCode::FAILURE;
65
}
else
{
66
if
(
msgLvl
(MSG::VERBOSE))
msg
(MSG::VERBOSE) <<
"Reference tracks found: "
<<
m_referenceTrackCollection
<<
endmsg
;
67
}
68
}
else
{
69
msg
(MSG::ERROR) <<
"No reference Track collection given!"
<<
endmsg
;
70
return
StatusCode::FAILURE;
71
}
72
// get collection for comparison
73
if
(!
m_comparedTrackCollection
.empty()) {
74
sc
=
evtStore
()->retrieve(comparedTracks,
m_comparedTrackCollection
);
75
if
(
sc
.isFailure()) {
76
msg
(MSG::ERROR) <<
"Tracks for comparison not found: "
<<
m_comparedTrackCollection
<<
endmsg
;
77
return
StatusCode::FAILURE;
78
}
else
{
79
if
(
msgLvl
(MSG::VERBOSE))
msg
(MSG::VERBOSE) <<
"Tracks for comparison found: "
<<
m_comparedTrackCollection
<<
endmsg
;
80
}
81
}
else
{
82
msg
(MSG::ERROR) <<
"No Track collection for comparison given!"
<<
endmsg
;
83
return
StatusCode::FAILURE;
84
}
85
// just compare the first tracks of both collections
86
TrackCollection::const_iterator
refTrackIterator = referenceTracks->
begin
();
87
TrackCollection::const_iterator
compTrackIterator = comparedTracks->
begin
();
88
if
(
msgLvl
(MSG::DEBUG))
msg
(MSG::DEBUG) << referenceTracks->
size
() <<
" reference track(s) and "
<< comparedTracks->
size
() <<
" comparison track(s)"
<<
endmsg
;
89
if
( refTrackIterator == referenceTracks->
end
() ) {
90
if
(
msgLvl
(MSG::DEBUG))
msg
(MSG::DEBUG) <<
"reference collection containes no tracks."
<<
endmsg
;
91
return
StatusCode::SUCCESS;
92
}
93
if
( compTrackIterator == comparedTracks->
end
() ) {
94
msg
(MSG::INFO) <<
"collection for comparison containes no tracks in contrast to the reference collection"
<<
endmsg
;
95
return
StatusCode::SUCCESS;
96
}
97
if
(!(*refTrackIterator)) {
98
msg
(MSG::WARNING) <<
"reference track collection containes a NULL pointer"
<<
endmsg
;
99
return
StatusCode::SUCCESS;
100
}
101
// find track in compared collection which fits best to track in reference collection
102
const
Perigee
* refPerigee = (*refTrackIterator)->perigeeParameters();
103
const
Track
* compTrack =
nullptr
;
// later for-loop with large min chi2 will assign a sane track
104
if
(refPerigee) {
105
//double minDeltaqOverP = 1.e20;
106
double
minChi2 = 1.e30;
107
for
(; compTrackIterator != comparedTracks->
end
(); ++compTrackIterator) {
108
if
(!(*compTrackIterator)) {
109
msg
(MSG::WARNING) <<
"track collection for comparison containes a NULL pointer"
<<
endmsg
;
110
continue
;
111
}
112
const
Perigee
* compPerigee = (*compTrackIterator)->perigeeParameters();
113
if
(compPerigee) {
114
double
chi2
= -1.;
115
if
(compPerigee->covariance()) {
116
AmgSymMatrix
(5) weight = compPerigee->covariance()->inverse();
117
AmgVector
(5) paramdiff = refPerigee->parameters() - compPerigee->parameters();
118
chi2
= paramdiff.transpose() * weight * paramdiff;
119
if
(
chi2
< minChi2) {
120
minChi2 =
chi2
;
121
compTrack = (*compTrackIterator);
122
}
123
}
/* else {
124
double deltaqOverP = fabs(refPerigee->pT() - compPerigee->pT());
125
if (deltaqOverP < minDeltaqOverP) {
126
minDeltaqOverP = deltaqOverP;
127
compTrack = (*compTrackIterator);
128
}
129
}*/
130
if
(
msgLvl
(MSG::DEBUG))
msg
(MSG::DEBUG) <<
"pTRef: "
<< refPerigee->
pT
() <<
" pT: "
<< compPerigee->
pT
() <<
" ThetaRef: "
<< refPerigee->parameters()[
Trk::theta
] <<
" Theta: "
<< compPerigee->parameters()[
Trk::theta
]<<
" PhiRef: "
<< refPerigee->parameters()[
Trk::phi0
] <<
" Phi: "
<< compPerigee->parameters()[
Trk::phi0
]<<
" chi2: "
<<
chi2
<<
endmsg
;
131
132
}
133
}
134
//if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) <<"minimum Delta pT: " << minDeltaqOverP <<endmsg;
135
if
(
msgLvl
(MSG::DEBUG))
msg
(MSG::DEBUG) <<
"minimum chi2: "
<< minChi2 <<
endmsg
;
136
}
137
if
(compTrack) {
138
sc
=
m_trackDiffTool
->diff( *(*refTrackIterator), *(compTrack) );
139
}
else
{
140
return
StatusCode::SUCCESS;
141
}
142
// refTrackIterator = (*referenceTracks).end();
143
// compTrackIterator = (*comparedTracks).end();
144
return
sc
;
145
//return StatusCode::SUCCESS;
146
}
147
148
StatusCode
Trk::SingleTrackDiffAlg::finalize
() {
149
msg
(MSG::INFO) <<
"SingleTrackDiffAlg finalize()"
<<
endmsg
;
150
151
return
StatusCode::SUCCESS;
152
}
153
154
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:54
AmgSymMatrix
#define AmgSymMatrix(dim)
Definition
EventPrimitives.h:50
AmgVector
#define AmgVector(rows)
Definition
EventPrimitives.h:55
ITrackDiff.h
sc
static Double_t sc
Definition
LArPhysWaveHECTool.cxx:37
SingleTrackDiffAlg.h
TrackCollection.h
TrackCollection
DataVector< Trk::Track > TrackCollection
This typedef represents a collection of Trk::Track objects.
Definition
TrackCollection.h:19
Track.h
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
AthCommonAlgorithm< Gaudi::Algorithm >::msgLvl
bool msgLvl(const MSG::Level lvl) const
Definition
AthCommonMsg.h:30
DataVector< Trk::Track >::const_iterator
DataModel_detail::const_iterator< DataVector > const_iterator
Definition
DataVector.h:838
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
Trk::ParametersBase::pT
double pT() const
Access method for transverse momentum.
Trk::SingleTrackDiffAlg::m_comparedTrackCollection
std::string m_comparedTrackCollection
jobOption: name of the compared TrackCollection
Definition
SingleTrackDiffAlg.h:49
Trk::SingleTrackDiffAlg::finalize
StatusCode finalize()
standard Athena-Algorithm method
Definition
SingleTrackDiffAlg.cxx:148
Trk::SingleTrackDiffAlg::execute
StatusCode execute(const EventContext &ctx)
standard Athena-Algorithm method
Definition
SingleTrackDiffAlg.cxx:52
Trk::SingleTrackDiffAlg::SingleTrackDiffAlg
SingleTrackDiffAlg(const std::string &name, ISvcLocator *pSvcLocator)
Standard Athena-Algorithm Constructor.
Definition
SingleTrackDiffAlg.cxx:23
Trk::SingleTrackDiffAlg::~SingleTrackDiffAlg
~SingleTrackDiffAlg()
Default Destructor.
Trk::SingleTrackDiffAlg::initialize
StatusCode initialize()
standard Athena-Algorithm method
Definition
SingleTrackDiffAlg.cxx:38
Trk::SingleTrackDiffAlg::m_trackDiffTool
ToolHandle< Trk::ITrackDiff > m_trackDiffTool
Definition
SingleTrackDiffAlg.h:46
Trk::SingleTrackDiffAlg::m_referenceTrackCollection
std::string m_referenceTrackCollection
jobOption: name of the reference TrackCollection
Definition
SingleTrackDiffAlg.h:48
chi2
double chi2(TH1 *h0, TH1 *h1)
Definition
comparitor.cxx:525
Track
Definition
TriggerChamberClusterOnTrackCreator.h:19
Trk::Perigee
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee
Definition
Tracking/TrkEvent/TrkParameters/TrkParameters/TrackParameters.h:33
Trk::phi0
@ phi0
Definition
ParamDefs.h:65
Trk::theta
@ theta
Definition
ParamDefs.h:66
msg
MsgStream & msg
Definition
testRead.cxx:32
Generated on
for ATLAS Offline Software by
1.17.0