13 m_fwVersion = microGMTParamsHelper->
fwVersion();
35 m_etaExtrapolationLUTs[
tftype::bmtf] = m_BEtaExtrapolation;
36 m_phiExtrapolationLUTs[
tftype::bmtf] = m_BPhiExtrapolation;
57 int phiIndex = m_IdxSelMemPhi->lookup(phi);
60 int etaIndex = m_IdxSelMemEta->lookup(eta);
64 return phiIndex + etaIndex * 36;
68 int outputShiftPhi = 3;
69 int outputShiftEta = 3;
70 if (m_fwVersion >= 0x4010000) {
75 for (
auto&
mu : inputmuons) {
77 std::shared_ptr<MicroGMTExtrapolationLUT> phiExtrapolationLUT = m_phiExtrapolationLUTs.at(
mu->trackFinderType());
78 int ptRedInWidth = phiExtrapolationLUT->getPtRedInWidth();
79 int ptMask = (1 << ptRedInWidth) - 1;
80 int etaRedInWidth = phiExtrapolationLUT->getEtaRedInWidth();
81 int redEtaShift = 8 - etaRedInWidth;
84 int ptRed =
mu->hwPt() & ptMask;
86 int etaAbsRed = (
std::abs(
mu->hwEta()) >> redEtaShift) & ((1 << etaRedInWidth) - 1);
91 if (
mu->hwPt() < (1 << ptRedInWidth)) {
93 if (
mu->hwSign() == 1) {
96 deltaPhi = (phiExtrapolationLUT->lookup(etaAbsRed, ptRed) << outputShiftPhi) * sign;
97 deltaEta = (m_etaExtrapolationLUTs.at(
mu->trackFinderType())->lookup(etaAbsRed, ptRed) << outputShiftEta);
98 if (
mu->hwEta() > 0) {
103 mu->setExtrapolation(deltaEta, deltaPhi);
108 m_5by1TowerSums.clear();
109 if (inputs.
size(bx) == 0)
112 for (
int iphi = 0; iphi < 36; ++iphi) {
113 int iphiIndexOffset = iphi * 28;
116 for (
int ieta = 0; ieta < 2; ++ieta) {
118 for (
int dIEta = 0 - ieta; dIEta <= 2; ++dIEta) {
119 if (m_caloInputsToDisable.test(ieta + dIEta) || m_maskedCaloInputs.test(ieta + dIEta))
121 sum += inputs.
at(bx, iphiIndexOffset + dIEta).etBits();
123 m_5by1TowerSums.push_back(sum);
126 for (
int ieta = 2; ieta < 26; ++ieta) {
128 for (
int dIEta = -2; dIEta <= 2; ++dIEta) {
129 if (m_caloInputsToDisable.test(ieta + dIEta) || m_maskedCaloInputs.test(ieta + dIEta))
131 sum += inputs.
at(bx, iphiIndexOffset + dIEta).etBits();
133 m_5by1TowerSums.push_back(sum);
137 for (
int ieta = 26; ieta < 28; ++ieta) {
139 for (
int dIEta = -2; dIEta <= 27 - ieta; ++dIEta) {
140 if (m_caloInputsToDisable.test(ieta + dIEta) || m_maskedCaloInputs.test(ieta + dIEta))
142 sum += inputs.
at(bx, iphiIndexOffset + dIEta).etBits();
144 m_5by1TowerSums.push_back(sum);
148 m_initialSums =
true;
152 if (index > m_5by1TowerSums.size()) {
158 for (
int dIPhi = -2; dIPhi <= 2; ++dIPhi) {
159 int currIndex = (index + dIPhi * 28) % 1008;
161 currIndex = 1008 + currIndex;
162 if ((
unsigned)currIndex < m_5by1TowerSums.size()) {
163 returnSum += m_5by1TowerSums[currIndex];
172 for (
auto&
mu : muons) {
173 int caloIndex = getCaloIndex(*
mu);
174 int energySum = calculate5by5Sum(caloIndex);
175 mu->setHwIsoSum(energySum);
177 int absIso = m_AbsIsoCheckMem->lookup(energySum);
178 int relIso = m_RelIsoCheckMem->lookup(energySum,
mu->hwPt());
180 mu->setHwRelIso(relIso);
181 mu->setHwAbsIso(absIso);
186 m_towerEnergies.clear();
189 if (inputs.
size(bx) == 0)
192 if (m_caloInputsToDisable.test(
input->hwEta()) || m_maskedCaloInputs.test(
input->hwEta())) {
195 if (
input->etBits() != 0) {
196 m_towerEnergies[
input->hwEta() * 36 +
input->hwPhi()] =
input->etBits();
200 m_initialSums =
true;
204 for (
const auto&
mu : muons) {
205 int caloIndex = getCaloIndex(*
mu);
207 if (m_towerEnergies.count(caloIndex) == 1) {
208 energySum = m_towerEnergies.at(caloIndex);
211 mu->setHwIsoSum(energySum);
213 int absIso = m_AbsIsoCheckMem->lookup(energySum);
214 int relIso = m_RelIsoCheckMem->lookup(energySum,
mu->hwPt());
216 mu->setHwRelIso(relIso);
217 mu->setHwAbsIso(absIso);
static unsigned getTwosComp(const int signedInt, const int width)
const_iterator end(int bx) const
l1t::LUT * fPhiExtrapolationLUT()
l1t::LUT * oEtaExtrapolationLUT()
void extrapolateMuons(MicroGMTConfiguration::InterMuonList &) const
unsigned size(int bx) const
void setTowerSums(const MicroGMTConfiguration::CaloInputCollection &inputs, int bx)
std::bitset< 28 > caloInputsToDisable() const
void setHwCaloPhi(int idx)
static ReturnType create(const std::string &filename, const int fwVersion)
static const double deltaEta
static std::string const input
static ReturnType create(const std::string &filename, const int fwVersion)
l1t::LUT * fEtaExtrapolationLUT()
l1t::LUT * absIsoCheckMemLUT()
l1t::LUT * relIsoCheckMemLUT()
Abs< T >::type abs(const T &t)
GMTInternalMuonList InterMuonList
l1t::LUT * idxSelMemPhiLUT()
void calculate5by1Sums(const MicroGMTConfiguration::CaloInputCollection &, int bx)
l1t::LUT * idxSelMemEtaLUT()
virtual ~MicroGMTIsolationUnit()
void isolate(MicroGMTConfiguration::InterMuonList &) const
const int hwGlobalPhi() const
int getCaloIndex(MicroGMTConfiguration::InterMuon &) const
unsigned fwVersion() const
l1t::LUT * oPhiExtrapolationLUT()
l1t::LUT * bPhiExtrapolationLUT()
l1t::LUT * bEtaExtrapolationLUT()
double energySum(const DataFrame &df, int fs, int ls)
Log< level::Warning, false > LogWarning
void initialise(L1TMuonGlobalParamsHelper *)
Initialisation from ES record.
void isolatePreSummed(MicroGMTConfiguration::InterMuonList &muons) const
const_iterator begin(int bx) const
std::bitset< 28 > maskedCaloInputs() const
void setHwCaloEta(int idx)
static ReturnType create(const std::string &filename, const int type, const int fwVersion)
int calculate5by5Sum(unsigned index) const
const T & at(int bx, unsigned i) const