1 #include "../interface/MicroGMTIsolationUnit.h"
31 m_etaExtrapolationLUTs[
tftype::bmtf] = m_BEtaExtrapolation;
32 m_phiExtrapolationLUTs[
tftype::bmtf] = m_BPhiExtrapolation;
55 int phiIndex = m_IdxSelMemPhi->lookup(phi);
58 int etaIndex = m_IdxSelMemEta->lookup(eta);
62 return phiIndex + etaIndex*36;
67 for (
auto &
mu : inputmuons) {
69 int ptRed =
mu->hwPt() & 0b111111;
71 int etaAbsRed = (
std::abs(
mu->hwEta()) >> 2) & ((1 << 6) - 1);
76 if (
mu->hwPt() < 64) {
78 if (
mu->hwSign() == 1) {
81 deltaPhi = (m_phiExtrapolationLUTs.at(
mu->trackFinderType())->lookup(etaAbsRed, ptRed) << 3) * sign;
82 deltaEta = (m_etaExtrapolationLUTs.at(
mu->trackFinderType())->lookup(etaAbsRed, ptRed) << 3);
85 mu->setExtrapolation(deltaEta, deltaPhi);
92 m_5by1TowerSums.clear();
93 if (inputs.
size(bx) == 0)
return;
95 for (
int iphi = 0; iphi < 36; ++iphi) {
96 int iphiIndexOffset = iphi*28;
99 for (
int ieta = 0; ieta < 2; ++ieta) {
101 for (
int dIEta = 0-ieta; dIEta <= 2; ++dIEta) {
102 if (m_caloInputsToDisable.test(ieta+dIEta) || m_maskedCaloInputs.test(ieta+dIEta))
continue;
103 sum += inputs.
at(bx, iphiIndexOffset+dIEta).etBits();
105 m_5by1TowerSums.push_back(sum);
108 for (
int ieta = 2; ieta < 26; ++ieta) {
110 for (
int dIEta = -2; dIEta <= 2; ++dIEta) {
111 if (m_caloInputsToDisable.test(ieta+dIEta) || m_maskedCaloInputs.test(ieta+dIEta))
continue;
112 sum += inputs.
at(bx, iphiIndexOffset+dIEta).etBits();
114 m_5by1TowerSums.push_back(sum);
118 for (
int ieta = 26; ieta < 28; ++ieta) {
120 for (
int dIEta = -2; dIEta <= 27-ieta; ++dIEta) {
121 if (m_caloInputsToDisable.test(ieta+dIEta) || m_maskedCaloInputs.test(ieta+dIEta))
continue;
122 sum += inputs.
at(bx, iphiIndexOffset+dIEta).etBits();
124 m_5by1TowerSums.push_back(sum);
128 m_initialSums =
true;
135 if (index > m_5by1TowerSums.size()) {
141 for (
int dIPhi = -2; dIPhi <= 2; ++dIPhi) {
142 int currIndex = (index + dIPhi*28)%1008;
143 if (currIndex < 0) currIndex = 1008+currIndex;
144 if ((
unsigned)currIndex < m_5by1TowerSums.size()) {
145 returnSum += m_5by1TowerSums[currIndex];
156 for (
auto&
mu : muons) {
157 int caloIndex = getCaloIndex(*
mu);
158 int energySum = calculate5by5Sum(caloIndex);
159 mu->setHwIsoSum(energySum);
161 int absIso = m_AbsIsoCheckMem->lookup(energySum);
162 int relIso = m_RelIsoCheckMem->lookup(energySum,
mu->hwPt());
164 mu->setHwRelIso(relIso);
165 mu->setHwAbsIso(absIso);
170 m_towerEnergies.clear();
172 if (inputs.
size(bx) == 0)
return;
174 if (m_caloInputsToDisable.test(
input->hwEta()) || m_maskedCaloInputs.test(
input->hwEta())) {
177 if (
input->etBits() != 0 ) {
182 m_initialSums =
true;
188 for (
auto mu : muons) {
189 int caloIndex = getCaloIndex(*
mu);
191 if (m_towerEnergies.count(caloIndex) == 1) {
192 energySum = m_towerEnergies.at(caloIndex);
195 mu->setHwIsoSum(energySum);
197 int absIso = m_AbsIsoCheckMem->lookup(energySum);
198 int relIso = m_RelIsoCheckMem->lookup(energySum,
mu->hwPt());
200 mu->setHwRelIso(relIso);
201 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
Geom::Phi< T > phi() const
unsigned fwVersion() const
l1t::LUT * oPhiExtrapolationLUT()
l1t::LUT * bPhiExtrapolationLUT()
l1t::LUT * bEtaExtrapolationLUT()
volatile std::atomic< bool > shutdown_flag false
double energySum(const DataFrame &df, int fs, int ls)
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