1 #include "../interface/MicroGMTIsolationUnit.h"
31 m_etaExtrapolationLUTs[
tftype::bmtf] = m_BEtaExtrapolation;
32 m_phiExtrapolationLUTs[
tftype::bmtf] = m_BPhiExtrapolation;
52 int phiIndex = m_IdxSelMemPhi->lookup(phi);
55 int etaIndex = m_IdxSelMemEta->lookup(eta);
59 return phiIndex + etaIndex*36;
64 for (
auto &
mu : inputmuons) {
66 int ptRed =
mu->hwPt() & 0b111111;
68 int etaAbsRed = (
std::abs(
mu->hwEta()) >> 2) & ((1 << 6) - 1);
73 if (
mu->hwPt() < 64) {
75 if (
mu->hwSign() == 1) {
78 deltaPhi = (m_phiExtrapolationLUTs.at(
mu->trackFinderType())->lookup(etaAbsRed, ptRed) << 3) * sign;
79 deltaEta = (m_etaExtrapolationLUTs.at(
mu->trackFinderType())->lookup(etaAbsRed, ptRed) << 3);
82 mu->setExtrapolation(deltaEta, deltaPhi);
89 m_5by1TowerSums.clear();
90 if (inputs.
size(bx) == 0)
return;
92 for (
int iphi = 0; iphi < 36; ++iphi) {
93 int iphiIndexOffset = iphi*28;
94 m_5by1TowerSums.push_back(inputs.
at(bx, iphiIndexOffset).etBits()+inputs.
at(bx, iphiIndexOffset+1).etBits()+inputs.
at(bx, iphiIndexOffset+2).etBits());
95 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());
96 for (
int ieta = 2; ieta < 26; ++ieta) {
98 for (
int dIEta = -2; dIEta <= 2; ++dIEta) {
99 sum += inputs.
at(bx, iphiIndexOffset+dIEta).etBits();
101 m_5by1TowerSums.push_back(sum);
103 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());
104 m_5by1TowerSums.push_back(inputs.
at(bx, iphiIndexOffset).etBits()+inputs.
at(bx, iphiIndexOffset-1).etBits()+inputs.
at(bx, iphiIndexOffset-2).etBits());
107 m_initialSums =
true;
114 if (index > m_5by1TowerSums.size()) {
120 for (
int dIPhi = -2; dIPhi <= 2; ++dIPhi) {
121 int currIndex = (index + dIPhi*28)%1008;
122 if (currIndex < 0) currIndex = 1008+currIndex;
123 if ((
unsigned)currIndex < m_5by1TowerSums.size()) {
124 returnSum += m_5by1TowerSums[currIndex];
135 for (
auto&
mu : muons) {
136 int caloIndex = getCaloIndex(*
mu);
137 int energySum = calculate5by5Sum(caloIndex);
138 mu->setHwIsoSum(energySum);
140 int absIso = m_AbsIsoCheckMem->lookup(energySum);
141 int relIso = m_RelIsoCheckMem->lookup(energySum,
mu->hwPt());
143 mu->setHwRelIso(relIso);
144 mu->setHwAbsIso(absIso);
149 m_towerEnergies.clear();
151 if (inputs.
size(bx) == 0)
return;
153 if (
input->etBits() != 0 ) {
158 m_initialSums =
true;
164 for (
auto mu : muons) {
165 int caloIndex = getCaloIndex(*
mu);
167 if (m_towerEnergies.count(caloIndex) == 1) {
168 energySum = m_towerEnergies.at(caloIndex);
171 mu->setHwIsoSum(energySum);
173 int absIso = m_AbsIsoCheckMem->lookup(energySum);
174 int relIso = m_RelIsoCheckMem->lookup(energySum,
mu->hwPt());
176 mu->setHwRelIso(relIso);
177 mu->setHwAbsIso(absIso);
static unsigned getTwosComp(const int signedInt, const int width)
const_iterator end(int bx) const
void extrapolateMuons(MicroGMTConfiguration::InterMuonList &) const
std::string oEtaExtrapolationLUTPath() const
unsigned size(int bx) const
std::string fEtaExtrapolationLUTPath() const
std::string idxSelMemPhiLUTPath() const
void setTowerSums(const MicroGMTConfiguration::CaloInputCollection &inputs, int bx)
std::string relIsoCheckMemLUTPath() const
void setHwCaloPhi(int idx)
static ReturnType create(const std::string &filename, const int fwVersion)
static const double deltaEta
static std::string const input
std::string absIsoCheckMemLUTPath() const
std::string oPhiExtrapolationLUTPath() const
std::string bPhiExtrapolationLUTPath() const
static ReturnType create(const std::string &filename, const int fwVersion)
std::string bEtaExtrapolationLUTPath() const
Abs< T >::type abs(const T &t)
GMTInternalMuonList InterMuonList
std::string fPhiExtrapolationLUTPath() const
void calculate5by1Sums(const MicroGMTConfiguration::CaloInputCollection &, int bx)
virtual ~MicroGMTIsolationUnit()
void isolate(MicroGMTConfiguration::InterMuonList &) const
const int hwGlobalPhi() const
int getCaloIndex(MicroGMTConfiguration::InterMuon &) const
Geom::Phi< T > phi() const
unsigned fwVersion() const
std::string idxSelMemEtaLUTPath() const
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
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