ATLAS Offline Software
Loading...
Searching...
No Matches
Muon::MuonSegmentConverterTool Class Reference

#include <MuonSegmentConverterTool.h>

Inheritance diagram for Muon::MuonSegmentConverterTool:
Collaboration diagram for Muon::MuonSegmentConverterTool:

Public Member Functions

 MuonSegmentConverterTool (const std::string &, const std::string &, const IInterface *)
 default AlgTool constructor
 ~MuonSegmentConverterTool ()=default
 destructor
StatusCode initialize ()
 initialize method, method taken from bass-class AlgTool
xAOD::MuonSegmentconvert (const ElementLink< ::Trk::SegmentCollection > &segLink, xAOD::MuonSegmentContainer *container=0) const
 convert a ElementLink to a Trk::Segment (should be of type MuonSegment) to a xAOD::MuonSegment, the segment is add to the container if provided so the caller should not delete it
xAOD::MuonSegmentconvert (const MuonSegment &seg, xAOD::MuonSegmentContainer *container=0) const
 convert a Muon::MuonSegment to a xAOD::MuonSegment, the segment is add to the container if provided so the caller should not delete it

Private Member Functions

void addClusterTiming (const MuonSegment &seg, xAOD::MuonSegment &xaodSeg) const
 helper function to dress output segment with cluster hit timing information

Private Attributes

ToolHandle< IMuonSegmentHitSummaryToolm_hitSummaryTool
ToolHandle< IMuonHitTimingToolm_hitTimingTool
ServiceHandle< Muon::IMuonIdHelperSvcm_idHelperSvc
ServiceHandle< IMuonEDMHelperSvcm_edmHelper

Detailed Description

Definition at line 25 of file MuonSegmentConverterTool.h.

Constructor & Destructor Documentation

◆ MuonSegmentConverterTool()

Muon::MuonSegmentConverterTool::MuonSegmentConverterTool ( const std::string & t,
const std::string & n,
const IInterface * p )

default AlgTool constructor

Definition at line 25 of file MuonSegmentConverterTool.cxx.

26 : base_class(t, n, p) {}

◆ ~MuonSegmentConverterTool()

Muon::MuonSegmentConverterTool::~MuonSegmentConverterTool ( )
default

destructor

Member Function Documentation

◆ addClusterTiming()

void Muon::MuonSegmentConverterTool::addClusterTiming ( const MuonSegment & seg,
xAOD::MuonSegment & xaodSeg ) const
private

helper function to dress output segment with cluster hit timing information

Definition at line 62 of file MuonSegmentConverterTool.cxx.

63{
64
65 // loop over hits and extract clusters
66 std::vector<const MuonClusterOnTrack*> clusters;
67 for (const Trk::MeasurementBase* meas : seg.containedMeasurements()) {
68
69 // get Identifier and remove MDT hits
70 Identifier id = m_edmHelper->getIdentifier(*meas);
71 if (!id.is_valid() || !m_idHelperSvc->isTrigger(id)) continue;
72
73 // cast to MuonClusterOnTrack
74 const MuonClusterOnTrack* clus = dynamic_cast<const MuonClusterOnTrack*>(meas);
75 if (clus)
76 clusters.push_back(clus);
77 else {
78 const CompetingMuonClustersOnTrack* crot = dynamic_cast<const CompetingMuonClustersOnTrack*>(meas);
79 if (!crot){
80 continue;
81 }
82 std::ranges::transform(crot->containedROTs(), std::back_inserter(clusters),
83 [](const auto& rot) { return rot.get();});
84 }
85 }
86
87 // call timing tool and dress xaodSeg
88 IMuonHitTimingTool::TimingResult result = m_hitTimingTool->calculateTimingResult(clusters);
89 if (std::abs(result.time) > std::numeric_limits<float>::max()
90 || std::abs(result.error) > std::numeric_limits<float>::max())
91 {
92 // xAOD stores this as a float. To avoid FPE, we need to check here...
93 if (result.valid)
94 ATH_MSG_WARNING("Unphysical time returned by tool - ignoring. result.valid = "
95 + std::to_string(result.valid));
96 acc_clusterTime(xaodSeg) = std::numeric_limits<float>::max();
97 acc_clusterTimeError(xaodSeg) = std::numeric_limits<float>::max();
98 acc_clusterTimeValid(xaodSeg) = 0;
99 } else {
100 acc_clusterTime(xaodSeg) = result.time;
101 acc_clusterTimeError(xaodSeg) = result.error;
102 acc_clusterTimeValid(xaodSeg) = result.valid;
103 }
104}
#define ATH_MSG_WARNING(x)
ToolHandle< IMuonHitTimingTool > m_hitTimingTool
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
ServiceHandle< IMuonEDMHelperSvc > m_edmHelper
const std::vector< const Trk::MeasurementBase * > & containedMeasurements() const
returns the vector of Trk::MeasurementBase objects

◆ convert() [1/2]

xAOD::MuonSegment * Muon::MuonSegmentConverterTool::convert ( const ElementLink< ::Trk::SegmentCollection > & segLink,
xAOD::MuonSegmentContainer * container = 0 ) const

convert a ElementLink to a Trk::Segment (should be of type MuonSegment) to a xAOD::MuonSegment, the segment is add to the container if provided so the caller should not delete it

Definition at line 40 of file MuonSegmentConverterTool.cxx.

42{
43 // sanity checks
44 if (!segLink.isValid() || !*segLink) {
45 ATH_MSG_WARNING(" Got invalid element link");
46 return nullptr;
47 }
48 const MuonSegment* seg = dynamic_cast<const MuonSegment*>(*segLink);
49 if (!seg) {
50 ATH_MSG_WARNING(" Trk::Segment is not a MuonSegment ");
51 return nullptr;
52 }
53
54 // create xAOD::Muon and set link
55 xAOD::MuonSegment* xaodSeg = convert(*seg, container);
56 if (xaodSeg) xaodSeg->setMuonSegment(segLink);
57 return xaodSeg;
58}
MuonSegment_v1 MuonSegment
Reference the current persistent version:
xAOD::MuonSegment * convert(const ElementLink< ::Trk::SegmentCollection > &segLink, xAOD::MuonSegmentContainer *container=0) const
convert a ElementLink to a Trk::Segment (should be of type MuonSegment) to a xAOD::MuonSegment,...
void setMuonSegment(const ElementLink< ::Trk::SegmentCollection > &segment)
MuonSegment_v1 MuonSegment
Reference the current persistent version:

◆ convert() [2/2]

xAOD::MuonSegment * Muon::MuonSegmentConverterTool::convert ( const MuonSegment & seg,
xAOD::MuonSegmentContainer * container = 0 ) const

convert a Muon::MuonSegment to a xAOD::MuonSegment, the segment is add to the container if provided so the caller should not delete it

NSW

Definition at line 108 of file MuonSegmentConverterTool.cxx.

109{
110
111 // create xAOD::MuonSegment
112 xAOD::MuonSegment* xaodSeg = new xAOD::MuonSegment();
113 if (container)
114 container->push_back(xaodSeg);
115 else
116 xaodSeg->makePrivateStore();
117
118 // set position and direction
119 xaodSeg->setPosition(seg.globalPosition().x(), seg.globalPosition().y(), seg.globalPosition().z());
120 xaodSeg->setDirection(seg.globalDirection().x(), seg.globalDirection().y(), seg.globalDirection().z());
121
122 // fit chi2
123 const Trk::FitQuality* fq = seg.fitQuality();
124 if (fq) xaodSeg->setFitQuality(fq->chiSquared(), fq->numberDoF());
125
126 // identifier
127 Identifier id = m_edmHelper->chamberId(seg);
128 int eta = m_idHelperSvc->stationEta(id);
129 int sector = m_idHelperSvc->sector(id);
131 MuonStationIndex::TechnologyIndex technology = m_idHelperSvc->technologyIndex(id);
132 xaodSeg->setIdentifier(sector, chIndex, eta, technology);
133
134 // hit counts
135 IMuonSegmentHitSummaryTool::HitCounts hitCounts = m_hitSummaryTool->getHitCounts(seg);
136 xaodSeg->setNHits(hitCounts.nmdtHits()+ hitCounts.nmmHits() + hitCounts.nstgcHits.netaHits + hitCounts.ncscHits.netaHits,
137 hitCounts.nphiTrigHitLayers + hitCounts.nstgcHits.nphiHits, hitCounts.netaTrigHitLayers);
138
139 // MDT + cluster timing
140 if (seg.hasFittedT0()) xaodSeg->setT0Error(seg.time(), seg.errorTime());
141 if (!m_hitTimingTool.empty()) addClusterTiming(seg, *xaodSeg);
143 if (m_idHelperSvc->hasMM()) {
144 acc_mmStereoHits(*xaodSeg) = hitCounts.nmmStereoHits;
145 acc_mmEtaHits(*xaodSeg) = hitCounts.nmmEtaHits;
146 }
147 if (m_idHelperSvc->hasSTGC()) {
148 acc_stgcEtaHits(*xaodSeg) = hitCounts.nstgcHits.netaHits;
149 acc_stgcPhiHits(*xaodSeg) = hitCounts.nstgcHits.nphiHits;
150 }
151 return xaodSeg;
152}
Scalar eta() const
pseudorapidity method
bool hasFittedT0() const
returns whether the segment has a fitted t0
virtual const Amg::Vector3D & globalPosition() const override final
global position
void addClusterTiming(const MuonSegment &seg, xAOD::MuonSegment &xaodSeg) const
helper function to dress output segment with cluster hit timing information
ToolHandle< IMuonSegmentHitSummaryTool > m_hitSummaryTool
int numberDoF() const
returns the number of degrees of freedom of the overall track or vertex fit as integer
Definition FitQuality.h:60
double chiSquared() const
returns the of the overall track fit
Definition FitQuality.h:56
const FitQuality * fitQuality() const
return the FitQuality object, returns NULL if no FitQuality is defined
float errorTime() const
access to the error on the measured time
float time() const
access to the measured time
void setDirection(float px, float py, float pz)
Sets the direction.
void setFitQuality(float chiSquared, float numberDoF)
Set the 'Fit Quality' information.
void setNHits(int nPrecisionHits, int nPhiLayers, int nTrigEtaLayers)
Set the number of hits/layers.
void setT0Error(float t0, float t0Error)
Sets the time error.
void setIdentifier(int sector, ::Muon::MuonStationIndex::ChIndex chamberIndex, int etaIndex, ::Muon::MuonStationIndex::TechnologyIndex technology)
Set the identifier.
void setPosition(float x, float y, float z)
Sets the global position.
ChIndex chIndex(const std::string &index)
convert ChIndex name string to enum
TechnologyIndex
enum to classify the different layers in the muon spectrometer
ChIndex
enum to classify the different chamber layers in the muon spectrometer
const SG::AuxVectorData * container() const
Return the container holding this element.

◆ initialize()

StatusCode Muon::MuonSegmentConverterTool::initialize ( )

initialize method, method taken from bass-class AlgTool

Definition at line 29 of file MuonSegmentConverterTool.cxx.

30{
31 ATH_CHECK(m_hitSummaryTool.retrieve());
32 ATH_CHECK(m_idHelperSvc.retrieve());
33 ATH_CHECK(m_edmHelper.retrieve());
34 ATH_CHECK(m_hitTimingTool.retrieve());
35
36 return StatusCode::SUCCESS;
37}
#define ATH_CHECK
Evaluate an expression and check for errors.

Member Data Documentation

◆ m_edmHelper

ServiceHandle<IMuonEDMHelperSvc> Muon::MuonSegmentConverterTool::m_edmHelper
private
Initial value:
{
this,
"edmHelper",
"Muon::MuonEDMHelperSvc/MuonEDMHelperSvc",
"Handle to the service providing the IMuonEDMHelperSvc interface",
}

Definition at line 64 of file MuonSegmentConverterTool.h.

64 {
65 this,
66 "edmHelper",
67 "Muon::MuonEDMHelperSvc/MuonEDMHelperSvc",
68 "Handle to the service providing the IMuonEDMHelperSvc interface",
69 };

◆ m_hitSummaryTool

ToolHandle<IMuonSegmentHitSummaryTool> Muon::MuonSegmentConverterTool::m_hitSummaryTool
private
Initial value:
{
this,
"MuonSegmentHitSummaryTool",
"Muon::MuonSegmentHitSummaryTool/MuonSegmentHitSummaryTool",
}

Definition at line 49 of file MuonSegmentConverterTool.h.

49 {
50 this,
51 "MuonSegmentHitSummaryTool",
52 "Muon::MuonSegmentHitSummaryTool/MuonSegmentHitSummaryTool",
53 };

◆ m_hitTimingTool

ToolHandle<IMuonHitTimingTool> Muon::MuonSegmentConverterTool::m_hitTimingTool
private
Initial value:
{
this,
"MuonHitTimingTool",
"Muon::MuonHitTimingTool/MuonHitTimingTool",
}

Definition at line 54 of file MuonSegmentConverterTool.h.

54 {
55 this,
56 "MuonHitTimingTool",
57 "Muon::MuonHitTimingTool/MuonHitTimingTool",
58 };

◆ m_idHelperSvc

ServiceHandle<Muon::IMuonIdHelperSvc> Muon::MuonSegmentConverterTool::m_idHelperSvc
private
Initial value:
{
this,
"MuonIdHelperSvc",
"Muon::MuonIdHelperSvc/MuonIdHelperSvc",
}

Definition at line 59 of file MuonSegmentConverterTool.h.

59 {
60 this,
61 "MuonIdHelperSvc",
62 "Muon::MuonIdHelperSvc/MuonIdHelperSvc",
63 };

The documentation for this class was generated from the following files: