34 #include "L1Trigger/L1TCaloLayer1/src/UCTLayer1.hh" 35 #include "L1Trigger/L1TCaloLayer1/src/UCTCrate.hh" 36 #include "L1Trigger/L1TCaloLayer1/src/UCTCard.hh" 37 #include "L1Trigger/L1TCaloLayer1/src/UCTRegion.hh" 38 #include "L1Trigger/L1TCaloLayer1/src/UCTTower.hh" 39 #include "L1Trigger/L1TCaloLayer1/src/UCTGeometry.hh" 41 #include "L1Trigger/L1TCaloLayer1/src/UCTObject.hh" 42 #include "L1Trigger/L1TCaloLayer1/src/UCTSummaryCard.hh" 43 #include "L1Trigger/L1TCaloLayer1/src/UCTGeometryExtended.hh" 57 #include "L1Trigger/L1TCaloLayer1/src/UCTLogging.hh" 62 #include "hls4ml/emulator.h" 72 template <
class INPUT,
class OUTPUT>
93 std::vector<std::vector<std::vector<uint32_t>>>
pumLUT;
112 std::shared_ptr<hls4mlEmulator::Model>
model;
126 template <
class INPUT,
class OUTPUT>
128 :
nPumBins(iConfig.getParameter<unsigned
int>(
"nPumBins")),
131 jetSeed(iConfig.getParameter<unsigned
int>(
"jetSeed")),
132 tauSeed(iConfig.getParameter<unsigned
int>(
"tauSeed")),
134 eGammaSeed(iConfig.getParameter<unsigned
int>(
"eGammaSeed")),
138 fwVersion(iConfig.getParameter<
int>(
"firmwareVersion")),
140 loader(hls4mlEmulator::ModelLoader(iConfig.getParameter<
string>(
"CICADAModelVersion"))) {
141 std::vector<double> pumLUTData;
142 char pumLUTString[10];
143 for (uint32_t pumBin = 0; pumBin <
nPumBins; pumBin++) {
144 for (uint32_t side = 0; side < 2; side++) {
146 sprintf(pumLUTString,
"pumLUT%2.2dp", pumBin);
148 sprintf(pumLUTString,
"pumLUT%2.2dn", pumBin);
149 pumLUTData = iConfig.
getParameter<std::vector<double>>(pumLUTString);
150 for (uint32_t
iEta = 0;
iEta <
std::max((uint32_t)pumLUTData.size(), MaxUCTRegionsEta);
iEta++) {
153 if (pumLUTData.size() != (MaxUCTRegionsEta))
154 edm::LogError(
"L1TCaloSummary") <<
"PUM LUT Data size integrity check failed; Expected size = " 155 << MaxUCTRegionsEta <<
"; Provided size = " << pumLUTData.size()
156 <<
"; Will use what is provided :(" << std::endl;
159 produces<L1JetParticleCollection>(
"Boosted");
163 produces<float>(
"CICADAScore");
171 template <
class INPUT,
class OUTPUT>
177 std::unique_ptr<float> CICADAScore = std::make_unique<float>();
185 UCTSummaryCard summaryCard =
187 std::vector<UCTRegion*> inputRegions;
188 inputRegions.clear();
191 edm::LogError(
"L1TCaloSummary") <<
"UCT: Failed to get regions from region collection!";
196 INPUT modelInput[252];
198 UCTRegionIndex r =
g.getUCTRegionIndexFromL1CaloRegion(
i.gctEta(),
i.gctPhi());
199 UCTTowerIndex
t =
g.getUCTTowerIndexFromL1CaloRegion(r,
i.raw());
201 uint32_t absCaloPhi =
std::abs(
t.second);
202 bool negativeEta =
false;
205 uint32_t crate =
g.getCrate(
t.first,
t.second);
206 uint32_t card =
g.getCard(
t.first,
t.second);
207 uint32_t
region =
g.getRegion(absCaloEta, absCaloPhi);
209 test->setRegionSummary(
i.raw());
210 inputRegions.push_back(
test);
216 modelInput[14 *
i.gctPhi() + (
i.gctEta() - 4)] =
i.et();
219 OUTPUT modelResult[1] = {
221 model->prepare_input(modelInput);
223 model->read_result(modelResult);
225 *CICADAScore = modelResult[0].to_float();
227 summaryCard.setRegionData(inputRegions);
229 if (!summaryCard.process()) {
230 edm::LogError(
"L1TCaloSummary") <<
"UCT: Failed to process summary card" << std::endl;
239 std::list<UCTObject*> boostedJetObjs = summaryCard.getBoostedJetObjs();
240 for (std::list<UCTObject*>::const_iterator
i = boostedJetObjs.begin();
i != boostedJetObjs.end();
i++) {
241 const UCTObject*
object = *
i;
244 phi =
g.getUCTTowerPhi(
object->iPhi());
245 bitset<3> activeRegionEtaPattern = 0;
247 bool activeStrip =
false;
248 for (uint32_t iPhi = 0; iPhi < 3; iPhi++) {
249 if (
object->boostedJetRegionET()[3 *
iEta + iPhi] > 30 &&
250 object->boostedJetRegionET()[3 *
iEta + iPhi] >
object->et() * 0.0625)
254 activeRegionEtaPattern |= (0x1 <<
iEta);
256 bitset<3> activeRegionPhiPattern = 0;
257 for (uint32_t iPhi = 0; iPhi < 3; iPhi++) {
258 bool activeStrip =
false;
260 if (
object->boostedJetRegionET()[3 *
iEta + iPhi] > 30 &&
261 object->boostedJetRegionET()[3 *
iEta + iPhi] >
object->et() * 0.0625)
265 activeRegionPhiPattern |= (0x1 << iPhi);
267 string regionEta = activeRegionEtaPattern.to_string<char, std::string::traits_type, std::string::allocator_type>();
268 string regionPhi = activeRegionPhiPattern.to_string<char, std::string::traits_type, std::string::allocator_type>();
270 bool centralHighest =
object->boostedJetRegionET()[4] >=
object->boostedJetRegionET()[0] &&
271 object->boostedJetRegionET()[4] >=
object->boostedJetRegionET()[1] &&
272 object->boostedJetRegionET()[4] >=
object->boostedJetRegionET()[2] &&
273 object->boostedJetRegionET()[4] >=
object->boostedJetRegionET()[3] &&
274 object->boostedJetRegionET()[4] >=
object->boostedJetRegionET()[5] &&
275 object->boostedJetRegionET()[4] >=
object->boostedJetRegionET()[6] &&
276 object->boostedJetRegionET()[4] >=
object->boostedJetRegionET()[7] &&
277 object->boostedJetRegionET()[4] >=
object->boostedJetRegionET()[8];
279 if (
abs(
eta) < 2.5 && ((regionEta ==
"101" && (regionPhi ==
"110" || regionPhi ==
"101" || regionPhi ==
"010")) ||
280 ((regionEta ==
"110" || regionEta ==
"101" || regionEta ==
"010") && regionPhi ==
"101") ||
281 (regionEta ==
"111" && (regionPhi ==
"110" || regionPhi ==
"010")) ||
282 ((regionEta ==
"110" || regionEta ==
"010") && regionPhi ==
"111") ||
283 ((regionEta ==
"010" || regionPhi ==
"010" || regionEta ==
"110" || regionPhi ==
"110" ||
284 regionEta ==
"011" || regionPhi ==
"011") &&
295 template <
class INPUT,
class OUTPUT>
T getParameter(std::string const &) const
L1TCaloSummary< ap_ufixed< 10, 10 >, ap_fixed< 11, 5 > > L1TCaloSummaryCICADAv1
L1TCaloSummary< ap_uint< 10 >, ap_ufixed< 16, 8 > > L1TCaloSummaryCICADAv2
Log< level::Error, false > LogError
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
L1TCaloSummary(const edm::ParameterSet &)
void addDefault(ParameterSetDescription const &psetDescription)
void produce(edm::Event &, const edm::EventSetup &) override
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Abs< T >::type abs(const T &t)
#define DEFINE_FWK_MODULE(type)
edm::EDGetTokenT< L1CaloRegionCollection > regionToken
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::shared_ptr< hls4mlEmulator::Model > model
double boostedJetPtFactor
double eGammaIsolationFactor
hls4mlEmulator::ModelLoader loader
std::vector< std::vector< std::vector< uint32_t > > > pumLUT
A calorimeter trigger region (sum of 4x4 trigger towers)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::vector< L1CaloRegion > L1CaloRegionCollection
void beginRun(edm::Run const &, edm::EventSetup const &) override