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: {
friend class InDet::InDetTrackSummaryHelperTool; public:
friend class ::InDetTrackSummaryCnv_p1; friend class InDet::InDetTrackSummaryHelperTool;
friend class ::TrackSummaryCnv_p2; friend class ::InDetTrackSummaryCnv_p1;
friend class ::TrackSummaryCnv_p2;
/** default constructor */
InDetTrackSummary(); /** default constructor */
InDetTrackSummary();
/** destructor */ InDetTrackSummary(const InDetTrackSummary&) = default;
~InDetTrackSummary(); InDetTrackSummary(InDetTrackSummary&&) = default;
InDetTrackSummary& operator=(const InDetTrackSummary&) = default;
/** access to the vector of likelihoods (pion/kaon/proton) */ InDetTrackSummary& operator=(InDetTrackSummary&&) = default;
const std::vector<float>& likelihoodsPixeldEdx() const { return m_likelihoodspixeldedx; } /** destructor */
~InDetTrackSummary() = default;
/** access to mass calculated using pixel dEdx */
float massPixeldEdx() const { return m_massdedx; } /** access to the vector of likelihoods (pion/kaon/proton) */
const std::vector<float>& likelihoodsPixeldEdx() const
private: {
return m_likelihoodspixeldedx;
std::vector<float> m_likelihoodspixeldedx; //<! vector with likelihoods }
float m_massdedx; //<! mass calculated using pixel dEdx
}; /** access to mass calculated using pixel dEdx */
float massPixeldEdx() const { return m_massdedx; }
private:
std::vector<float> m_likelihoodspixeldedx; //<! vector with likelihoods
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,155 +12,158 @@ class MuonTrackSummaryCnv_p1; ...@@ -12,155 +12,158 @@ 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;
/** structure to hold information per chamber in the muon system */
struct ChamberHitSummary
{
friend class Muon::MuonTrackSummaryHelperTool; friend class Muon::MuonTrackSummaryHelperTool;
/** structure to hold information per chamber in the muon system */ /** structure to hold the information for the eta/phi projection of RPC, TGC and CSC
struct ChamberHitSummary { chambers and per multilayer for MDT chambers */
friend class Muon::MuonTrackSummaryHelperTool; struct Projection
{
/** structure to hold the information for the eta/phi projection of RPC, TGC and CSC
chambers and per multilayer for MDT chambers */
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
(the boolean is passed as the ChamberHitSummary cannot unpack the identifier and it needs to know whether it is dealing dealing with a MDT chamber) */
with a MDT chamber) */ ChamberHitSummary(Identifier chID, bool isMdtTube)
ChamberHitSummary( Identifier chID, bool isMdtTube ) : m_chId(chID),m_isMdt(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; }
/** returns whether this is a MDT chamber */ /** returns whether this is a MDT chamber */
bool isMdt() const { return m_isMdt; } bool isMdt() const { return m_isMdt; }
/** returns the total number of hits on track in the chamber */ /** returns the total number of hits on track in the chamber */
int nhits() const { return m_first.nhits + m_second.nhits; } int nhits() const { return m_first.nhits + m_second.nhits; }
/** returns the total number of holes in the chamber */ /** returns the total number of holes in the chamber */
int nholes() const { return m_first.nholes + m_second.nholes; } int nholes() const { return m_first.nholes + m_second.nholes; }
/** returns the total number of outliers in the chamber */ /** returns the total number of outliers in the chamber */
int noutliers() const { return m_first.noutliers + m_second.noutliers; } int noutliers() const { return m_first.noutliers + m_second.noutliers; }
/** returns the total number of delta electrons in the chamber */ /** returns the total number of delta electrons in the chamber */
int ndeltas() const { return m_first.ndeltas + m_second.ndeltas; } int ndeltas() const { return m_first.ndeltas + m_second.ndeltas; }
/** returns the total number of close hits in the chamber */ /** returns the total number of close hits in the chamber */
int ncloseHits() const { return m_first.ncloseHits + m_second.ncloseHits; } int ncloseHits() const { return m_first.ncloseHits + m_second.ncloseHits; }
/** 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 */
int netaHits() const { return isMdt() ? nhits() : m_first.nhits; } int netaHits() const { return isMdt() ? nhits() : m_first.nhits; }
/** returns the total number of phi hits on track in the chamber */ /** returns the total number of phi hits on track in the chamber */
int nphiHits() const { return isMdt() ? 0 : m_second.nhits; } int nphiHits() const { return isMdt() ? 0 : m_second.nhits; }
/** returns the total number of MDT hits on track in the first multi layer */ /** returns the total number of MDT hits on track in the first multi layer */
int nMdtHitsMl1() const { return isMdt() ? m_first.nhits : 0; } int nMdtHitsMl1() const { return isMdt() ? m_first.nhits : 0; }
/** returns the total number of MDT hits on track in the second multi layer */ /** returns the total number of MDT hits on track in the second multi layer */
int nMdtHitsMl2() const { return isMdt() ? m_second.nhits : 0; } int nMdtHitsMl2() const { return isMdt() ? m_second.nhits : 0; }
/** access to the data of the first MDT multi layer, users have to check whether this is a MDT chamber first!! */ /** access to the data of the first MDT multi layer, users have to check whether this is a MDT chamber first!! */
const Projection& mdtMl1() const { return m_first; } const Projection& mdtMl1() const { return m_first; }
/** access to the data of the second MDT multi layer, users have to check whether this is a MDT chamber first!! */ /** access to the data of the second MDT multi layer, users have to check whether this is a MDT chamber first!! */
const Projection& mdtMl2() const { return m_second; } const Projection& mdtMl2() const { return m_second; }
/** access to the data of the eta projection, users have to check whether this is NOT a MDT chamber first!! */ /** access to the data of the eta projection, users have to check whether this is NOT a MDT chamber first!! */
const Projection& etaProjection() const { return m_first; } const Projection& etaProjection() const { return m_first; }
/** 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:
friend class ::MuonTrackSummaryCnv_p1;
friend class ::MuonTrackSummaryCnv_p2;
friend class ::TrackSummaryCnv_p2;
private: Identifier m_chId{ 0 }; //<! chamber identifier
friend class ::MuonTrackSummaryCnv_p1; bool m_isMdt{ false }; //<! is this a MDT chamber
friend class ::MuonTrackSummaryCnv_p2;
friend class ::TrackSummaryCnv_p2;
Identifier m_chId{0}; //<! chamber identifier Projection m_first; //<! eta projections for cluster chambers, first multi layer for mdt chambers
bool m_isMdt{false}; //<! is this a MDT chamber Projection m_second; //<! phi 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
};
/** default constructor */ /** default constructor */
MuonTrackSummary(); MuonTrackSummary();
/** destructor */ /** destructor */
~MuonTrackSummary(); ~MuonTrackSummary();
/** number of eta hits on the track */
unsigned int netaHits() const;
/** number of phi hits on the track */ /** number of eta hits on the track */
unsigned int nphiHits() const; unsigned int netaHits() const;
/** number of eta trigger hits on the track */ /** number of phi hits on the track */
unsigned int noutliers() const; unsigned int nphiHits() const;
/** number of holes on the track */ /** number of eta trigger hits on the track */
unsigned int nholes() const; unsigned int noutliers() const;
/** number of holes on the track */ /** number of holes on the track */
unsigned int ncloseHits() const; unsigned int nholes() const;
/** number of scattering centres on the track */ /** number of holes on the track */
unsigned int nscatterers() const { return m_nscatterers; } unsigned int ncloseHits() const;
/** number of pseudo measurements on the track */ /** number of scattering centres on the track */
unsigned int npseudoMeasurements() const { return m_npseudoMeasurements; } unsigned int nscatterers() const { return m_nscatterers; }
/** access to the vector of chamber hit summaries on the track */ /** number of pseudo measurements on the track */
const std::vector<ChamberHitSummary>& chamberHitSummary() const { return m_chamberHitSummary; } unsigned int npseudoMeasurements() const { return m_npseudoMeasurements; }
private: /** access to the vector of chamber hit summaries on the track */
friend class ::MuonTrackSummaryCnv_p1; const std::vector<ChamberHitSummary>& chamberHitSummary() const { return m_chamberHitSummary; }
friend class ::MuonTrackSummaryCnv_p2;
friend class ::TrackSummaryCnv_p2;
unsigned int m_nscatterers; //<! number of scattering centres on the track private:
unsigned int m_npseudoMeasurements; //<! number of pseudomeasurements on the track friend class ::MuonTrackSummaryCnv_p1;
std::vector<ChamberHitSummary> m_chamberHitSummary; //<! vector with chamber hit summaries friend class ::MuonTrackSummaryCnv_p2;
friend class ::TrackSummaryCnv_p2;
}; unsigned int m_nscatterers; //<! number of scattering centres on the track
unsigned int m_npseudoMeasurements; //<! number of pseudomeasurements on the track
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() {