ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
MuonSpectrometer
MuonReconstruction
MuonTrackMakers
MuonTrackMakerAlgs
MuonSegmentTrackMaker
src
MuPatTrackBuilder.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
MuPatTrackBuilder.h
"
6
7
#include <vector>
8
9
#include "
MuonRecHelperTools/IMuonEDMHelperSvc.h
"
10
#include "
MuonSegment/MuonSegment.h
"
11
#include "
Particle/TrackParticleContainer.h
"
12
#include "
TrkSegment/SegmentCollection.h
"
13
#include "
TrkTrack/Track.h
"
14
#include "
TrkTrack/TrackCollection.h
"
15
#include "
TrkTrack/TrackStateOnSurface.h
"
16
17
using namespace
Muon
;
18
MuPatTrackBuilder::MuPatTrackBuilder
(
const
std::string& name, ISvcLocator* pSvcLocator):
19
AthReentrantAlgorithm
(name,pSvcLocator) {
20
21
}
22
StatusCode
MuPatTrackBuilder::initialize
() {
23
ATH_CHECK
(
m_trackMaker
.retrieve());
24
ATH_CHECK
(
m_edmHelperSvc
.retrieve());
25
ATH_MSG_DEBUG
(
"Retrieved "
<<
m_trackMaker
);
26
27
ATH_CHECK
(
m_segmentKey
.initialize());
28
ATH_CHECK
(
m_spectroTrackKey
.initialize());
29
30
if
(!
m_monTool
.name().empty()) {
ATH_CHECK
(
m_monTool
.retrieve()); }
31
32
return
StatusCode::SUCCESS;
33
}
34
35
StatusCode
MuPatTrackBuilder::execute
(
const
EventContext& ctx)
const
{
36
typedef
std::vector<const Muon::MuonSegment*>
MuonSegmentCollection
;
37
38
SG::ReadHandle<Trk::SegmentCollection>
segmentColl(
m_segmentKey
, ctx);
39
if
(!segmentColl.
isValid
()) {
40
ATH_MSG_WARNING
(
"Could not find MuonSegmentCollection at "
<< segmentColl.
name
());
41
return
StatusCode::FAILURE;
42
}
43
44
if
(!segmentColl.
cptr
()) {
45
ATH_MSG_WARNING
(
"Obtained zero pointer for MuonSegmentCollection at "
<< segmentColl.
name
());
46
return
StatusCode::FAILURE;
47
;
48
}
49
50
ATH_MSG_DEBUG
(
"Retrieved MuonSegmentCollection "
<< segmentColl->size());
51
52
MuonSegmentCollection
msc;
53
msc.reserve(segmentColl->size());
54
for
(
const
Trk::Segment
* seg : *segmentColl) {
55
if
(!seg)
continue
;
56
const
Muon::MuonSegment
* ms =
dynamic_cast<
const
Muon::MuonSegment
*
>
(seg);
57
if
(ms) msc.push_back(ms);
58
}
59
60
if
(msc.size() != segmentColl->size()) {
61
ATH_MSG_WARNING
(
"Input segment collection (size "
<< segmentColl->size() <<
") and translated MuonSegment collection (size "
62
<< msc.size() <<
") are not the same size."
);
63
}
64
65
std::unique_ptr<TrackCollection> newtracks{
m_trackMaker
->find(ctx, msc)};
66
if
(!newtracks) newtracks = std::make_unique<TrackCollection>();
67
SG::WriteHandle<TrackCollection>
spectroTracks(
m_spectroTrackKey
, ctx);
68
//---------------------------------------------------------------------------------------------------------------------//
69
//------------ Monitoring of muon segments and tracks inside the trigger algs ------------//
70
//------------ Author: Laurynas Mince ------------//
71
//------------ Created: 03.10.2019 ------------//
72
//---------------------------------------------------------------------------------------------------------------------//
73
74
// Only run monitoring for online algorithms
75
if
(not
m_monTool
.name().empty()) {
76
auto
mstrks_n =
Monitored::Scalar<int>
(
"mstrks_n"
, newtracks->size());
77
auto
mstrks_pt =
Monitored::Collection
(
"mstrks_pt"
, *newtracks, [](
auto
const
& mstrk) {
78
return
mstrk->perigeeParameters()->momentum().perp() / 1000.0;
79
});
// pT converted to GeV
80
auto
mstrks_eta =
Monitored::Collection
(
"mstrks_eta"
, *newtracks, [](
auto
const
& mstrk) {
81
return
-log(tan(mstrk->perigeeParameters()->parameters()[
Trk::theta
] * 0.5));
82
});
83
auto
mstrks_phi =
Monitored::Collection
(
"mstrks_phi"
, *newtracks,
84
[](
auto
const
& mstrk) {
return
mstrk->perigeeParameters()->parameters()[
Trk::phi0
]; });
85
auto
mssegs_n =
Monitored::Scalar<int>
(
"mssegs_n"
, msc.size());
86
auto
mssegs_eta =
Monitored::Collection
(
"mssegs_eta"
, msc, [](
auto
const
& seg) {
return
seg->globalPosition().eta(); });
87
auto
mssegs_phi =
Monitored::Collection
(
"mssegs_phi"
, msc, [](
auto
const
& seg) {
return
seg->globalPosition().phi(); });
88
89
auto
monitorIt =
Monitored::Group
(
m_monTool
, mstrks_n, mstrks_pt, mstrks_eta, mstrks_phi, mssegs_n, mssegs_eta, mssegs_phi);
90
}
91
const
auto
nTracks = newtracks->size();
92
ATH_CHECK
(spectroTracks.
record
(std::move(newtracks)));
93
ATH_MSG_DEBUG
(
"TrackCollection '"
<<
m_spectroTrackKey
.key() <<
"' recorded in storegate, ntracks: "
<< nTracks);
94
return
StatusCode::SUCCESS;
95
}
// execute
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
IMuonEDMHelperSvc.h
MuPatTrackBuilder.h
MuonSegment.h
TrackParticleContainer.h
SegmentCollection.h
TrackCollection.h
TrackStateOnSurface.h
Track.h
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition
AthReentrantAlgorithm.h:74
Monitored::Group
Group of local monitoring quantities and retain correlation when filling histograms
Definition
MonitoredGroup.h:53
Monitored::Scalar
Declare a monitored scalar variable.
Definition
MonitoredScalar.h:34
MuPatTrackBuilder::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition
MuPatTrackBuilder.cxx:35
MuPatTrackBuilder::m_edmHelperSvc
ServiceHandle< Muon::IMuonEDMHelperSvc > m_edmHelperSvc
helper Tool
Definition
MuPatTrackBuilder.h:33
MuPatTrackBuilder::MuPatTrackBuilder
MuPatTrackBuilder(const std::string &name, ISvcLocator *pSvcLocator)
Definition
MuPatTrackBuilder.cxx:18
MuPatTrackBuilder::m_spectroTrackKey
SG::WriteHandleKey< TrackCollection > m_spectroTrackKey
Track output Key for tracks strictly in MS.
Definition
MuPatTrackBuilder.h:29
MuPatTrackBuilder::m_segmentKey
SG::ReadHandleKey< Trk::SegmentCollection > m_segmentKey
Key of input MuonSegmentCombination collection.
Definition
MuPatTrackBuilder.h:27
MuPatTrackBuilder::initialize
virtual StatusCode initialize() override
Definition
MuPatTrackBuilder.cxx:22
MuPatTrackBuilder::m_monTool
ToolHandle< GenericMonitoringTool > m_monTool
Definition
MuPatTrackBuilder.h:38
MuPatTrackBuilder::m_trackMaker
ToolHandle< Muon::IMuonTrackFinder > m_trackMaker
Actual tool to do the track finding.
Definition
MuPatTrackBuilder.h:31
Muon::MuonSegment
This is the common class for 3D segments used in the muon spectrometer.
Definition
MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonSegment/MuonSegment/MuonSegment.h:45
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
SG::ReadHandle::cptr
const_pointer_type cptr()
Dereference the pointer.
SG::VarHandleBase::name
const std::string & name() const
Return the StoreGate ID for the referenced object.
Definition
AthToolSupport/AsgDataHandles/Root/VarHandleBase.cxx:75
SG::WriteHandle
Definition
StoreGate/StoreGate/WriteHandle.h:73
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
Trk::Segment
Base class for all TrackSegment implementations, extends the common MeasurementBase.
Definition
Tracking/TrkEvent/TrkSegment/TrkSegment/Segment.h:56
Monitored::Collection
ValuesCollection< T > Collection(std::string name, const T &collection)
Declare a monitored (double-convertible) collection.
Definition
MonitoredCollection.h:38
Muon
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
Definition
TrackSystemController.h:46
Muon::MuonSegmentCollection
std::vector< const Muon::MuonSegment * > MuonSegmentCollection
Definition
MuonTrackSteering.h:44
Trk::phi0
@ phi0
Definition
ParamDefs.h:65
Trk::theta
@ theta
Definition
ParamDefs.h:66
Generated on
for ATLAS Offline Software by
1.17.0