CMS 3D CMS Logo

HLTL1TSeed.cc
Go to the documentation of this file.
1 #include <string>
2 #include <list>
3 #include <vector>
4 #include <algorithm>
5 #include <iostream>
6 #include <sstream>
7 #include <cassert>
8 
24 
25 
27 
28 #include "HLTL1TSeed.h"
29 
30 using namespace std;
31 
32 // constructors
34  HLTStreamFilter(parSet),
35  //useObjectMaps_(parSet.getParameter<bool>("L1UseL1TriggerObjectMaps")),
36  m_l1SeedsLogicalExpression(parSet.getParameter<string>("L1SeedsLogicalExpression")),
37  m_l1GtObjectMapTag(parSet.getParameter<edm::InputTag> ("L1ObjectMapInputTag")),
38  m_l1GtObjectMapToken(consumes<GlobalObjectMapRecord>(m_l1GtObjectMapTag)),
39  m_l1GlobalTag(parSet.getParameter<edm::InputTag> ("L1GlobalInputTag")),
40  m_l1GlobalToken(consumes<GlobalAlgBlkBxCollection>(m_l1GlobalTag)),
41  m_l1MuonCollectionsTag(parSet.getParameter<edm::InputTag>("L1MuonInputTag")), // FIX WHEN UNPACKERS ADDED
42  m_l1MuonTag(m_l1MuonCollectionsTag),
43  m_l1MuonToken(consumes<l1t::MuonBxCollection>(m_l1MuonTag)),
44  m_l1EGammaCollectionsTag(parSet.getParameter<edm::InputTag>("L1EGammaInputTag")), // FIX WHEN UNPACKERS ADDED
45  m_l1EGammaTag(m_l1EGammaCollectionsTag),
46  m_l1EGammaToken(consumes<l1t::EGammaBxCollection>(m_l1EGammaTag)),
47  m_l1JetCollectionsTag(parSet.getParameter<edm::InputTag>("L1JetInputTag")), // FIX WHEN UNPACKERS ADDED
48  m_l1JetTag(m_l1JetCollectionsTag),
49  m_l1JetToken(consumes<l1t::JetBxCollection>(m_l1JetTag)),
50  m_l1TauCollectionsTag(parSet.getParameter<edm::InputTag>("L1TauInputTag")), // FIX WHEN UNPACKERS ADDED
51  m_l1TauTag(m_l1TauCollectionsTag),
52  m_l1TauToken(consumes<l1t::TauBxCollection>(m_l1TauTag)),
53  m_l1EtSumCollectionsTag(parSet.getParameter<edm::InputTag>("L1EtSumInputTag")), // FIX WHEN UNPACKERS ADDED
54  m_l1EtSumTag(m_l1EtSumCollectionsTag),
55  m_l1EtSumToken(consumes<l1t::EtSumBxCollection>(m_l1EtSumTag)),
56  m_l1GlobalDecision(false),
57  m_isDebugEnabled(edm::isDebugEnabled())
58 {
59 
60  if (m_l1SeedsLogicalExpression == "") {
61 
62  throw cms::Exception("FailModule") << "\nTrying to seed with an empty L1SeedsLogicalExpression.\n" << std::endl;
63 
64  }
65  else if (m_l1SeedsLogicalExpression != "L1GlobalDecision") {
66 
67  // check also the logical expression - add/remove spaces if needed
69 
70  // list of required algorithms for seeding
71  // dummy values for tokenNumber and tokenResult
74  size_t l1AlgoSeedsSize = m_l1AlgoSeeds.size();
75 
76  m_l1AlgoSeedsRpn.reserve(l1AlgoSeedsSize);
77  m_l1AlgoSeedsObjType.reserve(l1AlgoSeedsSize);
78 
79  }
80  else {
81 
82  m_l1GlobalDecision = true;
83 
84  }
85 
86 }
87 
88 // destructor
90  // empty now
91 }
92 
93 // member functions
94 
95 void
99 
100 
101  // # logical expression for the required L1 algorithms;
102  // # the algorithms are specified by name
103  // # allowed operators: "AND", "OR", "NOT", "(", ")"
104  // #
105  // # by convention, "L1GlobalDecision" logical expression means global decision
106  desc.add<string>("L1SeedsLogicalExpression","");
107  desc.add<edm::InputTag>("L1ObjectMapInputTag",edm::InputTag("hltGtStage2ObjectMap"));
108  desc.add<edm::InputTag>("L1GlobalInputTag",edm::InputTag("hltGtStage2Digis"));
109  desc.add<edm::InputTag>("L1MuonInputTag",edm::InputTag("hltGmtStage2Digis:Muon"));
110  desc.add<edm::InputTag>("L1EGammaInputTag",edm::InputTag("hltCaloStage2Digis:EGamma"));
111  desc.add<edm::InputTag>("L1JetInputTag",edm::InputTag("hltCaloStage2Digis:Jet"));
112  desc.add<edm::InputTag>("L1TauInputTag",edm::InputTag("hltCaloStage2Digis:Tau"));
113  desc.add<edm::InputTag>("L1EtSumInputTag",edm::InputTag("hltCaloStage2Digis:EtSum"));
114  descriptions.add("hltL1TSeed", desc);
115 }
116 
118 
119  bool rc = false;
120 
121  // the filter object
122  if (saveTags()) {
123 
124  // muons
125  filterproduct.addCollectionTag(m_l1MuonTag);
126 
127  // egamma
128  filterproduct.addCollectionTag(m_l1EGammaTag);
129 
130  // jet
131  filterproduct.addCollectionTag(m_l1JetTag);
132 
133  // tau
134  filterproduct.addCollectionTag(m_l1TauTag);
135 
136  // etsum
137  filterproduct.addCollectionTag(m_l1EtSumTag);
138  }
139 
140  // Get all the seeding from iEvent (i.e. L1TriggerObjectMapRecord)
141  //
142  rc = seedsL1TriggerObjectMaps(iEvent, filterproduct);
143 
144  if (m_isDebugEnabled) {
145  dumpTriggerFilterObjectWithRefs(filterproduct);
146  }
147 
148  return rc;
149 
150 }
151 
152 // detailed print of filter content
154 {
155 
156  LogTrace("HLTL1TSeed")
157  << "\nHLTL1TSeed::hltFilter "
158  << "\n Dump TriggerFilterObjectWithRefs\n" << endl;
159 
160  vector<l1t::MuonRef> seedsL1Mu;
161  filterproduct.getObjects(trigger::TriggerL1Mu, seedsL1Mu);
162  const size_t sizeSeedsL1Mu = seedsL1Mu.size();
163 
164  LogTrace("HLTL1TSeed")
165  << "\n HLTL1TSeed: seed logical expression = " << m_l1SeedsLogicalExpression << endl;
166 
167  LogTrace("HLTL1TSeed")
168  << "\n L1Mu seeds: " << sizeSeedsL1Mu << endl << endl;
169 
170  for (size_t i = 0; i != sizeSeedsL1Mu; i++) {
171 
172 
173  l1t::MuonRef obj = l1t::MuonRef( seedsL1Mu[i]);
174 
175  LogTrace("HLTL1TSeed")
176  << "\tL1Mu " << "\t" << "q = " << obj->hwCharge() // TEMP get hwCharge insead of charge which is not yet set NEED FIX.
177  << "\t" << "pt = " << obj->pt() << "\t" << "eta = " << obj->eta()
178  << "\t" << "phi = " << obj->phi(); //<< "\t" << "BX = " << obj->bx();
179  }
180 
181  vector<l1t::EGammaRef> seedsL1EG;
182  filterproduct.getObjects(trigger::TriggerL1EG, seedsL1EG);
183  const size_t sizeSeedsL1EG = seedsL1EG.size();
184 
185  LogTrace("HLTL1TSeed")
186  << "\n L1EG seeds: " << sizeSeedsL1EG << endl << endl;
187 
188  for (size_t i = 0; i != sizeSeedsL1EG; i++) {
189 
190 
191  l1t::EGammaRef obj = l1t::EGammaRef( seedsL1EG[i]);
192 
193  LogTrace("HLTL1TSeed")
194  << "\tL1EG " << "\t" << "pt = "
195  << obj->pt() << "\t" << "eta = " << obj->eta()
196  << "\t" << "phi = " << obj->phi(); //<< "\t" << "BX = " << obj->bx();
197  }
198 
199  vector<l1t::JetRef> seedsL1Jet;
200  filterproduct.getObjects(trigger::TriggerL1Jet, seedsL1Jet);
201  const size_t sizeSeedsL1Jet = seedsL1Jet.size();
202 
203  LogTrace("HLTL1TSeed")
204  << "\n L1Jet seeds: " << sizeSeedsL1Jet << endl << endl;
205 
206  for (size_t i = 0; i != sizeSeedsL1Jet; i++) {
207 
208 
209  l1t::JetRef obj = l1t::JetRef( seedsL1Jet[i]);
210 
211  LogTrace("HLTL1TSeed") << "\tL1Jet " << "\t" << "pt = "
212  << obj->pt() << "\t" << "eta = " << obj->eta()
213  << "\t" << "phi = " << obj->phi(); //<< "\t" << "BX = " << obj->bx();
214  }
215 
216  vector<l1t::TauRef> seedsL1Tau;
217  filterproduct.getObjects(trigger::TriggerL1Tau, seedsL1Tau);
218  const size_t sizeSeedsL1Tau = seedsL1Tau.size();
219 
220  LogTrace("HLTL1TSeed")
221  << "\n L1Tau seeds: " << sizeSeedsL1Tau << endl << endl;
222 
223  for (size_t i = 0; i != sizeSeedsL1Tau; i++) {
224 
225 
226  l1t::TauRef obj = l1t::TauRef( seedsL1Tau[i]);
227 
228  LogTrace("HLTL1TSeed")
229  << "\tL1Tau " << "\t" << "pt = "
230  << obj->pt() << "\t" << "eta = " << obj->eta()
231  << "\t" << "phi = " << obj->phi(); //<< "\t" << "BX = " << obj->bx();
232  }
233 
234  vector<l1t::EtSumRef> seedsL1EtSumETT;
235  filterproduct.getObjects(trigger::TriggerL1ETT, seedsL1EtSumETT);
236  const size_t sizeSeedsL1EtSumETT = seedsL1EtSumETT.size();
237  LogTrace("HLTL1TSeed")
238  << "\n L1EtSum ETT seeds: " << sizeSeedsL1EtSumETT << endl << endl;
239 
240  for (size_t i = 0; i != sizeSeedsL1EtSumETT; i++) {
241  l1t::EtSumRef obj = l1t::EtSumRef( seedsL1EtSumETT[i]);
242 
243  LogTrace("HLTL1TSeed")
244  << "\tL1EtSum ETT" << "\t" << "pt = "
245  << obj->pt() << "\t" << "eta = " << obj->eta()
246  << "\t" << "phi = " << obj->phi(); //<< "\t" << "BX = " << obj->bx();
247  }
248 
249  vector<l1t::EtSumRef> seedsL1EtSumHTT;
250  filterproduct.getObjects(trigger::TriggerL1HTT, seedsL1EtSumHTT);
251  const size_t sizeSeedsL1EtSumHTT = seedsL1EtSumHTT.size();
252  LogTrace("HLTL1TSeed")
253  << "\n L1EtSum HTT seeds: " << sizeSeedsL1EtSumHTT << endl << endl;
254 
255  for (size_t i = 0; i != sizeSeedsL1EtSumHTT; i++) {
256  l1t::EtSumRef obj = l1t::EtSumRef( seedsL1EtSumHTT[i]);
257 
258  LogTrace("HLTL1TSeed")
259  << "\tL1EtSum HTT" << "\t" << "pt = "
260  << obj->pt() << "\t" << "eta = " << obj->eta()
261  << "\t" << "phi = " << obj->phi(); //<< "\t" << "BX = " << obj->bx();
262  }
263 
264  vector<l1t::EtSumRef> seedsL1EtSumETM;
265  filterproduct.getObjects(trigger::TriggerL1ETM, seedsL1EtSumETM);
266  const size_t sizeSeedsL1EtSumETM = seedsL1EtSumETM.size();
267  LogTrace("HLTL1TSeed")
268  << "\n L1EtSum ETM seeds: " << sizeSeedsL1EtSumETM << endl << endl;
269 
270  for (size_t i = 0; i != sizeSeedsL1EtSumETM; i++) {
271  l1t::EtSumRef obj = l1t::EtSumRef( seedsL1EtSumETM[i]);
272 
273  LogTrace("HLTL1TSeed")
274  << "\tL1EtSum ETM" << "\t" << "pt = "
275  << obj->pt() << "\t" << "eta = " << obj->eta()
276  << "\t" << "phi = " << obj->phi(); //<< "\t" << "BX = " << obj->bx();
277  }
278 
279  vector<l1t::EtSumRef> seedsL1EtSumETMHF;
280  filterproduct.getObjects(trigger::TriggerL1ETMHF, seedsL1EtSumETMHF);
281  const size_t sizeSeedsL1EtSumETMHF = seedsL1EtSumETMHF.size();
282  LogTrace("HLTL1TSeed")
283  << "\n L1EtSum ETMHF seeds: " << sizeSeedsL1EtSumETMHF << endl << endl;
284 
285  for (size_t i = 0; i != sizeSeedsL1EtSumETMHF; i++) {
286  l1t::EtSumRef obj = l1t::EtSumRef( seedsL1EtSumETMHF[i]);
287 
288  LogTrace("HLTL1TSeed")
289  << "\tL1EtSum ETMHF" << "\t" << "pt = "
290  << obj->pt() << "\t" << "eta = " << obj->eta()
291  << "\t" << "phi = " << obj->phi(); //<< "\t" << "BX = " << obj->bx();
292  }
293 
294  vector<l1t::EtSumRef> seedsL1EtSumHTM;
295  filterproduct.getObjects(trigger::TriggerL1HTM, seedsL1EtSumHTM);
296  const size_t sizeSeedsL1EtSumHTM = seedsL1EtSumHTM.size();
297  LogTrace("HLTL1TSeed")
298  << "\n L1EtSum HTM seeds: " << sizeSeedsL1EtSumHTM << endl << endl;
299 
300  for (size_t i = 0; i != sizeSeedsL1EtSumHTM; i++) {
301  l1t::EtSumRef obj = l1t::EtSumRef( seedsL1EtSumHTM[i]);
302 
303  LogTrace("HLTL1TSeed")
304  << "\tL1EtSum HTM" << "\t" << "pt = "
305  << obj->pt() << "\t" << "eta = " << obj->eta()
306  << "\t" << "phi = " << obj->phi(); //<< "\t" << "BX = " << obj->bx();
307  }
308 
309  LogTrace("HLTL1TSeed") << " \n\n" << endl;
310 
311 }
312 
313 // seeding is done via L1 trigger object maps, considering the objects which fired in L1
316  ) {
317 
318  // Two GT objects are obtained from the Event: (1) the unpacked GT and (2) the emulated GT.
319  // Return value of the function is the score of seeding logical expression, evaluated using (1).
320  // Seeding is performed (per l1_algo) if ACCEPT both in (1) and (2). Seed objects are identified
321  // and only available from ObjectMaps created in (2).
322 
323 
324  // define index lists for all particle types
325 
326  std::list<int> listMuon;
327 
328  std::list<int> listEG;
329 
330  std::list<int> listJet;
331  std::list<int> listTau;
332 
333  std::list<int> listETM;
334  std::list<int> listETT;
335  std::list<int> listHTT;
336  std::list<int> listHTM;
337  std::list<int> listETMHF;
338 
339  std::list<int> listJetCounts;
340 
341  // get handle to unpacked GT
343  iEvent.getByToken(m_l1GlobalToken, uGtAlgoBlocks);
344 
345  if (!uGtAlgoBlocks.isValid()) {
346 
347  edm::LogWarning("HLTL1TSeed")
348  << " Warning: GlobalAlgBlkBxCollection with input tag "
349  << m_l1GlobalTag
350  << " requested in configuration, but not found in the event." << std::endl;
351 
352  return false;
353  }
354 
355  // check size
356  if(uGtAlgoBlocks->size() == 0) {
357 
358  edm::LogWarning("HLTL1TSeed")
359  << " Warning: GlobalAlgBlkBxCollection with input tag "
360  << m_l1GlobalTag
361  << " is empty." << std::endl;
362 
363  return false;
364  }
365 
366  // get handle to object maps from emulator (one object map per algorithm)
367  edm::Handle<GlobalObjectMapRecord> gtObjectMapRecord;
368  iEvent.getByToken(m_l1GtObjectMapToken, gtObjectMapRecord);
369 
370  if (!gtObjectMapRecord.isValid()) {
371 
372  edm::LogWarning("HLTL1TSeed")
373  << " Warning: GlobalObjectMapRecord with input tag "
375  << " requested in configuration, but not found in the event." << std::endl;
376 
377  return false;
378  }
379 
380  if (m_isDebugEnabled) {
381 
382  const std::vector<GlobalObjectMap>& objMaps = gtObjectMapRecord->gtObjectMap();
383 
384  LogTrace("HLTL1TSeed")
385  << "\nHLTL1Seed"
386  << "\n---------------------------------------------------------------------------------------------------------------------";
387 
388  LogTrace("HLTL1TSeed")
389  << "\n\tAlgorithms in L1TriggerObjectMapRecord and GT results ( emulated | initial | prescaled | final ) " << endl;
390 
391  LogTrace("HLTL1TSeed")
392  << "\n\tmap" <<"\tAlgoBit" << std::setw(40) << "algoName" << "\t (emul|ini|pre|fin)" << endl;
393 
394  LogTrace("HLTL1TSeed")
395  << "---------------------------------------------------------------------------------------------------------------------";
396 
397  for (size_t imap =0; imap < objMaps.size(); imap++) {
398 
399  int bit = objMaps[imap].algoBitNumber(); // same as bit from L1T Menu
400 
401  int emulDecision = objMaps[imap].algoGtlResult();
402 
403  // For bx=0 , get 0th AlgoBlock, so in BXvector at(bx=0,i=0)
404  int initDecision = (uGtAlgoBlocks->at(0,0)).getAlgoDecisionInitial(bit);
405  int presDecision = (uGtAlgoBlocks->at(0,0)).getAlgoDecisionInterm(bit);
406  int finlDecision = (uGtAlgoBlocks->at(0,0)).getAlgoDecisionFinal(bit);
407 
408  if(emulDecision != initDecision) {
409 
410  LogTrace("HLTL1TSeed")
411  << "L1T decision (emulated vs. unpacked initial) is not the same:"
412  << "\n\tbit = " << std::setw(3) << bit
413  << std::setw(40) << objMaps[imap].algoName()
414  << "\t emulated decision = " << emulDecision << "\t unpacked initial decision = " << initDecision
415  << "\nThis should not happen. Include the L1TGtEmulCompare module in the sequence."<< endl;
416 
417  }
418 
419 
420  LogTrace("HLTL1TSeed")
421  << "\t" << std::setw(3) << imap
422  << "\tbit = " << std::setw(3) << bit
423  << std::setw(40) << objMaps[imap].algoName()
424  << "\t ( " << emulDecision << " | " << initDecision << " | " << presDecision << " | " << finlDecision << " ) ";
425 
426 
427  }
428  LogTrace("HLTL1TSeed") << endl;
429 
430  }
431 
432  // Filter decision in case of "L1GlobalDecision" logical expression.
433  // By convention, it means global decision.
434  // /////////////////////////////////////////////////////////////////
435  if (m_l1GlobalDecision) {
436 
437  // For bx=0 , get 0th AlgoBlock, so in BXvector at(bx=0,i=0)
438  return (uGtAlgoBlocks->at(0,0)).getFinalOR();
439 
440  }
441 
442 
443  // Update/Reset m_l1AlgoLogicParser by reseting token result
444  // /////////////////////////////////////////////////////////
445  std::vector<GlobalLogicParser::OperandToken>& algOpTokenVector =
447 
448  for (auto & i : algOpTokenVector) {
449 
450  // rest token result
451  //
452  i.tokenResult = false;
453 
454  }
455 
456  // Update m_l1AlgoLogicParser and store emulator results for algOpTokens
457  // /////////////////////////////////////////////////////////////////////
458  for (auto & i : algOpTokenVector) {
459 
460  std::string algoName = i.tokenName;
461 
462  const GlobalObjectMap* objMap = gtObjectMapRecord->getObjectMap(algoName);
463 
464  if(objMap == nullptr) {
465 
466  throw cms::Exception("FailModule") << "\nAlgorithm " << algoName
467  << ", requested as seed by a HLT path, cannot be matched to a L1 algo name in any GlobalObjectMap\n"
468  << "Please check if algorithm " << algoName << " is present in the L1 menu\n" << std::endl;
469 
470  }
471  else {
472 
473  //(algOpTokenVector[i]).tokenResult = objMap->algoGtlResult();
474 
475  int bit = objMap->algoBitNumber();
476  bool finalAlgoDecision = (uGtAlgoBlocks->at(0,0)).getAlgoDecisionFinal(bit);
477  i.tokenResult = finalAlgoDecision;
478 
479  }
480 
481  }
482 
483  // Filter decision
484  // ///////////////
485  bool seedsResult = m_l1AlgoLogicParser.expressionResult();
486 
487  if (m_isDebugEnabled ) {
488 
489  LogTrace("HLTL1TSeed")
490  << "\nHLTL1TSeed: l1SeedsLogicalExpression (names) = '" << m_l1SeedsLogicalExpression << "'"
491  << "\n Result for logical expression after update of algOpTokens: " << seedsResult << "\n"
492  << std::endl;
493  }
494 
497 
498  for (std::vector<GlobalLogicParser::OperandToken>::const_iterator
499  itSeed = m_l1AlgoSeeds.begin(); itSeed != m_l1AlgoSeeds.end(); ++itSeed) {
500 
501  std::string algoSeedName = (*itSeed).tokenName;
502 
503  LogTrace("HLTL1TSeed")
504  << "\n ---------------- algo seed name = " << algoSeedName << endl;
505 
506  const GlobalObjectMap* objMap = gtObjectMapRecord->getObjectMap(algoSeedName);
507 
508  if(objMap == nullptr) {
509 
510  // Should not get here
511  //
512  throw cms::Exception("FailModule") << "\nAlgorithm " << algoSeedName
513  << ", requested as seed by a HLT path, cannot be matched to a L1 algo name in any GlobalObjectMap\n"
514  << "Please check if algorithm " << algoSeedName << " is present in the L1 menu\n" << std::endl;
515 
516  }
517 
518  int algoSeedBitNumber = objMap->algoBitNumber();
519  bool algoSeedResult = objMap->algoGtlResult();
520 
521  // unpacked GT results: uGtAlgoBlock has decisions initial, prescaled, and final after masks
522  bool algoSeedResultMaskAndPresc = uGtAlgoBlocks->at(0,0).getAlgoDecisionFinal(algoSeedBitNumber);
523 
524  LogTrace("HLTL1TSeed")
525  << "\n\tAlgo seed " << algoSeedName << " result emulated | final = " << algoSeedResult << " | " << algoSeedResultMaskAndPresc << endl;
526 
529  if(!algoSeedResultMaskAndPresc) continue;
530 
532  // This should not happen if the emulated and unpacked GT are consistent
534  if(!algoSeedResult) continue;
535 
536  const std::vector<GlobalLogicParser::OperandToken>& opTokenVecObjMap = objMap->operandTokenVector();
537  const std::vector<L1TObjectTypeInCond>& condObjTypeVec = objMap->objectTypeVector();
538  const std::vector<CombinationsInCond>& condCombinations = objMap->combinationVector();
539 
540  LogTrace("HLTL1TSeed")
541  << "\n\talgoName =" << objMap->algoName()
542  << "\talgoBitNumber = " << algoSeedBitNumber
543  << "\talgoGtlResult = " << algoSeedResult << endl << endl;
544 
545 
546  if (opTokenVecObjMap.size() != condObjTypeVec.size() ) {
547  edm::LogWarning("HLTL1TSeed")
548  << "\nWarning: GlobalObjectMapRecord with input tag "
550  << "\nhas object map for bit number " << algoSeedBitNumber << " which contains different size vectors of operand tokens and of condition object types!" << std::endl;
551 
552  assert(opTokenVecObjMap.size() == condObjTypeVec.size());
553  }
554 
555  if (opTokenVecObjMap.size() != condCombinations.size()) {
556  edm::LogWarning("HLTL1TSeed")
557  << "\nWarning: GlobalObjectMapRecord with input tag "
559  << "\nhas object map for bit number " << algoSeedBitNumber << " which contains different size vectors of operand tokens and of condition object combinations!" << std::endl;
560 
561  assert(opTokenVecObjMap.size() == condCombinations.size());
562  }
563 
564  // operands are conditions of L1 algo
565  //
566  for (size_t condNumber = 0; condNumber < opTokenVecObjMap.size(); condNumber++) {
567 
568  std::vector<l1t::GlobalObject> condObjType = condObjTypeVec[condNumber];
569 
570  for (auto & jOb : condObjType) {
571 
572  LogTrace("HLTL1TSeed")
573  << setw(15) << "\tcondObjType = " << jOb << endl;
574 
575  }
576 
577  const std::string condName = opTokenVecObjMap[condNumber].tokenName;
578  bool condResult = opTokenVecObjMap[condNumber].tokenResult;
579 
580  // only procede for conditions that passed
581  //
582  if ( !condResult) {
583  continue;
584  }
585 
586  // loop over combinations for a given condition
587  //
588  const CombinationsInCond* condComb = objMap->getCombinationsInCond(condNumber);
589 
590  LogTrace("HLTL1TSeed")
591  << setw(15) << "\tcondCombinations = " << condComb->size() << endl;
592 
593  for (auto const & itComb : (*condComb)) {
594 
595  LogTrace("HLTL1TSeed")
596  << setw(15) << "\tnew combination" << endl;
597 
598  // loop over objects in a combination for a given condition
599  //
600  for (auto itObject = itComb.begin(); itObject != itComb.end(); itObject++) {
601 
602  // in case of object-less triggers (e.g. L1_ZeroBias) condObjType vector is empty, so don't seed!
603  //
604  if(condObjType.empty()) {
605 
606  LogTrace("HLTL1TSeed")
607  << "\talgoName = " << objMap->algoName() << " is object-less L1 algorithm, so do not attempt to store any objects to the list of seeds.\n"
608  << std::endl;
609  continue;
610 
611  }
612 
613  // the index of the object type is the same as the index of the object
614  size_t iType = std::distance(itComb.begin(), itObject);
615 
616  // get object type and push indices on the list
617  //
618  const l1t::GlobalObject objTypeVal = condObjType.at(iType);
619 
620  LogTrace("HLTL1TSeed")
621  << "\tAdd object of type " << objTypeVal << " and index " << (*itObject) << " to the seed list."
622  << std::endl;
623 
624 
625  // THESE OBJECT CASES ARE CURRENTLY MISSING:
626  //gtMinBias,
627  //gtExternal,
628  //ObjNull
629 
630  switch (objTypeVal) {
631  case l1t::gtMu: {
632  listMuon.push_back(*itObject);
633  }
634 
635  break;
636  case l1t::gtEG: {
637  listEG.push_back(*itObject);
638  }
639  break;
640  case l1t::gtJet: {
641  listJet.push_back(*itObject);
642  }
643  break;
644  case l1t::gtTau: {
645  listTau.push_back(*itObject);
646  }
647  break;
648  case l1t::gtETM: {
649  listETM.push_back(*itObject);
650  }
651  break;
652  case l1t::gtETT: {
653  listETT.push_back(*itObject);
654  }
655  break;
656  case l1t::gtHTT: {
657  listHTT.push_back(*itObject);
658  }
659  break;
660  case l1t::gtHTM: {
661  listHTM.push_back(*itObject);
662  }
663  break;
664  case l1t::gtETMHF: {
665  listETMHF.push_back(*itObject);
666  }
667  break;
668 
669  //case JetCounts: {
670  // listJetCounts.push_back(*itObject);
671  //}
672 
673  break;
674  default: {
675  // should not arrive here
676 
677  LogTrace("HLTL1TSeed")
678  << "\n HLTL1TSeed::hltFilter "
679  << "\n Unknown object of type " << objTypeVal
680  << " and index " << (*itObject) << " in the seed list."
681  << std::endl;
682  }
683  break;
684 
685  } // end switch objTypeVal
686 
687  } // end for itObj
688 
689  } // end for itComb
690 
691  } // end for condition
692 
693  } // end for itSeed
694 
695 
696  // eliminate duplicates
697 
698  listMuon.sort();
699  listMuon.unique();
700 
701  listEG.sort();
702  listEG.unique();
703 
704  listJet.sort();
705  listJet.unique();
706 
707  listTau.sort();
708  listTau.unique();
709 
710  listETM.sort();
711  listETM.unique();
712 
713  listETT.sort();
714  listETT.unique();
715 
716  listHTT.sort();
717  listHTT.unique();
718 
719  listHTM.sort();
720  listHTM.unique();
721 
722  listETMHF.sort();
723  listETMHF.unique();
724 
725  listJetCounts.sort();
726  listJetCounts.unique();
727 
728 
729  // record the L1 physics objects in the HLT filterproduct
730  // //////////////////////////////////////////////////////
731 
732  // Muon
733  if (!listMuon.empty()) {
734 
736  iEvent.getByToken(m_l1MuonToken, muons);
737 
738  if (!muons.isValid()){
739  edm::LogWarning("HLTL1TSeed")
740  << "\nWarning: L1MuonBxCollection with input tag "
741  << m_l1MuonTag
742  << "\nrequested in configuration, but not found in the event."
743  << "\nNo muons added to filterproduct."
744  << endl;
745  }
746  else {
747 
748  for (std::list<int>::const_iterator itObj = listMuon.begin(); itObj != listMuon.end(); ++itObj) {
749 
750 
751  // Transform to index for Bx = 0 to begin of BxVector
752  unsigned int index = muons->begin(0) - muons->begin() + *itObj;
753 
754  l1t::MuonRef myref(muons, index);
755  filterproduct.addObject(trigger::TriggerL1Mu, myref);
756 
757  }
758 
759  }
760 
761  }
762 
763  // EG (isolated)
764  if (!listEG.empty()) {
765 
767  iEvent.getByToken(m_l1EGammaToken, egammas);
768  if (!egammas.isValid()){
769  edm::LogWarning("HLTL1TSeed")
770  << "\nWarning: L1EGammaBxCollection with input tag " << m_l1EGammaTag
771  << "\nrequested in configuration, but not found in the event."
772  << "\nNo egammas added to filterproduct."
773  << endl;
774  }
775  else {
776 
777  for (std::list<int>::const_iterator itObj = listEG.begin(); itObj != listEG.end(); ++itObj) {
778 
779  // Transform to begin of BxVector
780  unsigned int index = egammas->begin(0) - egammas->begin() + *itObj;
781 
782  l1t::EGammaRef myref(egammas, index);
783  filterproduct.addObject(trigger::TriggerL1EG, myref);
784 
785  }
786 
787  }
788 
789  }
790 
791  // Jet
792  if (!listJet.empty()) {
793 
795  iEvent.getByToken(m_l1JetToken, jets);
796 
797  if (!jets.isValid()){
798  edm::LogWarning("HLTL1TSeed")
799  << "\nWarning: L1JetBxCollection with input tag " << m_l1JetTag
800  << "\nrequested in configuration, but not found in the event."
801  << "\nNo jets added to filterproduct."
802  << endl;
803  }
804  else {
805 
806  for (std::list<int>::const_iterator itObj = listJet.begin(); itObj != listJet.end(); ++itObj) {
807 
808  // Transform to begin of BxVector
809  unsigned int index = jets->begin(0) - jets->begin() + *itObj;
810 
811  l1t::JetRef myref(jets, index);
812  filterproduct.addObject(trigger::TriggerL1Jet, myref);
813 
814  }
815 
816  }
817 
818  }
819 
820  // Tau
821  if (!listTau.empty()) {
822 
824  iEvent.getByToken(m_l1TauToken, taus);
825 
826  if (!taus.isValid()){
827  edm::LogWarning("HLTL1TSeed")
828  << "\nWarning: L1TauBxCollection with input tag " << m_l1TauTag
829  << "\nrequested in configuration, but not found in the event."
830  << "\nNo taus added to filterproduct."
831  << endl;
832  }
833  else {
834 
835  for (std::list<int>::const_iterator itObj = listTau.begin(); itObj != listTau.end(); ++itObj) {
836 
837  // Transform to begin of BxVector
838  unsigned int index = taus->begin(0) - taus->begin() + *itObj;
839 
840  l1t::TauRef myref(taus, index);
841  filterproduct.addObject(trigger::TriggerL1Tau, myref);
842 
843  }
844 
845  }
846 
847  }
848 
849  // ETT, HTT, ETM, HTM
851  iEvent.getByToken(m_l1EtSumToken, etsums);
852  if (!etsums.isValid()){
853  edm::LogWarning("HLTL1TSeed")
854  << "\nWarning: L1EtSumBxCollection with input tag "
855  << m_l1EtSumTag
856  << "\nrequested in configuration, but not found in the event."
857  << "\nNo etsums added to filterproduct."
858  << endl;
859  } else {
860 
862 
863  for (iter = etsums->begin(0); iter != etsums->end(0); ++iter){
864 
865  l1t::EtSumRef myref(etsums, etsums->key(iter));
866 
867  switch(iter->getType()) {
868 
869  case l1t::EtSum::kTotalEt :
870  if(!listETT.empty())
871  filterproduct.addObject(trigger::TriggerL1ETT, myref);
872  break;
873  case l1t::EtSum::kTotalHt :
874  if(!listHTT.empty())
875  filterproduct.addObject(trigger::TriggerL1HTT, myref);
876  break;
878  if(!listETM.empty())
879  filterproduct.addObject(trigger::TriggerL1ETM, myref);
880  break;
882  if(!listHTM.empty())
883  filterproduct.addObject(trigger::TriggerL1HTM, myref);
884  break;
886  if(!listETMHF.empty())
887  filterproduct.addObject(trigger::TriggerL1ETMHF, myref);
888  break;
889  default:
890  LogTrace("HLTL1TSeed") << " L1EtSum seed of currently unsuported HLT TriggerType. l1t::EtSum type: " << iter->getType() << "\n";
891 
892  } // end switch
893 
894  } // end for
895 
896  } // end else
897 
898 
899  // TODO FIXME uncomment if block when JetCounts implemented
900 
901  // // jet counts
902  // if (!listJetCounts.empty()) {
903  // edm::Handle<l1extra::L1JetCounts> l1JetCounts;
904  // iEvent.getByToken(m_l1CollectionsToken.label(), l1JetCounts);
905  //
906  // for (std::list<int>::const_iterator itObj = listJetCounts.begin();
907  // itObj != listJetCounts.end(); ++itObj) {
908  //
909  // filterproduct.addObject(trigger::TriggerL1JetCounts,l1extra::L1JetCountsRefProd(l1JetCounts));
910  // // FIXME: RefProd!
911  //
912  // }
913  //
914  // }
915 
916 
917  LogTrace("HLTL1TSeed")
918  << "\nHLTL1Seed:seedsL1TriggerObjectMaps returning " << seedsResult << endl << endl;
919 
920  return seedsResult;
921 
922 }
923 
924 // register as framework plugin
size
Write out results.
BXVector< EGamma > EGammaBxCollection
Definition: EGamma.h:11
const_iterator end(int bx) const
std::string m_l1SeedsLogicalExpression
Definition: HLTL1TSeed.h:104
bool isDebugEnabled()
virtual const bool expressionResult() const
void getObjects(Vids &ids, VRphoton &refs) const
various physics-level getters:
edm::EDGetTokenT< l1t::EtSumBxCollection > m_l1EtSumToken
Definition: HLTL1TSeed.h:138
unsigned size(int bx) const
edm::Ref< TauBxCollection > TauRef
Definition: Tau.h:13
const GlobalObjectMap * getObjectMap(const std::string &algoNameVal) const
return the object map for the algorithm algoNameVal
std::vector< std::vector< const std::vector< l1t::GlobalObject > * > > m_l1AlgoSeedsObjType
vector of object-type vectors for each condition in the required algorithms for seeding ...
Definition: HLTL1TSeed.h:93
edm::Ref< EGammaBxCollection > EGammaRef
Definition: EGamma.h:13
const std::vector< L1TObjectTypeInCond > & objectTypeVector() const
std::vector< bool > const & getAlgoDecisionFinal() const
Definition: GlobalAlgBlk.h:90
edm::InputTag m_l1MuonTag
Definition: HLTL1TSeed.h:117
HLTL1TSeed(const edm::ParameterSet &)
constructor
Definition: HLTL1TSeed.cc:33
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:519
enum start value shifted to 81 so as to avoid clashes with PDG codes
bool seedsL1TriggerObjectMaps(edm::Event &, trigger::TriggerFilterObjectWithRefs &)
seeding is done via L1 trigger object maps, considering the objects which fired in L1 ...
Definition: HLTL1TSeed.cc:314
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
GlobalObject
Definition: GlobalObject.h:16
unsigned int key(const_iterator &iter) const
Definition: BXVector.h:104
bool algoGtlResult() const
delete x;
Definition: CaloConfig.h:22
const std::vector< GlobalObjectMap > & gtObjectMap() const
get / set the vector of object maps
BXVector< Tau > TauBxCollection
Definition: Tau.h:11
std::vector< GlobalLogicParser::OperandToken > expressionSeedsOperandList()
edm::Ref< MuonBxCollection > MuonRef
Definition: Muon.h:13
void addObject(int id, const reco::RecoEcalCandidateRef &ref)
setters for L3 collections: (id=physics type, and Ref<C>)
edm::Ref< JetBxCollection > JetRef
Definition: Jet.h:13
BXVector< EtSum > EtSumBxCollection
Definition: EtSum.h:11
int iEvent
Definition: GenABIO.cc:230
edm::InputTag m_l1JetTag
Definition: HLTL1TSeed.h:127
edm::InputTag m_l1GtObjectMapTag
InputTag for L1 Global Trigger object maps. This is done per menu. Should be part of Run...
Definition: HLTL1TSeed.h:107
~HLTL1TSeed() override
destructor
Definition: HLTL1TSeed.cc:89
vector< PseudoJet > jets
edm::EDGetTokenT< l1t::JetBxCollection > m_l1JetToken
Definition: HLTL1TSeed.h:128
std::vector< OperandToken > & operandTokenVector()
return the vector of operand tokens
GlobalLogicParser m_l1AlgoLogicParser
logic parser for m_l1SeedsLogicalExpression
Definition: HLTL1TSeed.h:84
edm::EDGetTokenT< l1t::EGammaBxCollection > m_l1EGammaToken
Definition: HLTL1TSeed.h:123
edm::InputTag m_l1EtSumTag
Definition: HLTL1TSeed.h:137
std::vector< const std::vector< GlobalLogicParser::TokenRPN > * > m_l1AlgoSeedsRpn
vector of Rpn vectors for the required algorithms for seeding
Definition: HLTL1TSeed.h:90
edm::InputTag m_l1TauTag
Definition: HLTL1TSeed.h:132
int algoBitNumber() const
get / set bit number for algorithm in the object map
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool isValid() const
Definition: HandleBase.h:74
const std::vector< CombinationsInCond > & combinationVector() const
#define LogTrace(id)
BXVector< Muon > MuonBxCollection
Definition: Muon.h:11
const std::vector< GlobalLogicParser::OperandToken > & operandTokenVector() const
bool m_isDebugEnabled
cache edm::isDebugEnabled()
Definition: HLTL1TSeed.h:144
std::vector< GlobalLogicParser::OperandToken > m_l1AlgoSeeds
list of required algorithms for seeding
Definition: HLTL1TSeed.h:87
const std::string & algoName() const
destructor
BXVector< Jet > JetBxCollection
Definition: Jet.h:11
edm::InputTag m_l1EGammaTag
Definition: HLTL1TSeed.h:122
void addCollectionTag(const edm::InputTag &collectionTag)
collectionTags
void add(std::string const &label, ParameterSetDescription const &psetDescription)
edm::Ref< EtSumBxCollection > EtSumRef
Definition: EtSum.h:13
edm::InputTag m_l1GlobalTag
InputTag for L1 Global Trigger.
Definition: HLTL1TSeed.h:111
edm::EDGetTokenT< GlobalAlgBlkBxCollection > m_l1GlobalToken
Definition: HLTL1TSeed.h:112
const CombinationsInCond * getCombinationsInCond(const std::string &condNameVal) const
return all the combinations passing the requirements imposed in condition condNameVal ...
HLT enums.
void dumpTriggerFilterObjectWithRefs(trigger::TriggerFilterObjectWithRefs &) const
detailed print of filter content
Definition: HLTL1TSeed.cc:153
bool hltFilter(edm::Event &, const edm::EventSetup &, trigger::TriggerFilterObjectWithRefs &filterproduct) override
filter the event
Definition: HLTL1TSeed.cc:117
bool m_l1GlobalDecision
flag to pass if L1TGlobal accept
Definition: HLTL1TSeed.h:141
std::vector< SingleCombInCond > CombinationsInCond
all the object combinations evaluated to true in the condition
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
parameter description
Definition: HLTL1TSeed.cc:96
const_iterator begin(int bx) const
static void makeHLTFilterDescription(edm::ParameterSetDescription &desc)
edm::EDGetTokenT< l1t::MuonBxCollection > m_l1MuonToken
Definition: HLTL1TSeed.h:118
bool saveTags() const
std::vector< EtSum >::const_iterator const_iterator
Definition: BXVector.h:20
edm::EDGetTokenT< l1t::TauBxCollection > m_l1TauToken
Definition: HLTL1TSeed.h:133
edm::EDGetTokenT< GlobalObjectMapRecord > m_l1GtObjectMapToken
Definition: HLTL1TSeed.h:108
const T & at(int bx, unsigned i) const