20#include <unordered_map>
24struct LocalSegSorter {
27 if (
a == b)
return false;
28 if (
a->chamberIndex() !=
b->chamberIndex())
29 return a->chamberIndex() <
b->chamberIndex();
30 if (
a->sector() !=
b->sector())
31 return a->sector() <
b->sector();
32 if (
a->etaIndex() !=
b->etaIndex())
33 return a->etaIndex() <
b->etaIndex();
34 using namespace MuonR4::SegmentFit;
55 m_tree.addBranch(std::make_shared<MuonVal::EventHashBranch>(
m_tree.tree()));
57 return StatusCode::SUCCESS;
62 return StatusCode::SUCCESS;
66 const EventContext& ctx{Gaudi::Hive::currentContext()};
68 using SegmentsPerBucket_t =
70 std::set<const xAOD::MuonSegment*, LocalSegSorter>>;
84 SegmentsPerBucket_t segPerBucket{};
88 segPerBucket[detSeg->parent()->parentBucket()].insert(seg);
98 const auto it = segPerBucket.find(bucket);
99 m_bucket_segments = (it != segPerBucket.end()) ?
static_cast<uint16_t
>(it->second.size()) : 0;
100 if (it != segPerBucket.end()) {
110 float segEta =
static_cast<float>(globDir.eta());
111 float segPhi =
static_cast<float>(globDir.phi());
116 int32_t truthIdx = -1;
117 int32_t truthPdg = -1;
120 truthIdx =
static_cast<int32_t
>(tp->index());
121 truthPdg =
static_cast<int32_t
>(tp->pdgId());
140 return StatusCode::FAILURE;
145 return StatusCode::SUCCESS;
150 std::vector<unsigned int> uniqueLayers;
151 uniqueLayers.reserve(bucket.size());
153 for (
const SpacePointBucket::value_type&
sp : bucket) {
154 const unsigned layNum = sorter.sectorLayerNum(*
sp);
155 if (std::find(uniqueLayers.begin(), uniqueLayers.end(), layNum) == uniqueLayers.end()) {
156 uniqueLayers.push_back(layNum);
159 return static_cast<uint16_t
>(uniqueLayers.size());
#define ATH_CHECK
Evaluate an expression and check for errors.
Handle class for reading from StoreGate.
MuonVal::ThreeVectorBranch m_segmentPos
MuonVal::VectorBranch< float > & m_segment_numberDoF
SG::ReadDecorHandleKeyArray< xAOD::MuonSegmentContainer > m_truthDecorKeys
Truth decoration (MC)
MuonVal::VectorBranch< float > & m_segmentTruthPhi
MuonVal::VectorBranch< float > & m_segmentTruthEta
SG::ReadHandleKeyArray< SpacePointContainer > m_spacePointKeys
Inputs.
SG::ReadHandleKey< xAOD::MuonSegmentContainer > m_segmentKeys
MuonVal::VectorBranch< float > & m_segmentTruthPt
MuonVal::ScalarBranch< uint16_t > & m_bucket_spacePoints
MuonVal::MuonTesterTree m_tree
Output tree.
MuonVal::VectorBranch< float > & m_segmentRecoEta
MuonVal::ScalarBranch< uint16_t > & m_bucket_segments
MuonVal::ScalarBranch< uint8_t > & m_bucket_chamberIdx
MuonVal::VectorBranch< int32_t > & m_segmentTruthPDGId
SG::ReadHandleKey< ActsTrk::GeometryContext > m_geoCtxKey
uint16_t countLayersInBucket(const SpacePointBucket &bucket) const
MuonVal::ScalarBranch< uint8_t > & m_bucket_sector
MuonVal::VectorBranch< float > & m_segmentRecoPhi
StatusCode finalize() override final
MuonVal::VectorBranch< uint8_t > & m_segmentHasTruth
StatusCode initialize() override final
StatusCode execute() override final
MuonVal::VectorBranch< float > & m_segment_chiSquared
MuonVal::VectorBranch< int32_t > & m_segmentTruthIdx
MuonVal::ThreeVectorBranch m_segmentDir
MuonVal::ScalarBranch< uint16_t > & m_bucket_layers
: The muon space point bucket represents a collection of points that will bre processed together in t...
The SpacePointPerLayerSorter sort two given space points by their layer Identifier.
float numberDoF() const
Returns the numberDoF.
Amg::Vector3D direction() const
Returns the direction as Amg::Vector.
Amg::Vector3D position() const
Returns the position as Amg::Vector.
Eigen::Matrix< double, 3, 1 > Vector3D
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.
DataVector< SpacePointBucket > SpacePointContainer
Abrivation of the space point container type.
const Segment * detailedSegment(const xAOD::MuonSegment &seg)
Helper function to navigate from the xAOD::MuonSegment to the MuonR4::Segment.
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".
TruthParticle_v1 TruthParticle
Typedef to implementation.
MuonSegment_v1 MuonSegment
Reference the current persistent version: