ATLAS Offline Software
Loading...
Searching...
No Matches
SegmentVariables.cxx
Go to the documentation of this file.
1
2/*
3 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
4*/
8
9namespace MuonPRDTest {
11 const std::string& containerKey,
12 const std::string& outName,
13 MSG::Level msglvl) :
14 PrdTesterModule(tree, "Segments"+ containerKey+outName, msglvl),
15 m_key{containerKey},
16 m_name{outName}{
17
18 for (const auto summary : {"nPrecisionOutliers", "nTriggerPhiOutliers", "nTriggerEtaOutliers",
19 "nPrecisionHoles", "nTriggerPhiHoles", "nTriggerEtaHoles"}) {
20 auto br = std::make_unique<AuxElementBranch<std::uint8_t>>(tree, std::format("{:}_{:}", outName, summary), summary);
21 br->setDefault(0);
22 addVariable(std::move(br));
23 }
24 }
25
26 bool SegmentVariables::fill(const EventContext& ctx) {
27 SG::ReadHandle readHandle{m_key, ctx};
28 if(!readHandle.isPresent()) {
29 ATH_MSG_FATAL("Failed to retrieve "<<m_key.fullKey());
30 return false;
31 }
32 if (!m_filterMode) {
33 for (const xAOD::MuonSegment* segment : *readHandle){
34 fill(*segment);
35 }
36 }
37 m_idxLookUp.clear();
38 return true;
39 }
43 unsigned int SegmentVariables::push_back(const xAOD::MuonSegment& segment) {
44 m_filterMode = true;
45 return fill(segment);
46 }
47 bool SegmentVariables::addVariable(std::shared_ptr<IAuxElementDecorationBranch> br) {
48 m_addBranches.push_back(br);
49 return parent().addBranch(br);
50 }
51 unsigned int SegmentVariables::fill(const xAOD::MuonSegment& segment){
52 auto insert_itr = m_idxLookUp.insert(std::make_pair(&segment, m_idxLookUp.size()));
53 if (!insert_itr.second) {
54 return insert_itr.first->second;
55 }
56 m_pos.push_back(segment.position());
57 m_dir.push_back(segment.direction());
58 m_etaIdx += segment.etaIndex();
59 m_sector += segment.sector();
60 using namespace Muon::MuonStationIndex;
61 m_chamberIdx += toInt(segment.chamberIndex());
62 m_chi2 +=segment.chiSquared();
63 m_nDoF +=segment.numberDoF();
64
65 m_nPrecHits += segment.nPrecisionHits();
67 m_nTrigPhiLayers += segment.nPhiLayers();
68 for(const auto& br : m_addBranches){
69 br->push_back(segment);
70 }
71
72 return insert_itr.first->second;
73 }
74}
#define ATH_MSG_FATAL(x)
Handle class for reading from StoreGate.
PrdTesterModule(MuonTesterTree &tree, const std::string &grp_name, MSG::Level msglvl)
bool fill(const EventContext &ctx) override final
The fill method checks if enough information is provided such that the branch is cleared from the inf...
VectorBranch< char > & m_etaIdx
Station-eta index of the segment's precision hits.
VectorBranch< uint8_t > & m_nPrecHits
Number of precision hits i.e.
VectorBranch< uint8_t > & m_sector
MS-sector of the segment's precision hits.
unsigned int push_back(const xAOD::MuonSegment &segment)
push back a particuar segment
VectorBranch< uint8_t > & m_nTrigEtaLayers
Number of trigger hits, i.e.
SegmentVariables(MuonTesterTree &tree, const std::string &containerKey, const std::string &outName, MSG::Level msglvl)
bool declare_keys() override final
VectorBranch< float > & m_chi2
chi 2 of the segment fit
VectorBranch< uint8_t > & m_chamberIdx
MS station of the segment.
VectorBranch< unsigned int > & m_nDoF
number of degrees of freedom
SG::ReadHandleKey< xAOD::MuonSegmentContainer > m_key
Store gate key of the segment container.
bool addVariable(std::shared_ptr< IAuxElementDecorationBranch > br)
UnitThreeVectorBranch m_dir
Global direction of the segment.
std::unordered_map< const xAOD::MuonSegment *, unsigned int > m_idxLookUp
ThreeVectorBranch m_pos
Global position of the segment.
VectorBranch< uint8_t > & m_nTrigPhiLayers
Number of trigger hits, i.e.
std::vector< std::shared_ptr< IAuxElementDecorationBranch > > m_addBranches
std::string m_name
Name of the segment collection in the output collection.
MuonTesterTree & parent()
Returns the reference to the MuonTesterTree parent.
bool declare_dependency(Key &key)
Declares the ReadHandle/ ReadCondHandleKey as data dependency of the algorithm.
TTree * tree() override final
Returns the underlying TTree object.
bool addBranch(std::shared_ptr< IMuonTesterBranch > branch)
Branch is added to the tree without transferring the ownership.
bool isPresent() const
Is the referenced object present in SG?
std::uint8_t nTrigEtaLayers() const
Returns the number of trigger eta hits.
float numberDoF() const
Returns the numberDoF.
Amg::Vector3D direction() const
Returns the direction as Amg::Vector.
float chiSquared() const
std::uint8_t nPrecisionHits() const
Returns the number of precision hits.
::Muon::MuonStationIndex::ChIndex chamberIndex() const
Returns the chamber index.
Amg::Vector3D position() const
Returns the position as Amg::Vector.
int etaIndex() const
Returns the eta index, which corresponds to stationEta in the offline identifiers (and the ).
std::uint8_t nPhiLayers() const
Returns the number of trigger phi hits.
constexpr int toInt(const EnumType enumVal)
MuonSegment_v1 MuonSegment
Reference the current persistent version: