Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:53:04

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> seedsL1EtSumHTM;
0308   filterproduct.getObjects(trigger::TriggerL1HTM, seedsL1EtSumHTM);
0309   const size_t sizeSeedsL1EtSumHTM = seedsL1EtSumHTM.size();
0310   LogTrace("HLTL1TSeed") << "\n  L1EtSum HTM seeds:      " << sizeSeedsL1EtSumHTM << endl << endl;
0311 
0312   for (size_t i = 0; i != sizeSeedsL1EtSumHTM; i++) {
0313     l1t::EtSumRef obj = l1t::EtSumRef(seedsL1EtSumHTM[i]);
0314 
0315     LogTrace("HLTL1TSeed") << "\tL1EtSum  HTM"
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> seedsL1EtSumCentrality;
0323   filterproduct.getObjects(trigger::TriggerL1Centrality, seedsL1EtSumCentrality);
0324   const size_t sizeSeedsL1EtSumCentrality = seedsL1EtSumCentrality.size();
0325   LogTrace("HLTL1TSeed") << "\n  L1EtSum Centrality seeds:      " << sizeSeedsL1EtSumCentrality << endl << endl;
0326 
0327   for (size_t i = 0; i != sizeSeedsL1EtSumCentrality; i++) {
0328     l1t::EtSumRef obj = l1t::EtSumRef(seedsL1EtSumCentrality[i]);
0329 
0330     LogTrace("HLTL1TSeed") << "\tL1EtSum  Centrality Bits: " << std::bitset<8>(obj->hwPt())
0331                            << " (hwPt = " << obj->hwPt() << ")";
0332   }
0333 
0334   vector<l1t::EtSumRef> seedsL1EtSumMinBiasHFP0;
0335   filterproduct.getObjects(trigger::TriggerL1MinBiasHFP0, seedsL1EtSumMinBiasHFP0);
0336   const size_t sizeSeedsL1EtSumMinBiasHFP0 = seedsL1EtSumMinBiasHFP0.size();
0337   LogTrace("HLTL1TSeed") << "\n  L1EtSum MinBiasHFP0 seeds:      " << sizeSeedsL1EtSumMinBiasHFP0 << endl << endl;
0338 
0339   for (size_t i = 0; i != sizeSeedsL1EtSumMinBiasHFP0; i++) {
0340     l1t::EtSumRef obj = l1t::EtSumRef(seedsL1EtSumMinBiasHFP0[i]);
0341 
0342     LogTrace("HLTL1TSeed") << "\tL1EtSum  MinBiasHFP0: hwPt = " << obj->hwPt();
0343   }
0344 
0345   vector<l1t::EtSumRef> seedsL1EtSumMinBiasHFM0;
0346   filterproduct.getObjects(trigger::TriggerL1MinBiasHFM0, seedsL1EtSumMinBiasHFM0);
0347   const size_t sizeSeedsL1EtSumMinBiasHFM0 = seedsL1EtSumMinBiasHFM0.size();
0348   LogTrace("HLTL1TSeed") << "\n  L1EtSum MinBiasHFM0 seeds:      " << sizeSeedsL1EtSumMinBiasHFM0 << endl << endl;
0349 
0350   for (size_t i = 0; i != sizeSeedsL1EtSumMinBiasHFM0; i++) {
0351     l1t::EtSumRef obj = l1t::EtSumRef(seedsL1EtSumMinBiasHFM0[i]);
0352 
0353     LogTrace("HLTL1TSeed") << "\tL1EtSum  MinBiasHFM0: hwPt = " << obj->hwPt();
0354   }
0355 
0356   vector<l1t::EtSumRef> seedsL1EtSumMinBiasHFP1;
0357   filterproduct.getObjects(trigger::TriggerL1MinBiasHFP1, seedsL1EtSumMinBiasHFP1);
0358   const size_t sizeSeedsL1EtSumMinBiasHFP1 = seedsL1EtSumMinBiasHFP1.size();
0359   LogTrace("HLTL1TSeed") << "\n  L1EtSum MinBiasHFP1 seeds:      " << sizeSeedsL1EtSumMinBiasHFP1 << endl << endl;
0360 
0361   for (size_t i = 0; i != sizeSeedsL1EtSumMinBiasHFP1; i++) {
0362     l1t::EtSumRef obj = l1t::EtSumRef(seedsL1EtSumMinBiasHFP1[i]);
0363 
0364     LogTrace("HLTL1TSeed") << "\tL1EtSum  MinBiasHFP1: hwPt = " << obj->hwPt();
0365   }
0366 
0367   vector<l1t::EtSumRef> seedsL1EtSumMinBiasHFM1;
0368   filterproduct.getObjects(trigger::TriggerL1MinBiasHFM1, seedsL1EtSumMinBiasHFM1);
0369   const size_t sizeSeedsL1EtSumMinBiasHFM1 = seedsL1EtSumMinBiasHFM1.size();
0370   LogTrace("HLTL1TSeed") << "\n  L1EtSum MinBiasHFM1 seeds:      " << sizeSeedsL1EtSumMinBiasHFM1 << endl << endl;
0371 
0372   for (size_t i = 0; i != sizeSeedsL1EtSumMinBiasHFM1; i++) {
0373     l1t::EtSumRef obj = l1t::EtSumRef(seedsL1EtSumMinBiasHFM1[i]);
0374 
0375     LogTrace("HLTL1TSeed") << "\tL1EtSum  MinBiasHFM1: hwPt = " << obj->hwPt();
0376   }
0377 
0378   vector<l1t::EtSumRef> seedsL1EtSumTowerCount;
0379   filterproduct.getObjects(trigger::TriggerL1TowerCount, seedsL1EtSumTowerCount);
0380   const size_t sizeSeedsL1EtSumTowerCount = seedsL1EtSumTowerCount.size();
0381   LogTrace("HLTL1TSeed") << "\n  L1EtSum TowerCount seeds:      " << sizeSeedsL1EtSumTowerCount << endl << endl;
0382 
0383   for (size_t i = 0; i != sizeSeedsL1EtSumTowerCount; i++) {
0384     l1t::EtSumRef obj = l1t::EtSumRef(seedsL1EtSumTowerCount[i]);
0385 
0386     LogTrace("HLTL1TSeed") << "\tL1EtSum  TowerCount: hwPt = " << obj->hwPt();
0387   }
0388 
0389   vector<l1t::EtSumRef> seedsL1EtSumAsymEt;
0390   filterproduct.getObjects(trigger::TriggerL1AsymEt, seedsL1EtSumAsymEt);
0391   const size_t sizeSeedsL1EtSumAsymEt = seedsL1EtSumAsymEt.size();
0392   LogTrace("HLTL1TSeed") << "\n  L1EtSum AsymEt seeds:      " << sizeSeedsL1EtSumAsymEt << endl << endl;
0393 
0394   for (size_t i = 0; i != sizeSeedsL1EtSumAsymEt; i++) {
0395     l1t::EtSumRef obj = l1t::EtSumRef(seedsL1EtSumAsymEt[i]);
0396 
0397     LogTrace("HLTL1TSeed") << "\tL1EtSum  AsymEt: hwPt = " << obj->hwPt();
0398   }
0399 
0400   vector<l1t::EtSumRef> seedsL1EtSumAsymHt;
0401   filterproduct.getObjects(trigger::TriggerL1AsymHt, seedsL1EtSumAsymHt);
0402   const size_t sizeSeedsL1EtSumAsymHt = seedsL1EtSumAsymHt.size();
0403   LogTrace("HLTL1TSeed") << "\n  L1EtSum AsymHt seeds:      " << sizeSeedsL1EtSumAsymHt << endl << endl;
0404 
0405   for (size_t i = 0; i != sizeSeedsL1EtSumAsymHt; i++) {
0406     l1t::EtSumRef obj = l1t::EtSumRef(seedsL1EtSumAsymHt[i]);
0407 
0408     LogTrace("HLTL1TSeed") << "\tL1EtSum  AsymHt: hwPt = " << obj->hwPt();
0409   }
0410 
0411   vector<l1t::EtSumRef> seedsL1EtSumAsymEtHF;
0412   filterproduct.getObjects(trigger::TriggerL1AsymEtHF, seedsL1EtSumAsymEtHF);
0413   const size_t sizeSeedsL1EtSumAsymEtHF = seedsL1EtSumAsymEtHF.size();
0414   LogTrace("HLTL1TSeed") << "\n  L1EtSum AsymEtHF seeds:      " << sizeSeedsL1EtSumAsymEtHF << endl << endl;
0415 
0416   for (size_t i = 0; i != sizeSeedsL1EtSumAsymEtHF; i++) {
0417     l1t::EtSumRef obj = l1t::EtSumRef(seedsL1EtSumAsymEtHF[i]);
0418 
0419     LogTrace("HLTL1TSeed") << "\tL1EtSum  AsymEtHF: hwPt = " << obj->hwPt();
0420   }
0421 
0422   vector<l1t::EtSumRef> seedsL1EtSumAsymHtHF;
0423   filterproduct.getObjects(trigger::TriggerL1AsymHtHF, seedsL1EtSumAsymHtHF);
0424   const size_t sizeSeedsL1EtSumAsymHtHF = seedsL1EtSumAsymHtHF.size();
0425   LogTrace("HLTL1TSeed") << "\n  L1EtSum AsymHtHF seeds:      " << sizeSeedsL1EtSumAsymHtHF << endl << endl;
0426 
0427   for (size_t i = 0; i != sizeSeedsL1EtSumAsymHtHF; i++) {
0428     l1t::EtSumRef obj = l1t::EtSumRef(seedsL1EtSumAsymHtHF[i]);
0429 
0430     LogTrace("HLTL1TSeed") << "\tL1EtSum  AsymHtHF: hwPt = " << obj->hwPt();
0431   }
0432 
0433   vector<l1t::EtSumRef> seedsL1EtSumZDCP;
0434   filterproduct.getObjects(trigger::TriggerL1ZDCP, seedsL1EtSumZDCP);
0435   const size_t sizeSeedsL1EtSumZDCP = seedsL1EtSumZDCP.size();
0436   LogTrace("HLTL1TSeed") << "\n  L1EtSum ZDCP seeds:      " << sizeSeedsL1EtSumZDCP << endl << endl;
0437 
0438   for (size_t i = 0; i != sizeSeedsL1EtSumZDCP; i++) {
0439     l1t::EtSumRef obj = l1t::EtSumRef(seedsL1EtSumZDCP[i]);
0440 
0441     LogTrace("HLTL1TSeed") << "\tL1EtSum  ZDCP"
0442                            << "\t"
0443                            << "pt = " << obj->pt() << "\t"
0444                            << "eta =  " << obj->eta() << "\t"
0445                            << "phi =  " << obj->phi();  //<< "\t" << "BX = " << obj->bx();
0446   }
0447 
0448   vector<l1t::EtSumRef> seedsL1EtSumZDCM;
0449   filterproduct.getObjects(trigger::TriggerL1ZDCM, seedsL1EtSumZDCM);
0450   const size_t sizeSeedsL1EtSumZDCM = seedsL1EtSumZDCM.size();
0451   LogTrace("HLTL1TSeed") << "\n  L1EtSum ZDCM seeds:      " << sizeSeedsL1EtSumZDCM << endl << endl;
0452 
0453   for (size_t i = 0; i != sizeSeedsL1EtSumZDCM; i++) {
0454     l1t::EtSumRef obj = l1t::EtSumRef(seedsL1EtSumZDCM[i]);
0455 
0456     LogTrace("HLTL1TSeed") << "\tL1EtSum  ZDCM"
0457                            << "\t"
0458                            << "pt = " << obj->pt() << "\t"
0459                            << "eta =  " << obj->eta() << "\t"
0460                            << "phi =  " << obj->phi();  //<< "\t" << "BX = " << obj->bx();
0461   }
0462 
0463   LogTrace("HLTL1TSeed") << " \n\n" << endl;
0464 }
0465 
0466 // seeding is done via L1 trigger object maps, considering the objects which fired in L1
0467 bool HLTL1TSeed::seedsL1TriggerObjectMaps(edm::Event& iEvent, trigger::TriggerFilterObjectWithRefs& filterproduct) {
0468   // Two GT objects are obtained from the Event: (1) the unpacked GT and (2) the emulated GT.
0469   // Return value of the function is the score of seeding logical expression, evaluated using (1).
0470   // Seeding is performed (per l1_algo) if ACCEPT both in (1) and (2). Seed objects are identified
0471   // and only available from ObjectMaps created in (2).
0472 
0473   // define index lists for all particle types
0474 
0475   std::list<int> listMuon;
0476   std::list<int> listMuonShower;
0477 
0478   std::list<int> listEG;
0479 
0480   std::list<int> listJet;
0481   std::list<int> listTau;
0482 
0483   std::list<int> listETM;
0484   std::list<int> listETT;
0485   std::list<int> listHTT;
0486   std::list<int> listHTM;
0487   std::list<int> listETMHF;
0488 
0489   std::list<int> listJetCounts;
0490 
0491   std::list<int> listCentrality;
0492   std::list<int> listMinBiasHFP0;
0493   std::list<int> listMinBiasHFM0;
0494   std::list<int> listMinBiasHFP1;
0495   std::list<int> listMinBiasHFM1;
0496   std::list<int> listTotalEtEm;
0497   std::list<int> listMissingEtHF;
0498   std::list<int> listTowerCount;
0499   std::list<int> listAsymEt;
0500   std::list<int> listAsymHt;
0501   std::list<int> listAsymEtHF;
0502   std::list<int> listAsymHtHF;
0503   std::list<int> listZDCP;
0504   std::list<int> listZDCM;
0505 
0506   // get handle to unpacked GT
0507   edm::Handle<GlobalAlgBlkBxCollection> uGtAlgoBlocks;
0508   iEvent.getByToken(m_l1GlobalToken, uGtAlgoBlocks);
0509 
0510   if (!uGtAlgoBlocks.isValid()) {
0511     edm::LogWarning("HLTL1TSeed") << " Warning: GlobalAlgBlkBxCollection with input tag " << m_l1GlobalTag
0512                                   << " requested in configuration, but not found in the event." << std::endl;
0513 
0514     return false;
0515   }
0516 
0517   // check size (all BXs)
0518   if (uGtAlgoBlocks->size() == 0) {
0519     edm::LogWarning("HLTL1TSeed") << " Warning: GlobalAlgBlkBxCollection with input tag " << m_l1GlobalTag
0520                                   << " is empty for all BXs.";
0521     return false;
0522   }
0523 
0524   // check size (BX 0)
0525   if (uGtAlgoBlocks->isEmpty(0)) {
0526     edm::LogWarning("HLTL1TSeed") << " Warning: GlobalAlgBlkBxCollection with input tag " << m_l1GlobalTag
0527                                   << " is empty for BX=0.";
0528     return false;
0529   }
0530 
0531   // get handle to object maps from emulator (one object map per algorithm)
0532   edm::Handle<GlobalObjectMapRecord> gtObjectMapRecord;
0533   iEvent.getByToken(m_l1GtObjectMapToken, gtObjectMapRecord);
0534 
0535   if (!gtObjectMapRecord.isValid()) {
0536     edm::LogWarning("HLTL1TSeed") << " Warning: GlobalObjectMapRecord with input tag " << m_l1GtObjectMapTag
0537                                   << " requested in configuration, but not found in the event." << std::endl;
0538 
0539     return false;
0540   }
0541 
0542   if (m_isDebugEnabled) {
0543     const std::vector<GlobalObjectMap>& objMaps = gtObjectMapRecord->gtObjectMap();
0544 
0545     LogTrace("HLTL1TSeed") << "\nHLTL1Seed"
0546                            << "\n--------------------------------------------------------------------------------------"
0547                               "-------------------------------";
0548 
0549     LogTrace("HLTL1TSeed")
0550         << "\n\tAlgorithms in L1TriggerObjectMapRecord and GT results ( emulated | initial | prescaled | final ) "
0551         << endl;
0552 
0553     LogTrace("HLTL1TSeed") << "\n\tmap"
0554                            << "\tAlgoBit" << std::setw(40) << "algoName"
0555                            << "\t (emul|ini|pre|fin)" << endl;
0556 
0557     LogTrace("HLTL1TSeed") << "----------------------------------------------------------------------------------------"
0558                               "-----------------------------";
0559 
0560     for (size_t imap = 0; imap < objMaps.size(); imap++) {
0561       int bit = objMaps[imap].algoBitNumber();  //  same as bit from L1T Menu
0562 
0563       int emulDecision = objMaps[imap].algoGtlResult();
0564 
0565       // For bx=0 , get 0th AlgoBlock, so in BXvector at(bx=0,i=0)
0566       int initDecision = (uGtAlgoBlocks->at(0, 0)).getAlgoDecisionInitial(bit);
0567       int presDecision = (uGtAlgoBlocks->at(0, 0)).getAlgoDecisionInterm(bit);
0568       int finlDecision = (uGtAlgoBlocks->at(0, 0)).getAlgoDecisionFinal(bit);
0569 
0570       if (emulDecision != initDecision) {
0571         LogTrace("HLTL1TSeed") << "L1T decision (emulated vs. unpacked initial) is not the same:"
0572                                << "\n\tbit = " << std::setw(3) << bit << std::setw(40) << objMaps[imap].algoName()
0573                                << "\t emulated decision = " << emulDecision
0574                                << "\t unpacked initial decision = " << initDecision
0575                                << "\nThis should not happen. Include the L1TGtEmulCompare module in the sequence."
0576                                << endl;
0577       }
0578 
0579       LogTrace("HLTL1TSeed") << "\t" << std::setw(3) << imap << "\tbit = " << std::setw(3) << bit << std::setw(40)
0580                              << objMaps[imap].algoName() << "\t (  " << emulDecision << " | " << initDecision << " | "
0581                              << presDecision << " | " << finlDecision << " ) ";
0582     }
0583     LogTrace("HLTL1TSeed") << endl;
0584   }
0585 
0586   // Filter decision in case of "L1GlobalDecision" logical expression.
0587   // By convention, it means global decision.
0588   // /////////////////////////////////////////////////////////////////
0589   if (m_l1GlobalDecision) {
0590     // For bx=0 , get 0th AlgoBlock, so in BXvector at(bx=0,i=0)
0591     return (uGtAlgoBlocks->at(0, 0)).getFinalOR();
0592   }
0593 
0594   // Update/Reset m_l1AlgoLogicParser by reseting token result
0595   // /////////////////////////////////////////////////////////
0596   std::vector<GlobalLogicParser::OperandToken>& algOpTokenVector = m_l1AlgoLogicParser.operandTokenVector();
0597 
0598   for (auto& i : algOpTokenVector) {
0599     // rest token result
0600     //
0601     i.tokenResult = false;
0602   }
0603 
0604   // Update m_l1AlgoLogicParser and store emulator results for algOpTokens
0605   // /////////////////////////////////////////////////////////////////////
0606   for (auto& i : algOpTokenVector) {
0607     std::string algoName = i.tokenName;
0608 
0609     const GlobalObjectMap* objMap = gtObjectMapRecord->getObjectMap(algoName);
0610 
0611     if (objMap == nullptr) {
0612       throw cms::Exception("FailModule")
0613           << "\nAlgorithm " << algoName
0614           << ", requested as seed by a HLT path, cannot be matched to a L1 algo name in any GlobalObjectMap\n"
0615           << "Please check if algorithm " << algoName << " is present in the L1 menu\n"
0616           << std::endl;
0617 
0618     } else {
0619       //(algOpTokenVector[i]).tokenResult = objMap->algoGtlResult();
0620 
0621       int bit = objMap->algoBitNumber();
0622       bool finalAlgoDecision = (uGtAlgoBlocks->at(0, 0)).getAlgoDecisionFinal(bit);
0623       i.tokenResult = finalAlgoDecision;
0624     }
0625   }
0626 
0627   // Filter decision
0628   // ///////////////
0629   bool seedsResult = m_l1AlgoLogicParser.expressionResult();
0630 
0631   if (m_isDebugEnabled) {
0632     LogTrace("HLTL1TSeed") << "\nHLTL1TSeed: l1SeedsLogicalExpression (names) = '" << m_l1SeedsLogicalExpression << "'"
0633                            << "\n  Result for logical expression after update of algOpTokens: " << seedsResult << "\n"
0634                            << std::endl;
0635   }
0636 
0637   /// Loop over the list of required algorithms for seeding
0638   /// /////////////////////////////////////////////////////
0639 
0640   for (std::vector<GlobalLogicParser::OperandToken>::const_iterator itSeed = m_l1AlgoSeeds.begin();
0641        itSeed != m_l1AlgoSeeds.end();
0642        ++itSeed) {
0643     std::string algoSeedName = (*itSeed).tokenName;
0644 
0645     LogTrace("HLTL1TSeed") << "\n ----------------  algo seed name = " << algoSeedName << endl;
0646 
0647     const GlobalObjectMap* objMap = gtObjectMapRecord->getObjectMap(algoSeedName);
0648 
0649     if (objMap == nullptr) {
0650       // Should not get here
0651       //
0652       throw cms::Exception("FailModule")
0653           << "\nAlgorithm " << algoSeedName
0654           << ", requested as seed by a HLT path, cannot be matched to a L1 algo name in any GlobalObjectMap\n"
0655           << "Please check if algorithm " << algoSeedName << " is present in the L1 menu\n"
0656           << std::endl;
0657     }
0658 
0659     int algoSeedBitNumber = objMap->algoBitNumber();
0660     bool algoSeedResult = objMap->algoGtlResult();
0661 
0662     // unpacked GT results: uGtAlgoBlock has decisions initial, prescaled, and final after masks
0663     bool algoSeedResultMaskAndPresc = uGtAlgoBlocks->at(0, 0).getAlgoDecisionFinal(algoSeedBitNumber);
0664 
0665     LogTrace("HLTL1TSeed") << "\n\tAlgo seed " << algoSeedName << " result emulated | final = " << algoSeedResult
0666                            << " | " << algoSeedResultMaskAndPresc << endl;
0667 
0668     /// Unpacked GT result of algorithm is false after masks and prescales  - no seeds
0669     /// ////////////////////////////////////////////////////////////////////////////////
0670     if (!algoSeedResultMaskAndPresc)
0671       continue;
0672 
0673     /// Emulated GT result of algorithm is false - no seeds - but still save the event
0674     //  This should not happen if the emulated and unpacked GT are consistent
0675     /// ////////////////////////////////////////////////////////////////////////////////
0676     if (!algoSeedResult)
0677       continue;
0678 
0679     const std::vector<GlobalLogicParser::OperandToken>& opTokenVecObjMap = objMap->operandTokenVector();
0680     const std::vector<L1TObjectTypeInCond>& condObjTypeVec = objMap->objectTypeVector();
0681     const std::vector<CombinationsInCond>& condCombinations = objMap->combinationVector();
0682 
0683     LogTrace("HLTL1TSeed") << "\n\talgoName =" << objMap->algoName() << "\talgoBitNumber = " << algoSeedBitNumber
0684                            << "\talgoGtlResult = " << algoSeedResult << endl
0685                            << endl;
0686 
0687     if (opTokenVecObjMap.size() != condObjTypeVec.size()) {
0688       edm::LogWarning("HLTL1TSeed")
0689           << "\nWarning: GlobalObjectMapRecord with input tag " << m_l1GtObjectMapTag
0690           << "\nhas object map for bit number " << algoSeedBitNumber
0691           << " which contains different size vectors of operand tokens and of condition object types!" << std::endl;
0692 
0693       assert(opTokenVecObjMap.size() == condObjTypeVec.size());
0694     }
0695 
0696     if (opTokenVecObjMap.size() != condCombinations.size()) {
0697       edm::LogWarning("HLTL1TSeed")
0698           << "\nWarning: GlobalObjectMapRecord with input tag " << m_l1GtObjectMapTag
0699           << "\nhas object map for bit number " << algoSeedBitNumber
0700           << " which contains different size vectors of operand tokens and of condition object combinations!"
0701           << std::endl;
0702 
0703       assert(opTokenVecObjMap.size() == condCombinations.size());
0704     }
0705 
0706     // operands are conditions of L1 algo
0707     //
0708     for (size_t condNumber = 0; condNumber < opTokenVecObjMap.size(); condNumber++) {
0709       std::vector<l1t::GlobalObject> condObjType = condObjTypeVec[condNumber];
0710 
0711       for (auto& jOb : condObjType) {
0712         LogTrace("HLTL1TSeed") << setw(15) << "\tcondObjType = " << jOb << endl;
0713       }
0714 
0715       const std::string condName = opTokenVecObjMap[condNumber].tokenName;
0716       bool condResult = opTokenVecObjMap[condNumber].tokenResult;
0717 
0718       // only procede for conditions that passed
0719       //
0720       if (!condResult) {
0721         continue;
0722       }
0723 
0724       // loop over combinations for a given condition
0725       //
0726       const CombinationsInCond* condComb = objMap->getCombinationsInCond(condNumber);
0727 
0728       LogTrace("HLTL1TSeed") << setw(15) << "\tcondCombinations = " << condComb->size() << endl;
0729 
0730       for (auto const& itComb : (*condComb)) {
0731         LogTrace("HLTL1TSeed") << setw(15) << "\tnew combination" << endl;
0732 
0733         // loop over objects in a combination for a given condition
0734         //
0735         for (auto itObject = itComb.begin(); itObject != itComb.end(); itObject++) {
0736           // in case of object-less triggers (e.g. L1_ZeroBias) condObjType vector is empty, so don't seed!
0737           //
0738           if (condObjType.empty()) {
0739             LogTrace("HLTL1TSeed")
0740                 << "\talgoName = " << objMap->algoName()
0741                 << " is object-less L1 algorithm, so do not attempt to store any objects to the list of seeds.\n"
0742                 << std::endl;
0743             continue;
0744           }
0745 
0746           // the index of the object type is the same as the index of the object
0747           size_t iType = std::distance(itComb.begin(), itObject);
0748 
0749           // get object type and push indices on the list
0750           //
0751           const l1t::GlobalObject objTypeVal = condObjType.at(iType);
0752 
0753           LogTrace("HLTL1TSeed") << "\tAdd object of type " << objTypeVal << " and index " << (*itObject)
0754                                  << " to the seed list." << std::endl;
0755 
0756           // THESE OBJECT CASES ARE CURRENTLY MISSING:
0757           //gtMinBias,
0758           //gtExternal,
0759           //ObjNull
0760 
0761           switch (objTypeVal) {
0762             case l1t::gtMu: {
0763               listMuon.push_back(*itObject);
0764             } break;
0765             case l1t::gtMuShower: {
0766               listMuonShower.push_back(*itObject);
0767             } break;
0768             case l1t::gtEG: {
0769               listEG.push_back(*itObject);
0770             } break;
0771             case l1t::gtJet: {
0772               listJet.push_back(*itObject);
0773             } break;
0774             case l1t::gtTau: {
0775               listTau.push_back(*itObject);
0776             } break;
0777             case l1t::gtETM: {
0778               listETM.push_back(*itObject);
0779             } break;
0780             case l1t::gtETT: {
0781               listETT.push_back(*itObject);
0782             } break;
0783             case l1t::gtHTT: {
0784               listHTT.push_back(*itObject);
0785             } break;
0786             case l1t::gtHTM: {
0787               listHTM.push_back(*itObject);
0788             } break;
0789             case l1t::gtETMHF: {
0790               listETMHF.push_back(*itObject);
0791             } break;
0792             case l1t::gtTowerCount: {
0793               listTowerCount.push_back(*itObject);
0794             } break;
0795             case l1t::gtMinBiasHFP0: {
0796               listMinBiasHFP0.push_back(*itObject);
0797             } break;
0798             case l1t::gtMinBiasHFM0: {
0799               listMinBiasHFM0.push_back(*itObject);
0800             } break;
0801             case l1t::gtMinBiasHFP1: {
0802               listMinBiasHFP1.push_back(*itObject);
0803             } break;
0804             case l1t::gtMinBiasHFM1: {
0805               listMinBiasHFM1.push_back(*itObject);
0806             } break;
0807             case l1t::gtETTem: {
0808               listTotalEtEm.push_back(*itObject);
0809             } break;
0810             case l1t::gtAsymmetryEt: {
0811               listAsymEt.push_back(*itObject);
0812             } break;
0813             case l1t::gtAsymmetryHt: {
0814               listAsymHt.push_back(*itObject);
0815             } break;
0816             case l1t::gtAsymmetryEtHF: {
0817               listAsymEtHF.push_back(*itObject);
0818             } break;
0819             case l1t::gtAsymmetryHtHF: {
0820               listAsymHtHF.push_back(*itObject);
0821             } break;
0822             case l1t::gtZDCP: {
0823               listZDCP.push_back(*itObject);
0824             } break;
0825             case l1t::gtZDCM: {
0826               listZDCM.push_back(*itObject);
0827             } break;
0828             case l1t::gtCentrality0:
0829             case l1t::gtCentrality1:
0830             case l1t::gtCentrality2:
0831             case l1t::gtCentrality3:
0832             case l1t::gtCentrality4:
0833             case l1t::gtCentrality5:
0834             case l1t::gtCentrality6:
0835             case l1t::gtCentrality7: {
0836               listCentrality.push_back(*itObject);
0837             } break;
0838 
0839               //case JetCounts: {
0840               //    listJetCounts.push_back(*itObject);
0841               //}
0842 
0843               break;
0844             default: {
0845               // should not arrive here
0846 
0847               LogTrace("HLTL1TSeed") << "\n    HLTL1TSeed::hltFilter "
0848                                      << "\n      Unknown object of type " << objTypeVal << " and index " << (*itObject)
0849                                      << " in the seed list." << std::endl;
0850             } break;
0851 
0852           }  // end switch objTypeVal
0853 
0854         }  // end for itObj
0855 
0856       }  // end for itComb
0857 
0858     }  // end for condition
0859 
0860   }  // end for itSeed
0861 
0862   // eliminate duplicates
0863 
0864   listMuon.sort();
0865   listMuon.unique();
0866 
0867   listMuonShower.sort();
0868   listMuonShower.unique();
0869 
0870   listEG.sort();
0871   listEG.unique();
0872 
0873   listJet.sort();
0874   listJet.unique();
0875 
0876   listTau.sort();
0877   listTau.unique();
0878 
0879   listETM.sort();
0880   listETM.unique();
0881 
0882   listETT.sort();
0883   listETT.unique();
0884 
0885   listHTT.sort();
0886   listHTT.unique();
0887 
0888   listHTM.sort();
0889   listHTM.unique();
0890 
0891   listETMHF.sort();
0892   listETMHF.unique();
0893 
0894   listJetCounts.sort();
0895   listJetCounts.unique();
0896 
0897   listCentrality.sort();
0898   listCentrality.unique();
0899 
0900   listMinBiasHFP0.sort();
0901   listMinBiasHFP0.unique();
0902 
0903   listMinBiasHFM0.sort();
0904   listMinBiasHFM0.unique();
0905 
0906   listMinBiasHFP1.sort();
0907   listMinBiasHFP1.unique();
0908 
0909   listMinBiasHFM1.sort();
0910   listMinBiasHFM1.unique();
0911 
0912   listTotalEtEm.sort();
0913   listTotalEtEm.unique();
0914 
0915   listMissingEtHF.sort();
0916   listMissingEtHF.unique();
0917 
0918   listTowerCount.sort();
0919   listTowerCount.unique();
0920 
0921   listAsymEt.sort();
0922   listAsymEt.unique();
0923 
0924   listAsymHt.sort();
0925   listAsymHt.unique();
0926 
0927   listAsymEtHF.sort();
0928   listAsymEtHF.unique();
0929 
0930   listAsymHtHF.sort();
0931   listAsymHtHF.unique();
0932 
0933   listZDCP.sort();
0934   listZDCP.unique();
0935 
0936   listZDCM.sort();
0937   listZDCM.unique();
0938 
0939   // record the L1 physics objects in the HLT filterproduct
0940   // //////////////////////////////////////////////////////
0941 
0942   // Muon
0943   if (!listMuon.empty()) {
0944     edm::Handle<l1t::MuonBxCollection> muons;
0945     iEvent.getByToken(m_l1MuonToken, muons);
0946 
0947     if (!muons.isValid()) {
0948       edm::LogWarning("HLTL1TSeed") << "\nWarning: L1MuonBxCollection with input tag " << m_l1MuonTag
0949                                     << "\nrequested in configuration, but not found in the event."
0950                                     << "\nNo muons added to filterproduct." << endl;
0951     } else {
0952       for (std::list<int>::const_iterator itObj = listMuon.begin(); itObj != listMuon.end(); ++itObj) {
0953         // Transform to index for Bx = 0 to begin of BxVector
0954         unsigned int index = muons->begin(0) - muons->begin() + *itObj;
0955 
0956         l1t::MuonRef myref(muons, index);
0957         filterproduct.addObject(trigger::TriggerL1Mu, myref);
0958       }
0959     }
0960   }
0961 
0962   // Muon Shower
0963   if (!listMuonShower.empty()) {
0964     edm::Handle<l1t::MuonShowerBxCollection> muonShowers;
0965     iEvent.getByToken(m_l1MuonShowerToken, muonShowers);
0966 
0967     if (!muonShowers.isValid()) {
0968       edm::LogWarning("HLTL1TSeed") << "\nWarning: L1MuonShowerBxCollection with input tag " << m_l1MuonShowerTag
0969                                     << "\nrequested in configuration, but not found in the event."
0970                                     << "\nNo muon showers added to filterproduct." << endl;
0971     } else {
0972       for (std::list<int>::const_iterator itObj = listMuonShower.begin(); itObj != listMuonShower.end(); ++itObj) {
0973         // Transform to index for Bx = 0 to begin of BxVector
0974         unsigned int index = muonShowers->begin(0) - muonShowers->begin() + *itObj;
0975 
0976         l1t::MuonShowerRef myref(muonShowers, index);
0977         filterproduct.addObject(trigger::TriggerL1MuShower, myref);
0978       }
0979     }
0980   }
0981 
0982   // EG (isolated)
0983   if (!listEG.empty()) {
0984     edm::Handle<l1t::EGammaBxCollection> egammas;
0985     iEvent.getByToken(m_l1EGammaToken, egammas);
0986     if (!egammas.isValid()) {
0987       edm::LogWarning("HLTL1TSeed") << "\nWarning: L1EGammaBxCollection with input tag " << m_l1EGammaTag
0988                                     << "\nrequested in configuration, but not found in the event."
0989                                     << "\nNo egammas added to filterproduct." << endl;
0990     } else {
0991       for (std::list<int>::const_iterator itObj = listEG.begin(); itObj != listEG.end(); ++itObj) {
0992         // Transform to begin of BxVector
0993         unsigned int index = egammas->begin(0) - egammas->begin() + *itObj;
0994 
0995         l1t::EGammaRef myref(egammas, index);
0996         filterproduct.addObject(trigger::TriggerL1EG, myref);
0997       }
0998     }
0999   }
1000 
1001   // Jet
1002   if (!listJet.empty()) {
1003     edm::Handle<l1t::JetBxCollection> jets;
1004     iEvent.getByToken(m_l1JetToken, jets);
1005 
1006     if (!jets.isValid()) {
1007       edm::LogWarning("HLTL1TSeed") << "\nWarning: L1JetBxCollection with input tag " << m_l1JetTag
1008                                     << "\nrequested in configuration, but not found in the event."
1009                                     << "\nNo jets added to filterproduct." << endl;
1010     } else {
1011       for (std::list<int>::const_iterator itObj = listJet.begin(); itObj != listJet.end(); ++itObj) {
1012         // Transform to begin of BxVector
1013         unsigned int index = jets->begin(0) - jets->begin() + *itObj;
1014 
1015         l1t::JetRef myref(jets, index);
1016         filterproduct.addObject(trigger::TriggerL1Jet, myref);
1017       }
1018     }
1019   }
1020 
1021   // Tau
1022   if (!listTau.empty()) {
1023     edm::Handle<l1t::TauBxCollection> taus;
1024     iEvent.getByToken(m_l1TauToken, taus);
1025 
1026     if (!taus.isValid()) {
1027       edm::LogWarning("HLTL1TSeed") << "\nWarning: L1TauBxCollection with input tag " << m_l1TauTag
1028                                     << "\nrequested in configuration, but not found in the event."
1029                                     << "\nNo taus added to filterproduct." << endl;
1030     } else {
1031       for (std::list<int>::const_iterator itObj = listTau.begin(); itObj != listTau.end(); ++itObj) {
1032         // Transform to begin of BxVector
1033         unsigned int index = taus->begin(0) - taus->begin() + *itObj;
1034 
1035         l1t::TauRef myref(taus, index);
1036         filterproduct.addObject(trigger::TriggerL1Tau, myref);
1037       }
1038     }
1039   }
1040 
1041   // ETT, HTT, ETM, HTM
1042   edm::Handle<l1t::EtSumBxCollection> etsums;
1043   iEvent.getByToken(m_l1EtSumToken, etsums);
1044   if (!etsums.isValid()) {
1045     edm::LogWarning("HLTL1TSeed") << "\nWarning: L1EtSumBxCollection with input tag " << m_l1EtSumTag
1046                                   << "\nrequested in configuration, but not found in the event."
1047                                   << "\nNo etsums added to filterproduct." << endl;
1048   } else {
1049     l1t::EtSumBxCollection::const_iterator iter;
1050 
1051     for (iter = etsums->begin(0); iter != etsums->end(0); ++iter) {
1052       l1t::EtSumRef myref(etsums, etsums->key(iter));
1053 
1054       switch (iter->getType()) {
1055         case l1t::EtSum::kTotalEt:
1056           if (!listETT.empty())
1057             filterproduct.addObject(trigger::TriggerL1ETT, myref);
1058           break;
1059         case l1t::EtSum::kTotalHt:
1060           if (!listHTT.empty())
1061             filterproduct.addObject(trigger::TriggerL1HTT, myref);
1062           break;
1063         case l1t::EtSum::kMissingEt:
1064           if (!listETM.empty())
1065             filterproduct.addObject(trigger::TriggerL1ETM, myref);
1066           break;
1067         case l1t::EtSum::kMissingHt:
1068           if (!listHTM.empty())
1069             filterproduct.addObject(trigger::TriggerL1HTM, myref);
1070           break;
1071         case l1t::EtSum::kMissingEtHF:
1072           if (!listETMHF.empty())
1073             filterproduct.addObject(trigger::TriggerL1ETMHF, myref);
1074           break;
1075         case l1t::EtSum::kCentrality:
1076           if (!listCentrality.empty())
1077             filterproduct.addObject(trigger::TriggerL1Centrality, myref);
1078           break;
1079         case l1t::EtSum::kMinBiasHFP0:
1080           if (!listMinBiasHFP0.empty())
1081             filterproduct.addObject(trigger::TriggerL1MinBiasHFP0, myref);
1082           break;
1083         case l1t::EtSum::kMinBiasHFM0:
1084           if (!listMinBiasHFM0.empty())
1085             filterproduct.addObject(trigger::TriggerL1MinBiasHFM0, myref);
1086           break;
1087         case l1t::EtSum::kMinBiasHFP1:
1088           if (!listMinBiasHFP1.empty())
1089             filterproduct.addObject(trigger::TriggerL1MinBiasHFP1, myref);
1090           break;
1091         case l1t::EtSum::kMinBiasHFM1:
1092           if (!listMinBiasHFM1.empty())
1093             filterproduct.addObject(trigger::TriggerL1MinBiasHFM1, myref);
1094           break;
1095         case l1t::EtSum::kTotalEtEm:
1096           if (!listTotalEtEm.empty())
1097             filterproduct.addObject(trigger::TriggerL1TotalEtEm, myref);
1098           break;
1099         case l1t::EtSum::kTowerCount:
1100           if (!listTowerCount.empty())
1101             filterproduct.addObject(trigger::TriggerL1TowerCount, myref);
1102           break;
1103         case l1t::EtSum::kAsymEt:
1104           if (!listAsymEt.empty())
1105             filterproduct.addObject(trigger::TriggerL1AsymEt, myref);
1106           break;
1107         case l1t::EtSum::kAsymHt:
1108           if (!listAsymHt.empty())
1109             filterproduct.addObject(trigger::TriggerL1AsymHt, myref);
1110           break;
1111         case l1t::EtSum::kAsymEtHF:
1112           if (!listAsymEtHF.empty())
1113             filterproduct.addObject(trigger::TriggerL1AsymEtHF, myref);
1114           break;
1115         case l1t::EtSum::kAsymHtHF:
1116           if (!listAsymHtHF.empty())
1117             filterproduct.addObject(trigger::TriggerL1AsymHtHF, myref);
1118           break;
1119         default:
1120           LogTrace("HLTL1TSeed") << "  L1EtSum seed of currently unsuported HLT TriggerType. l1t::EtSum type:      "
1121                                  << iter->getType() << "\n";
1122 
1123       }  // end switch
1124 
1125     }  // end for
1126 
1127   }  // end else
1128 
1129   // ZDCP, ZDCM
1130   edm::Handle<l1t::EtSumBxCollection> etsumzdcs;
1131   iEvent.getByToken(m_l1EtSumZdcToken, etsumzdcs);
1132   if (!etsumzdcs.isValid()) {
1133     //!! FIXME: replace LogDebug with edm::LogWarning once unpacker of ZDC inputs to L1-uGT becomes available
1134     //!!        https://github.com/cms-sw/cmssw/pull/42634#issuecomment-1698132805
1135     //!!        https://github.com/cms-sw/cmssw/blob/bece38936ef0ba111f4b5f4502e819595560afa6/EventFilter/L1TRawToDigi/plugins/implementations_stage2/GTSetup.cc#L76
1136     LogDebug("HLTL1TSeed") << "\nWarning: L1EtSumBxCollection with input tag " << m_l1EtSumZdcTag
1137                            << "\nrequested in configuration, but not found in the event."
1138                            << "\nNo etsums (ZDC) added to filterproduct.";
1139   } else {
1140     l1t::EtSumBxCollection::const_iterator iter;
1141 
1142     for (iter = etsumzdcs->begin(0); iter != etsumzdcs->end(0); ++iter) {
1143       l1t::EtSumRef myref(etsumzdcs, etsumzdcs->key(iter));
1144 
1145       switch (iter->getType()) {
1146         case l1t::EtSum::kZDCP:
1147           if (!listZDCP.empty())
1148             filterproduct.addObject(trigger::TriggerL1ZDCP, myref);
1149           break;
1150         case l1t::EtSum::kZDCM:
1151           if (!listZDCM.empty())
1152             filterproduct.addObject(trigger::TriggerL1ZDCM, myref);
1153           break;
1154         default:
1155           LogTrace("HLTL1TSeed")
1156               << "  L1EtSum (ZDC) seed of currently unsuported HLT TriggerType. l1t::EtSum type:      "
1157               << iter->getType() << "\n";
1158 
1159       }  // end switch
1160 
1161     }  // end for
1162 
1163   }  // end else
1164 
1165   // TODO FIXME uncomment if block when JetCounts implemented
1166 
1167   //    // jet counts
1168   //    if (!listJetCounts.empty()) {
1169   //        edm::Handle<l1extra::L1JetCounts> l1JetCounts;
1170   //        iEvent.getByToken(m_l1CollectionsToken.label(), l1JetCounts);
1171   //
1172   //        for (std::list<int>::const_iterator itObj = listJetCounts.begin();
1173   //                itObj != listJetCounts.end(); ++itObj) {
1174   //
1175   //            filterproduct.addObject(trigger::TriggerL1JetCounts,l1extra::L1JetCountsRefProd(l1JetCounts));
1176   //                  // FIXME: RefProd!
1177   //
1178   //        }
1179   //
1180   //    }
1181 
1182   LogTrace("HLTL1TSeed") << "\nHLTL1Seed:seedsL1TriggerObjectMaps returning " << seedsResult << endl << endl;
1183 
1184   return seedsResult;
1185 }
1186 
1187 // register as framework plugin
1188 #include "FWCore/Framework/interface/MakerMacros.h"
1189 DEFINE_FWK_MODULE(HLTL1TSeed);