Commit ad2b0557 authored by Christos Anastopoulos's avatar Christos Anastopoulos Committed by Frank Winklmeier
Browse files

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

parent dcd82ebd
......@@ -559,7 +559,7 @@ InDet::InDetTrackSummaryHelperTool::addDetailedTrackSummary(
return;
}
ATH_MSG_DEBUG("Adding detailed indet track summary");
delete summary.m_indetTrackSummary;
summary.m_indetTrackSummary.reset();
Trk::InDetTrackSummary* indetTrackSummary = new Trk::InDetTrackSummary();
Trk::InDetTrackSummary& trackSummary = *indetTrackSummary;
if (m_usePixel and not m_pixeldedxtool.empty() and
......@@ -582,7 +582,7 @@ InDet::InDetTrackSummaryHelperTool::addDetailedTrackSummary(
m_pixeldedxtool->getMass(ctx, dedx, p, ngoodhits);
}
}
summary.m_indetTrackSummary = indetTrackSummary;
summary.m_indetTrackSummary.reset(indetTrackSummary);
}
StatusCode
......
......@@ -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
if (currentChamberSummary && !currentChamberSummary->isMdt()) { updateHoleContent(*currentChamberSummary); }
summary.m_muonTrackSummary = muonTrackSummary;
summary.m_muonTrackSummary.reset(muonTrackSummary);
}
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
......@@ -11,45 +11,52 @@ class MsgStream;
class InDetTrackSummaryCnv_p1;
class TrackSummaryCnv_p2;
namespace InDet {
class InDetTrackSummaryHelperTool;
class InDetTrackSummaryHelperTool;
}
namespace Trk {
/**
Detailed track summary for the indet system
*/
class InDetTrackSummary {
public:
friend class InDet::InDetTrackSummaryHelperTool;
friend class ::InDetTrackSummaryCnv_p1;
friend class ::TrackSummaryCnv_p2;
/** default constructor */
InDetTrackSummary();
/** destructor */
~InDetTrackSummary();
/** access to the vector of likelihoods (pion/kaon/proton) */
const std::vector<float>& likelihoodsPixeldEdx() const { return m_likelihoodspixeldedx; }
/** 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
};
/**
Detailed track summary for the indet system
*/
class InDetTrackSummary
{
public:
friend class InDet::InDetTrackSummaryHelperTool;
friend class ::InDetTrackSummaryCnv_p1;
friend class ::TrackSummaryCnv_p2;
/** default constructor */
InDetTrackSummary();
InDetTrackSummary(const InDetTrackSummary&) = default;
InDetTrackSummary(InDetTrackSummary&&) = default;
InDetTrackSummary& operator=(const InDetTrackSummary&) = default;
InDetTrackSummary& operator=(InDetTrackSummary&&) = default;
/** destructor */
~InDetTrackSummary() = default;
/** access to the vector of likelihoods (pion/kaon/proton) */
const std::vector<float>& likelihoodsPixeldEdx() const
{
return m_likelihoodspixeldedx;
}
/** 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*/
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*/
std::ostream& operator<<(std::ostream& out, const InDetTrackSummary& trackSum);
std::ostream&
operator<<(std::ostream& out, const InDetTrackSummary& trackSum);
}
#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
......@@ -12,155 +12,158 @@ class MuonTrackSummaryCnv_p1;
class MuonTrackSummaryCnv_p2;
class TrackSummaryCnv_p2;
namespace Muon {
class MuonTrackSummaryHelperTool;
class MuonTrackSummaryHelperTool;
}
namespace Trk {
/**
Detailed track summary for the muon system
Give access to hit counts per chamber.
*/
class MuonTrackSummary {
public:
/**
Detailed track summary for the muon system
Give access to hit counts per chamber.
*/
class MuonTrackSummary
{
public:
friend class Muon::MuonTrackSummaryHelperTool;
/** structure to hold information per chamber in the muon system */
struct ChamberHitSummary
{
friend class Muon::MuonTrackSummaryHelperTool;
/** structure to hold information per chamber in the muon system */
struct ChamberHitSummary {
friend class Muon::MuonTrackSummaryHelperTool;
/** structure to hold the information for the eta/phi projection of RPC, TGC and CSC
chambers and per multilayer for MDT chambers */
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() {}
int nhits{0}; //<! number of hits on track in the projection
int nholes{0}; //<! number of holes 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 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 noutBounds{0}; //<! number of out-of-bounds hits
};
int nhits{ 0 }; //<! number of hits on track in the projection
int nholes{ 0 }; //<! number of holes 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 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 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
(the boolean is passed as the ChamberHitSummary cannot unpack the identifier and it needs to know whether it is dealing
with a MDT chamber) */
ChamberHitSummary( Identifier chID, bool isMdtTube ) : m_chId(chID),m_isMdt(isMdtTube) {}
/** 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 with a MDT chamber) */
ChamberHitSummary(Identifier chID, bool isMdtTube)
: m_chId(chID)
, m_isMdt(isMdtTube)
{}
/** returns the chamber identifier */
const Identifier& chamberId() const { return m_chId; }
/** returns the chamber identifier */
const Identifier& chamberId() const { return m_chId; }
/** returns whether this is a MDT chamber */
bool isMdt() const { return m_isMdt; }
/** returns whether this is a MDT chamber */
bool isMdt() const { return m_isMdt; }
/** returns the total number of hits on track in the chamber */
int nhits() const { return m_first.nhits + m_second.nhits; }
/** returns the total number of hits on track in the chamber */
int nhits() const { return m_first.nhits + m_second.nhits; }
/** returns the total number of holes in the chamber */
int nholes() const { return m_first.nholes + m_second.nholes; }
/** returns the total number of holes in the chamber */
int nholes() const { return m_first.nholes + m_second.nholes; }
/** returns the total number of outliers in the chamber */
int noutliers() const { return m_first.noutliers + m_second.noutliers; }
/** returns the total number of outliers in the chamber */
int noutliers() const { return m_first.noutliers + m_second.noutliers; }
/** returns the total number of delta electrons in the chamber */
int ndeltas() const { return m_first.ndeltas + m_second.ndeltas; }
/** returns the total number of delta electrons in the chamber */
int ndeltas() const { return m_first.ndeltas + m_second.ndeltas; }
/** returns the total number of close hits in the chamber */
int ncloseHits() const { return m_first.ncloseHits + m_second.ncloseHits; }
/** returns the total number of close hits in the chamber */
int ncloseHits() const { return m_first.ncloseHits + m_second.ncloseHits; }
/** returns the number of non-deweighted hits in the chamber */
int ngoodHits() const { return m_first.ngoodHits + m_second.ngoodHits; }
/** returns the number of non-deweighted hits in the chamber */
int ngoodHits() const { return m_first.ngoodHits + m_second.ngoodHits; }
//returns the number of out of bounds hits
int noutBoundsHits() const { return m_first.noutBounds + m_second.noutBounds; }
// returns the number of out of bounds hits
int noutBoundsHits() const { return m_first.noutBounds + m_second.noutBounds; }
/** returns the total number of eta hits on track in the chamber */
int netaHits() const { return isMdt() ? nhits() : m_first.nhits; }
/** returns the total number of eta hits on track in the chamber */
int netaHits() const { return isMdt() ? nhits() : m_first.nhits; }
/** returns the total number of phi hits on track in the chamber */
int nphiHits() const { return isMdt() ? 0 : m_second.nhits; }
/** returns the total number of phi hits on track in the chamber */
int nphiHits() const { return isMdt() ? 0 : m_second.nhits; }
/** returns the total number of MDT hits on track in the first multi layer */
int nMdtHitsMl1() const { return isMdt() ? m_first.nhits : 0; }
/** returns the total number of MDT hits on track in the first multi layer */
int nMdtHitsMl1() const { return isMdt() ? m_first.nhits : 0; }
/** returns the total number of MDT hits on track in the second multi layer */
int nMdtHitsMl2() const { return isMdt() ? m_second.nhits : 0; }
/** returns the total number of MDT hits on track in the second multi layer */
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!! */
const Projection& mdtMl1() const { return m_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; }
/** 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; }
/** 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; }
/** 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; }
/** 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; }
/** 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; }
/** 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; }
private:
friend class ::MuonTrackSummaryCnv_p1;
friend class ::MuonTrackSummaryCnv_p2;
friend class ::TrackSummaryCnv_p2;
private:
friend class ::MuonTrackSummaryCnv_p1;
friend class ::MuonTrackSummaryCnv_p2;
friend class ::TrackSummaryCnv_p2;
Identifier m_chId{ 0 }; //<! chamber identifier
bool m_isMdt{ false }; //<! is this a MDT chamber
Identifier m_chId{0}; //<! chamber identifier
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_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 */
MuonTrackSummary();
/** default constructor */
MuonTrackSummary();
/** destructor */
~MuonTrackSummary();
/** number of eta hits on the track */
unsigned int netaHits() const;
/** destructor */
~MuonTrackSummary();
/** number of phi hits on the track */
unsigned int nphiHits() const;
/** number of eta hits on the track */
unsigned int netaHits() const;
/** number of eta trigger hits on the track */
unsigned int noutliers() const;
/** number of phi hits on the track */
unsigned int nphiHits() const;
/** number of holes on the track */
unsigned int nholes() const;
/** number of eta trigger hits on the track */
unsigned int noutliers() const;
/** number of holes on the track */
unsigned int ncloseHits() const;
/** number of holes on the track */
unsigned int nholes() const;
/** number of scattering centres on the track */
unsigned int nscatterers() const { return m_nscatterers; }
/** number of holes on the track */
unsigned int ncloseHits() const;
/** number of pseudo measurements on the track */
unsigned int npseudoMeasurements() const { return m_npseudoMeasurements; }
/** number of scattering centres on the track */
unsigned int nscatterers() const { return m_nscatterers; }
/** access to the vector of chamber hit summaries on the track */
const std::vector<ChamberHitSummary>& chamberHitSummary() const { return m_chamberHitSummary; }
/** number of pseudo measurements on the track */
unsigned int npseudoMeasurements() const { return m_npseudoMeasurements; }
private:
friend class ::MuonTrackSummaryCnv_p1;
friend class ::MuonTrackSummaryCnv_p2;
friend class ::TrackSummaryCnv_p2;
/** access to the vector of chamber hit summaries on the track */
const std::vector<ChamberHitSummary>& chamberHitSummary() const { return m_chamberHitSummary; }
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
private:
friend class ::MuonTrackSummaryCnv_p1;
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*/
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*/
std::ostream& operator<<(std::ostream& out, const MuonTrackSummary& trackSum);
std::ostream&
operator<<(std::ostream& out, const MuonTrackSummary& trackSum);
}
#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
Trk::TrackSummary::get(const Trk::SummaryType& type) const
......@@ -52,26 +52,25 @@ Trk::TrackSummary::isHit(const Trk::DetectorType& type) const
inline const Trk::InDetTrackSummary*
Trk::TrackSummary::indetTrackSummary() const
{
return m_indetTrackSummary;
return m_indetTrackSummary.get();
}
inline Trk::InDetTrackSummary*
Trk::TrackSummary::indetTrackSummary()
Trk::TrackSummary::indetTrackSummary()
{
return m_indetTrackSummary;
return m_indetTrackSummary.get();
}
inline const Trk::MuonTrackSummary*
Trk::TrackSummary::muonTrackSummary() const
{
return m_muonTrackSummary;
return m_muonTrackSummary.get();
}
inline Trk::MuonTrackSummary*
Trk::TrackSummary::muonTrackSummary()
{
return m_muonTrackSummary;
return m_muonTrackSummary.get();
}
inline unsigned long
......
......@@ -4,29 +4,35 @@
#include "TrkTrackSummary/InDetTrackSummary.h"
#include <iostream>
#include "GaudiKernel/MsgStream.h"
#include <iostream>
Trk::InDetTrackSummary::InDetTrackSummary() :
m_likelihoodspixeldedx(3,-1),
m_massdedx(-1){
}
Trk::InDetTrackSummary::~InDetTrackSummary() {
}
Trk::InDetTrackSummary::InDetTrackSummary()
: m_likelihoodspixeldedx(3, -1)
, m_massdedx(-1)
{}
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: mass calculated using pixel dEdx: " << trackSum.massPixeldEdx() << std::endl;
out << "InDetTrackSummary: likelihoods from pixel dEdx (pion/kaon/proton): "
<< trackSum.likelihoodsPixeldEdx()[0] << " "
<< trackSum.likelihoodsPixeldEdx()[1] << " "
<< trackSum.likelihoodsPixeldEdx()[2] << std::endl;
out << "InDetTrackSummary: mass calculated using pixel dEdx: "
<< trackSum.massPixeldEdx() << std::endl;
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: mass calculated using pixel dEdx: " << trackSum.massPixeldEdx() << endmsg;
out << "InDetTrackSummary: likelihoods from pixel dEdx (pion/kaon/proton): "
<< trackSum.likelihoodsPixeldEdx()[0] << " "
<< trackSum.likelihoodsPixeldEdx()[1] << " "
<< trackSum.likelihoodsPixeldEdx()[2] << endmsg;
out << "InDetTrackSummary: mass calculated using pixel dEdx: "
<< trackSum.massPixeldEdx() << endmsg;
return out;
}
......@@ -4,94 +4,137 @@
#include "TrkTrackSummary/MuonTrackSummary.h"
#include <iostream>
#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;
std::vector<ChamberHitSummary>::const_iterator it = m_chamberHitSummary.begin();
std::vector<ChamberHitSummary>::const_iterator it_end = m_chamberHitSummary.end();
for( ;it!=it_end; ++it ) count += it->netaHits();
std::vector<ChamberHitSummary>::const_iterator it =
m_chamberHitSummary.begin();
std::vector<ChamberHitSummary>::const_iterator it_end =
m_chamberHitSummary.end();
for (; it != it_end; ++it)
count += it->netaHits();
return count;
}
unsigned int Trk::MuonTrackSummary::nphiHits() const {
unsigned int
Trk::MuonTrackSummary::nphiHits() const
{
unsigned int count = 0;
std::vector<ChamberHitSummary>::const_iterator it = m_chamberHitSummary.begin();
std::vector<ChamberHitSummary>::const_iterator it_end = m_chamberHitSummary.end();
for( ;it!=it_end; ++it ) count += it->nphiHits();
std::vector<ChamberHitSummary>::const_iterator it =
m_chamberHitSummary.begin();
std::vector<ChamberHitSummary>::const_iterator it_end =
m_chamberHitSummary.end();
for (; it != it_end; ++it)
count += it->nphiHits();
return count;
}
unsigned int Trk::MuonTrackSummary::nholes() const {
unsigned int
Trk::MuonTrackSummary::nholes() const
{
unsigned int count = 0;
std::vector<ChamberHitSummary>::const_iterator it = m_chamberHitSummary.begin();
std::vector<ChamberHitSummary>::const_iterator it_end = m_chamberHitSummary.end();
for( ;it!=it_end; ++it ) count += it->nholes();
std::vector<ChamberHitSummary>::const_iterator it =
m_chamberHitSummary.begin();
std::vector<ChamberHitSummary>::const_iterator it_end =
m_chamberHitSummary.end();
for (; it != it_end; ++it)
count += it->nholes();
return count;
}
unsigned int Trk::MuonTrackSummary::noutliers() const {
unsigned int
Trk::MuonTrackSummary::noutliers() const
{
unsigned int count = 0;
std::vector<ChamberHitSummary>::const_iterator it = m_chamberHitSummary.begin();
std::vector<ChamberHitSummary>::const_iterator it_end = m_chamberHitSummary.end();
for( ;it!=it_end; ++it ) count += it->noutliers();
std::vector<ChamberHitSummary>::const_iterator it =
m_chamberHitSummary.begin();
std::vector<ChamberHitSummary>::const_iterator it_end =
m_chamberHitSummary.end();
for (; it != it_end; ++it)
count += it->noutliers();
return count;
}
unsigned int Trk::MuonTrackSummary::ncloseHits() const {
unsigned int
Trk::MuonTrackSummary::ncloseHits() const
{
unsigned int count = 0;
std::vector