12#include "GaudiKernel/MsgStream.h"
13#include "GaudiKernel/SmartDataPtr.h"
39 msg(MSG::INFO) <<
"SingleTrackDiffAlg initialize()" <<
endmsg;
49 return StatusCode::SUCCESS;
53 if (
msgLvl(MSG::VERBOSE))
msg(MSG::VERBOSE) <<
"SingleTrackDiffAlg execute() start" <<
endmsg;
55 StatusCode
sc = StatusCode::SUCCESS;
64 return StatusCode::FAILURE;
69 msg(MSG::ERROR) <<
"No reference Track collection given!" <<
endmsg;
70 return StatusCode::FAILURE;
77 return StatusCode::FAILURE;
82 msg(MSG::ERROR) <<
"No Track collection for comparison given!" <<
endmsg;
83 return StatusCode::FAILURE;
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;
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;
97 if (!(*refTrackIterator)) {
98 msg(MSG::WARNING) <<
"reference track collection containes a NULL pointer" <<
endmsg;
99 return StatusCode::SUCCESS;
102 const Perigee* refPerigee = (*refTrackIterator)->perigeeParameters();
103 const Track* compTrack =
nullptr;
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;
112 const Perigee* compPerigee = (*compTrackIterator)->perigeeParameters();
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) {
121 compTrack = (*compTrackIterator);
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;
135 if (
msgLvl(MSG::DEBUG))
msg(MSG::DEBUG) <<
"minimum chi2: " << minChi2 <<
endmsg;
140 return StatusCode::SUCCESS;
149 msg(MSG::INFO) <<
"SingleTrackDiffAlg finalize()" <<
endmsg;
151 return StatusCode::SUCCESS;
#define AmgSymMatrix(dim)
DataVector< Trk::Track > TrackCollection
This typedef represents a collection of Trk::Track objects.
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
ServiceHandle< StoreGateSvc > & evtStore()
bool msgLvl(const MSG::Level lvl) const
DataModel_detail::const_iterator< DataVector > const_iterator
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
double pT() const
Access method for transverse momentum.
std::string m_comparedTrackCollection
jobOption: name of the compared TrackCollection
StatusCode finalize()
standard Athena-Algorithm method
SingleTrackDiffAlg(const std::string &name, ISvcLocator *pSvcLocator)
Standard Athena-Algorithm Constructor.
~SingleTrackDiffAlg()
Default Destructor.
StatusCode execute()
standard Athena-Algorithm method
StatusCode initialize()
standard Athena-Algorithm method
ToolHandle< Trk::ITrackDiff > m_trackDiffTool
std::string m_referenceTrackCollection
jobOption: name of the reference TrackCollection
double chi2(TH1 *h0, TH1 *h1)
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee