ATLAS Offline Software
Loading...
Searching...
No Matches
ICandData_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#include <string>
10
11namespace {
12 static const std::string preFixStr{"L0Mu_"};
13}
14
15namespace xAOD
16{
17 // cppcheck-suppress unknownMacro
18 IMPLEMENT_SETTER_GETTER( ICandData_v1, uint8_t, threshold, setThreshold )
19 IMPLEMENT_SETTER_GETTER( ICandData_v1, uint8_t, candCharge, setCandCharge )
20 IMPLEMENT_SETTER_GETTER( ICandData_v1, uint8_t, mdtFlag, setMdtFlag )
21 IMPLEMENT_SETTER_GETTER( ICandData_v1, uint16_t, subdetectorId, setSubdetectorId )
22 IMPLEMENT_SETTER_GETTER( ICandData_v1, uint16_t, sectorId, setSectorId )
25
26 void ICandData_v1::setEta(float eta) {
27 float etaClamped = std::clamp(eta, -s_etaRange, s_etaRange);
28 uint16_t etaBinary = static_cast<uint16_t>(std::lround((etaClamped + s_etaRange) / (2.0f * s_etaRange) * static_cast<float>(s_etaBitRange)));
29 static const SG::AuxElement::Accessor<uint16_t> acc(preFixStr + "eta");
30 acc(*this) = etaBinary;
31 }
32
34 static const SG::AuxElement::Accessor<uint16_t> acc(preFixStr + "eta");
35 return acc(*this);
36 }
37
39 uint16_t phiBinary = static_cast<uint16_t>(((phi + M_PI) / s_phiRange) * static_cast<float>(s_phiBitRange));
40 static const SG::AuxElement::Accessor<uint16_t> acc(preFixStr + "phi");
41 acc(*this) = phiBinary;
42 }
43
45 static const SG::AuxElement::Accessor<uint16_t> acc(preFixStr + "phi");
46 //return (static_cast<float>(acc(*this)) / static_cast<float>(s_phiBitRange)) * s_phiRange-M_PI;
47 return acc(*this);
48 }
49
51 const float ptClamped = std::clamp(pt, 0.0f, s_ptRange);
52 const uint8_t ptBinary = static_cast<uint8_t>(
53 std::lround((ptClamped / s_ptRange) * static_cast<float>(s_ptBitRange)));
54 static const SG::AuxElement::Accessor<uint8_t> acc(preFixStr + "pt");
55 acc(*this) = ptBinary;
56 }
57
59 static const SG::AuxElement::Accessor<uint8_t> acc(preFixStr + "pt");
60 return acc(*this);
61 }
62
64 uint8_t coinTypeBin = cointype & COINTYPE_BIT_MASK;
65 static const SG::AuxElement::Accessor<uint8_t> acc(preFixStr + "coinType");
66 acc(*this) = coinTypeBin;
67 }
68
70 static const SG::AuxElement::Accessor<uint8_t> acc(preFixStr + "coinType");
71 return acc(*this);
72 }
73
79
80} // namespace xAOD
#define M_PI
#define IMPLEMENT_SETTER_GETTER(DTYPE, GETTER, SETTER)
unsigned bcTag(unsigned bcBitMap)
base class providing a common interface with shared variables for the L0 muon candidates from RPC/TGC...
static constexpr uint8_t COINTYPE_BIT_MASK
Bit mask for Coincidence Types.
void setBcTag(uint16_t bcTag)
Set the bunch crossing tag.
void setPhi(float phi)
Set the phi.
uint16_t sectorId() const
Retrieve the sector id.
uint16_t eta() const
Retrieve the eta.
uint8_t coinType() const
Retrieve the coincidence type.
void setPt(float pt)
Set the pt.
static constexpr float s_ptRange
static constexpr float s_phiRange
uint16_t bcTag() const
Retrieve the bunch crossing tag.
void setEta(float eta)
Set the eta.
uint8_t pt() const
Retrieve the pt.
static constexpr uint16_t s_phiBitRange
ICandData_v1()=default
Default constructor.
uint16_t phi() const
Retrieve the phi.
void setSubdetectorId(uint16_t subdetectorId)
Set the sub detector id.
static constexpr float s_etaRange
Variables range.
uint16_t subdetectorId() const
Retrieve the sub detector id.
void setSectorId(uint16_t sectorId)
Set the sector id.
static constexpr uint8_t s_ptBitRange
void initialize(uint16_t subdetectorId, uint16_t sectorId, uint16_t bcTag)
Initialize candidate with basic properties.
static constexpr uint16_t s_etaBitRange
Variables bit size 14 bits for eta, 9 bits for phi, 8 bits for pt.
void setCoinType(uint8_t coinType)
Set the coincidence type.
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
setWord1 uint16_t
static const SG::AuxElement::Accessor< ElementLink< IParticleContainer > > acc("originalObjectLink")
Object used for setting/getting the dynamic decoration in question.