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