Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-07-02 00:53:50

0001 #include <string>
0002 #include <list>
0003 #include <vector>
0004 #include <algorithm>
0005 #include <iostream>
0006 #include <sstream>
0007 #include <cassert>
0008 
0009 #include "DataFormats/Common/interface/Handle.h"
0010 #include "DataFormats/Common/interface/Ref.h"
0011 #include "DataFormats/L1TGlobal/interface/GlobalObjectMapFwd.h"
0012 #include "DataFormats/L1TGlobal/interface/GlobalObjectMap.h"
0013 #include "DataFormats/L1TGlobal/interface/GlobalObjectMapRecord.h"
0014 #include "DataFormats/L1TGlobal/interface/GlobalObject.h"
0015 #include "DataFormats/HLTReco/interface/TriggerFilterObjectWithRefs.h"
0016 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0017 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0018 #include "FWCore/Utilities/interface/InputTag.h"
0019 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0020 #include "FWCore/MessageLogger/interface/MessageDrop.h"
0021 #include "FWCore/Utilities/interface/Exception.h"
0022 #include "FWCore/Framework/interface/EventSetup.h"
0023 #include "FWCore/Framework/interface/ESHandle.h"
0024 
0025 #include "DataFormats/L1TGlobal/interface/GlobalAlgBlk.h"
0026 
0027 #include "HLTL1TSeed.h"
0028 
0029 using namespace std;
0030 
0031 // constructors
0032 HLTL1TSeed::HLTL1TSeed(const edm::ParameterSet& parSet)
0033     : HLTStreamFilter(parSet),
0034       //useObjectMaps_(parSet.getParameter<bool>("L1UseL1TriggerObjectMaps")),
0035       m_l1SeedsLogicalExpression(parSet.getParameter<string>("L1SeedsLogicalExpression")),
0036       m_l1GtObjectMapTag(parSet.getParameter<edm::InputTag>("L1ObjectMapInputTag")),
0037       m_l1GtObjectMapToken(consumes<GlobalObjectMapRecord>(m_l1GtObjectMapTag)),
0038       m_l1GlobalTag(parSet.getParameter<edm::InputTag>("L1GlobalInputTag")),
0039       m_l1GlobalToken(consumes<GlobalAlgBlkBxCollection>(m_l1GlobalTag)),
0040       m_l1MuonCollectionsTag(parSet.getParameter<edm::InputTag>("L1MuonInputTag")),  // FIX WHEN UNPACKERS ADDED
0041       m_l1MuonTag(m_l1MuonCollectionsTag),
0042       m_l1MuonToken(consumes<l1t::MuonBxCollection>(m_l1MuonTag)),
0043       m_l1MuonShowerCollectionsTag(
0044           parSet.getParameter<edm::InputTag>("L1MuonShowerInputTag")),  // FIX WHEN UNPACKERS ADDED
0045       m_l1MuonShowerTag(m_l1MuonShowerCollectionsTag),
0046       m_l1MuonShowerToken(consumes<l1t::MuonShowerBxCollection>(m_l1MuonShowerTag)),
0047       m_l1EGammaCollectionsTag(parSet.getParameter<edm::InputTag>("L1EGammaInputTag")),  // FIX WHEN UNPACKERS ADDED
0048       m_l1EGammaTag(m_l1EGammaCollectionsTag),
0049       m_l1EGammaToken(consumes<l1t::EGammaBxCollection>(m_l1EGammaTag)),
0050       m_l1JetCollectionsTag(parSet.getParameter<edm::InputTag>("L1JetInputTag")),  // FIX WHEN UNPACKERS ADDED
0051       m_l1JetTag(m_l1JetCollectionsTag),
0052       m_l1JetToken(consumes<l1t::JetBxCollection>(m_l1JetTag)),
0053       m_l1TauCollectionsTag(parSet.getParameter<edm::InputTag>("L1TauInputTag")),  // FIX WHEN UNPACKERS ADDED
0054       m_l1TauTag(m_l1TauCollectionsTag),
0055       m_l1TauToken(consumes<l1t::TauBxCollection>(m_l1TauTag)),
0056       m_l1EtSumCollectionsTag(parSet.getParameter<edm::InputTag>("L1EtSumInputTag")),  // FIX WHEN UNPACKERS ADDED
0057       m_l1EtSumTag(m_l1EtSumCollectionsTag),
0058       m_l1EtSumToken(consumes<l1t::EtSumBxCollection>(m_l1EtSumTag)),
0059       m_l1EtSumZdcCollectionsTag(parSet.getParameter<edm::InputTag>("L1EtSumZdcInputTag")),  // FIX WHEN UNPACKERS ADDED
0060       m_l1EtSumZdcTag(m_l1EtSumZdcCollectionsTag),
0061       m_l1EtSumZdcToken(consumes<l1t::EtSumBxCollection>(m_l1EtSumZdcTag)),
0062       m_l1GlobalDecision(false),
0063       m_isDebugEnabled(edm::isDebugEnabled()) {
0064   if (m_l1SeedsLogicalExpression.empty()) {
0065     throw cms::Exception("FailModule") << "\nTrying to seed with an empty L1SeedsLogicalExpression.\n" << std::endl;
0066 
0067   } else if (m_l1SeedsLogicalExpression != "L1GlobalDecision") {
0068     // check also the logical expression - add/remove spaces if needed
0069     m_l1AlgoLogicParser = GlobalLogicParser(m_l1SeedsLogicalExpression);
0070 
0071     // list of required algorithms for seeding
0072     // dummy values for tokenNumber and tokenResult
0073     m_l1AlgoSeeds.reserve((m_l1AlgoLogicParser.operandTokenVector()).size());
0074     m_l1AlgoSeeds = m_l1AlgoLogicParser.expressionSeedsOperandList();
0075     size_t l1AlgoSeedsSize = m_l1AlgoSeeds.size();
0076 
0077     m_l1AlgoSeedsRpn.reserve(l1AlgoSeedsSize);
0078     m_l1AlgoSeedsObjType.reserve(l1AlgoSeedsSize);
0079 
0080   } else {
0081     m_l1GlobalDecision = true;
0082   }
0083 }
0084 
0085 // destructor
0086 HLTL1TSeed::~HLTL1TSeed() {
0087   // empty now
0088 }
0089 
0090 // member functions
0091 
0092 void HLTL1TSeed::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0093   edm::ParameterSetDescription desc;
0094   makeHLTFilterDescription(desc);
0095 
0096   // # logical expression for the required L1 algorithms;
0097   // # the algorithms are specified by name
0098   // # allowed operators: "AND", "OR", "NOT", "(", ")"
0099   // #
0100   // # by convention, "L1GlobalDecision" logical expression means global decision
0101   desc.add<string>("L1SeedsLogicalExpression", "");
0102   desc.add<edm::InputTag>("L1ObjectMapInputTag", edm::InputTag("hltGtStage2ObjectMap"));
0103   desc.add<edm::InputTag>("L1GlobalInputTag", edm::InputTag("hltGtStage2Digis"));
0104   desc.add<edm::InputTag>("L1MuonInputTag", edm::InputTag("hltGtStage2Digis:Muon"));
0105   desc.add<edm::InputTag>("L1MuonShowerInputTag", edm::InputTag("hltGtStage2Digis:MuonShower"));
0106   desc.add<edm::InputTag>("L1EGammaInputTag", edm::InputTag("hltGtStage2Digis:EGamma"));
0107   desc.add<edm::InputTag>("L1JetInputTag", edm::InputTag("hltGtStage2Digis:Jet"));
0108   desc.add<edm::InputTag>("L1TauInputTag", edm::InputTag("hltGtStage2Digis:Tau"));
0109   desc.add<edm::InputTag>("L1EtSumInputTag", edm::InputTag("hltGtStage2Digis:EtSum"));
0110   desc.add<edm::InputTag>("L1EtSumZdcInputTag", edm::InputTag("hltGtStage2Digis:EtSumZDC"));
0111   descriptions.add("hltL1TSeed", desc);
0112 }
0113 
0114 bool HLTL1TSeed::hltFilter(edm::Event& iEvent,
0115                            const edm::EventSetup& evSetup,
0116                            trigger::TriggerFilterObjectWithRefs& filterproduct) {
0117   bool rc = false;
0118 
0119   // the filter object
0120   if (saveTags()) {
0121     // muons
0122     filterproduct.addCollectionTag(m_l1MuonTag);
0123 
0124     // muon showers
0125     filterproduct.addCollectionTag(m_l1MuonShowerTag);
0126 
0127     // egamma
0128     filterproduct.addCollectionTag(m_l1EGammaTag);
0129 
0130     // jet
0131     filterproduct.addCollectionTag(m_l1JetTag);
0132 
0133     // tau
0134     filterproduct.addCollectionTag(m_l1TauTag);
0135 
0136     // etsum
0137     filterproduct.addCollectionTag(m_l1EtSumTag);
0138 
0139     // etsum (ZDC)
0140     filterproduct.addCollectionTag(m_l1EtSumZdcTag);
0141   }
0142 
0143   // Get all the seeding from iEvent (i.e. L1TriggerObjectMapRecord)
0144   //
0145   rc = seedsL1TriggerObjectMaps(iEvent, filterproduct);
0146 
0147   if (m_isDebugEnabled) {
0148     dumpTriggerFilterObjectWithRefs(filterproduct);
0149   }
0150 
0151   return rc;
0152 }
0153 
0154 // detailed print of filter content
0155 void HLTL1TSeed::dumpTriggerFilterObjectWithRefs(trigger::TriggerFilterObjectWithRefs& filterproduct) const {
0156   LogTrace("HLTL1TSeed") << "\nHLTL1TSeed::hltFilter "
0157                          << "\n  Dump TriggerFilterObjectWithRefs\n"
0158                          << endl;
0159 
0160   vector<l1t::MuonRef> seedsL1Mu;
0161   filterproduct.getObjects(trigger::TriggerL1Mu, seedsL1Mu);
0162   const size_t sizeSeedsL1Mu = seedsL1Mu.size();
0163 
0164   LogTrace("HLTL1TSeed") << "\n  HLTL1TSeed: seed logical expression = " << m_l1SeedsLogicalExpression << endl;
0165 
0166   LogTrace("HLTL1TSeed") << "\n  L1Mu seeds:      " << sizeSeedsL1Mu << endl << endl;
0167 
0168   for (size_t i = 0; i != sizeSeedsL1Mu; i++) {
0169     l1t::MuonRef obj = l1t::MuonRef(seedsL1Mu[i]);
0170 
0171     LogTrace("HLTL1TSeed") << "\tL1Mu     "
0172                            << "\t"
0173                            << "q = "
0174                            << obj->hwCharge()  // TEMP get hwCharge insead of charge which is not yet set NEED FIX.
0175                            << "\t"
0176                            << "pt = " << obj->pt() << "\t"
0177                            << "eta =  " << obj->eta() << "\t"
0178                            << "phi =  " << obj->phi();  //<< "\t" << "BX = " << obj->bx();
0179   }
0180 
0181   vector<l1t::MuonShowerRef> seedsL1MuShower;
0182   filterproduct.getObjects(trigger::TriggerL1MuShower, seedsL1MuShower);
0183   const size_t sizeSeedsL1MuShower = seedsL1MuShower.size();
0184 
0185   LogTrace("HLTL1TSeed") << "\n  HLTL1TSeed: seed logical expression = " << m_l1SeedsLogicalExpression << endl;
0186 
0187   LogTrace("HLTL1TSeed") << "\n  L1MuShower seeds:      " << sizeSeedsL1MuShower << endl << endl;
0188 
0189   for (size_t i = 0; i != sizeSeedsL1MuShower; i++) {
0190     l1t::MuonShowerRef obj = l1t::MuonShowerRef(seedsL1MuShower[i]);
0191 
0192     LogTrace("HLTL1TSeed") << "\tL1MuShower     "
0193                            << "\t"
0194                            << "pt = " << obj->pt() << "\t"
0195                            << "eta =  " << obj->eta() << "\t"
0196                            << "phi =  " << obj->phi();  //<< "\t" << "BX = " << obj->bx();
0197   }
0198 
0199   vector<l1t::EGammaRef> seedsL1EG;
0200   filterproduct.getObjects(trigger::TriggerL1EG, seedsL1EG);
0201   const size_t sizeSeedsL1EG = seedsL1EG.size();
0202 
0203   LogTrace("HLTL1TSeed") << "\n  L1EG seeds:      " << sizeSeedsL1EG << endl << endl;
0204 
0205   for (size_t i = 0; i != sizeSeedsL1EG; i++) {
0206     l1t::EGammaRef obj = l1t::EGammaRef(seedsL1EG[i]);
0207 
0208     LogTrace("HLTL1TSeed") << "\tL1EG     "
0209                            << "\t"
0210                            << "pt = " << obj->pt() << "\t"
0211                            << "eta =  " << obj->eta() << "\t"
0212                            << "phi =  " << obj->phi();  //<< "\t" << "BX = " << obj->bx();
0213   }
0214 
0215   vector<l1t::JetRef> seedsL1Jet;
0216   filterproduct.getObjects(trigger::TriggerL1Jet, seedsL1Jet);
0217   const size_t sizeSeedsL1Jet = seedsL1Jet.size();
0218 
0219   LogTrace("HLTL1TSeed") << "\n  L1Jet seeds:      " << sizeSeedsL1Jet << endl << endl;
0220 
0221   for (size_t i = 0; i != sizeSeedsL1Jet; i++) {
0222     l1t::JetRef obj = l1t::JetRef(seedsL1Jet[i]);
0223 
0224     LogTrace("HLTL1TSeed") << "\tL1Jet     "
0225                            << "\t"
0226                            << "pt = " << obj->pt() << "\t"
0227                            << "eta =  " << obj->eta() << "\t"
0228                            << "phi =  " << obj->phi();  //<< "\t" << "BX = " << obj->bx();
0229   }
0230 
0231   vector<l1t::TauRef> seedsL1Tau;
0232   filterproduct.getObjects(trigger::TriggerL1Tau, seedsL1Tau);
0233   const size_t sizeSeedsL1Tau = seedsL1Tau.size();
0234 
0235   LogTrace("HLTL1TSeed") << "\n  L1Tau seeds:      " << sizeSeedsL1Tau << endl << endl;
0236 
0237   for (size_t i = 0; i != sizeSeedsL1Tau; i++) {
0238     l1t::TauRef obj = l1t::TauRef(seedsL1Tau[i]);
0239 
0240     LogTrace("HLTL1TSeed") << "\tL1Tau     "
0241                            << "\t"
0242                            << "pt = " << obj->pt() << "\t"
0243                            << "eta =  " << obj->eta() << "\t"
0244                            << "phi =  " << obj->phi();  //<< "\t" << "BX = " << obj->bx();
0245   }
0246 
0247   vector<l1t::EtSumRef> seedsL1EtSumETT;
0248   filterproduct.getObjects(trigger::TriggerL1ETT, seedsL1EtSumETT);
0249   const size_t sizeSeedsL1EtSumETT = seedsL1EtSumETT.size();
0250   LogTrace("HLTL1TSeed") << "\n  L1EtSum ETT seeds:      " << sizeSeedsL1EtSumETT << endl << endl;
0251 
0252   for (size_t i = 0; i != sizeSeedsL1EtSumETT; i++) {
0253     l1t::EtSumRef obj = l1t::EtSumRef(seedsL1EtSumETT[i]);
0254 
0255     LogTrace("HLTL1TSeed") << "\tL1EtSum  ETT"
0256                            << "\t"
0257                            << "pt = " << obj->pt() << "\t"
0258                            << "eta =  " << obj->eta() << "\t"
0259                            << "phi =  " << obj->phi();  //<< "\t" << "BX = " << obj->bx();
0260   }
0261 
0262   vector<l1t::EtSumRef> seedsL1EtSumHTT;
0263   filterproduct.getObjects(trigger::TriggerL1HTT, seedsL1EtSumHTT);
0264   const size_t sizeSeedsL1EtSumHTT = seedsL1EtSumHTT.size();
0265   LogTrace("HLTL1TSeed") << "\n  L1EtSum HTT seeds:      " << sizeSeedsL1EtSumHTT << endl << endl;
0266 
0267   for (size_t i = 0; i != sizeSeedsL1EtSumHTT; i++) {
0268     l1t::EtSumRef obj = l1t::EtSumRef(seedsL1EtSumHTT[i]);
0269 
0270     LogTrace("HLTL1TSeed") << "\tL1EtSum  HTT"
0271                            << "\t"
0272                            << "pt = " << obj->pt() << "\t"
0273                            << "eta =  " << obj->eta() << "\t"
0274                            << "phi =  " << obj->phi();  //<< "\t" << "BX = " << obj->bx();
0275   }
0276 
0277   vector<l1t::EtSumRef> seedsL1EtSumETM;
0278   filterproduct.getObjects(trigger::TriggerL1ETM, seedsL1EtSumETM);
0279   const size_t sizeSeedsL1EtSumETM = seedsL1EtSumETM.size();
0280   LogTrace("HLTL1TSeed") << "\n  L1EtSum ETM seeds:      " << sizeSeedsL1EtSumETM << endl << endl;
0281 
0282   for (size_t i = 0; i != sizeSeedsL1EtSumETM; i++) {
0283     l1t::EtSumRef obj = l1t::EtSumRef(seedsL1EtSumETM[i]);
0284 
0285     LogTrace("HLTL1TSeed") << "\tL1EtSum  ETM"
0286                            << "\t"
0287                            << "pt = " << obj->pt() << "\t"
0288                            << "eta =  " << obj->eta() << "\t"
0289                            << "phi =  " << obj->phi();  //<< "\t" << "BX = " << obj->bx();
0290   }
0291 
0292   vector<l1t::EtSumRef> seedsL1EtSumETMHF;
0293   filterproduct.getObjects(trigger::TriggerL1ETMHF, seedsL1EtSumETMHF);
0294   const size_t sizeSeedsL1EtSumETMHF = seedsL1EtSumETMHF.size();
0295   LogTrace("HLTL1TSeed") << "\n  L1EtSum ETMHF seeds:      " << sizeSeedsL1EtSumETMHF << endl << endl;
0296 
0297   for (size_t i = 0; i != sizeSeedsL1EtSumETMHF; i++) {
0298     l1t::EtSumRef obj = l1t::EtSumRef(seedsL1EtSumETMHF[i]);
0299 
0300     LogTrace("HLTL1TSeed") << "\tL1EtSum  ETMHF"
0301                            << "\t"
0302                            << "pt = " << obj->pt() << "\t"
0303                            << "eta =  " << obj->eta() << "\t"
0304                            << "phi =  " << obj->phi();  //<< "\t" << "BX = " << obj->bx();
0305   }
0306 
0307   vector<l1t::EtSumRef> seedsL1EtSumHTMHF;
0308   filterproduct.getObjects(trigger::TriggerL1HTMHF, seedsL1EtSumHTMHF);
0309   const size_t sizeSeedsL1EtSumHTMHF = seedsL1EtSumHTMHF.size();
0310   LogTrace("HLTL1TSeed") << "\n  L1EtSum HTMHF seeds:      " << sizeSeedsL1EtSumHTMHF << endl << endl;
0311 
0312   for (size_t i = 0; i != sizeSeedsL1EtSumHTMHF; i++) {
0313     l1t::EtSumRef obj = l1t::EtSumRef(seedsL1EtSumHTMHF[i]);
0314 
0315     LogTrace("HLTL1TSeed") << "\tL1EtSum  HTMHF"
0316                            << "\t"
0317                            << "pt = " << obj->pt() << "\t"
0318                            << "eta =  " << obj->eta() << "\t"
0319                            << "phi =  " << obj->phi();  //<< "\t" << "BX = " << obj->bx();
0320   }
0321 
0322   vector<l1t::EtSumRef> seedsL1EtSumHTM;
0323   filterproduct.getObjects(trigger::TriggerL1HTM, seedsL1EtSumHTM);
0324   const size_t sizeSeedsL1EtSumHTM = seedsL1EtSumHTM.size();
0325   LogTrace("HLTL1TSeed") << "\n  L1EtSum HTM seeds:      " << sizeSeedsL1EtSumHTM << endl << endl;
0326 
0327   for (size_t i = 0; i != sizeSeedsL1EtSumHTM; i++) {
0328     l1t::EtSumRef obj = l1t::EtSumRef(seedsL1EtSumHTM[i]);
0329 
0330     LogTrace("HLTL1TSeed") << "\tL1EtSum  HTM"
0331                            << "\t"
0332                            << "pt = " << obj->pt() << "\t"
0333                            << "eta =  " << obj->eta() << "\t"
0334                            << "phi =  " << obj->phi();  //<< "\t" << "BX = " << obj->bx();
0335   }
0336 
0337   vector<l1t::EtSumRef> seedsL1EtSumCentrality;
0338   filterproduct.getObjects(trigger::TriggerL1Centrality, seedsL1EtSumCentrality);
0339   const size_t sizeSeedsL1EtSumCentrality = seedsL1EtSumCentrality.size();
0340   LogTrace("HLTL1TSeed") << "\n  L1EtSum Centrality seeds:      " << sizeSeedsL1EtSumCentrality << endl << endl;
0341 
0342   for (size_t i = 0; i != sizeSeedsL1EtSumCentrality; i++) {
0343     l1t::EtSumRef obj = l1t::EtSumRef(seedsL1EtSumCentrality[i]);
0344 
0345     LogTrace("HLTL1TSeed") << "\tL1EtSum  Centrality Bits: " << std::bitset<8>(obj->hwPt())
0346                            << " (hwPt = " << obj->hwPt() << ")";
0347   }
0348 
0349   vector<l1t::EtSumRef> seedsL1EtSumMinBiasHFP0;
0350   filterproduct.getObjects(trigger::TriggerL1MinBiasHFP0, seedsL1EtSumMinBiasHFP0);
0351   const size_t sizeSeedsL1EtSumMinBiasHFP0 = seedsL1EtSumMinBiasHFP0.size();
0352   LogTrace("HLTL1TSeed") << "\n  L1EtSum MinBiasHFP0 seeds:      " << sizeSeedsL1EtSumMinBiasHFP0 << endl << endl;
0353 
0354   for (size_t i = 0; i != sizeSeedsL1EtSumMinBiasHFP0; i++) {
0355     l1t::EtSumRef obj = l1t::EtSumRef(seedsL1EtSumMinBiasHFP0[i]);
0356 
0357     LogTrace("HLTL1TSeed") << "\tL1EtSum  MinBiasHFP0: hwPt = " << obj->hwPt();
0358   }
0359 
0360   vector<l1t::EtSumRef> seedsL1EtSumMinBiasHFM0;
0361   filterproduct.getObjects(trigger::TriggerL1MinBiasHFM0, seedsL1EtSumMinBiasHFM0);
0362   const size_t sizeSeedsL1EtSumMinBiasHFM0 = seedsL1EtSumMinBiasHFM0.size();
0363   LogTrace("HLTL1TSeed") << "\n  L1EtSum MinBiasHFM0 seeds:      " << sizeSeedsL1EtSumMinBiasHFM0 << endl << endl;
0364 
0365   for (size_t i = 0; i != sizeSeedsL1EtSumMinBiasHFM0; i++) {
0366     l1t::EtSumRef obj = l1t::EtSumRef(seedsL1EtSumMinBiasHFM0[i]);
0367 
0368     LogTrace("HLTL1TSeed") << "\tL1EtSum  MinBiasHFM0: hwPt = " << obj->hwPt();
0369   }
0370 
0371   vector<l1t::EtSumRef> seedsL1EtSumMinBiasHFP1;
0372   filterproduct.getObjects(trigger::TriggerL1MinBiasHFP1, seedsL1EtSumMinBiasHFP1);
0373   const size_t sizeSeedsL1EtSumMinBiasHFP1 = seedsL1EtSumMinBiasHFP1.size();
0374   LogTrace("HLTL1TSeed") << "\n  L1EtSum MinBiasHFP1 seeds:      " << sizeSeedsL1EtSumMinBiasHFP1 << endl << endl;
0375 
0376   for (size_t i = 0; i != sizeSeedsL1EtSumMinBiasHFP1; i++) {
0377     l1t::EtSumRef obj = l1t::EtSumRef(seedsL1EtSumMinBiasHFP1[i]);
0378 
0379     LogTrace("HLTL1TSeed") << "\tL1EtSum  MinBiasHFP1: hwPt = " << obj->hwPt();
0380   }
0381 
0382   vector<l1t::EtSumRef> seedsL1EtSumMinBiasHFM1;
0383   filterproduct.getObjects(trigger::TriggerL1MinBiasHFM1, seedsL1EtSumMinBiasHFM1);
0384   const size_t sizeSeedsL1EtSumMinBiasHFM1 = seedsL1EtSumMinBiasHFM1.size();
0385   LogTrace("HLTL1TSeed") << "\n  L1EtSum MinBiasHFM1 seeds:      " << sizeSeedsL1EtSumMinBiasHFM1 << endl << endl;
0386 
0387   for (size_t i = 0; i != sizeSeedsL1EtSumMinBiasHFM1; i++) {
0388     l1t::EtSumRef obj = l1t::EtSumRef(seedsL1EtSumMinBiasHFM1[i]);
0389 
0390     LogTrace("HLTL1TSeed") << "\tL1EtSum  MinBiasHFM1: hwPt = " << obj->hwPt();
0391   }
0392 
0393   vector<l1t::EtSumRef> seedsL1EtSumTowerCount;
0394   filterproduct.getObjects(trigger::TriggerL1TowerCount, seedsL1EtSumTowerCount);
0395   const size_t sizeSeedsL1EtSumTowerCount = seedsL1EtSumTowerCount.size();
0396   LogTrace("HLTL1TSeed") << "\n  L1EtSum TowerCount seeds:      " << sizeSeedsL1EtSumTowerCount << endl << endl;
0397 
0398   for (size_t i = 0; i != sizeSeedsL1EtSumTowerCount; i++) {
0399     l1t::EtSumRef obj = l1t::EtSumRef(seedsL1EtSumTowerCount[i]);
0400 
0401     LogTrace("HLTL1TSeed") << "\tL1EtSum  TowerCount: hwPt = " << obj->hwPt();
0402   }
0403 
0404   vector<l1t::EtSumRef> seedsL1EtSumAsymEt;
0405   filterproduct.getObjects(trigger::TriggerL1AsymEt, seedsL1EtSumAsymEt);
0406   const size_t sizeSeedsL1EtSumAsymEt = seedsL1EtSumAsymEt.size();
0407   LogTrace("HLTL1TSeed") << "\n  L1EtSum AsymEt seeds:      " << sizeSeedsL1EtSumAsymEt << endl << endl;
0408 
0409   for (size_t i = 0; i != sizeSeedsL1EtSumAsymEt; i++) {
0410     l1t::EtSumRef obj = l1t::EtSumRef(seedsL1EtSumAsymEt[i]);
0411 
0412     LogTrace("HLTL1TSeed") << "\tL1EtSum  AsymEt: hwPt = " << obj->hwPt();
0413   }
0414 
0415   vector<l1t::EtSumRef> seedsL1EtSumAsymHt;
0416   filterproduct.getObjects(trigger::TriggerL1AsymHt, seedsL1EtSumAsymHt);
0417   const size_t sizeSeedsL1EtSumAsymHt = seedsL1EtSumAsymHt.size();
0418   LogTrace("HLTL1TSeed") << "\n  L1EtSum AsymHt seeds:      " << sizeSeedsL1EtSumAsymHt << endl << endl;
0419 
0420   for (size_t i = 0; i != sizeSeedsL1EtSumAsymHt; i++) {
0421     l1t::EtSumRef obj = l1t::EtSumRef(seedsL1EtSumAsymHt[i]);
0422 
0423     LogTrace("HLTL1TSeed") << "\tL1EtSum  AsymHt: hwPt = " << obj->hwPt();
0424   }
0425 
0426   vector<l1t::EtSumRef> seedsL1EtSumAsymEtHF;
0427   filterproduct.getObjects(trigger::TriggerL1AsymEtHF, seedsL1EtSumAsymEtHF);
0428   const size_t sizeSeedsL1EtSumAsymEtHF = seedsL1EtSumAsymEtHF.size();
0429   LogTrace("HLTL1TSeed") << "\n  L1EtSum AsymEtHF seeds:      " << sizeSeedsL1EtSumAsymEtHF << endl << endl;
0430 
0431   for (size_t i = 0; i != sizeSeedsL1EtSumAsymEtHF; i++) {
0432     l1t::EtSumRef obj = l1t::EtSumRef(seedsL1EtSumAsymEtHF[i]);
0433 
0434     LogTrace("HLTL1TSeed") << "\tL1EtSum  AsymEtHF: hwPt = " << obj->hwPt();
0435   }
0436 
0437   vector<l1t::EtSumRef> seedsL1EtSumAsymHtHF;
0438   filterproduct.getObjects(trigger::TriggerL1AsymHtHF, seedsL1EtSumAsymHtHF);
0439   const size_t sizeSeedsL1EtSumAsymHtHF = seedsL1EtSumAsymHtHF.size();
0440   LogTrace("HLTL1TSeed") << "\n  L1EtSum AsymHtHF seeds:      " << sizeSeedsL1EtSumAsymHtHF << endl << endl;
0441 
0442   for (size_t i = 0; i != sizeSeedsL1EtSumAsymHtHF; i++) {
0443     l1t::EtSumRef obj = l1t::EtSumRef(seedsL1EtSumAsymHtHF[i]);
0444 
0445     LogTrace("HLTL1TSeed") << "\tL1EtSum  AsymHtHF: hwPt = " << obj->hwPt();
0446   }
0447 
0448   vector<l1t::EtSumRef> seedsL1EtSumZDCP;
0449   filterproduct.getObjects(trigger::TriggerL1ZDCP, seedsL1EtSumZDCP);
0450   const size_t sizeSeedsL1EtSumZDCP = seedsL1EtSumZDCP.size();
0451   LogTrace("HLTL1TSeed") << "\n  L1EtSum ZDCP seeds:      " << sizeSeedsL1EtSumZDCP << endl << endl;
0452 
0453   for (size_t i = 0; i != sizeSeedsL1EtSumZDCP; i++) {
0454     l1t::EtSumRef obj = l1t::EtSumRef(seedsL1EtSumZDCP[i]);
0455 
0456     LogTrace("HLTL1TSeed") << "\tL1EtSum  ZDCP"
0457                            << "\t"
0458                            << "pt = " << obj->pt() << "\t"
0459                            << "eta =  " << obj->eta() << "\t"
0460                            << "phi =  " << obj->phi();  //<< "\t" << "BX = " << obj->bx();
0461   }
0462 
0463   vector<l1t::EtSumRef> seedsL1EtSumZDCM;
0464   filterproduct.getObjects(trigger::TriggerL1ZDCM, seedsL1EtSumZDCM);
0465   const size_t sizeSeedsL1EtSumZDCM = seedsL1EtSumZDCM.size();
0466   LogTrace("HLTL1TSeed") << "\n  L1EtSum ZDCM seeds:      " << sizeSeedsL1EtSumZDCM << endl << endl;
0467 
0468   for (size_t i = 0; i != sizeSeedsL1EtSumZDCM; i++) {
0469     l1t::EtSumRef obj = l1t::EtSumRef(seedsL1EtSumZDCM[i]);
0470 
0471     LogTrace("HLTL1TSeed") << "\tL1EtSum  ZDCM"
0472                            << "\t"
0473                            << "pt = " << obj->pt() << "\t"
0474                            << "eta =  " << obj->eta() << "\t"
0475                            << "phi =  " << obj->phi();  //<< "\t" << "BX = " << obj->bx();
0476   }
0477 
0478   LogTrace("HLTL1TSeed") << " \n\n" << endl;
0479 }
0480 
0481 // seeding is done via L1 trigger object maps, considering the objects which fired in L1
0482 bool HLTL1TSeed::seedsL1TriggerObjectMaps(edm::Event& iEvent, trigger::TriggerFilterObjectWithRefs& filterproduct) {
0483   // Two GT objects are obtained from the Event: (1) the unpacked GT and (2) the emulated GT.
0484   // Return value of the function is the score of seeding logical expression, evaluated using (1).
0485   // Seeding is performed (per l1_algo) if ACCEPT both in (1) and (2). Seed objects are identified
0486   // and only available from ObjectMaps created in (2).
0487 
0488   // define index lists for all particle types
0489 
0490   std::list<int> listMuon;
0491   std::list<int> listMuonShower;
0492 
0493   std::list<int> listEG;
0494 
0495   std::list<int> listJet;
0496   std::list<int> listTau;
0497 
0498   std::list<int> listETM;
0499   std::list<int> listETT;
0500   std::list<int> listHTT;
0501   std::list<int> listHTM;
0502   std::list<int> listETMHF;
0503   std::list<int> listHTMHF;
0504 
0505   std::list<int> listJetCounts;
0506 
0507   std::list<int> listCentrality;
0508   std::list<int> listMinBiasHFP0;
0509   std::list<int> listMinBiasHFM0;
0510   std::list<int> listMinBiasHFP1;
0511   std::list<int> listMinBiasHFM1;
0512   std::list<int> listTotalEtEm;
0513   std::list<int> listMissingEtHF;
0514   std::list<int> listTowerCount;
0515   std::list<int> listAsymEt;
0516   std::list<int> listAsymHt;
0517   std::list<int> listAsymEtHF;
0518   std::list<int> listAsymHtHF;
0519   std::list<int> listZDCP;
0520   std::list<int> listZDCM;
0521 
0522   // get handle to unpacked GT
0523   edm::Handle<GlobalAlgBlkBxCollection> uGtAlgoBlocks;
0524   iEvent.getByToken(m_l1GlobalToken, uGtAlgoBlocks);
0525 
0526   if (!uGtAlgoBlocks.isValid()) {
0527     edm::LogWarning("HLTL1TSeed") << " Warning: GlobalAlgBlkBxCollection with input tag " << m_l1GlobalTag
0528                                   << " requested in configuration, but not found in the event." << std::endl;
0529 
0530     return false;
0531   }
0532 
0533   // check size (all BXs)
0534   if (uGtAlgoBlocks->size() == 0) {
0535     edm::LogWarning("HLTL1TSeed") << " Warning: GlobalAlgBlkBxCollection with input tag " << m_l1GlobalTag
0536                                   << " is empty for all BXs.";
0537     return false;
0538   }
0539 
0540   // check size (BX 0)
0541   if (uGtAlgoBlocks->isEmpty(0)) {
0542     edm::LogWarning("HLTL1TSeed") << " Warning: GlobalAlgBlkBxCollection with input tag " << m_l1GlobalTag
0543                                   << " is empty for BX=0.";
0544     return false;
0545   }
0546 
0547   // get handle to object maps from emulator (one object map per algorithm)
0548   edm::Handle<GlobalObjectMapRecord> gtObjectMapRecord;
0549   iEvent.getByToken(m_l1GtObjectMapToken, gtObjectMapRecord);
0550 
0551   if (!gtObjectMapRecord.isValid()) {
0552     edm::LogWarning("HLTL1TSeed") << " Warning: GlobalObjectMapRecord with input tag " << m_l1GtObjectMapTag
0553                                   << " requested in configuration, but not found in the event." << std::endl;
0554 
0555     return false;
0556   }
0557 
0558   if (m_isDebugEnabled) {
0559     const std::vector<GlobalObjectMap>& objMaps = gtObjectMapRecord->gtObjectMap();
0560 
0561     LogTrace("HLTL1TSeed") << "\nHLTL1Seed"
0562                            << "\n--------------------------------------------------------------------------------------"
0563                               "-------------------------------";
0564 
0565     LogTrace("HLTL1TSeed")
0566         << "\n\tAlgorithms in L1TriggerObjectMapRecord and GT results ( emulated | initial | prescaled | final ) "
0567         << endl;
0568 
0569     LogTrace("HLTL1TSeed") << "\n\tmap"
0570                            << "\tAlgoBit" << std::setw(40) << "algoName"
0571                            << "\t (emul|ini|pre|fin)" << endl;
0572 
0573     LogTrace("HLTL1TSeed") << "----------------------------------------------------------------------------------------"
0574                               "-----------------------------";
0575 
0576     for (size_t imap = 0; imap < objMaps.size(); imap++) {
0577       int bit = objMaps[imap].algoBitNumber();  //  same as bit from L1T Menu
0578 
0579       int emulDecision = objMaps[imap].algoGtlResult();
0580 
0581       // For bx=0 , get 0th AlgoBlock, so in BXvector at(bx=0,i=0)
0582       int initDecision = (uGtAlgoBlocks->at(0, 0)).getAlgoDecisionInitial(bit);
0583       int presDecision = (uGtAlgoBlocks->at(0, 0)).getAlgoDecisionInterm(bit);
0584       int finlDecision = (uGtAlgoBlocks->at(0, 0)).getAlgoDecisionFinal(bit);
0585 
0586       if (emulDecision != initDecision) {
0587         LogTrace("HLTL1TSeed") << "L1T decision (emulated vs. unpacked initial) is not the same:"
0588                                << "\n\tbit = " << std::setw(3) << bit << std::setw(40) << objMaps[imap].algoName()
0589                                << "\t emulated decision = " << emulDecision
0590                                << "\t unpacked initial decision = " << initDecision
0591                                << "\nThis should not happen. Include the L1TGtEmulCompare module in the sequence."
0592                                << endl;
0593       }
0594 
0595       LogTrace("HLTL1TSeed") << "\t" << std::setw(3) << imap << "\tbit = " << std::setw(3) << bit << std::setw(40)
0596                              << objMaps[imap].algoName() << "\t (  " << emulDecision << " | " << initDecision << " | "
0597                              << presDecision << " | " << finlDecision << " ) ";
0598     }
0599     LogTrace("HLTL1TSeed") << endl;
0600   }
0601 
0602   // Filter decision in case of "L1GlobalDecision" logical expression.
0603   // By convention, it means global decision.
0604   // /////////////////////////////////////////////////////////////////
0605   if (m_l1GlobalDecision) {
0606     // For bx=0 , get 0th AlgoBlock, so in BXvector at(bx=0,i=0)
0607     return (uGtAlgoBlocks->at(0, 0)).getFinalOR();
0608   }
0609 
0610   // Update/Reset m_l1AlgoLogicParser by reseting token result
0611   // /////////////////////////////////////////////////////////
0612   std::vector<GlobalLogicParser::OperandToken>& algOpTokenVector = m_l1AlgoLogicParser.operandTokenVector();
0613 
0614   for (auto& i : algOpTokenVector) {
0615     // rest token result
0616     //
0617     i.tokenResult = false;
0618   }
0619 
0620   // Update m_l1AlgoLogicParser and store emulator results for algOpTokens
0621   // /////////////////////////////////////////////////////////////////////
0622   for (auto& i : algOpTokenVector) {
0623     std::string algoName = i.tokenName;
0624 
0625     const GlobalObjectMap* objMap = gtObjectMapRecord->getObjectMap(algoName);
0626 
0627     if (objMap == nullptr) {
0628       throw cms::Exception("FailModule")
0629           << "\nAlgorithm " << algoName
0630           << ", requested as seed by a HLT path, cannot be matched to a L1 algo name in any GlobalObjectMap\n"
0631           << "Please check if algorithm " << algoName << " is present in the L1 menu\n"
0632           << std::endl;
0633 
0634     } else {
0635       //(algOpTokenVector[i]).tokenResult = objMap->algoGtlResult();
0636 
0637       int bit = objMap->algoBitNumber();
0638       bool finalAlgoDecision = (uGtAlgoBlocks->at(0, 0)).getAlgoDecisionFinal(bit);
0639       i.tokenResult = finalAlgoDecision;
0640     }
0641   }
0642 
0643   // Filter decision
0644   // ///////////////
0645   bool seedsResult = m_l1AlgoLogicParser.expressionResult();
0646 
0647   if (m_isDebugEnabled) {
0648     LogTrace("HLTL1TSeed") << "\nHLTL1TSeed: l1SeedsLogicalExpression (names) = '" << m_l1SeedsLogicalExpression << "'"
0649                            << "\n  Result for logical expression after update of algOpTokens: " << seedsResult << "\n"
0650                            << std::endl;
0651   }
0652 
0653   /// Loop over the list of required algorithms for seeding
0654   /// /////////////////////////////////////////////////////
0655 
0656   for (std::vector<GlobalLogicParser::OperandToken>::const_iterator itSeed = m_l1AlgoSeeds.begin();
0657        itSeed != m_l1AlgoSeeds.end();
0658        ++itSeed) {
0659     std::string algoSeedName = (*itSeed).tokenName;
0660 
0661     LogTrace("HLTL1TSeed") << "\n ----------------  algo seed name = " << algoSeedName << endl;
0662 
0663     const GlobalObjectMap* objMap = gtObjectMapRecord->getObjectMap(algoSeedName);
0664 
0665     if (objMap == nullptr) {
0666       // Should not get here
0667       //
0668       throw cms::Exception("FailModule")
0669           << "\nAlgorithm " << algoSeedName
0670           << ", requested as seed by a HLT path, cannot be matched to a L1 algo name in any GlobalObjectMap\n"
0671           << "Please check if algorithm " << algoSeedName << " is present in the L1 menu\n"
0672           << std::endl;
0673     }
0674 
0675     int algoSeedBitNumber = objMap->algoBitNumber();
0676     bool algoSeedResult = objMap->algoGtlResult();
0677 
0678     // unpacked GT results: uGtAlgoBlock has decisions initial, prescaled, and final after masks
0679     bool algoSeedResultMaskAndPresc = uGtAlgoBlocks->at(0, 0).getAlgoDecisionFinal(algoSeedBitNumber);
0680 
0681     LogTrace("HLTL1TSeed") << "\n\tAlgo seed " << algoSeedName << " result emulated | final = " << algoSeedResult
0682                            << " | " << algoSeedResultMaskAndPresc << endl;
0683 
0684     /// Unpacked GT result of algorithm is false after masks and prescales  - no seeds
0685     /// ////////////////////////////////////////////////////////////////////////////////
0686     if (!algoSeedResultMaskAndPresc)
0687       continue;
0688 
0689     /// Emulated GT result of algorithm is false - no seeds - but still save the event
0690     //  This should not happen if the emulated and unpacked GT are consistent
0691     /// ////////////////////////////////////////////////////////////////////////////////
0692     if (!algoSeedResult)
0693       continue;
0694 
0695     const std::vector<GlobalLogicParser::OperandToken>& opTokenVecObjMap = objMap->operandTokenVector();
0696     const std::vector<L1TObjectTypeInCond>& condObjTypeVec = objMap->objectTypeVector();
0697     const std::vector<CombinationsInCond>& condCombinations = objMap->combinationVector();
0698 
0699     LogTrace("HLTL1TSeed") << "\n\talgoName =" << objMap->algoName() << "\talgoBitNumber = " << algoSeedBitNumber
0700                            << "\talgoGtlResult = " << algoSeedResult << endl
0701                            << endl;
0702 
0703     if (opTokenVecObjMap.size() != condObjTypeVec.size()) {
0704       edm::LogWarning("HLTL1TSeed")
0705           << "\nWarning: GlobalObjectMapRecord with input tag " << m_l1GtObjectMapTag
0706           << "\nhas object map for bit number " << algoSeedBitNumber
0707           << " which contains different size vectors of operand tokens and of condition object types!" << std::endl;
0708 
0709       assert(opTokenVecObjMap.size() == condObjTypeVec.size());
0710     }
0711 
0712     if (opTokenVecObjMap.size() != condCombinations.size()) {
0713       edm::LogWarning("HLTL1TSeed")
0714           << "\nWarning: GlobalObjectMapRecord with input tag " << m_l1GtObjectMapTag
0715           << "\nhas object map for bit number " << algoSeedBitNumber
0716           << " which contains different size vectors of operand tokens and of condition object combinations!"
0717           << std::endl;
0718 
0719       assert(opTokenVecObjMap.size() == condCombinations.size());
0720     }
0721 
0722     // operands are conditions of L1 algo
0723     //
0724     for (size_t condNumber = 0; condNumber < opTokenVecObjMap.size(); condNumber++) {
0725       std::vector<l1t::GlobalObject> condObjType = condObjTypeVec[condNumber];
0726 
0727       for (auto& jOb : condObjType) {
0728         LogTrace("HLTL1TSeed") << setw(15) << "\tcondObjType = " << jOb << endl;
0729       }
0730 
0731       const std::string condName = opTokenVecObjMap[condNumber].tokenName;
0732       bool condResult = opTokenVecObjMap[condNumber].tokenResult;
0733 
0734       // only procede for conditions that passed
0735       //
0736       if (!condResult) {
0737         continue;
0738       }
0739 
0740       // loop over combinations for a given condition
0741       //
0742       const CombinationsInCond* condComb = objMap->getCombinationsInCond(condNumber);
0743 
0744       LogTrace("HLTL1TSeed") << setw(15) << "\tcondCombinations = " << condComb->size() << endl;
0745 
0746       for (auto const& itComb : (*condComb)) {
0747         LogTrace("HLTL1TSeed") << setw(15) << "\tnew combination" << endl;
0748 
0749         // loop over objects in a combination for a given condition
0750         //
0751         for (auto itObject = itComb.begin(); itObject != itComb.end(); itObject++) {
0752           // in case of object-less triggers (e.g. L1_ZeroBias) condObjType vector is empty, so don't seed!
0753           //
0754           if (condObjType.empty()) {
0755             LogTrace("HLTL1TSeed")
0756                 << "\talgoName = " << objMap->algoName()
0757                 << " is object-less L1 algorithm, so do not attempt to store any objects to the list of seeds.\n"
0758                 << std::endl;
0759             continue;
0760           }
0761 
0762           // the index of the object type is the same as the index of the object
0763           size_t iType = std::distance(itComb.begin(), itObject);
0764 
0765           // get object type and push indices on the list
0766           //
0767           const l1t::GlobalObject objTypeVal = condObjType.at(iType);
0768 
0769           LogTrace("HLTL1TSeed") << "\tAdd object of type " << objTypeVal << " and index " << (*itObject)
0770                                  << " to the seed list." << std::endl;
0771 
0772           // THESE OBJECT CASES ARE CURRENTLY MISSING:
0773           //gtMinBias,
0774           //gtExternal,
0775           //ObjNull
0776 
0777           switch (objTypeVal) {
0778             case l1t::gtMu: {
0779               listMuon.push_back(*itObject);
0780             } break;
0781             case l1t::gtMuShower: {
0782               listMuonShower.push_back(*itObject);
0783             } break;
0784             case l1t::gtEG: {
0785               listEG.push_back(*itObject);
0786             } break;
0787             case l1t::gtJet: {
0788               listJet.push_back(*itObject);
0789             } break;
0790             case l1t::gtTau: {
0791               listTau.push_back(*itObject);
0792             } break;
0793             case l1t::gtETM: {
0794               listETM.push_back(*itObject);
0795             } break;
0796             case l1t::gtETT: {
0797               listETT.push_back(*itObject);
0798             } break;
0799             case l1t::gtHTT: {
0800               listHTT.push_back(*itObject);
0801             } break;
0802             case l1t::gtHTM: {
0803               listHTM.push_back(*itObject);
0804             } break;
0805             case l1t::gtETMHF: {
0806               listETMHF.push_back(*itObject);
0807             } break;
0808             case l1t::gtHTMHF: {
0809               listHTMHF.push_back(*itObject);
0810             } break;
0811             case l1t::gtTowerCount: {
0812               listTowerCount.push_back(*itObject);
0813             } break;
0814             case l1t::gtMinBiasHFP0: {
0815               listMinBiasHFP0.push_back(*itObject);
0816             } break;
0817             case l1t::gtMinBiasHFM0: {
0818               listMinBiasHFM0.push_back(*itObject);
0819             } break;
0820             case l1t::gtMinBiasHFP1: {
0821               listMinBiasHFP1.push_back(*itObject);
0822             } break;
0823             case l1t::gtMinBiasHFM1: {
0824               listMinBiasHFM1.push_back(*itObject);
0825             } break;
0826             case l1t::gtETTem: {
0827               listTotalEtEm.push_back(*itObject);
0828             } break;
0829             case l1t::gtAsymmetryEt: {
0830               listAsymEt.push_back(*itObject);
0831             } break;
0832             case l1t::gtAsymmetryHt: {
0833               listAsymHt.push_back(*itObject);
0834             } break;
0835             case l1t::gtAsymmetryEtHF: {
0836               listAsymEtHF.push_back(*itObject);
0837             } break;
0838             case l1t::gtAsymmetryHtHF: {
0839               listAsymHtHF.push_back(*itObject);
0840             } break;
0841             case l1t::gtZDCP: {
0842               listZDCP.push_back(*itObject);
0843             } break;
0844             case l1t::gtZDCM: {
0845               listZDCM.push_back(*itObject);
0846             } break;
0847             case l1t::gtCentrality0:
0848             case l1t::gtCentrality1:
0849             case l1t::gtCentrality2:
0850             case l1t::gtCentrality3:
0851             case l1t::gtCentrality4:
0852             case l1t::gtCentrality5:
0853             case l1t::gtCentrality6:
0854             case l1t::gtCentrality7: {
0855               listCentrality.push_back(*itObject);
0856             } break;
0857 
0858               //case JetCounts: {
0859               //    listJetCounts.push_back(*itObject);
0860               //}
0861 
0862               break;
0863             default: {
0864               // should not arrive here
0865 
0866               LogTrace("HLTL1TSeed") << "\n    HLTL1TSeed::hltFilter "
0867                                      << "\n      Unknown object of type " << objTypeVal << " and index " << (*itObject)
0868                                      << " in the seed list." << std::endl;
0869             } break;
0870 
0871           }  // end switch objTypeVal
0872 
0873         }  // end for itObj
0874 
0875       }  // end for itComb
0876 
0877     }  // end for condition
0878 
0879   }  // end for itSeed
0880 
0881   // eliminate duplicates
0882 
0883   listMuon.sort();
0884   listMuon.unique();
0885 
0886   listMuonShower.sort();
0887   listMuonShower.unique();
0888 
0889   listEG.sort();
0890   listEG.unique();
0891 
0892   listJet.sort();
0893   listJet.unique();
0894 
0895   listTau.sort();
0896   listTau.unique();
0897 
0898   listETM.sort();
0899   listETM.unique();
0900 
0901   listETT.sort();
0902   listETT.unique();
0903 
0904   listHTT.sort();
0905   listHTT.unique();
0906 
0907   listHTM.sort();
0908   listHTM.unique();
0909 
0910   listETMHF.sort();
0911   listETMHF.unique();
0912 
0913   listHTMHF.sort();
0914   listHTMHF.unique();
0915 
0916   listJetCounts.sort();
0917   listJetCounts.unique();
0918 
0919   listCentrality.sort();
0920   listCentrality.unique();
0921 
0922   listMinBiasHFP0.sort();
0923   listMinBiasHFP0.unique();
0924 
0925   listMinBiasHFM0.sort();
0926   listMinBiasHFM0.unique();
0927 
0928   listMinBiasHFP1.sort();
0929   listMinBiasHFP1.unique();
0930 
0931   listMinBiasHFM1.sort();
0932   listMinBiasHFM1.unique();
0933 
0934   listTotalEtEm.sort();
0935   listTotalEtEm.unique();
0936 
0937   listMissingEtHF.sort();
0938   listMissingEtHF.unique();
0939 
0940   listTowerCount.sort();
0941   listTowerCount.unique();
0942 
0943   listAsymEt.sort();
0944   listAsymEt.unique();
0945 
0946   listAsymHt.sort();
0947   listAsymHt.unique();
0948 
0949   listAsymEtHF.sort();
0950   listAsymEtHF.unique();
0951 
0952   listAsymHtHF.sort();
0953   listAsymHtHF.unique();
0954 
0955   listZDCP.sort();
0956   listZDCP.unique();
0957 
0958   listZDCM.sort();
0959   listZDCM.unique();
0960 
0961   // record the L1 physics objects in the HLT filterproduct
0962   // //////////////////////////////////////////////////////
0963 
0964   // Muon
0965   if (!listMuon.empty()) {
0966     edm::Handle<l1t::MuonBxCollection> muons;
0967     iEvent.getByToken(m_l1MuonToken, muons);
0968 
0969     if (!muons.isValid()) {
0970       edm::LogWarning("HLTL1TSeed") << "\nWarning: L1MuonBxCollection with input tag " << m_l1MuonTag
0971                                     << "\nrequested in configuration, but not found in the event."
0972                                     << "\nNo muons added to filterproduct." << endl;
0973     } else {
0974       for (std::list<int>::const_iterator itObj = listMuon.begin(); itObj != listMuon.end(); ++itObj) {
0975         // skip invalid indices
0976         if (*itObj < 0 or unsigned(*itObj) >= muons->size(0)) {
0977           edm::LogWarning("HLTL1TSeed")
0978               << "Invalid index from the L1ObjectMap (L1uGT emulator), will be ignored (l1t::MuonBxCollection):"
0979               << " index=" << *itObj << " (size of unpacked L1T objects in BX0 = " << muons->size(0) << ")";
0980           continue;
0981         }
0982 
0983         // Transform to index for Bx = 0 to begin of BxVector
0984         unsigned int index = muons->begin(0) - muons->begin() + *itObj;
0985 
0986         l1t::MuonRef myref(muons, index);
0987         filterproduct.addObject(trigger::TriggerL1Mu, myref);
0988       }
0989     }
0990   }
0991 
0992   // Muon Shower
0993   if (!listMuonShower.empty()) {
0994     edm::Handle<l1t::MuonShowerBxCollection> muonShowers;
0995     iEvent.getByToken(m_l1MuonShowerToken, muonShowers);
0996 
0997     if (!muonShowers.isValid()) {
0998       edm::LogWarning("HLTL1TSeed") << "\nWarning: L1MuonShowerBxCollection with input tag " << m_l1MuonShowerTag
0999                                     << "\nrequested in configuration, but not found in the event."
1000                                     << "\nNo muon showers added to filterproduct." << endl;
1001     } else {
1002       for (std::list<int>::const_iterator itObj = listMuonShower.begin(); itObj != listMuonShower.end(); ++itObj) {
1003         // skip invalid indices
1004         if (*itObj < 0 or unsigned(*itObj) >= muonShowers->size(0)) {
1005           edm::LogWarning("HLTL1TSeed")
1006               << "Invalid index from the L1ObjectMap (L1uGT emulator), will be ignored (l1t::MuonShowerBxCollection):"
1007               << " index=" << *itObj << " (size of unpacked L1T objects in BX0 = " << muonShowers->size(0) << ")";
1008           continue;
1009         }
1010 
1011         // Transform to index for Bx = 0 to begin of BxVector
1012         unsigned int index = muonShowers->begin(0) - muonShowers->begin() + *itObj;
1013 
1014         l1t::MuonShowerRef myref(muonShowers, index);
1015         filterproduct.addObject(trigger::TriggerL1MuShower, myref);
1016       }
1017     }
1018   }
1019 
1020   // EG (isolated)
1021   if (!listEG.empty()) {
1022     edm::Handle<l1t::EGammaBxCollection> egammas;
1023     iEvent.getByToken(m_l1EGammaToken, egammas);
1024     if (!egammas.isValid()) {
1025       edm::LogWarning("HLTL1TSeed") << "\nWarning: L1EGammaBxCollection with input tag " << m_l1EGammaTag
1026                                     << "\nrequested in configuration, but not found in the event."
1027                                     << "\nNo egammas added to filterproduct." << endl;
1028     } else {
1029       for (std::list<int>::const_iterator itObj = listEG.begin(); itObj != listEG.end(); ++itObj) {
1030         // skip invalid indices
1031         if (*itObj < 0 or unsigned(*itObj) >= egammas->size(0)) {
1032           edm::LogWarning("HLTL1TSeed")
1033               << "Invalid index from the L1ObjectMap (L1uGT emulator), will be ignored (l1t::EGammaBxCollection):"
1034               << " index=" << *itObj << " (size of unpacked L1T objects in BX0 = " << egammas->size(0) << ")";
1035           continue;
1036         }
1037 
1038         // Transform to begin of BxVector
1039         unsigned int index = egammas->begin(0) - egammas->begin() + *itObj;
1040 
1041         l1t::EGammaRef myref(egammas, index);
1042         filterproduct.addObject(trigger::TriggerL1EG, myref);
1043       }
1044     }
1045   }
1046 
1047   // Jet
1048   if (!listJet.empty()) {
1049     edm::Handle<l1t::JetBxCollection> jets;
1050     iEvent.getByToken(m_l1JetToken, jets);
1051 
1052     if (!jets.isValid()) {
1053       edm::LogWarning("HLTL1TSeed") << "\nWarning: L1JetBxCollection with input tag " << m_l1JetTag
1054                                     << "\nrequested in configuration, but not found in the event."
1055                                     << "\nNo jets added to filterproduct." << endl;
1056     } else {
1057       for (std::list<int>::const_iterator itObj = listJet.begin(); itObj != listJet.end(); ++itObj) {
1058         // skip invalid indices
1059         if (*itObj < 0 or unsigned(*itObj) >= jets->size(0)) {
1060           edm::LogWarning("HLTL1TSeed")
1061               << "Invalid index from the L1ObjectMap (L1uGT emulator), will be ignored (l1t::JetBxCollection):"
1062               << " index=" << *itObj << " (size of unpacked L1T objects in BX0 = " << jets->size(0) << ")";
1063           continue;
1064         }
1065 
1066         // Transform to begin of BxVector
1067         unsigned int index = jets->begin(0) - jets->begin() + *itObj;
1068 
1069         l1t::JetRef myref(jets, index);
1070         filterproduct.addObject(trigger::TriggerL1Jet, myref);
1071       }
1072     }
1073   }
1074 
1075   // Tau
1076   if (!listTau.empty()) {
1077     edm::Handle<l1t::TauBxCollection> taus;
1078     iEvent.getByToken(m_l1TauToken, taus);
1079 
1080     if (!taus.isValid()) {
1081       edm::LogWarning("HLTL1TSeed") << "\nWarning: L1TauBxCollection with input tag " << m_l1TauTag
1082                                     << "\nrequested in configuration, but not found in the event."
1083                                     << "\nNo taus added to filterproduct." << endl;
1084     } else {
1085       for (std::list<int>::const_iterator itObj = listTau.begin(); itObj != listTau.end(); ++itObj) {
1086         // skip invalid indices
1087         if (*itObj < 0 or unsigned(*itObj) >= taus->size(0)) {
1088           edm::LogWarning("HLTL1TSeed")
1089               << "Invalid index from the L1ObjectMap (L1uGT emulator), will be ignored (l1t::TauBxCollection):"
1090               << " index=" << *itObj << " (size of unpacked L1T objects in BX0 = " << taus->size(0) << ")";
1091           continue;
1092         }
1093 
1094         // Transform to begin of BxVector
1095         unsigned int index = taus->begin(0) - taus->begin() + *itObj;
1096 
1097         l1t::TauRef myref(taus, index);
1098         filterproduct.addObject(trigger::TriggerL1Tau, myref);
1099       }
1100     }
1101   }
1102 
1103   // ETT, HTT, ETM, HTM
1104   edm::Handle<l1t::EtSumBxCollection> etsums;
1105   iEvent.getByToken(m_l1EtSumToken, etsums);
1106   if (!etsums.isValid()) {
1107     edm::LogWarning("HLTL1TSeed") << "\nWarning: L1EtSumBxCollection with input tag " << m_l1EtSumTag
1108                                   << "\nrequested in configuration, but not found in the event."
1109                                   << "\nNo etsums added to filterproduct." << endl;
1110   } else {
1111     l1t::EtSumBxCollection::const_iterator iter;
1112 
1113     for (iter = etsums->begin(0); iter != etsums->end(0); ++iter) {
1114       l1t::EtSumRef myref(etsums, etsums->key(iter));
1115 
1116       switch (iter->getType()) {
1117         case l1t::EtSum::kTotalEt:
1118           if (!listETT.empty())
1119             filterproduct.addObject(trigger::TriggerL1ETT, myref);
1120           break;
1121         case l1t::EtSum::kTotalHt:
1122           if (!listHTT.empty())
1123             filterproduct.addObject(trigger::TriggerL1HTT, myref);
1124           break;
1125         case l1t::EtSum::kMissingEt:
1126           if (!listETM.empty())
1127             filterproduct.addObject(trigger::TriggerL1ETM, myref);
1128           break;
1129         case l1t::EtSum::kMissingHt:
1130           if (!listHTM.empty())
1131             filterproduct.addObject(trigger::TriggerL1HTM, myref);
1132           break;
1133         case l1t::EtSum::kMissingEtHF:
1134           if (!listETMHF.empty())
1135             filterproduct.addObject(trigger::TriggerL1ETMHF, myref);
1136           break;
1137         case l1t::EtSum::kMissingHtHF:
1138           if (!listHTMHF.empty())
1139             filterproduct.addObject(trigger::TriggerL1HTMHF, myref);
1140           break;
1141         case l1t::EtSum::kCentrality:
1142           if (!listCentrality.empty())
1143             filterproduct.addObject(trigger::TriggerL1Centrality, myref);
1144           break;
1145         case l1t::EtSum::kMinBiasHFP0:
1146           if (!listMinBiasHFP0.empty())
1147             filterproduct.addObject(trigger::TriggerL1MinBiasHFP0, myref);
1148           break;
1149         case l1t::EtSum::kMinBiasHFM0:
1150           if (!listMinBiasHFM0.empty())
1151             filterproduct.addObject(trigger::TriggerL1MinBiasHFM0, myref);
1152           break;
1153         case l1t::EtSum::kMinBiasHFP1:
1154           if (!listMinBiasHFP1.empty())
1155             filterproduct.addObject(trigger::TriggerL1MinBiasHFP1, myref);
1156           break;
1157         case l1t::EtSum::kMinBiasHFM1:
1158           if (!listMinBiasHFM1.empty())
1159             filterproduct.addObject(trigger::TriggerL1MinBiasHFM1, myref);
1160           break;
1161         case l1t::EtSum::kTotalEtEm:
1162           if (!listTotalEtEm.empty())
1163             filterproduct.addObject(trigger::TriggerL1TotalEtEm, myref);
1164           break;
1165         case l1t::EtSum::kTowerCount:
1166           if (!listTowerCount.empty())
1167             filterproduct.addObject(trigger::TriggerL1TowerCount, myref);
1168           break;
1169         case l1t::EtSum::kAsymEt:
1170           if (!listAsymEt.empty())
1171             filterproduct.addObject(trigger::TriggerL1AsymEt, myref);
1172           break;
1173         case l1t::EtSum::kAsymHt:
1174           if (!listAsymHt.empty())
1175             filterproduct.addObject(trigger::TriggerL1AsymHt, myref);
1176           break;
1177         case l1t::EtSum::kAsymEtHF:
1178           if (!listAsymEtHF.empty())
1179             filterproduct.addObject(trigger::TriggerL1AsymEtHF, myref);
1180           break;
1181         case l1t::EtSum::kAsymHtHF:
1182           if (!listAsymHtHF.empty())
1183             filterproduct.addObject(trigger::TriggerL1AsymHtHF, myref);
1184           break;
1185         default:
1186           LogTrace("HLTL1TSeed") << "  L1EtSum seed of currently unsuported HLT TriggerType. l1t::EtSum type:      "
1187                                  << iter->getType() << "\n";
1188 
1189       }  // end switch
1190 
1191     }  // end for
1192 
1193   }  // end else
1194 
1195   // ZDCP, ZDCM
1196   edm::Handle<l1t::EtSumBxCollection> etsumzdcs;
1197   iEvent.getByToken(m_l1EtSumZdcToken, etsumzdcs);
1198   if (!etsumzdcs.isValid()) {
1199     //!! FIXME: replace LogDebug with edm::LogWarning once unpacker of ZDC inputs to L1-uGT becomes available
1200     //!!        https://github.com/cms-sw/cmssw/pull/42634#issuecomment-1698132805
1201     //!!        https://github.com/cms-sw/cmssw/blob/bece38936ef0ba111f4b5f4502e819595560afa6/EventFilter/L1TRawToDigi/plugins/implementations_stage2/GTSetup.cc#L76
1202     LogDebug("HLTL1TSeed") << "\nWarning: L1EtSumBxCollection with input tag " << m_l1EtSumZdcTag
1203                            << "\nrequested in configuration, but not found in the event."
1204                            << "\nNo etsums (ZDC) added to filterproduct.";
1205   } else {
1206     l1t::EtSumBxCollection::const_iterator iter;
1207 
1208     for (iter = etsumzdcs->begin(0); iter != etsumzdcs->end(0); ++iter) {
1209       l1t::EtSumRef myref(etsumzdcs, etsumzdcs->key(iter));
1210 
1211       switch (iter->getType()) {
1212         case l1t::EtSum::kZDCP:
1213           if (!listZDCP.empty())
1214             filterproduct.addObject(trigger::TriggerL1ZDCP, myref);
1215           break;
1216         case l1t::EtSum::kZDCM:
1217           if (!listZDCM.empty())
1218             filterproduct.addObject(trigger::TriggerL1ZDCM, myref);
1219           break;
1220         default:
1221           LogTrace("HLTL1TSeed")
1222               << "  L1EtSum (ZDC) seed of currently unsuported HLT TriggerType. l1t::EtSum type:      "
1223               << iter->getType() << "\n";
1224 
1225       }  // end switch
1226 
1227     }  // end for
1228 
1229   }  // end else
1230 
1231   // TODO FIXME uncomment if block when JetCounts implemented
1232 
1233   //    // jet counts
1234   //    if (!listJetCounts.empty()) {
1235   //        edm::Handle<l1extra::L1JetCounts> l1JetCounts;
1236   //        iEvent.getByToken(m_l1CollectionsToken.label(), l1JetCounts);
1237   //
1238   //        for (std::list<int>::const_iterator itObj = listJetCounts.begin();
1239   //                itObj != listJetCounts.end(); ++itObj) {
1240   //
1241   //            filterproduct.addObject(trigger::TriggerL1JetCounts,l1extra::L1JetCountsRefProd(l1JetCounts));
1242   //                  // FIXME: RefProd!
1243   //
1244   //        }
1245   //
1246   //    }
1247 
1248   LogTrace("HLTL1TSeed") << "\nHLTL1Seed:seedsL1TriggerObjectMaps returning " << seedsResult << endl << endl;
1249 
1250   return seedsResult;
1251 }
1252 
1253 // register as framework plugin
1254 #include "FWCore/Framework/interface/MakerMacros.h"
1255 DEFINE_FWK_MODULE(HLTL1TSeed);