ATLAS Offline Software
Loading...
Searching...
No Matches
SegmentVariables.cxx
Go to the documentation of this file.
1
2/*
3 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
4*/
7
8namespace MuonPRDTest {
10 const std::string& containerKey,
11 const std::string& outName,
12 MSG::Level msglvl) :
13 PrdTesterModule(tree, "Segments"+ containerKey+outName, msglvl),
14 m_key{containerKey},
15 m_name{outName}{}
16
17 bool SegmentVariables::fill(const EventContext& ctx) {
18 SG::ReadHandle readHandle{m_key, ctx};
19 if(!readHandle.isPresent()) {
20 ATH_MSG_FATAL("Failed to retrieve "<<m_key.fullKey());
21 return false;
22 }
23 if (!m_filterMode) {
24 for (const xAOD::MuonSegment* segment : *readHandle){
25 fill(*segment);
26 }
27 }
28 m_idxLookUp.clear();
29 return true;
30 }
34 unsigned int SegmentVariables::push_back(const xAOD::MuonSegment& segment) {
35 m_filterMode = true;
36 return fill(segment);
37 }
38 bool SegmentVariables::addVariable(std::shared_ptr<IAuxElementDecorationBranch> br) {
39 m_addBranches.push_back(br);
40 return parent().addBranch(br);
41 }
42 unsigned int SegmentVariables::fill(const xAOD::MuonSegment& segment){
43 auto insert_itr = m_idxLookUp.insert(std::make_pair(&segment, m_idxLookUp.size()));
44 if (!insert_itr.second) {
45 return insert_itr.first->second;
46 }
47 m_pos.push_back(segment.position());
48 m_dir.push_back(segment.direction());
49 m_etaIdx += segment.etaIndex();
50 m_sector += segment.sector();
51 using namespace Muon::MuonStationIndex;
52 m_chamberIdx += toInt(segment.chamberIndex());
53 m_chi2 +=segment.chiSquared();
54 m_nDoF +=segment.numberDoF();
55
56 m_nPrecHits += segment.nPrecisionHits();
58 m_nTrigPhiLayers += segment.nPhiLayers();
59 for(const auto& br : m_addBranches){
60 br->push_back(segment);
61 }
62
63 return insert_itr.first->second;
64 }
65}
#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.
ThreeVectorBranch m_dir
Global direction of the segment.
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)
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?
int nTrigEtaLayers() const
Returns the number of trigger eta layers.
float numberDoF() const
Returns the numberDoF.
int nPrecisionHits() const
Amg::Vector3D direction() const
Returns the direction as Amg::Vector.
float chiSquared() const
::Muon::MuonStationIndex::ChIndex chamberIndex() const
Returns the chamber index.
Amg::Vector3D position() const
Returns the position as Amg::Vector.
int nPhiLayers() const
Returns the number of phi layers.
int etaIndex() const
Returns the eta index, which corresponds to stationEta in the offline identifiers (and the ).
constexpr int toInt(const EnumType enumVal)
MuonSegment_v1 MuonSegment
Reference the current persistent version: