CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MicroGMTIsolationUnit.cc
Go to the documentation of this file.
1 #include "../interface/MicroGMTIsolationUnit.h"
2 
7 
8 
10 {
11 }
12 
14 {
15 }
16 
17 void
19  int fwVersion = microGMTParamsHelper->fwVersion();
28  m_RelIsoCheckMem = l1t::MicroGMTRelativeIsolationCheckLUTFactory::create(microGMTParamsHelper->relIsoCheckMemLUT(), fwVersion);
29  m_AbsIsoCheckMem = l1t::MicroGMTAbsoluteIsolationCheckLUTFactory::create(microGMTParamsHelper->absIsoCheckMemLUT(), fwVersion);
30 
31  m_etaExtrapolationLUTs[tftype::bmtf] = m_BEtaExtrapolation;
32  m_phiExtrapolationLUTs[tftype::bmtf] = m_BPhiExtrapolation;
33  m_etaExtrapolationLUTs[tftype::omtf_pos] = m_OEtaExtrapolation;
34  m_etaExtrapolationLUTs[tftype::omtf_neg] = m_OEtaExtrapolation;
35  m_phiExtrapolationLUTs[tftype::omtf_pos] = m_OPhiExtrapolation;
36  m_phiExtrapolationLUTs[tftype::omtf_neg] = m_OPhiExtrapolation;
37  m_etaExtrapolationLUTs[tftype::emtf_pos] = m_FEtaExtrapolation;
38  m_etaExtrapolationLUTs[tftype::emtf_neg] = m_FEtaExtrapolation;
39  m_phiExtrapolationLUTs[tftype::emtf_pos] = m_FPhiExtrapolation;
40  m_phiExtrapolationLUTs[tftype::emtf_neg] = m_FPhiExtrapolation;
41 }
42 
43 int
45 {
46  // handle the wrap-around of phi:
47  int phi = (mu.hwGlobalPhi() + mu.hwDPhi())%576;
48  if (phi < 0) {
49  phi = 576+phi;
50  }
51 
52  int phiIndex = m_IdxSelMemPhi->lookup(phi);
53  int eta = mu.hwEta()+mu.hwDEta();
55  int etaIndex = m_IdxSelMemEta->lookup(eta);
56  mu.setHwCaloEta(etaIndex);
57  mu.setHwCaloPhi(phiIndex);
58 
59  return phiIndex + etaIndex*36;
60 }
61 
62 void
64  for (auto &mu : inputmuons) {
65  // only use 6 LSBs of pt:
66  int ptRed = mu->hwPt() & 0b111111;
67  // here we drop the two LSBs and masking the MSB
68  int etaAbsRed = (std::abs(mu->hwEta()) >> 2) & ((1 << 6) - 1);
69 
70  int deltaPhi = 0;
71  int deltaEta = 0;
72 
73  if (mu->hwPt() < 64) { // extrapolation only for "low" pT muons
74  int sign = 1;
75  if (mu->hwSign() == 1) {
76  sign = -1;
77  }
78  deltaPhi = (m_phiExtrapolationLUTs.at(mu->trackFinderType())->lookup(etaAbsRed, ptRed) << 3) * sign;
79  deltaEta = (m_etaExtrapolationLUTs.at(mu->trackFinderType())->lookup(etaAbsRed, ptRed) << 3);
80  }
81 
82  mu->setExtrapolation(deltaEta, deltaPhi);
83  }
84 }
85 
86 void
88 {
89  m_5by1TowerSums.clear();
90  if (inputs.size(bx) == 0) return;
91 
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());//ieta = 0 (tower -28)
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) {
97  int sum = 0;
98  for (int dIEta = -2; dIEta <= 2; ++dIEta) {
99  sum += inputs.at(bx, iphiIndexOffset+dIEta).etBits();
100  }
101  m_5by1TowerSums.push_back(sum);
102  }
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());//ieta = 0 (tower 28)
105  }
106 
107  m_initialSums = true;
108 }
109 
110 
111 int
113 {
114  if (index > m_5by1TowerSums.size()) {
115  edm::LogWarning("energysum out of bounds!");
116  return 0;
117  }
118  // phi wrap around:
119  int returnSum = 0;
120  for (int dIPhi = -2; dIPhi <= 2; ++dIPhi) {
121  int currIndex = (index + dIPhi*28)%1008; // wrap-around at top
122  if (currIndex < 0) currIndex = 1008+currIndex;
123  if ((unsigned)currIndex < m_5by1TowerSums.size()) {
124  returnSum += m_5by1TowerSums[currIndex];
125  } else {
126  edm::LogWarning("energysum out of bounds!");
127  }
128  }
129  return std::min(31, returnSum);
130 }
131 
132 void
134 {
135  for (auto& mu : muons) {
136  int caloIndex = getCaloIndex(*mu);
137  int energySum = calculate5by5Sum(caloIndex);
138  mu->setHwIsoSum(energySum);
139 
140  int absIso = m_AbsIsoCheckMem->lookup(energySum);
141  int relIso = m_RelIsoCheckMem->lookup(energySum, mu->hwPt());
142 
143  mu->setHwRelIso(relIso);
144  mu->setHwAbsIso(absIso);
145  }
146 }
147 
149  m_towerEnergies.clear();
150  if (bx < inputs.getFirstBX() || bx > inputs.getLastBX()) return;
151  if (inputs.size(bx) == 0) return;
152  for (auto input = inputs.begin(bx); input != inputs.end(bx); ++input) {
153  if ( input->etBits() != 0 ) {
154  m_towerEnergies[input->hwEta()*36+input->hwPhi()] = input->etBits();
155  }
156  }
157 
158  m_initialSums = true;
159 
160 }
161 
163 {
164  for (auto mu : muons) {
165  int caloIndex = getCaloIndex(*mu);
166  int energySum = 0;
167  if (m_towerEnergies.count(caloIndex) == 1) {
168  energySum = m_towerEnergies.at(caloIndex);
169  }
170 
171  mu->setHwIsoSum(energySum);
172 
173  int absIso = m_AbsIsoCheckMem->lookup(energySum);
174  int relIso = m_RelIsoCheckMem->lookup(energySum, mu->hwPt());
175 
176  mu->setHwRelIso(relIso);
177  mu->setHwAbsIso(absIso);
178  }
179 
180 }
static unsigned getTwosComp(const int signedInt, const int width)
const_iterator end(int bx) const
void extrapolateMuons(MicroGMTConfiguration::InterMuonList &) const
const int hwDEta() const
unsigned size(int bx) const
void setTowerSums(const MicroGMTConfiguration::CaloInputCollection &inputs, int bx)
double sign(double x)
void setHwCaloPhi(int idx)
static ReturnType create(const std::string &filename, const int fwVersion)
static const double deltaEta
Definition: CaloConstants.h:8
static ReturnType create(const std::string &filename, const int type, const int fwVersion)
static std::string const input
Definition: EdmProvDump.cc:44
static ReturnType create(const std::string &filename, const int fwVersion)
const int hwDPhi() const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const int mu
Definition: Constants.h:22
T min(T a, T b)
Definition: MathUtil.h:58
GMTInternalMuonList InterMuonList
const int hwEta() const
int getFirstBX() const
void calculate5by1Sums(const MicroGMTConfiguration::CaloInputCollection &, int bx)
void isolate(MicroGMTConfiguration::InterMuonList &) const
const int hwGlobalPhi() const
int getCaloIndex(MicroGMTConfiguration::InterMuon &) const
Geom::Phi< T > phi() const
tuple muons
Definition: patZpeak.py:38
int getLastBX() 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