CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
23 
25 
27 
28 using namespace std;
29 
30 
31 // constructors
33  HLTStreamFilter(parSet),
34  //useObjectMaps_(parSet.getParameter<bool>("L1UseL1TriggerObjectMaps")),
35  m_l1SeedsLogicalExpression(parSet.getParameter<string>("L1SeedsLogicalExpression")),
36  m_l1GtObjectMapTag(parSet.getParameter<edm::InputTag> ("L1ObjectMapInputTag")),
37  m_l1GtObjectMapToken(consumes<L1GlobalTriggerObjectMapRecord>(m_l1GtObjectMapTag)),
38  m_l1GlobalTag(parSet.getParameter<edm::InputTag> ("L1GlobalInputTag")),
39  m_l1GlobalToken(consumes<GlobalAlgBlkBxCollection>(m_l1GlobalTag)),
40  m_l1MuonCollectionsTag(parSet.getParameter<edm::InputTag>("L1MuonInputTag")), // FIX WHEN UNPACKERS ADDED
41  m_l1MuonTag(m_l1MuonCollectionsTag),
42  m_l1MuonToken(consumes<l1t::MuonBxCollection>(m_l1MuonTag)),
43  m_l1EGammaCollectionsTag(parSet.getParameter<edm::InputTag>("L1EGammaInputTag")), // FIX WHEN UNPACKERS ADDED
44  m_l1EGammaTag(m_l1EGammaCollectionsTag),
45  m_l1EGammaToken(consumes<l1t::EGammaBxCollection>(m_l1EGammaTag)),
46  m_l1JetCollectionsTag(parSet.getParameter<edm::InputTag>("L1JetInputTag")), // FIX WHEN UNPACKERS ADDED
47  m_l1JetTag(m_l1JetCollectionsTag),
48  m_l1JetToken(consumes<l1t::JetBxCollection>(m_l1JetTag)),
49  m_l1TauCollectionsTag(parSet.getParameter<edm::InputTag>("L1TauInputTag")), // FIX WHEN UNPACKERS ADDED
50  m_l1TauTag(m_l1TauCollectionsTag),
51  m_l1TauToken(consumes<l1t::TauBxCollection>(m_l1TauTag)),
52  m_l1EtSumCollectionsTag(parSet.getParameter<edm::InputTag>("L1EtSumInputTag")), // FIX WHEN UNPACKERS ADDED
53  m_l1EtSumTag(m_l1EtSumCollectionsTag),
54  m_l1EtSumToken(consumes<l1t::EtSumBxCollection>(m_l1EtSumTag)),
55  m_isDebugEnabled(edm::isDebugEnabled())
56 {
57 
58  if (m_l1SeedsLogicalExpression != "L1GlobalDecision") {
59 
60  // check also the logical expression - add/remove spaces if needed
62 
63  // list of required algorithms for seeding
64  // dummy values for tokenNumber and tokenResult
67  size_t l1AlgoSeedsSize = m_l1AlgoSeeds.size();
68 
69  m_l1AlgoSeedsRpn.reserve(l1AlgoSeedsSize);
70  m_l1AlgoSeedsObjType.reserve(l1AlgoSeedsSize);
71 
72  } else {
73 
74 
75  m_l1GlobalDecision = true;
76 
77  }
78 
79 }
80 
81 // destructor
83  // empty now
84 }
85 
86 // member functions
87 
88 void
92 
93 
94  // # logical expression for the required L1 algorithms;
95  // # the algorithms are specified by name
96  // # allowed operators: "AND", "OR", "NOT", "(", ")"
97  // #
98  // # by convention, "L1GlobalDecision" logical expression means global decision
99  desc.add<string>("L1SeedsLogicalExpression","");
100  desc.add<bool>("SaveTags",true);
101  desc.add<edm::InputTag>("L1ObjectMapInputTag",edm::InputTag("hltGtStage2ObjectMap"));
102  desc.add<edm::InputTag>("L1GlobalInputTag",edm::InputTag("hltGtStage2Digis"));
103  desc.add<edm::InputTag>("L1MuonInputTag",edm::InputTag("hltGmtStage2Digis"));
104  desc.add<edm::InputTag>("L1EGammaInputTag",edm::InputTag("hltCaloStage2Digis"));
105  desc.add<edm::InputTag>("L1JetInputTag",edm::InputTag("hltCaloStage2Digis"));
106  desc.add<edm::InputTag>("L1TauInputTag",edm::InputTag("hltCaloStage2Digis"));
107  desc.add<edm::InputTag>("L1EtSumInputTag",edm::InputTag("hltCaloStage2Digis"));
108  descriptions.add("hltL1TSeed", desc);
109 }
110 
112 
113  bool rc = false;
114 
115  // the filter object
116  if (saveTags()) {
117 
118  // muons
119  filterproduct.addCollectionTag(m_l1MuonTag);
120 
121  // egamma
122  filterproduct.addCollectionTag(m_l1EGammaTag);
123 
124  // jet
125  filterproduct.addCollectionTag(m_l1JetTag);
126 
127  // tau
128  filterproduct.addCollectionTag(m_l1TauTag);
129 
130  // etsum
131  filterproduct.addCollectionTag(m_l1EtSumTag);
132  }
133 
134  // Get all the seeding from iEvent (i.e. L1TriggerObjectMapRecord)
135  //
136  rc = seedsL1TriggerObjectMaps(iEvent, filterproduct);
137 
138  //seedsAll(iEvent, filterproduct);
139 
140  if (m_isDebugEnabled) {
141  dumpTriggerFilterObjectWithRefs(filterproduct);
142  }
143 
144  return rc;
145 
146 }
147 
148 // seeding is done ignoring if a L1 object fired or not
149 // if the event is selected at L1, fill all the L1 objects of types corresponding to the
150 // L1 conditions from the seeding logical expression for bunch crosses F, 0, 1
151 // directly from L1Extra and use them as seeds at HLT
152 // method and filter return true if at least an object is filled
154 
155  //
156  bool objectsInFilter = false;
157 
158  // Muon L1T
159 
161  iEvent.getByToken(m_l1MuonToken, muons);
162  if (!muons.isValid()){
163  edm::LogWarning("HLTL1TSeed")
164  << "\nWarning: L1MuonBxCollection with input tag "
165  << m_l1MuonTag
166  << "\nrequested in configuration, but not found in the event."
167  << "\nNo muons added to filterproduct."
168  << endl;
169  } else {
170 
172  for (iter = muons->begin(0); iter != muons->end(0); ++iter){
173  //objectsInFilter = true;
174  l1t::MuonRef myref(muons, muons->key(iter));
175  filterproduct.addObject(trigger::TriggerL1Mu, myref);
176  }
177  }
178 
179  //l1t::MuonBxCollection::const_iterator iter;
180 
181  // EGamma L1T
182 
184  iEvent.getByToken(m_l1EGammaToken, egammas);
185  if (!egammas.isValid()){
186  edm::LogWarning("HLTL1TSeed")
187  << "\nWarning: L1EGammaBxCollection with input tag "
188  << m_l1EGammaTag
189  << "\nrequested in configuration, but not found in the event."
190  << "\nNo egammas added to filterproduct."
191  << endl;
192  } else {
193 
195  for (iter = egammas->begin(0); iter != egammas->end(0); ++iter){
196  //objectsInFilter = true;
197  l1t::EGammaRef myref(egammas, egammas->key(iter));
198  filterproduct.addObject(trigger::TriggerL1EG, myref);
199  }
200  }
201 
202  //l1t::EGammaBxCollection::const_iterator iter;
203 
204  // Jet L1T
205 
207  iEvent.getByToken(m_l1JetToken, jets);
208  if (!jets.isValid()){
209  edm::LogWarning("HLTL1TSeed")
210  << "\nWarning: L1JetBxCollection with input tag "
211  << m_l1JetTag
212  << "\nrequested in configuration, but not found in the event."
213  << "\nNo jets added to filterproduct."
214  << endl;
215  } else {
216 
218  for (iter = jets->begin(0); iter != jets->end(0); ++iter){
219  //objectsInFilter = true;
220  l1t::JetRef myref(jets, jets->key(iter));
221  filterproduct.addObject(trigger::TriggerL1Jet, myref);
222  }
223  }
224 
225  //l1t::JetBxCollection::const_iterator iter;
226 
227  // Tau L1T
228 
230  iEvent.getByToken(m_l1TauToken, taus);
231  if (!taus.isValid()){
232  edm::LogWarning("HLTL1TSeed")
233  << "\nWarning: L1TauBxCollection with input tag "
234  << m_l1TauTag
235  << "\nrequested in configuration, but not found in the event."
236  << "\nNo taus added to filterproduct."
237  << endl;
238  } else {
239 
241  for (iter = taus->begin(0); iter != taus->end(0); ++iter){
242  //objectsInFilter = true;
243  l1t::TauRef myref(taus, taus->key(iter));
244  filterproduct.addObject(trigger::TriggerL1Tau, myref);
245  }
246  }
247 
248  //l1t::TauBxCollection::const_iterator iter;
249 
250  // EtSum L1T
251 
253  iEvent.getByToken(m_l1EtSumToken, etsums);
254  if (!etsums.isValid()){
255  edm::LogWarning("HLTL1TSeed")
256  << "\nWarning: L1EtSumBxCollection with input tag "
257  << m_l1EtSumTag
258  << "\nrequested in configuration, but not found in the event."
259  << "\nNo etsums added to filterproduct."
260  << endl;
261  } else {
262 
263  LogTrace("HLTL1TSeed") << "\nHLT1TSeed::seedsAll: L1EtSum objects found in the EtSumBxCollection " << endl;
265  for (iter = etsums->begin(0); iter != etsums->end(0); ++iter){
266 
267  //objectsInFilter = true;
268  l1t::EtSumRef myref(etsums, etsums->key(iter));
269 
270  LogTrace("HLTL1TSeed") << "pt="<<myref->pt() << "\ttype = " << iter->getType() << endl;
271 
272  switch(iter->getType()) {
273  case l1t::EtSum::kTotalEt :
274  filterproduct.addObject(trigger::TriggerL1ETT, myref);
275  break;
276  case l1t::EtSum::kTotalHt :
277  filterproduct.addObject(trigger::TriggerL1HTT, myref);
278  break;
280  filterproduct.addObject(trigger::TriggerL1ETM, myref);
281  break;
283  filterproduct.addObject(trigger::TriggerL1HTM, myref);
284  break;
285  default:
286  LogTrace("HLTL1TSeed") << " L1EtSum seed of currently unsuported HLT TriggerType. l1t::EtSum type: " << iter->getType() << "\n";
287  }
288  }
289  }
290 
291  //l1t::EtSumBxCollection::const_iterator iter;
292 
293  /*
294  int iObj = -1;
295 
296  iObj++;
297  int bxNr = objIter->bx();
298  if ((bxNr >= minBxInEvent) && (bxNr <= maxBxInEvent))
299  objectsInFilter = true;
300  filterproduct.addObject(
301  trigger::TriggerL1Mu,
302  l1extra::L1MuonParticleRef(
303  l1Muon, iObj));
304  */
305 
306  return objectsInFilter;
307 }
308 
309 // detailed print of filter content
311 {
312 
313  LogTrace("HLTL1TSeed")
314  << "\nHLTL1TSeed::hltFilter "
315  << "\n Dump TriggerFilterObjectWithRefs\n" << endl;
316 
317  vector<l1t::MuonRef> seedsL1Mu;
318  filterproduct.getObjects(trigger::TriggerL1Mu, seedsL1Mu);
319  const size_t sizeSeedsL1Mu = seedsL1Mu.size();
320 
321  LogTrace("HLTL1TSeed")
322  << "\n HLTL1TSeed: seed logical expression = " << m_l1SeedsLogicalExpression << endl;
323 
324  LogTrace("HLTL1TSeed")
325  << "\n L1Mu seeds: " << sizeSeedsL1Mu << endl << endl;
326 
327  for (size_t i = 0; i != sizeSeedsL1Mu; i++) {
328 
329 
330  l1t::MuonRef obj = l1t::MuonRef( seedsL1Mu[i]);
331 
332  LogTrace("HLTL1TSeed")
333  << "\tL1Mu " << "\t" << "q = " << obj->hwCharge() // TEMP get hwCharge insead of charge which is not yet set NEED FIX.
334  << "\t" << "pt = " << obj->pt() << "\t" << "eta = " << obj->eta()
335  << "\t" << "phi = " << obj->phi(); //<< "\t" << "BX = " << obj->bx();
336  }
337 
338  vector<l1t::EGammaRef> seedsL1EG;
339  filterproduct.getObjects(trigger::TriggerL1EG, seedsL1EG);
340  const size_t sizeSeedsL1EG = seedsL1EG.size();
341 
342  LogTrace("HLTL1TSeed")
343  << "\n L1EG seeds: " << sizeSeedsL1EG << endl << endl;
344 
345  for (size_t i = 0; i != sizeSeedsL1EG; i++) {
346 
347 
348  l1t::EGammaRef obj = l1t::EGammaRef( seedsL1EG[i]);
349 
350  LogTrace("HLTL1TSeed")
351  << "\tL1EG " << "\t" << "pt = "
352  << obj->pt() << "\t" << "eta = " << obj->eta()
353  << "\t" << "phi = " << obj->phi(); //<< "\t" << "BX = " << obj->bx();
354  }
355 
356  vector<l1t::JetRef> seedsL1Jet;
357  filterproduct.getObjects(trigger::TriggerL1Jet, seedsL1Jet);
358  const size_t sizeSeedsL1Jet = seedsL1Jet.size();
359 
360  LogTrace("HLTL1TSeed")
361  << "\n L1Jet seeds: " << sizeSeedsL1Jet << endl << endl;
362 
363  for (size_t i = 0; i != sizeSeedsL1Jet; i++) {
364 
365 
366  l1t::JetRef obj = l1t::JetRef( seedsL1Jet[i]);
367 
368  LogTrace("HLTL1TSeed") << "\tL1Jet " << "\t" << "pt = "
369  << obj->pt() << "\t" << "eta = " << obj->eta()
370  << "\t" << "phi = " << obj->phi(); //<< "\t" << "BX = " << obj->bx();
371  }
372 
373  vector<l1t::TauRef> seedsL1Tau;
374  filterproduct.getObjects(trigger::TriggerL1Tau, seedsL1Tau);
375  const size_t sizeSeedsL1Tau = seedsL1Tau.size();
376 
377  LogTrace("HLTL1TSeed")
378  << "\n L1Tau seeds: " << sizeSeedsL1Tau << endl << endl;
379 
380  for (size_t i = 0; i != sizeSeedsL1Tau; i++) {
381 
382 
383  l1t::TauRef obj = l1t::TauRef( seedsL1Tau[i]);
384 
385  LogTrace("HLTL1TSeed")
386  << "\tL1Tau " << "\t" << "pt = "
387  << obj->pt() << "\t" << "eta = " << obj->eta()
388  << "\t" << "phi = " << obj->phi(); //<< "\t" << "BX = " << obj->bx();
389  }
390 
391  vector<l1t::EtSumRef> seedsL1EtSumETT;
392  filterproduct.getObjects(trigger::TriggerL1ETT, seedsL1EtSumETT);
393  const size_t sizeSeedsL1EtSumETT = seedsL1EtSumETT.size();
394  LogTrace("HLTL1TSeed")
395  << "\n L1EtSum ETT seeds: " << sizeSeedsL1EtSumETT << endl << endl;
396 
397  for (size_t i = 0; i != sizeSeedsL1EtSumETT; i++) {
398  l1t::EtSumRef obj = l1t::EtSumRef( seedsL1EtSumETT[i]);
399 
400  LogTrace("HLTL1TSeed")
401  << "\tL1EtSum ETT" << "\t" << "pt = "
402  << obj->pt() << "\t" << "eta = " << obj->eta()
403  << "\t" << "phi = " << obj->phi(); //<< "\t" << "BX = " << obj->bx();
404  }
405 
406  vector<l1t::EtSumRef> seedsL1EtSumHTT;
407  filterproduct.getObjects(trigger::TriggerL1HTT, seedsL1EtSumHTT);
408  const size_t sizeSeedsL1EtSumHTT = seedsL1EtSumHTT.size();
409  LogTrace("HLTL1TSeed")
410  << "\n L1EtSum HTT seeds: " << sizeSeedsL1EtSumHTT << endl << endl;
411 
412  for (size_t i = 0; i != sizeSeedsL1EtSumHTT; i++) {
413  l1t::EtSumRef obj = l1t::EtSumRef( seedsL1EtSumHTT[i]);
414 
415  LogTrace("HLTL1TSeed")
416  << "\tL1EtSum HTT" << "\t" << "pt = "
417  << obj->pt() << "\t" << "eta = " << obj->eta()
418  << "\t" << "phi = " << obj->phi(); //<< "\t" << "BX = " << obj->bx();
419  }
420 
421  vector<l1t::EtSumRef> seedsL1EtSumETM;
422  filterproduct.getObjects(trigger::TriggerL1ETM, seedsL1EtSumETM);
423  const size_t sizeSeedsL1EtSumETM = seedsL1EtSumETM.size();
424  LogTrace("HLTL1TSeed")
425  << "\n L1EtSum ETM seeds: " << sizeSeedsL1EtSumETM << endl << endl;
426 
427  for (size_t i = 0; i != sizeSeedsL1EtSumETM; i++) {
428  l1t::EtSumRef obj = l1t::EtSumRef( seedsL1EtSumETM[i]);
429 
430  LogTrace("HLTL1TSeed")
431  << "\tL1EtSum ETM" << "\t" << "pt = "
432  << obj->pt() << "\t" << "eta = " << obj->eta()
433  << "\t" << "phi = " << obj->phi(); //<< "\t" << "BX = " << obj->bx();
434  }
435 
436  vector<l1t::EtSumRef> seedsL1EtSumHTM;
437  filterproduct.getObjects(trigger::TriggerL1HTM, seedsL1EtSumHTM);
438  const size_t sizeSeedsL1EtSumHTM = seedsL1EtSumHTM.size();
439  LogTrace("HLTL1TSeed")
440  << "\n L1EtSum HTM seeds: " << sizeSeedsL1EtSumHTM << endl << endl;
441 
442  for (size_t i = 0; i != sizeSeedsL1EtSumHTM; i++) {
443  l1t::EtSumRef obj = l1t::EtSumRef( seedsL1EtSumHTM[i]);
444 
445  LogTrace("HLTL1TSeed")
446  << "\tL1EtSum HTM" << "\t" << "pt = "
447  << obj->pt() << "\t" << "eta = " << obj->eta()
448  << "\t" << "phi = " << obj->phi(); //<< "\t" << "BX = " << obj->bx();
449  }
450 
451  LogTrace("HLTL1TSeed") << " \n\n" << endl;
452 
453 }
454 
455 // seeding is done via L1 trigger object maps, considering the objects which fired in L1
458  ) {
459 
460 
461  // define index lists for all particle types
462 
463  std::list<int> listMuon;
464 
465  std::list<int> listEG;
466 
467  std::list<int> listJet;
468  std::list<int> listTau;
469 
470  std::list<int> listETM;
471  std::list<int> listETT;
472  std::list<int> listHTT;
473  std::list<int> listHTM;
474 
475  std::list<int> listJetCounts;
476 
477  // get handle to uGT
479  iEvent.getByToken(m_l1GlobalToken, uGtAlgoBlocks);
480 
481  if (!uGtAlgoBlocks.isValid()) {
482 
483  edm::LogWarning("HLTL1TSeed")
484  << "\nWarning: GlobalAlgBlkBxCollection with input tag "
485  << m_l1GlobalTag
486  << "\nrequested in configuration, but not found in the event." << std::endl;
487 
488  return false;
489  }
490 
491  // get handle to object maps (one object map per algorithm)
493  iEvent.getByToken(m_l1GtObjectMapToken, gtObjectMapRecord);
494 
495  if (!gtObjectMapRecord.isValid()) {
496 
497  edm::LogWarning("HLTL1TSeed")
498  << "\nWarning: L1GlobalTriggerObjectMapRecord with input tag "
500  << "\nrequested in configuration, but not found in the event." << std::endl;
501 
502  return false;
503  }
504 
505  if (m_isDebugEnabled) {
506 
507  const std::vector<L1GlobalTriggerObjectMap>& objMaps = gtObjectMapRecord->gtObjectMap();
508 
509  LogTrace("HLTL1TSeed")
510  << "\nHLTL1Seed"
511  << "\n---------------------------------------------------------------------------------------------------------------------";
512 
513  LogTrace("HLTL1TSeed")
514  << "\n\tAlgorithms in L1TriggerObjectMapRecord and GT results ( emulated | initial | prescaled | final ) " << endl;
515 
516  LogTrace("HLTL1TSeed")
517  << "\n\tmap" <<"\tAlgoBit" << std::setw(40) << "algoName" << "\t (emul|ini|pre|fin)" << endl;
518 
519  LogTrace("HLTL1TSeed")
520  << "---------------------------------------------------------------------------------------------------------------------";
521 
522  for (size_t imap =0; imap < objMaps.size(); imap++) {
523 
524  int bit = objMaps[imap].algoBitNumber(); // same as bit from L1T Menu
525 
526  int emulDecision = objMaps[imap].algoGtlResult();
527 
528  // For bx=0 , get 0th AlgoBlock, so in BXvector at(bx=0,i=0)
529  int initDecision = (uGtAlgoBlocks->at(0,0)).getAlgoDecisionInitial(bit);
530  int presDecision = (uGtAlgoBlocks->at(0,0)).getAlgoDecisionPreScaled(bit);
531  int finlDecision = (uGtAlgoBlocks->at(0,0)).getAlgoDecisionFinal(bit);
532 
533  LogTrace("HLTL1TSeed")
534  << "\t" << std::setw(3) << imap
535  << "\tbit = " << std::setw(3) << bit
536  << std::setw(40) << objMaps[imap].algoName()
537  << "\t ( " << emulDecision << " | " << initDecision << " | " << presDecision << " | " << finlDecision << " ) ";
538 
539 
540  }
541  LogTrace("HLTL1TSeed") << endl;
542 
543  }
544 
545  // Update/Reset m_l1AlgoLogicParser by reseting token result
546  //
547  std::vector<L1GtLogicParser::OperandToken>& algOpTokenVector =
549 
550  for (size_t i = 0; i < algOpTokenVector.size(); ++i) {
551 
552  // rest token result
553  //
554  (algOpTokenVector[i]).tokenResult = false;
555 
556  }
557 
558  // Update m_l1AlgoLogicParser and store results for algOpTokens
559  //
560  for (size_t i = 0; i < algOpTokenVector.size(); ++i) {
561 
562  std::string algoName = (algOpTokenVector[i]).tokenName;
563 
564  const L1GlobalTriggerObjectMap* objMap = gtObjectMapRecord->getObjectMap(algoName);
565 
566  if(objMap == 0) {
567 
568  edm::LogWarning("HLTL1TSeed")
569  << "\nWarning: seed with name " << algoName << " cannot be matched to a L1 algo name in any L1GlobalTriggerObjectMap" << std::endl;
570  return false;
571 
572  }
573  else {
574 
575  (algOpTokenVector[i]).tokenResult = objMap->algoGtlResult();
576 
577  }
578 
579  }
580 
581  bool seedsResult = m_l1AlgoLogicParser.expressionResult();
582 
583  if (m_isDebugEnabled ) {
584 
585  LogTrace("HLTL1TSeed")
586  << "\nHLTL1TSeed: l1SeedsLogicalExpression (names) = '" << m_l1SeedsLogicalExpression << "'"
587  << "\n Result for logical expression after update of algOpTokens: " << seedsResult << "\n"
588  << std::endl;
589  }
590 
591 
592  // TODO check that the L1GlobalTriggerObjectMapRecord corresponds to the same menu as
593  // the menu run by HLTL1TSeed. True normally online (they are run in the same job)
594  // can be false offline, when re-running HLT without re-running the object map producer
595  //
596 
599 
600  for (std::vector<L1GtLogicParser::OperandToken>::const_iterator
601  itSeed = m_l1AlgoSeeds.begin(); itSeed != m_l1AlgoSeeds.end(); ++itSeed) {
602 
603  std::string algoSeedName = (*itSeed).tokenName;
604 
605  LogTrace("HLTL1TSeed")
606  << "\n ---------------- algo seed name = " << algoSeedName << endl;
607 
608  const L1GlobalTriggerObjectMap* objMap = gtObjectMapRecord->getObjectMap(algoSeedName);
609 
610  if(objMap == 0) {
611 
612  // Should not get here
613  //
614  edm::LogWarning("HLTL1TSeed")
615  << "\nWarning: seed with name " << algoSeedName << " cannot be matched to a L1 algo name in any L1GlobalTriggerObjectMap" << std::endl;
616  return false;
617 
618  }
619 
620  int algoSeedBitNumber = objMap->algoBitNumber();
621  bool algoSeedResult = objMap->algoGtlResult();
622 
623  // uGtAlgoBlock has decisions initial, prescaled, and final
624  bool algoSeedRsultMaskAndPresc = uGtAlgoBlocks->at(0,0).getAlgoDecisionFinal(algoSeedBitNumber);
625 
626  LogTrace("HLTL1TSeed")
627  << "\n\tAlgo seed " << algoSeedName << " result emulated (initial) | final = " << algoSeedResult << " | " << algoSeedRsultMaskAndPresc << endl;
628 
629 
630  // algorithm result is false - no seeds
632  if ( !algoSeedResult) continue;
633 
636  if(!algoSeedRsultMaskAndPresc) continue;
637 
638  const std::vector<L1GtLogicParser::OperandToken>& opTokenVecObjMap = objMap->operandTokenVector();
639  const std::vector<ObjectTypeInCond>& condObjTypeVec = objMap->objectTypeVector();
640  const std::vector<CombinationsInCond>& condCombinations = objMap->combinationVector();
641 
642  LogTrace("HLTL1TSeed")
643  << "\n\talgoName =" << objMap->algoName()
644  << "\talgoBitNumber = " << algoSeedBitNumber
645  << "\talgoGtlResult = " << algoSeedResult << endl << endl;
646 
647 
648  if (opTokenVecObjMap.size() != condObjTypeVec.size() ) {
649  edm::LogWarning("HLTL1TSeed")
650  << "\nWarning: L1GlobalTriggerObjectMapRecord with input tag "
652  << "\nhas object map for bit number " << algoSeedBitNumber << " which contains different size vectors of operand tokens and of condition object types!" << std::endl;
653 
654  assert(opTokenVecObjMap.size() == condObjTypeVec.size());
655  }
656 
657  if (opTokenVecObjMap.size() != condCombinations.size()) {
658  edm::LogWarning("HLTL1TSeed")
659  << "\nWarning: L1GlobalTriggerObjectMapRecord with input tag "
661  << "\nhas object map for bit number " << algoSeedBitNumber << " which contains different size vectors of operand tokens and of condition object combinations!" << std::endl;
662 
663  assert(opTokenVecObjMap.size() == condCombinations.size());
664  }
665 
666  // operands are conditions of L1 algo
667  //
668  for (size_t condNumber = 0; condNumber < opTokenVecObjMap.size(); condNumber++) {
669 
670  std::vector<L1GtObject> condObjType = condObjTypeVec[condNumber];
671 
672  for (size_t jOb =0; jOb < condObjType.size(); jOb++) {
673 
674  LogTrace("HLTL1TSeed")
675  << setw(15) << "\tcondObjType = " << condObjType[jOb] << endl;
676 
677  }
678 
679  const std::string condName = opTokenVecObjMap[condNumber].tokenName;
680  bool condResult = opTokenVecObjMap[condNumber].tokenResult;
681 
682  // only procede for conditions that passed
683  //
684  if ( !condResult) {
685  continue;
686  }
687 
688  // loop over combinations for a given condition
689  //
690  const CombinationsInCond* condComb = objMap->getCombinationsInCond(condNumber);
691 
692  LogTrace("HLTL1TSeed")
693  << setw(15) << "\tcondCombinations = " << condComb->size() << endl;
694 
695  for (std::vector<SingleCombInCond>::const_iterator itComb = (*condComb).begin(); itComb != (*condComb).end(); itComb++) {
696 
697  // loop over objects in a combination for a given condition
698  //
699  for (SingleCombInCond::const_iterator itObject = (*itComb).begin(); itObject != (*itComb).end(); itObject++) {
700 
701  // loop over types for the object in a combination. This object might have more then one type (i.e. mu-eg)
702  //
703  for (size_t iType =0; iType < condObjType.size(); iType++) {
704 
705  // get object type and push indices on the list
706  //
707  const L1GtObject objTypeVal = condObjType.at(iType);
708 
709  LogTrace("HLTL1TSeed")
710  << "\tAdd object of type " << objTypeVal << " and index " << (*itObject) << " to the seed list."
711  << std::endl;
712 
713  switch (objTypeVal) {
714  case Mu: {
715  listMuon.push_back(*itObject);
716  }
717 
718  break;
719  case NoIsoEG: {
720  listEG.push_back(*itObject);
721  }
722 
723  break;
724  case IsoEG: {
725  listEG.push_back(*itObject);
726  }
727 
728  break;
729  case CenJet: {
730  listJet.push_back(*itObject);
731  }
732 
733  break;
734  case ForJet: {
735  listJet.push_back(*itObject);
736  }
737 
738  break;
739  case TauJet: {
740  listTau.push_back(*itObject);
741  }
742 
743  break;
744  case HfRingEtSums: {
745  // Special treatment needed to match HFRingEtSums index (Ind) with corresponding l1extra item
746  // Same ranking (Et) is assumed for both HFRingEtSums indexes and items in l1extra IsoTau collection
747  // Each HFRingEtSums_IndN corresponds with one object (with (*itObject)=0);
748  // its index (hfInd) encodded by parsing algorithm name
749  int hfInd = (*itObject);
750  if(condName.find("Ind0")!=std::string::npos)
751  hfInd = 0;
752  else if(condName.find("Ind1")!=std::string::npos)
753  hfInd = 1;
754  else if(condName.find("Ind2")!=std::string::npos)
755  hfInd = 2;
756  else if(condName.find("Ind3")!=std::string::npos)
757  hfInd = 3;
758  listTau.push_back(hfInd);
759  }
760 
761  break;
762  case ETM: {
763  listETM.push_back(*itObject);
764 
765  }
766 
767  break;
768  case ETT: {
769  listETT.push_back(*itObject);
770 
771  }
772 
773  break;
774  case HTT: {
775  listHTT.push_back(*itObject);
776 
777  }
778 
779  break;
780  case HTM: {
781  listHTM.push_back(*itObject);
782 
783  }
784 
785  break;
786  case JetCounts: {
787  listJetCounts.push_back(*itObject);
788  }
789 
790  break;
791  default: {
792  // should not arrive here
793 
794  LogTrace("HLTL1TSeed")
795  << "\n HLTL1TSeed::hltFilter "
796  << "\n Unknown object of type " << objTypeVal
797  << " and index " << (*itObject) << " in the seed list."
798  << std::endl;
799  }
800  break;
801 
802  } // end switch objTypeVal
803 
804  } // end for iType
805 
806  } // end for itObj
807 
808  } // end for itComb
809 
810  } // end for condition
811 
812  } // end for itSeed
813 
814 
815  // eliminate duplicates
816 
817  listMuon.sort();
818  listMuon.unique();
819 
820  listEG.sort();
821  listEG.unique();
822 
823  listJet.sort();
824  listJet.unique();
825 
826  listTau.sort();
827  listTau.unique();
828 
829  listETM.sort();
830  listETM.unique();
831 
832  listETT.sort();
833  listETT.unique();
834 
835  listHTT.sort();
836  listHTT.unique();
837 
838  listHTM.sort();
839  listHTM.unique();
840 
841  listJetCounts.sort();
842  listJetCounts.unique();
843 
844 
845  // record the L1 physics objects in the HLT filterproduct
846  // //////////////////////////////////////////////////////
847 
848  // Muon
849  if (!listMuon.empty()) {
850 
852  iEvent.getByToken(m_l1MuonToken, muons);
853 
854  if (!muons.isValid()){
855  edm::LogWarning("HLTL1TSeed")
856  << "\nWarning: L1MuonBxCollection with input tag "
857  << m_l1MuonTag
858  << "\nrequested in configuration, but not found in the event."
859  << "\nNo muons added to filterproduct."
860  << endl;
861  }
862  else {
863 
864  for (std::list<int>::const_iterator itObj = listMuon.begin(); itObj != listMuon.end(); ++itObj) {
865 
866  l1t::MuonRef myref(muons, *itObj);
867  filterproduct.addObject(trigger::TriggerL1Mu, myref);
868 
869  }
870 
871  }
872 
873  }
874 
875  // EG (isolated)
876  if (!listEG.empty()) {
877 
879  iEvent.getByToken(m_l1EGammaToken, egammas);
880  if (!egammas.isValid()){
881  edm::LogWarning("HLTL1TSeed")
882  << "\nWarning: L1EGammaBxCollection with input tag " << m_l1EGammaTag
883  << "\nrequested in configuration, but not found in the event."
884  << "\nNo egammas added to filterproduct."
885  << endl;
886  }
887  else {
888 
889  for (std::list<int>::const_iterator itObj = listEG.begin(); itObj != listEG.end(); ++itObj) {
890 
891  l1t::EGammaRef myref(egammas, *itObj);
892  filterproduct.addObject(trigger::TriggerL1EG, myref);
893 
894  }
895 
896  }
897 
898  }
899 
900  // Jet
901  if (!listJet.empty()) {
902 
904  iEvent.getByToken(m_l1JetToken, jets);
905 
906  if (!jets.isValid()){
907  edm::LogWarning("HLTL1TSeed")
908  << "\nWarning: L1JetBxCollection with input tag " << m_l1JetTag
909  << "\nrequested in configuration, but not found in the event."
910  << "\nNo jets added to filterproduct."
911  << endl;
912  }
913  else {
914 
915  for (std::list<int>::const_iterator itObj = listJet.begin(); itObj != listJet.end(); ++itObj) {
916  l1t::JetRef myref(jets, *itObj);
917  filterproduct.addObject(trigger::TriggerL1Jet, myref);
918  }
919 
920  }
921 
922  }
923 
924  // Tau
925  if (!listTau.empty()) {
926 
928  iEvent.getByToken(m_l1TauToken, taus);
929 
930  if (!taus.isValid()){
931  edm::LogWarning("HLTL1TSeed")
932  << "\nWarning: L1TauBxCollection with input tag " << m_l1TauTag
933  << "\nrequested in configuration, but not found in the event."
934  << "\nNo taus added to filterproduct."
935  << endl;
936  }
937  else {
938 
939  for (std::list<int>::const_iterator itObj = listTau.begin(); itObj != listTau.end(); ++itObj) {
940  l1t::TauRef myref(taus, *itObj);
941  filterproduct.addObject(trigger::TriggerL1Tau, myref);
942  }
943 
944  }
945 
946  }
947 
948  // ETT, HTT, ETM, HTM
950  iEvent.getByToken(m_l1EtSumToken, etsums);
951  if (!etsums.isValid()){
952  edm::LogWarning("HLTL1TSeed")
953  << "\nWarning: L1EtSumBxCollection with input tag "
954  << m_l1EtSumTag
955  << "\nrequested in configuration, but not found in the event."
956  << "\nNo etsums added to filterproduct."
957  << endl;
958  } else {
959 
961 
962  for (iter = etsums->begin(0); iter != etsums->end(0); ++iter){
963 
964  l1t::EtSumRef myref(etsums, etsums->key(iter));
965 
966  switch(iter->getType()) {
967 
968  case l1t::EtSum::kTotalEt :
969  if(!listETT.empty())
970  filterproduct.addObject(trigger::TriggerL1ETT, myref);
971  break;
972  case l1t::EtSum::kTotalHt :
973  if(!listHTT.empty())
974  filterproduct.addObject(trigger::TriggerL1HTT, myref);
975  break;
977  if(!listETM.empty())
978  filterproduct.addObject(trigger::TriggerL1ETM, myref);
979  break;
981  if(!listHTM.empty())
982  filterproduct.addObject(trigger::TriggerL1HTM, myref);
983  break;
984  default:
985  LogTrace("HLTL1TSeed") << " L1EtSum seed of currently unsuported HLT TriggerType. l1t::EtSum type: " << iter->getType() << "\n";
986 
987  } // end switch
988 
989  } // end for
990 
991  } // end else
992 
993 
994  // TODO FIXME uncomment if block when JetCounts implemented
995 
996  // // jet counts
997  // if (!listJetCounts.empty()) {
998  // edm::Handle<l1extra::L1JetCounts> l1JetCounts;
999  // iEvent.getByToken(m_l1CollectionsToken.label(), l1JetCounts);
1000  //
1001  // for (std::list<int>::const_iterator itObj = listJetCounts.begin();
1002  // itObj != listJetCounts.end(); ++itObj) {
1003  //
1004  // filterproduct.addObject(trigger::TriggerL1JetCounts,l1extra::L1JetCountsRefProd(l1JetCounts));
1005  // // FIXME: RefProd!
1006  //
1007  // }
1008  //
1009  // }
1010 
1011 
1012  LogTrace("HLTL1TSeed")
1013  << "\nHLTL1Seed:seedsL1TriggerObjectMaps returning " << seedsResult << endl << endl;
1014 
1015  return seedsResult;
1016 
1017 }
1018 
1019 // register as framework plugin
BXVector< EGamma > EGammaBxCollection
Definition: EGamma.h:11
std::vector< L1GtLogicParser::OperandToken > expressionSeedsOperandList()
std::string m_l1SeedsLogicalExpression
Definition: HLTL1TSeed.h:144
bool isDebugEnabled()
int i
Definition: DBlmapReader.cc:9
edm::EDGetTokenT< L1GlobalTriggerObjectMapRecord > m_l1GtObjectMapToken
Definition: HLTL1TSeed.h:148
const std::vector< CombinationsInCond > & combinationVector() const
void getObjects(Vids &ids, VRphoton &refs) const
various physics-level getters:
edm::EDGetTokenT< l1t::EtSumBxCollection > m_l1EtSumToken
Definition: HLTL1TSeed.h:178
edm::Ref< TauBxCollection > TauRef
Definition: Tau.h:12
std::vector< const std::vector< L1GtLogicParser::TokenRPN > * > m_l1AlgoSeedsRpn
vector of Rpn vectors for the required algorithms for seeding
Definition: HLTL1TSeed.h:114
edm::Ref< EGammaBxCollection > EGammaRef
Definition: EGamma.h:13
Definition: L1GtObject.h:39
edm::InputTag m_l1MuonTag
Definition: HLTL1TSeed.h:157
HLTL1TSeed(const edm::ParameterSet &)
constructor
Definition: HLTL1TSeed.cc:32
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
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:456
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
Definition: L1GtObject.h:36
const std::vector< L1GtLogicParser::OperandToken > & operandTokenVector() const
virtual ~HLTL1TSeed()
destructor
Definition: HLTL1TSeed.cc:82
assert(m_qm.get())
const std::vector< ObjectTypeInCond > & objectTypeVector() const
BXVector< Tau > TauBxCollection
Definition: Tau.h:10
bool seedsAll(edm::Event &, trigger::TriggerFilterObjectWithRefs &) const
Definition: HLTL1TSeed.cc:153
edm::Ref< MuonBxCollection > MuonRef
Definition: Muon.h:12
Definition: L1GtObject.h:38
void addObject(int id, const reco::RecoEcalCandidateRef &ref)
setters for L3 collections: (id=physics type, and Ref&lt;C&gt;)
edm::Ref< JetBxCollection > JetRef
Definition: Jet.h:12
BXVector< EtSum > EtSumBxCollection
Definition: EtSum.h:10
int iEvent
Definition: GenABIO.cc:230
const std::string & algoName() const
get / set name for algorithm in the object map
std::vector< std::vector< const std::vector< L1GtObject > * > > m_l1AlgoSeedsObjType
vector of object-type vectors for each condition in the required algorithms for seeding ...
Definition: HLTL1TSeed.h:117
edm::InputTag m_l1JetTag
Definition: HLTL1TSeed.h:167
edm::InputTag m_l1GtObjectMapTag
InputTag for L1 Global Trigger object maps. This is done per menu. Should be part of Run...
Definition: HLTL1TSeed.h:147
std::vector< OperandToken > & operandTokenVector()
return the vector of operand tokens
const CombinationsInCond * getCombinationsInCond(const std::string &condNameVal) const
return all the combinations passing the requirements imposed in condition condNameVal ...
vector< PseudoJet > jets
edm::EDGetTokenT< l1t::JetBxCollection > m_l1JetToken
Definition: HLTL1TSeed.h:168
edm::EDGetTokenT< l1t::EGammaBxCollection > m_l1EGammaToken
Definition: HLTL1TSeed.h:163
edm::InputTag m_l1EtSumTag
Definition: HLTL1TSeed.h:177
edm::InputTag m_l1TauTag
Definition: HLTL1TSeed.h:172
std::vector< L1GtLogicParser::OperandToken > m_l1AlgoSeeds
list of required algorithms for seeding
Definition: HLTL1TSeed.h:111
L1GtLogicParser m_l1AlgoLogicParser
logic parser for m_l1SeedsLogicalExpression
Definition: HLTL1TSeed.h:108
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool isValid() const
Definition: HandleBase.h:75
#define LogTrace(id)
BXVector< Muon > MuonBxCollection
Definition: Muon.h:10
bool m_isDebugEnabled
cache edm::isDebugEnabled()
Definition: HLTL1TSeed.h:184
BXVector< Jet > JetBxCollection
Definition: Jet.h:10
Definition: L1GtObject.h:30
edm::InputTag m_l1EGammaTag
Definition: HLTL1TSeed.h:162
void addCollectionTag(const edm::InputTag &collectionTag)
collectionTags
void add(std::string const &label, ParameterSetDescription const &psetDescription)
edm::Ref< EtSumBxCollection > EtSumRef
Definition: EtSum.h:12
edm::InputTag m_l1GlobalTag
InputTag for L1 Global Trigger.
Definition: HLTL1TSeed.h:151
edm::EDGetTokenT< GlobalAlgBlkBxCollection > m_l1GlobalToken
Definition: HLTL1TSeed.h:152
Definition: L1GtObject.h:37
tuple muons
Definition: patZpeak.py:38
void dumpTriggerFilterObjectWithRefs(trigger::TriggerFilterObjectWithRefs &) const
detailed print of filter content
Definition: HLTL1TSeed.cc:310
int algoBitNumber() const
get / set bit number for algorithm in the object map
virtual bool hltFilter(edm::Event &, const edm::EventSetup &, trigger::TriggerFilterObjectWithRefs &filterproduct) override
filter the event
Definition: HLTL1TSeed.cc:111
bool m_l1GlobalDecision
replace string &quot;L1GlobalDecision&quot; with bool to speed up the &quot;if&quot;
Definition: HLTL1TSeed.h:181
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:89
static void makeHLTFilterDescription(edm::ParameterSetDescription &desc)
edm::EDGetTokenT< l1t::MuonBxCollection > m_l1MuonToken
Definition: HLTL1TSeed.h:158
tuple size
Write out results.
bool saveTags() const
std::vector< Muon >::const_iterator const_iterator
Definition: BXVector.h:16
edm::EDGetTokenT< l1t::TauBxCollection > m_l1TauToken
Definition: HLTL1TSeed.h:173
virtual const bool expressionResult() const