Commit 70d156e8 authored by Frank Winklmeier's avatar Frank Winklmeier
Browse files

Merge branch 'TrackSummary_try_to_simplify_clean' into 'master'

Trk Track Summary. Use unique_ptr, default move ctors , tidy up the code

See merge request !44474
parents 0d2afd3d ad2b0557
...@@ -559,7 +559,7 @@ InDet::InDetTrackSummaryHelperTool::addDetailedTrackSummary( ...@@ -559,7 +559,7 @@ InDet::InDetTrackSummaryHelperTool::addDetailedTrackSummary(
return; return;
} }
ATH_MSG_DEBUG("Adding detailed indet track summary"); ATH_MSG_DEBUG("Adding detailed indet track summary");
delete summary.m_indetTrackSummary; summary.m_indetTrackSummary.reset();
Trk::InDetTrackSummary* indetTrackSummary = new Trk::InDetTrackSummary(); Trk::InDetTrackSummary* indetTrackSummary = new Trk::InDetTrackSummary();
Trk::InDetTrackSummary& trackSummary = *indetTrackSummary; Trk::InDetTrackSummary& trackSummary = *indetTrackSummary;
if (m_usePixel and not m_pixeldedxtool.empty() and if (m_usePixel and not m_pixeldedxtool.empty() and
...@@ -582,7 +582,7 @@ InDet::InDetTrackSummaryHelperTool::addDetailedTrackSummary( ...@@ -582,7 +582,7 @@ InDet::InDetTrackSummaryHelperTool::addDetailedTrackSummary(
m_pixeldedxtool->getMass(ctx, dedx, p, ngoodhits); m_pixeldedxtool->getMass(ctx, dedx, p, ngoodhits);
} }
} }
summary.m_indetTrackSummary = indetTrackSummary; summary.m_indetTrackSummary.reset(indetTrackSummary);
} }
StatusCode StatusCode
......
...@@ -368,7 +368,7 @@ void Muon::MuonTrackSummaryHelperTool::addDetailedTrackSummary(const Trk::Track& ...@@ -368,7 +368,7 @@ void Muon::MuonTrackSummaryHelperTool::addDetailedTrackSummary(const Trk::Track&
// given that we cannot separate eta/phi holes, redo the assignment before moving to the next chamber // given that we cannot separate eta/phi holes, redo the assignment before moving to the next chamber
if (currentChamberSummary && !currentChamberSummary->isMdt()) { updateHoleContent(*currentChamberSummary); } if (currentChamberSummary && !currentChamberSummary->isMdt()) { updateHoleContent(*currentChamberSummary); }
summary.m_muonTrackSummary = muonTrackSummary; summary.m_muonTrackSummary.reset(muonTrackSummary);
} }
void Muon::MuonTrackSummaryHelperTool::updateHoleContent(Trk::MuonTrackSummary::ChamberHitSummary& chamberHitSummary) const { void Muon::MuonTrackSummaryHelperTool::updateHoleContent(Trk::MuonTrackSummary::ChamberHitSummary& chamberHitSummary) const {
......
/* /*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
*/ */
#ifndef TRK_INDETTRACKSUMMARY_H #ifndef TRK_INDETTRACKSUMMARY_H
...@@ -11,45 +11,52 @@ class MsgStream; ...@@ -11,45 +11,52 @@ class MsgStream;
class InDetTrackSummaryCnv_p1; class InDetTrackSummaryCnv_p1;
class TrackSummaryCnv_p2; class TrackSummaryCnv_p2;
namespace InDet { namespace InDet {
class InDetTrackSummaryHelperTool; class InDetTrackSummaryHelperTool;
} }
namespace Trk { namespace Trk {
/** /**
Detailed track summary for the indet system Detailed track summary for the indet system
*/ */
class InDetTrackSummary { class InDetTrackSummary
public: {
public:
friend class InDet::InDetTrackSummaryHelperTool; friend class InDet::InDetTrackSummaryHelperTool;
friend class ::InDetTrackSummaryCnv_p1; friend class ::InDetTrackSummaryCnv_p1;
friend class ::TrackSummaryCnv_p2; friend class ::TrackSummaryCnv_p2;
/** default constructor */ /** default constructor */
InDetTrackSummary(); InDetTrackSummary();
InDetTrackSummary(const InDetTrackSummary&) = default;
InDetTrackSummary(InDetTrackSummary&&) = default;
InDetTrackSummary& operator=(const InDetTrackSummary&) = default;
InDetTrackSummary& operator=(InDetTrackSummary&&) = default;
/** destructor */ /** destructor */
~InDetTrackSummary(); ~InDetTrackSummary() = default;
/** access to the vector of likelihoods (pion/kaon/proton) */ /** access to the vector of likelihoods (pion/kaon/proton) */
const std::vector<float>& likelihoodsPixeldEdx() const { return m_likelihoodspixeldedx; } const std::vector<float>& likelihoodsPixeldEdx() const
{
return m_likelihoodspixeldedx;
}
/** access to mass calculated using pixel dEdx */ /** access to mass calculated using pixel dEdx */
float massPixeldEdx() const { return m_massdedx; } float massPixeldEdx() const { return m_massdedx; }
private: private:
std::vector<float> m_likelihoodspixeldedx; //<! vector with likelihoods std::vector<float> m_likelihoodspixeldedx; //<! vector with likelihoods
float m_massdedx; //<! mass calculated using pixel dEdx float m_massdedx; //<! mass calculated using pixel dEdx
}; };
/**output. This dumps the values of each of the possible summary enums*/ /**output. This dumps the values of each of the possible summary enums*/
MsgStream& operator<<(MsgStream& out, const InDetTrackSummary& trackSum); MsgStream&
operator<<(MsgStream& out, const InDetTrackSummary& trackSum);
/**output. This dumps the values of each of the possible summary enums*/ /**output. This dumps the values of each of the possible summary enums*/
std::ostream& operator<<(std::ostream& out, const InDetTrackSummary& trackSum); std::ostream&
operator<<(std::ostream& out, const InDetTrackSummary& trackSum);
} }
#endif #endif
/* /*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
*/ */
#ifndef TRK_MUONTRACKSUMMARY_H #ifndef TRK_MUONTRACKSUMMARY_H
...@@ -12,43 +12,47 @@ class MuonTrackSummaryCnv_p1; ...@@ -12,43 +12,47 @@ class MuonTrackSummaryCnv_p1;
class MuonTrackSummaryCnv_p2; class MuonTrackSummaryCnv_p2;
class TrackSummaryCnv_p2; class TrackSummaryCnv_p2;
namespace Muon { namespace Muon {
class MuonTrackSummaryHelperTool; class MuonTrackSummaryHelperTool;
} }
namespace Trk { namespace Trk {
/** /**
Detailed track summary for the muon system Detailed track summary for the muon system
Give access to hit counts per chamber. Give access to hit counts per chamber.
*/ */
class MuonTrackSummary { class MuonTrackSummary
public: {
public:
friend class Muon::MuonTrackSummaryHelperTool; friend class Muon::MuonTrackSummaryHelperTool;
/** structure to hold information per chamber in the muon system */ /** structure to hold information per chamber in the muon system */
struct ChamberHitSummary { struct ChamberHitSummary
{
friend class Muon::MuonTrackSummaryHelperTool; friend class Muon::MuonTrackSummaryHelperTool;
/** structure to hold the information for the eta/phi projection of RPC, TGC and CSC /** structure to hold the information for the eta/phi projection of RPC, TGC and CSC
chambers and per multilayer for MDT chambers */ chambers and per multilayer for MDT chambers */
struct Projection { struct Projection
{
Projection() {} Projection() {}
int nhits{0}; //<! number of hits on track in the projection int nhits{ 0 }; //<! number of hits on track in the projection
int nholes{0}; //<! number of holes in the projection int nholes{ 0 }; //<! number of holes in the projection
int noutliers{0}; //<! number of outliers in the projection int noutliers{ 0 }; //<! number of outliers in the projection
int ndeltas{0}; //<! number of delta electrons in the projection (only filled for MDT chambers) int ndeltas{ 0 }; //<! number of delta electrons in the projection (only filled for MDT chambers)
int ncloseHits{0}; //<! number of hits within a road around the track in the projection int ncloseHits{ 0 }; //<! number of hits within a road around the track in the projection
int ngoodHits{0}; //<! number of hits that matter for the track int ngoodHits{ 0 }; //<! number of hits that matter for the track
int noutBounds{0}; //<! number of out-of-bounds hits int noutBounds{ 0 }; //<! number of out-of-bounds hits
}; };
/** constructor taking the Identifier of the chamber and a boolean whether we are dealing with a MDT chamber or not /** constructor taking the Identifier of the chamber and a boolean whether we are dealing with a MDT chamber or not
(the boolean is passed as the ChamberHitSummary cannot unpack the identifier and it needs to know whether it is dealing (the boolean is passed as the ChamberHitSummary cannot unpack the identifier and it needs to know whether it is
with a MDT chamber) */ dealing with a MDT chamber) */
ChamberHitSummary( Identifier chID, bool isMdtTube ) : m_chId(chID),m_isMdt(isMdtTube) {} ChamberHitSummary(Identifier chID, bool isMdtTube)
: m_chId(chID)
, m_isMdt(isMdtTube)
{}
/** returns the chamber identifier */ /** returns the chamber identifier */
const Identifier& chamberId() const { return m_chId; } const Identifier& chamberId() const { return m_chId; }
...@@ -74,7 +78,7 @@ namespace Trk { ...@@ -74,7 +78,7 @@ namespace Trk {
/** returns the number of non-deweighted hits in the chamber */ /** returns the number of non-deweighted hits in the chamber */
int ngoodHits() const { return m_first.ngoodHits + m_second.ngoodHits; } int ngoodHits() const { return m_first.ngoodHits + m_second.ngoodHits; }
//returns the number of out of bounds hits // returns the number of out of bounds hits
int noutBoundsHits() const { return m_first.noutBounds + m_second.noutBounds; } int noutBoundsHits() const { return m_first.noutBounds + m_second.noutBounds; }
/** returns the total number of eta hits on track in the chamber */ /** returns the total number of eta hits on track in the chamber */
...@@ -101,18 +105,16 @@ namespace Trk { ...@@ -101,18 +105,16 @@ namespace Trk {
/** access to the data of the phi projection, users have to check whether this is NOT a MDT chamber first!! */ /** access to the data of the phi projection, users have to check whether this is NOT a MDT chamber first!! */
const Projection& phiProjection() const { return m_second; } const Projection& phiProjection() const { return m_second; }
private: private:
friend class ::MuonTrackSummaryCnv_p1; friend class ::MuonTrackSummaryCnv_p1;
friend class ::MuonTrackSummaryCnv_p2; friend class ::MuonTrackSummaryCnv_p2;
friend class ::TrackSummaryCnv_p2; friend class ::TrackSummaryCnv_p2;
Identifier m_chId{0}; //<! chamber identifier Identifier m_chId{ 0 }; //<! chamber identifier
bool m_isMdt{false}; //<! is this a MDT chamber bool m_isMdt{ false }; //<! is this a MDT chamber
Projection m_first; //<! eta projections for cluster chambers, first multi layer for mdt chambers Projection m_first; //<! eta projections for cluster chambers, first multi layer for mdt chambers
Projection m_second; //<! phi projections for cluster chambers, first multi layer for mdt chambers Projection m_second; //<! phi projections for cluster chambers, first multi layer for mdt chambers
}; };
/** default constructor */ /** default constructor */
...@@ -145,7 +147,7 @@ namespace Trk { ...@@ -145,7 +147,7 @@ namespace Trk {
/** access to the vector of chamber hit summaries on the track */ /** access to the vector of chamber hit summaries on the track */
const std::vector<ChamberHitSummary>& chamberHitSummary() const { return m_chamberHitSummary; } const std::vector<ChamberHitSummary>& chamberHitSummary() const { return m_chamberHitSummary; }
private: private:
friend class ::MuonTrackSummaryCnv_p1; friend class ::MuonTrackSummaryCnv_p1;
friend class ::MuonTrackSummaryCnv_p2; friend class ::MuonTrackSummaryCnv_p2;
friend class ::TrackSummaryCnv_p2; friend class ::TrackSummaryCnv_p2;
...@@ -153,14 +155,15 @@ namespace Trk { ...@@ -153,14 +155,15 @@ namespace Trk {
unsigned int m_nscatterers; //<! number of scattering centres on the track unsigned int m_nscatterers; //<! number of scattering centres on the track
unsigned int m_npseudoMeasurements; //<! number of pseudomeasurements on the track unsigned int m_npseudoMeasurements; //<! number of pseudomeasurements on the track
std::vector<ChamberHitSummary> m_chamberHitSummary; //<! vector with chamber hit summaries std::vector<ChamberHitSummary> m_chamberHitSummary; //<! vector with chamber hit summaries
};
};
/**output. This dumps the values of each of the possible summary enums*/ /**output. This dumps the values of each of the possible summary enums*/
MsgStream& operator<<(MsgStream& out, const MuonTrackSummary& trackSum); MsgStream&
operator<<(MsgStream& out, const MuonTrackSummary& trackSum);
/**output. This dumps the values of each of the possible summary enums*/ /**output. This dumps the values of each of the possible summary enums*/
std::ostream& operator<<(std::ostream& out, const MuonTrackSummary& trackSum); std::ostream&
operator<<(std::ostream& out, const MuonTrackSummary& trackSum);
} }
#endif #endif
/* /*
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
*/ */
inline int inline int
Trk::TrackSummary::get(const Trk::SummaryType& type) const Trk::TrackSummary::get(const Trk::SummaryType& type) const
...@@ -52,26 +52,25 @@ Trk::TrackSummary::isHit(const Trk::DetectorType& type) const ...@@ -52,26 +52,25 @@ Trk::TrackSummary::isHit(const Trk::DetectorType& type) const
inline const Trk::InDetTrackSummary* inline const Trk::InDetTrackSummary*
Trk::TrackSummary::indetTrackSummary() const Trk::TrackSummary::indetTrackSummary() const
{ {
return m_indetTrackSummary; return m_indetTrackSummary.get();
} }
inline Trk::InDetTrackSummary* inline Trk::InDetTrackSummary*
Trk::TrackSummary::indetTrackSummary() Trk::TrackSummary::indetTrackSummary()
{ {
return m_indetTrackSummary; return m_indetTrackSummary.get();
} }
inline const Trk::MuonTrackSummary* inline const Trk::MuonTrackSummary*
Trk::TrackSummary::muonTrackSummary() const Trk::TrackSummary::muonTrackSummary() const
{ {
return m_muonTrackSummary; return m_muonTrackSummary.get();
} }
inline Trk::MuonTrackSummary* inline Trk::MuonTrackSummary*
Trk::TrackSummary::muonTrackSummary() Trk::TrackSummary::muonTrackSummary()
{ {
return m_muonTrackSummary; return m_muonTrackSummary.get();
} }
inline unsigned long inline unsigned long
......
...@@ -4,29 +4,35 @@ ...@@ -4,29 +4,35 @@
#include "TrkTrackSummary/InDetTrackSummary.h" #include "TrkTrackSummary/InDetTrackSummary.h"
#include <iostream>
#include "GaudiKernel/MsgStream.h" #include "GaudiKernel/MsgStream.h"
#include <iostream>
Trk::InDetTrackSummary::InDetTrackSummary()
Trk::InDetTrackSummary::InDetTrackSummary() : : m_likelihoodspixeldedx(3, -1)
m_likelihoodspixeldedx(3,-1), , m_massdedx(-1)
m_massdedx(-1){ {}
}
Trk::InDetTrackSummary::~InDetTrackSummary() {
}
std::ostream& Trk::operator<<( std::ostream& out, const InDetTrackSummary& trackSum ) std::ostream&
Trk::operator<<(std::ostream& out, const InDetTrackSummary& trackSum)
{ {
out<<"InDetTrackSummary: likelihoods from pixel dEdx (pion/kaon/proton): " << trackSum.likelihoodsPixeldEdx()[0] << " " << trackSum.likelihoodsPixeldEdx()[1] << " " << trackSum.likelihoodsPixeldEdx()[2] << std::endl; out << "InDetTrackSummary: likelihoods from pixel dEdx (pion/kaon/proton): "
out<<"InDetTrackSummary: mass calculated using pixel dEdx: " << trackSum.massPixeldEdx() << std::endl; << trackSum.likelihoodsPixeldEdx()[0] << " "
<< trackSum.likelihoodsPixeldEdx()[1] << " "
<< trackSum.likelihoodsPixeldEdx()[2] << std::endl;
out << "InDetTrackSummary: mass calculated using pixel dEdx: "
<< trackSum.massPixeldEdx() << std::endl;
return out; return out;
} }
MsgStream& Trk::operator<<( MsgStream& out, const InDetTrackSummary& trackSum ) MsgStream&
Trk::operator<<(MsgStream& out, const InDetTrackSummary& trackSum)
{ {
out<<"InDetTrackSummary: likelihoods from pixel dEdx (pion/kaon/proton): " << trackSum.likelihoodsPixeldEdx()[0] << " " << trackSum.likelihoodsPixeldEdx()[1] << " " << trackSum.likelihoodsPixeldEdx()[2] << endmsg; out << "InDetTrackSummary: likelihoods from pixel dEdx (pion/kaon/proton): "
out<<"InDetTrackSummary: mass calculated using pixel dEdx: " << trackSum.massPixeldEdx() << endmsg; << trackSum.likelihoodsPixeldEdx()[0] << " "
<< trackSum.likelihoodsPixeldEdx()[1] << " "
<< trackSum.likelihoodsPixeldEdx()[2] << endmsg;
out << "InDetTrackSummary: mass calculated using pixel dEdx: "
<< trackSum.massPixeldEdx() << endmsg;
return out; return out;
} }
...@@ -4,94 +4,137 @@ ...@@ -4,94 +4,137 @@
#include "TrkTrackSummary/MuonTrackSummary.h" #include "TrkTrackSummary/MuonTrackSummary.h"
#include <iostream>
#include "GaudiKernel/MsgStream.h" #include "GaudiKernel/MsgStream.h"
#include <iostream>
Trk::MuonTrackSummary::MuonTrackSummary()
: m_nscatterers(0)
, m_npseudoMeasurements(0)
{}
Trk::MuonTrackSummary::MuonTrackSummary() : m_nscatterers(0), m_npseudoMeasurements(0) { Trk::MuonTrackSummary::~MuonTrackSummary() {}
}
Trk::MuonTrackSummary::~MuonTrackSummary() {
}
unsigned int Trk::MuonTrackSummary::netaHits() const { unsigned int
Trk::MuonTrackSummary::netaHits() const
{
unsigned int count = 0; unsigned int count = 0;
std::vector<ChamberHitSummary>::const_iterator it = m_chamberHitSummary.begin(); std::vector<ChamberHitSummary>::const_iterator it =
std::vector<ChamberHitSummary>::const_iterator it_end = m_chamberHitSummary.end(); m_chamberHitSummary.begin();
for( ;it!=it_end; ++it ) count += it->netaHits(); std::vector<ChamberHitSummary>::const_iterator it_end =
m_chamberHitSummary.end();
for (; it != it_end; ++it)
count += it->netaHits();
return count; return count;
} }
unsigned int Trk::MuonTrackSummary::nphiHits() const { unsigned int
Trk::MuonTrackSummary::nphiHits() const
{
unsigned int count = 0; unsigned int count = 0;
std::vector<ChamberHitSummary>::const_iterator it = m_chamberHitSummary.begin(); std::vector<ChamberHitSummary>::const_iterator it =
std::vector<ChamberHitSummary>::const_iterator it_end = m_chamberHitSummary.end(); m_chamberHitSummary.begin();
for( ;it!=it_end; ++it ) count += it->nphiHits(); std::vector<ChamberHitSummary>::const_iterator it_end =
m_chamberHitSummary.end();
for (; it != it_end; ++it)
count += it->nphiHits();
return count; return count;
} }
unsigned int Trk::MuonTrackSummary::nholes() const { unsigned int
Trk::MuonTrackSummary::nholes() const
{
unsigned int count = 0; unsigned int count = 0;
std::vector<ChamberHitSummary>::const_iterator it = m_chamberHitSummary.begin(); std::vector<ChamberHitSummary>::const_iterator it =
std::vector<ChamberHitSummary>::const_iterator it_end = m_chamberHitSummary.end(); m_chamberHitSummary.begin();
for( ;it!=it_end; ++it ) count += it->nholes(); std::vector<ChamberHitSummary>::const_iterator it_end =
m_chamberHitSummary.end();
for (; it != it_end; ++it)
count += it->nholes();
return count; return count;
} }
unsigned int Trk::MuonTrackSummary::noutliers() const { unsigned int
Trk::MuonTrackSummary::noutliers() const
{
unsigned int count = 0; unsigned int count = 0;
std::vector<ChamberHitSummary>::const_iterator it = m_chamberHitSummary.begin(); std::vector<ChamberHitSummary>::const_iterator it =
std::vector<ChamberHitSummary>::const_iterator it_end = m_chamberHitSummary.end(); m_chamberHitSummary.begin();
for( ;it!=it_end; ++it ) count += it->noutliers(); std::vector<ChamberHitSummary>::const_iterator it_end =
m_chamberHitSummary.end();
for (; it != it_end; ++it)
count += it->noutliers();
return count; return count;
} }
unsigned int Trk::MuonTrackSummary::ncloseHits() const { unsigned int
Trk::MuonTrackSummary::ncloseHits() const
{
unsigned int count = 0; unsigned int count = 0;
std::vector<ChamberHitSummary>::const_iterator it = m_chamberHitSummary.begin(); std::vector<ChamberHitSummary>::const_iterator it =
std::vector<ChamberHitSummary>::const_iterator it_end = m_chamberHitSummary.end(); m_chamberHitSummary.begin();
for( ;it!=it_end; ++it ) count += it->ncloseHits(); std::vector<ChamberHitSummary>::const_iterator it_end =
m_chamberHitSummary.end();
for (; it != it_end; ++it)
count += it->ncloseHits();
return count; return count;
} }
std::ostream& Trk::operator<<( std::ostream& out, const MuonTrackSummary& trackSum ) std::ostream&
Trk::operator<<(std::ostream& out, const MuonTrackSummary& trackSum)
{ {
out<<"MuonTrackSummary: npseudo " << trackSum.npseudoMeasurements() << " nscat " << trackSum.nscatterers() out << "MuonTrackSummary: npseudo " << trackSum.npseudoMeasurements()
<< " number of chambers " << trackSum.chamberHitSummary().size() << std::endl; << " nscat " << trackSum.nscatterers() << " number of chambers "
std::vector<MuonTrackSummary::ChamberHitSummary>::const_iterator it = trackSum.chamberHitSummary().begin(); << trackSum.chamberHitSummary().size() << std::endl;
std::vector<MuonTrackSummary::ChamberHitSummary>::const_iterator it_end = trackSum.chamberHitSummary().end(); std::vector<MuonTrackSummary::ChamberHitSummary>::const_iterator it =
trackSum.chamberHitSummary().begin();
std::vector<MuonTrackSummary::ChamberHitSummary>::const_iterator it_end =
trackSum.chamberHitSummary().end();
for( ;it!=it_end;++it ){