CMS 3D CMS Logo

MicroGMTIsolationUnit.cc
Go to the documentation of this file.
2 
7 
8 l1t::MicroGMTIsolationUnit::MicroGMTIsolationUnit() : m_fwVersion(0), m_initialSums(false) {}
9 
11 
13  m_fwVersion = microGMTParamsHelper->fwVersion();
15  microGMTParamsHelper->bEtaExtrapolationLUT(), MicroGMTConfiguration::ETA_OUT, m_fwVersion);
17  microGMTParamsHelper->bPhiExtrapolationLUT(), MicroGMTConfiguration::PHI_OUT, m_fwVersion);
19  microGMTParamsHelper->oEtaExtrapolationLUT(), MicroGMTConfiguration::ETA_OUT, m_fwVersion);
21  microGMTParamsHelper->oPhiExtrapolationLUT(), MicroGMTConfiguration::PHI_OUT, m_fwVersion);
23  microGMTParamsHelper->fEtaExtrapolationLUT(), MicroGMTConfiguration::ETA_OUT, m_fwVersion);
25  microGMTParamsHelper->fPhiExtrapolationLUT(), MicroGMTConfiguration::PHI_OUT, m_fwVersion);
27  microGMTParamsHelper->idxSelMemEtaLUT(), MicroGMTConfiguration::ETA, m_fwVersion);
29  microGMTParamsHelper->idxSelMemPhiLUT(), MicroGMTConfiguration::PHI, m_fwVersion);
30  m_RelIsoCheckMem =
32  m_AbsIsoCheckMem =
34 
35  m_etaExtrapolationLUTs[tftype::bmtf] = m_BEtaExtrapolation;
36  m_phiExtrapolationLUTs[tftype::bmtf] = m_BPhiExtrapolation;
37  m_etaExtrapolationLUTs[tftype::omtf_pos] = m_OEtaExtrapolation;
38  m_etaExtrapolationLUTs[tftype::omtf_neg] = m_OEtaExtrapolation;
39  m_phiExtrapolationLUTs[tftype::omtf_pos] = m_OPhiExtrapolation;
40  m_phiExtrapolationLUTs[tftype::omtf_neg] = m_OPhiExtrapolation;
41  m_etaExtrapolationLUTs[tftype::emtf_pos] = m_FEtaExtrapolation;
42  m_etaExtrapolationLUTs[tftype::emtf_neg] = m_FEtaExtrapolation;
43  m_phiExtrapolationLUTs[tftype::emtf_pos] = m_FPhiExtrapolation;
44  m_phiExtrapolationLUTs[tftype::emtf_neg] = m_FPhiExtrapolation;
45 
46  m_caloInputsToDisable = microGMTParamsHelper->caloInputsToDisable();
47  m_maskedCaloInputs = microGMTParamsHelper->maskedCaloInputs();
48 }
49 
51  // handle the wrap-around of phi:
52  int phi = (mu.hwGlobalPhi() + mu.hwDPhi()) % 576;
53  if (phi < 0) {
54  phi = 576 + phi;
55  }
56 
57  int phiIndex = m_IdxSelMemPhi->lookup(phi);
58  int eta = mu.hwEta() + mu.hwDEta();
60  int etaIndex = m_IdxSelMemEta->lookup(eta);
61  mu.setHwCaloEta(etaIndex);
62  mu.setHwCaloPhi(phiIndex);
63 
64  return phiIndex + etaIndex * 36;
65 }
66 
68  int outputShiftPhi = 3;
69  int outputShiftEta = 3;
70  if (m_fwVersion >= 0x4010000) {
71  outputShiftPhi = 2;
72  outputShiftEta = 0;
73  }
74 
75  for (auto& mu : inputmuons) {
76  // get input format
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;
82 
83  // only use LSBs of pt:
84  int ptRed = mu->hwPt() & ptMask;
85  // here we drop the LSBs and mask the MSB
86  int etaAbsRed = (std::abs(mu->hwEta()) >> redEtaShift) & ((1 << etaRedInWidth) - 1);
87 
88  int deltaPhi = 0;
89  int deltaEta = 0;
90 
91  if (mu->hwPt() < (1 << ptRedInWidth)) { // extrapolation only for "low" pT muons
92  int sign = 1;
93  if (mu->hwSign() == 1) {
94  sign = -1;
95  }
96  deltaPhi = (phiExtrapolationLUT->lookup(etaAbsRed, ptRed) << outputShiftPhi) * sign;
97  deltaEta = (m_etaExtrapolationLUTs.at(mu->trackFinderType())->lookup(etaAbsRed, ptRed) << outputShiftEta);
98  if (mu->hwEta() > 0) {
99  deltaEta *= -1;
100  }
101  }
102 
103  mu->setExtrapolation(deltaEta, deltaPhi);
104  }
105 }
106 
108  m_5by1TowerSums.clear();
109  if (inputs.size(bx) == 0)
110  return;
111 
112  for (int iphi = 0; iphi < 36; ++iphi) {
113  int iphiIndexOffset = iphi * 28;
114  // ieta = 0 (tower -28) and ieta = 1 (tower 27)
115  // 3by1 and 4by1 sums
116  for (int ieta = 0; ieta < 2; ++ieta) {
117  int sum = 0;
118  for (int dIEta = 0 - ieta; dIEta <= 2; ++dIEta) {
119  if (m_caloInputsToDisable.test(ieta + dIEta) || m_maskedCaloInputs.test(ieta + dIEta))
120  continue; // only process if input link is enabled and not masked
121  sum += inputs.at(bx, iphiIndexOffset + dIEta).etBits();
122  }
123  m_5by1TowerSums.push_back(sum);
124  }
125  // 5by1 sums
126  for (int ieta = 2; ieta < 26; ++ieta) {
127  int sum = 0;
128  for (int dIEta = -2; dIEta <= 2; ++dIEta) {
129  if (m_caloInputsToDisable.test(ieta + dIEta) || m_maskedCaloInputs.test(ieta + dIEta))
130  continue; // only process if input link is enabled and not masked
131  sum += inputs.at(bx, iphiIndexOffset + dIEta).etBits();
132  }
133  m_5by1TowerSums.push_back(sum);
134  }
135  // ieta = 26 (tower 27) and ieta = 27 (tower 28)
136  // 4by1 and 3by1 sums
137  for (int ieta = 26; ieta < 28; ++ieta) {
138  int sum = 0;
139  for (int dIEta = -2; dIEta <= 27 - ieta; ++dIEta) {
140  if (m_caloInputsToDisable.test(ieta + dIEta) || m_maskedCaloInputs.test(ieta + dIEta))
141  continue; // only process if input link is enabled and not masked
142  sum += inputs.at(bx, iphiIndexOffset + dIEta).etBits();
143  }
144  m_5by1TowerSums.push_back(sum);
145  }
146  }
147 
148  m_initialSums = true;
149 }
150 
152  if (index > m_5by1TowerSums.size()) {
153  edm::LogWarning("energysum out of bounds!");
154  return 0;
155  }
156  // phi wrap around:
157  int returnSum = 0;
158  for (int dIPhi = -2; dIPhi <= 2; ++dIPhi) {
159  int currIndex = (index + dIPhi * 28) % 1008; // wrap-around at top
160  if (currIndex < 0)
161  currIndex = 1008 + currIndex;
162  if ((unsigned)currIndex < m_5by1TowerSums.size()) {
163  returnSum += m_5by1TowerSums[currIndex];
164  } else {
165  edm::LogWarning("energysum out of bounds!");
166  }
167  }
168  return std::min(31, returnSum);
169 }
170 
172  for (auto& mu : muons) {
173  int caloIndex = getCaloIndex(*mu);
174  int energySum = calculate5by5Sum(caloIndex);
175  mu->setHwIsoSum(energySum);
176 
177  int absIso = m_AbsIsoCheckMem->lookup(energySum);
178  int relIso = m_RelIsoCheckMem->lookup(energySum, mu->hwPt());
179 
180  mu->setHwRelIso(relIso);
181  mu->setHwAbsIso(absIso);
182  }
183 }
184 
186  m_towerEnergies.clear();
187  if (bx < inputs.getFirstBX() || bx > inputs.getLastBX())
188  return;
189  if (inputs.size(bx) == 0)
190  return;
191  for (auto input = inputs.begin(bx); input != inputs.end(bx); ++input) {
192  if (m_caloInputsToDisable.test(input->hwEta()) || m_maskedCaloInputs.test(input->hwEta())) {
193  continue; // only process if input link is enabled and not masked
194  }
195  if (input->etBits() != 0) {
196  m_towerEnergies[input->hwEta() * 36 + input->hwPhi()] = input->etBits();
197  }
198  }
199 
200  m_initialSums = true;
201 }
202 
204  for (const auto& mu : muons) {
205  int caloIndex = getCaloIndex(*mu);
206  int energySum = 0;
207  if (m_towerEnergies.count(caloIndex) == 1) {
208  energySum = m_towerEnergies.at(caloIndex);
209  }
210 
211  mu->setHwIsoSum(energySum);
212 
213  int absIso = m_AbsIsoCheckMem->lookup(energySum);
214  int relIso = m_RelIsoCheckMem->lookup(energySum, mu->hwPt());
215 
216  mu->setHwRelIso(relIso);
217  mu->setHwAbsIso(absIso);
218  }
219 }
PDWG_BPHSkim_cff.muons
muons
Definition: PDWG_BPHSkim_cff.py:47
l1t::bmtf
Definition: RegionalMuonCandFwd.h:8
l1t::emtf_neg
Definition: RegionalMuonCandFwd.h:8
input
static const std::string input
Definition: EdmProvDump.cc:48
L1TMuonGlobalParamsHelper::idxSelMemPhiLUT
l1t::LUT * idxSelMemPhiLUT()
Definition: L1TMuonGlobalParamsHelper.h:140
MessageLogger.h
funct::false
false
Definition: Factorize.h:29
GMTInternalMuon.h
l1t::GMTInternalMuon
Definition: GMTInternalMuon.h:10
l1t::MicroGMTConfiguration::PHI
Definition: MicroGMTConfiguration.h:22
l1t::MicroGMTAbsoluteIsolationCheckLUTFactory::create
static ReturnType create(const std::string &filename, const int fwVersion)
Definition: MicroGMTAbsoluteIsolationCheckLUTFactory.cc:18
l1t::omtf_pos
Definition: RegionalMuonCandFwd.h:8
l1t::MicroGMTConfiguration::InterMuonList
GMTInternalMuonList InterMuonList
Definition: MicroGMTConfiguration.h:39
amptDefaultParameters_cff.mu
mu
Definition: amptDefaultParameters_cff.py:16
min
T min(T a, T b)
Definition: MathUtil.h:58
l1t::MicroGMTIsolationUnit::calculate5by1Sums
void calculate5by1Sums(const MicroGMTConfiguration::CaloInputCollection &, int bx)
Definition: MicroGMTIsolationUnit.cc:107
L1TMuonGlobalParamsHelper::bPhiExtrapolationLUT
l1t::LUT * bPhiExtrapolationLUT()
Definition: L1TMuonGlobalParamsHelper.h:150
l1t::MicroGMTIsolationUnit::~MicroGMTIsolationUnit
virtual ~MicroGMTIsolationUnit()
Definition: MicroGMTIsolationUnit.cc:10
Muon.h
l1GtPatternGenerator_cfi.bx
bx
Definition: l1GtPatternGenerator_cfi.py:18
Validation_hcalonly_cfi.sign
sign
Definition: Validation_hcalonly_cfi.py:32
l1t::MicroGMTIsolationUnit::initialise
void initialise(L1TMuonGlobalParamsHelper *)
Initialisation from ES record.
Definition: MicroGMTIsolationUnit.cc:12
L1TMuonGlobalParamsHelper::idxSelMemEtaLUT
l1t::LUT * idxSelMemEtaLUT()
Definition: L1TMuonGlobalParamsHelper.h:141
l1t::MicroGMTIsolationUnit::isolate
void isolate(MicroGMTConfiguration::InterMuonList &) const
Definition: MicroGMTIsolationUnit.cc:171
L1TMuonGlobalParamsHelper::relIsoCheckMemLUT
l1t::LUT * relIsoCheckMemLUT()
Definition: L1TMuonGlobalParamsHelper.h:139
L1TMuonGlobalParamsHelper::fEtaExtrapolationLUT
l1t::LUT * fEtaExtrapolationLUT()
Definition: L1TMuonGlobalParamsHelper.h:155
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
l1t::MicroGMTCaloIndexSelectionLUTFactory::create
static ReturnType create(const std::string &filename, const int type, const int fwVersion)
Definition: MicroGMTCaloIndexSelectionLUTFactory.cc:18
CastorDataFrameFilter_impl::energySum
double energySum(const DataFrame &df, int fs, int ls)
Definition: CastorDataFrameFilter.cc:22
LEDCalibrationChannels.iphi
iphi
Definition: LEDCalibrationChannels.py:64
BXVector
Definition: BXVector.h:15
l1t::MicroGMTExtrapolationLUTFactory::create
static ReturnType create(const std::string &filename, const int type, const int fwVersion)
Definition: MicroGMTExtrapolationLUTFactory.cc:18
l1t::MicroGMTIsolationUnit::calculate5by5Sum
int calculate5by5Sum(unsigned index) const
Definition: MicroGMTIsolationUnit.cc:151
spr::deltaEta
static const double deltaEta
Definition: CaloConstants.h:8
SiPixelRawToDigiRegional_cfi.deltaPhi
deltaPhi
Definition: SiPixelRawToDigiRegional_cfi.py:9
PVValHelper::eta
Definition: PVValidationHelpers.h:70
objects.autophobj.relIso
relIso
Definition: autophobj.py:169
l1t::MicroGMTRelativeIsolationCheckLUTFactory::create
static ReturnType create(const std::string &filename, const int fwVersion)
Definition: MicroGMTRelativeIsolationCheckLUTFactory.cc:18
L1TMuonGlobalParamsHelper::maskedCaloInputs
std::bitset< 28 > maskedCaloInputs() const
Definition: L1TMuonGlobalParamsHelper.h:121
l1t::MicroGMTIsolationUnit::setTowerSums
void setTowerSums(const MicroGMTConfiguration::CaloInputCollection &inputs, int bx)
Definition: MicroGMTIsolationUnit.cc:185
L1TMuonGlobalParamsHelper::fPhiExtrapolationLUT
l1t::LUT * fPhiExtrapolationLUT()
Definition: L1TMuonGlobalParamsHelper.h:152
MicroGMTIsolationUnit.h
LEDCalibrationChannels.ieta
ieta
Definition: LEDCalibrationChannels.py:63
l1t::MicroGMTIsolationUnit::extrapolateMuons
void extrapolateMuons(MicroGMTConfiguration::InterMuonList &) const
Definition: MicroGMTIsolationUnit.cc:67
l1t::MicroGMTConfiguration::getTwosComp
static unsigned getTwosComp(const int signedInt, const int width)
Definition: MicroGMTConfiguration.cc:3
L1TMuonGlobalParamsHelper::oPhiExtrapolationLUT
l1t::LUT * oPhiExtrapolationLUT()
Definition: L1TMuonGlobalParamsHelper.h:151
l1t::MicroGMTConfiguration::ETA_OUT
Definition: MicroGMTConfiguration.h:31
l1t::MicroGMTIsolationUnit::getCaloIndex
int getCaloIndex(MicroGMTConfiguration::InterMuon &) const
Definition: MicroGMTIsolationUnit.cc:50
L1TMuonGlobalParamsHelper::absIsoCheckMemLUT
l1t::LUT * absIsoCheckMemLUT()
Definition: L1TMuonGlobalParamsHelper.h:138
PixelMapPlotter.inputs
inputs
Definition: PixelMapPlotter.py:490
L1TMuonGlobalParamsHelper::fwVersion
unsigned fwVersion() const
Definition: L1TMuonGlobalParamsHelper.h:84
L1TMuonGlobalParamsHelper::bEtaExtrapolationLUT
l1t::LUT * bEtaExtrapolationLUT()
Definition: L1TMuonGlobalParamsHelper.h:153
l1t::MicroGMTIsolationUnit::isolatePreSummed
void isolatePreSummed(MicroGMTConfiguration::InterMuonList &muons) const
Definition: MicroGMTIsolationUnit.cc:203
MuonCaloSum.h
l1t::emtf_pos
Definition: RegionalMuonCandFwd.h:8
objects.autophobj.absIso
absIso
Definition: autophobj.py:147
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
L1TMuonGlobalParamsHelper::oEtaExtrapolationLUT
l1t::LUT * oEtaExtrapolationLUT()
Definition: L1TMuonGlobalParamsHelper.h:154
L1TMuonGlobalParamsHelper::caloInputsToDisable
std::bitset< 28 > caloInputsToDisable() const
Definition: L1TMuonGlobalParamsHelper.h:91
l1t::omtf_neg
Definition: RegionalMuonCandFwd.h:8
L1TMuonGlobalParamsHelper
Definition: L1TMuonGlobalParamsHelper.h:24
l1t::MicroGMTConfiguration::PHI_OUT
Definition: MicroGMTConfiguration.h:31
l1t::MicroGMTConfiguration::ETA
Definition: MicroGMTConfiguration.h:23
l1t::MicroGMTIsolationUnit::MicroGMTIsolationUnit
MicroGMTIsolationUnit()
Definition: MicroGMTIsolationUnit.cc:8