11#include "Acts/Surfaces/PlaneSurface.hpp"
12#include "Acts/Definitions/Units.hpp"
13#include "Acts/Geometry/GeometryIdentifier.hpp"
14#include "Acts/Surfaces/Surface.hpp"
16using namespace Acts::UnitLiterals;
20 constexpr float inDeg(
const float rad) {
21 return rad / 1._degree;
38 std::vector<unsigned short>>>(
m_tree.tree(),
40 std::vector<unsigned short> idx{};
47 m_truthTrks->addVariable(
49 std::format(
"{:}_nTruthSegments", m_truthTrks->name()), [&] (
const xAOD::TruthParticle& p) ->
unsigned short {
50 return getTruthSegments(p).size();
53 m_tree.addBranch(m_truthTrks);
55 const std::string segName =
"Segments";
56 m_segmentBranches = std::make_unique<MuonPRDTest::SegmentVariables>(m_tree, m_segmentKey.key(),
59 m_segmentFrames = std::make_unique<MuonVal::CoordSystemsBranch>(m_tree, std::format(
"{:}_localToGlobal", segName));
60 m_tree.addBranch(m_segmentFrames);
62 std::format(
"{:}_truthLink", segName),[
this](
const SG::AuxElement* aux){
65 m_truthTrks->push_back(truthP);
66 unsigned short linkIdx = m_truthTrks->find(truthP);
71 std::vector<Acts::GeometryIdentifier::Value>>>(m_tree,
72 std::format(
"{:}_hitGeoIds", segName),[
this](
const SG::AuxElement* aux){
74 std::vector<Acts::GeometryIdentifier::Value> geoIds{};
76 geoIds.push_back(getSurface(hit->identify()).geometryId().value());
78 std::ranges::sort(geoIds);
83 std::vector<float>>>(m_tree,
84 std::format(
"{:}_localSegPars", segName),[](
const SG::AuxElement* aux){
88 std::vector<float> ret{
pars.begin(),
pars.end()};
89 ret[Acts::toUnderlying(ParamDefs::phi)] =
inDeg(ret[Acts::toUnderlying(ParamDefs::phi)]);
90 ret[Acts::toUnderlying(ParamDefs::theta)] =
inDeg(ret[Acts::toUnderlying(ParamDefs::theta)]);
94 m_tree.addBranch(m_segmentBranches);
96 return StatusCode::SUCCESS;
109 return StatusCode::SUCCESS;
113 return StatusCode::SUCCESS;
118 re->measurementHash(simHitId) :
re->layerHash(simHitId);
119 return re->surface(surfHash);
#define ATH_CHECK
Evaluate an expression and check for errors.
const ServiceHandle< StoreGateSvc > & detStore() const
StatusCode addVariable(const std::string &name, T *&ptr, const std::string &docstring="")
Add a variable to the tuple.
This is a "hash" representation of an Identifier.
MuonReadoutElement is an abstract class representing the geometry of a muon detector.
virtual StatusCode initialize() override final
virtual StatusCode execute(const EventContext &ctx) override final
Execute method.
virtual StatusCode finalize() override final
std::shared_ptr< MuonVal::IParticleFourMomBranch > m_truthTrks
The pointer to the associated truth particles.
SG::ReadHandleKey< xAOD::MuonSegmentContainer > m_segmentKey
Data dependency on the truth segment container.
PublicToolHandle< ActsTrk::ITrackingGeometryTool > m_trackingGeometryTool
The tool handle of the tracking geometry tool.
std::shared_ptr< MuonVal::CoordSystemsBranch > m_segmentFrames
Pointer to the associated track vari.
MuonVal::ScalarBranch< std::uint32_t > & m_eventId
The event number in this event.
const MuonGMR4::MuonDetectorManager * m_detMgr
The muon detector manager.
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Service handle towards the IdHelper svc.
MuonVal::MuonTesterTree m_tree
instance to the Event tree
std::shared_ptr< MuonPRDTest::SegmentVariables > m_segmentBranches
The pointer to the segment variables.
const Acts::Surface & getSurface(const Identifier &simHitId) const
Retrieves the surface associated with a sim hit identifier.
SG::ReadDecorHandleKey< xAOD::MuonSegmentContainer > m_truthLinkKey
Data dependency on the truth particle link.
Generic branch object where the information is evaluated by a std::function instead reading it from t...
::Muon::MuonStationIndex::ChIndex chamberIndex() const
Returns the chamber index.
int etaIndex() const
Returns the eta index, which corresponds to stationEta in the offline identifiers (and the ).
ID3PD * m_tree
Pointer to the ID3PD object used.
Parameters localSegmentPars(const xAOD::MuonSegment &seg)
Returns the localSegPars decoration from a xAODMuon::Segment.
This header ties the generic definitions in this package.
const xAOD::TruthParticle * getTruthMatchedParticle(const xAOD::MuonSegment &segment)
Returns the particle truth-matched to the segment.
std::unordered_set< const xAOD::MuonSimHit * > getMatchingSimHits(const xAOD::MuonSegment &segment)
: Returns all sim hits matched to a xAOD::MuonSegment
std::vector< const xAOD::MuonSegment * > getTruthSegments(const xAOD::TruthParticle &truthMuon)
Returns the segments associated to the truth muon.
Lightweight algorithm to read xAOD MDT sim hits and (fast-digitised) drift circles from SG and fill a...
constexpr float inDeg(const float rad)
Class to store array like branches into the n-tuples.
AuxElement(SG::AuxVectorData *container, size_t index)
Base class for elements of a container that can have aux data.
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
MuonSegmentContainer_v1 MuonSegmentContainer
Definition of the current "MuonSegment container version".
MuonSimHit_v1 MuonSimHit
Defined the version of the MuonSimHit.
TruthParticle_v1 TruthParticle
Typedef to implementation.
MuonSegment_v1 MuonSegment
Reference the current persistent version: