ATLAS Offline Software
Loading...
Searching...
No Matches
L1TGCCandData_v1.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
5
7#include <cmath>
8#include <algorithm>
9
10namespace {
11
12 // The maximum magnitude code maps to the documented compact-word range.
13 constexpr uint8_t encodeSigned(float value, float range, uint8_t magnitudeMask) {
14 const float absValue = std::min(std::abs(value), range);
15 uint8_t word = static_cast<uint8_t>(std::lround(absValue / range *
16 static_cast<float>(magnitudeMask)));
17 word &= magnitudeMask;
18 if (value < 0.F) word |= static_cast<uint8_t>(magnitudeMask + 1);
19 return word;
20 }
21
22 constexpr float decodeSigned(uint8_t word, float range, uint8_t magnitudeMask) {
23 const float magnitude = static_cast<float>(word & magnitudeMask) /
24 static_cast<float>(magnitudeMask) * range;
25 return (word & static_cast<uint8_t>(magnitudeMask + 1)) ? -magnitude : magnitude;
26 }
27}
28
29namespace xAOD {
30
32 return ptResolution() * static_cast<float>(l1Pt());
33}
34
38
42
44 return decodeSigned(l1DeltaPhiWord(), s_dphiRange, DPHI_BIT_MASK);
45}
46
48 return decodeSigned(l1DeltaThetaWord(), s_dthetaRange, DTHETA_BIT_MASK);
49}
50
52 static const SG::ConstAccessor<uint8_t> acc("l1DeltaPhiWord");
53 return acc(*this);
54}
55
57 static const SG::ConstAccessor<uint8_t> acc("l1DeltaThetaWord");
58 return acc(*this);
59}
60
62 static const SG::ConstAccessor<uint32_t> acc("l1NswSegment");
63 return acc(*this) & NSW_BIT_MASK;
64}
65
70
75
77 setL1DeltaPhiWord(encodeSigned(dphi, s_dphiRange, DPHI_BIT_MASK));
78}
79
82}
83
85 static const SG::Accessor<uint8_t> acc("l1DeltaPhiWord");
86 acc(*this) = value & static_cast<uint8_t>((DPHI_BIT_MASK << 1) | 0x1);
87}
88
90 static const SG::Accessor<uint8_t> acc("l1DeltaThetaWord");
91 acc(*this) = value & static_cast<uint8_t>((DTHETA_BIT_MASK << 1) | 0x1);
92}
93
95 static const SG::Accessor<uint32_t> acc("l1NswSegment");
96 acc(*this) = nswout & NSW_BIT_MASK;
97}
98
99} // namespace xAOD
Helper class to provide type-safe access to aux data.
Helper class to provide constant type-safe access to aux data.
static constexpr float ptResolution()
void setCoinType(uint8_t coinType)
Set the coincidence type.
uint8_t coinType() const
Retrieve the coincidence type.
uint8_t l1Pt() const
Retrieve the encoded candidate pT.
static constexpr uint8_t COINTYPE_INNER_COINCIDENCE_BIT
CoinType bit for Inner Coincidence.
float deltaPhi() const
Retrieve the delta phi wrt vector from IP to segment position.
uint8_t l1DeltaPhiWord() const
Retrieve the raw encoded delta phi word.
void setDeltaTheta(float dtheta)
Set the delta theta value.
float deltaTheta() const
Retrieve the delta theta value wrt vector from IP to segment position.
static constexpr float s_dthetaRange
range of the RPC hits z positions
static constexpr uint8_t DTHETA_BIT_MASK
Bit mask for deltaTheta : 1 bit for sign and 6 bits.
void setDeltaPhi(float dphi)
Set the delta phi value.
bool goodMagneticField() const
Check whether the candidate is in a good magnetic-field region.
static constexpr uint8_t COINTYPE_GOOD_MAGNETIC_FIELD_BIT
CoinType bit for the GoodMag flag.
void setL1DeltaPhiWord(uint8_t value)
Set the raw encoded delta phi word.
void setGoodMagneticField(bool value)
Set the GoodMag bit in CoinType.
void setHasInnerCoincidence(bool value)
Set the Inner Coincidence bit in CoinType.
static constexpr uint32_t NSW_BIT_MASK
Bit mask for NSW-TP output.
bool hasInnerCoincidence() const
Check whether the candidate passed Inner Coincidence.
static constexpr uint8_t DPHI_BIT_MASK
Bit mask for deltaPhi : 1 bit for sign and 3 bits.
void setL1DeltaThetaWord(uint8_t value)
Set the raw encoded delta theta word.
uint32_t l1NswSegment() const
Retrieve the NSW segments.
static constexpr float s_dphiRange
float ptValueGeV() const
Retrieve the inherited encoded pT value in GeV.
void setL1NswSegment(uint32_t nswout)
Set the NSW segments.
uint8_t l1DeltaThetaWord() const
Retrieve the raw encoded delta theta word.
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
setEventNumber uint32_t
static const SG::Accessor< ElementLink< IParticleContainer > > acc("originalObjectLink")
Object used for setting/getting the dynamic decoration in question.