1 #include "../interface/MicroGMTIsolationUnit.h"
10 m_BEtaExtrapolation(iConfig,
"BEtaExtrapolationLUTSettings", 0), m_BPhiExtrapolation(iConfig,
"BPhiExtrapolationLUTSettings", 1), m_OEtaExtrapolation(iConfig,
"OEtaExtrapolationLUTSettings", 0),
11 m_OPhiExtrapolation(iConfig,
"OPhiExtrapolationLUTSettings", 1), m_FEtaExtrapolation(iConfig,
"FEtaExtrapolationLUTSettings", 0), m_FPhiExtrapolation(iConfig,
"FPhiExtrapolationLUTSettings", 1),
12 m_IdxSelMemEta(iConfig,
"IdxSelMemEtaLUTSettings", 0), m_IdxSelMemPhi(iConfig,
"IdxSelMemPhiLUTSettings", 1), m_RelIsoCheckMem(iConfig,
"RelIsoCheckMemLUTSettings"),
13 m_AbsIsoCheckMem(iConfig,
"AbsIsoCheckMemLUTSettings"), m_initialSums(
false)
40 int phiIndex = m_IdxSelMemPhi.lookup(phi);
43 int etaIndex = m_IdxSelMemEta.lookup(eta);
47 return phiIndex + etaIndex*36;
52 for (
auto &
mu : inputmuons) {
54 int ptRed =
mu->hwPt() & 0b111111;
56 int etaAbsRed = (
std::abs(
mu->hwEta()) >> 2) & ((1 << 6) - 1);
61 if (
mu->hwPt() < 64) {
63 if (
mu->hwSign() == 0) {
66 deltaPhi = (m_phiExtrapolationLUTs.at(
mu->trackFinderType())->lookup(etaAbsRed, ptRed) << 3) * sign;
67 deltaEta = (m_etaExtrapolationLUTs.at(
mu->trackFinderType())->lookup(etaAbsRed, ptRed) << 3);
70 mu->setExtrapolation(deltaEta, deltaPhi);
77 m_5by1TowerSums.clear();
78 if (inputs.
size(bx) == 0)
return;
80 for (
int iphi = 0; iphi < 36; ++iphi) {
81 int iphiIndexOffset = iphi*28;
82 m_5by1TowerSums.push_back(inputs.
at(bx, iphiIndexOffset).etBits()+inputs.
at(bx, iphiIndexOffset+1).etBits()+inputs.
at(bx, iphiIndexOffset+2).etBits());
83 m_5by1TowerSums.push_back(inputs.
at(bx, iphiIndexOffset-1).etBits()+inputs.
at(bx, iphiIndexOffset).etBits()+inputs.
at(bx, iphiIndexOffset+1).etBits()+inputs.
at(bx, iphiIndexOffset+2).etBits());
84 for (
int ieta = 2; ieta < 26; ++ieta) {
86 for (
int dIEta = -2; dIEta <= 2; ++dIEta) {
87 sum += inputs.
at(bx, iphiIndexOffset+dIEta).etBits();
89 m_5by1TowerSums.push_back(sum);
91 m_5by1TowerSums.push_back(inputs.
at(bx, iphiIndexOffset+1).etBits()+inputs.
at(bx, iphiIndexOffset).etBits()+inputs.
at(bx, iphiIndexOffset-1).etBits()+inputs.
at(bx, iphiIndexOffset-2).etBits());
92 m_5by1TowerSums.push_back(inputs.
at(bx, iphiIndexOffset).etBits()+inputs.
at(bx, iphiIndexOffset-1).etBits()+inputs.
at(bx, iphiIndexOffset-2).etBits());
102 if (index > m_5by1TowerSums.size()) {
108 for (
int dIPhi = -2; dIPhi <= 2; ++dIPhi) {
109 int currIndex = (index + dIPhi*28)%1008;
110 if (currIndex < 0) currIndex = 1008+currIndex;
111 if ((
unsigned)currIndex < m_5by1TowerSums.size()) {
112 returnSum += m_5by1TowerSums[currIndex];
123 for (
auto&
mu : muons) {
124 int caloIndex = getCaloIndex(*
mu);
125 int energySum = calculate5by5Sum(caloIndex);
126 mu->setHwIsoSum(energySum);
128 int absIso = m_AbsIsoCheckMem.lookup(energySum);
129 int relIso = m_RelIsoCheckMem.lookup(energySum,
mu->hwPt());
131 mu->setHwRelIso(relIso);
132 mu->setHwAbsIso(absIso);
137 m_towerEnergies.clear();
138 if (inputs.
size(bx) == 0)
return;
140 if (
input->etBits() != 0 ) {
145 m_initialSums =
true;
151 for (
auto mu : muons) {
152 int caloIndex = getCaloIndex(*
mu);
154 if (m_towerEnergies.count(caloIndex) == 1) {
155 energySum = m_towerEnergies.at(caloIndex);
158 mu->setHwIsoSum(energySum);
160 int absIso = m_AbsIsoCheckMem.lookup(energySum);
161 int relIso = m_RelIsoCheckMem.lookup(energySum,
mu->hwPt());
163 mu->setHwRelIso(relIso);
164 mu->setHwAbsIso(absIso);
std::map< tftype, MicroGMTExtrapolationLUT * > m_etaExtrapolationLUTs
static unsigned getTwosComp(const int signedInt, const int width)
const_iterator end(int bx) const
MicroGMTExtrapolationLUT m_BEtaExtrapolation
void extrapolateMuons(MicroGMTConfiguration::InterMuonList &) const
unsigned size(int bx) const
void setTowerSums(const MicroGMTConfiguration::CaloInputCollection &inputs, int bx)
MicroGMTExtrapolationLUT m_OEtaExtrapolation
void setHwCaloPhi(int idx)
MicroGMTExtrapolationLUT m_FEtaExtrapolation
static std::string const input
std::map< tftype, MicroGMTExtrapolationLUT * > m_phiExtrapolationLUTs
Abs< T >::type abs(const T &t)
MicroGMTExtrapolationLUT m_FPhiExtrapolation
GMTInternalMuonList InterMuonList
void calculate5by1Sums(const MicroGMTConfiguration::CaloInputCollection &, int bx)
MicroGMTExtrapolationLUT m_BPhiExtrapolation
virtual ~MicroGMTIsolationUnit()
void isolate(MicroGMTConfiguration::InterMuonList &) const
const int hwGlobalPhi() const
int getCaloIndex(MicroGMTConfiguration::InterMuon &) const
Geom::Phi< T > phi() const
MicroGMTExtrapolationLUT m_OPhiExtrapolation
MicroGMTIsolationUnit(const edm::ParameterSet &)
volatile std::atomic< bool > shutdown_flag false
double energySum(const DataFrame &df, int fs, int ls)
void isolatePreSummed(MicroGMTConfiguration::InterMuonList &muons) const
const_iterator begin(int bx) const
void setHwCaloEta(int idx)
int calculate5by5Sum(unsigned index) const
const T & at(int bx, unsigned i) const