CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PATTriggerProducer.cc
Go to the documentation of this file.
1 //
2 // $Id: PATTriggerProducer.cc,v 1.26.2.2 2011/06/21 23:39:36 vadler Exp $
3 //
4 
5 
7 
8 #include <vector>
9 #include <map>
10 #include <utility>
11 #include <cassert>
12 
22 
28 
31 
32 
33 using namespace pat;
34 using namespace edm;
35 
36 
37 // Constants' definitions
41 
42 
44  nameProcess_( iConfig.getParameter< std::string >( "processName" ) ),
45  autoProcessName_( nameProcess_ == "*" ),
46  onlyStandAlone_( iConfig.getParameter< bool >( "onlyStandAlone" ) ),
47  // L1 configuration parameters
48  addL1Algos_( false ),
49  tagL1GlobalTriggerObjectMapRecord_( "hltL1GtObjectMap" ),
50  tagL1ExtraMu_(),
51  tagL1ExtraNoIsoEG_(),
52  tagL1ExtraIsoEG_(),
53  tagL1ExtraCenJet_(),
54  tagL1ExtraForJet_(),
55  tagL1ExtraTauJet_(),
56  tagL1ExtraETM_(),
57  tagL1ExtraHTM_(),
58  autoProcessNameL1ExtraMu_( false ),
59  autoProcessNameL1ExtraNoIsoEG_( false ),
60  autoProcessNameL1ExtraIsoEG_( false ),
61  autoProcessNameL1ExtraCenJet_( false ),
62  autoProcessNameL1ExtraForJet_( false ),
63  autoProcessNameL1ExtraTauJet_( false ),
64  autoProcessNameL1ExtraETM_( false ),
65  autoProcessNameL1ExtraHTM_( false ),
66  mainBxOnly_( true ),
67  saveL1Refs_( false ),
68  // HLT configuration parameters
69  tagTriggerResults_( "TriggerResults" ),
70  tagTriggerEvent_( "hltTriggerSummaryAOD" ),
71  hltPrescaleLabel_(),
72  labelHltPrescaleTable_(),
73  hltPrescaleTableRun_(),
74  hltPrescaleTableLumi_(),
75  addPathModuleLabels_( false )
76 {
77 
78  // L1 configuration parameters
79  if ( iConfig.exists( "addL1Algos" ) ) addL1Algos_ = iConfig.getParameter< bool >( "addL1Algos" );
80  if ( iConfig.exists( "l1GlobalTriggerObjectMapRecord" ) ) tagL1GlobalTriggerObjectMapRecord_ = iConfig.getParameter< InputTag >( "l1GlobalTriggerObjectMapRecord" );
81  if ( iConfig.exists( "l1ExtraMu" ) ) {
82  tagL1ExtraMu_ = iConfig.getParameter< InputTag >( "l1ExtraMu" );
83  if ( tagL1ExtraMu_.process() == "*" ) {
86  }
87  }
88  if ( iConfig.exists( "l1ExtraNoIsoEG" ) ) {
89  tagL1ExtraNoIsoEG_ = iConfig.getParameter< InputTag >( "l1ExtraNoIsoEG" );
90  if ( tagL1ExtraNoIsoEG_.process() == "*" ) {
93  }
94  }
95  if ( iConfig.exists( "l1ExtraIsoEG" ) ) {
96  tagL1ExtraIsoEG_ = iConfig.getParameter< InputTag >( "l1ExtraIsoEG" );
97  if ( tagL1ExtraIsoEG_.process() == "*" ) {
100  }
101  }
102  if ( iConfig.exists( "l1ExtraCenJet" ) ) {
103  tagL1ExtraCenJet_ = iConfig.getParameter< InputTag >( "l1ExtraCenJet" );
104  if ( tagL1ExtraCenJet_.process() == "*" ) {
107  }
108  }
109  if ( iConfig.exists( "l1ExtraForJet" ) ) {
110  tagL1ExtraForJet_ = iConfig.getParameter< InputTag >( "l1ExtraForJet" );
111  if ( tagL1ExtraForJet_.process() == "*" ) {
114  }
115  }
116  if ( iConfig.exists( "l1ExtraTauJet" ) ) {
117  tagL1ExtraTauJet_ = iConfig.getParameter< InputTag >( "l1ExtraTauJet" );
118  if ( tagL1ExtraTauJet_.process() == "*" ) {
121  }
122  }
123  if ( iConfig.exists( "l1ExtraETM" ) ) {
124  tagL1ExtraETM_ = iConfig.getParameter< InputTag >( "l1ExtraETM" );
125  if ( tagL1ExtraETM_.process() == "*" ) {
128  }
129  }
130  if ( iConfig.exists( "l1ExtraHTM" ) ) {
131  tagL1ExtraHTM_ = iConfig.getParameter< InputTag >( "l1ExtraHTM" );
132  if ( tagL1ExtraHTM_.process() == "*" ) {
135  }
136  }
137  if ( iConfig.exists( "mainBxOnly" ) ) mainBxOnly_ = iConfig.getParameter< bool >( "mainBxOnly" );
138  if ( iConfig.exists( "saveL1Refs" ) ) saveL1Refs_ = iConfig.getParameter< bool >( "saveL1Refs" );
139 
140  // HLT configuration parameters
141  if ( iConfig.exists( "triggerResults" ) ) tagTriggerResults_ = iConfig.getParameter< InputTag >( "triggerResults" );
142  if ( iConfig.exists( "triggerEvent" ) ) tagTriggerEvent_ = iConfig.getParameter< InputTag >( "triggerEvent" );
143  if ( iConfig.exists( "hltPrescaleLabel" ) ) hltPrescaleLabel_ = iConfig.getParameter< std::string >( "hltPrescaleLabel" );
144  if ( iConfig.exists( "hltPrescaleTable" ) ) labelHltPrescaleTable_ = iConfig.getParameter< std::string >( "hltPrescaleTable" );
145  if ( iConfig.exists( "addPathModuleLabels" ) ) addPathModuleLabels_ = iConfig.getParameter< bool >( "addPathModuleLabels" );
146  exludeCollections_.clear();
147  if ( iConfig.exists( "exludeCollections" ) ) exludeCollections_ = iConfig.getParameter< std::vector< std::string > >( "exludeCollections" );
148 
149  if ( ! onlyStandAlone_ ) {
150  produces< TriggerAlgorithmCollection >();
151  produces< TriggerConditionCollection >();
152  produces< TriggerPathCollection >();
153  produces< TriggerFilterCollection >();
154  produces< TriggerObjectCollection >();
155  }
156  produces< TriggerObjectStandAloneCollection >();
157 
158 }
159 
160 
161 void PATTriggerProducer::beginRun( Run & iRun, const EventSetup & iSetup )
162 {
163 
164  // Initialize
165  hltConfigInit_ = false;
166 
167  // Initialize process name
168  if ( autoProcessName_ ) {
169  // reset
170  nameProcess_ = "*";
171  // determine process name from last run TriggerSummaryProducerAOD module in process history of input
172  const ProcessHistory & processHistory( iRun.processHistory() );
173  ProcessConfiguration processConfiguration;
174  ParameterSet processPSet;
175  // unbroken loop, which relies on time ordering (accepts the last found entry)
176  for ( ProcessHistory::const_iterator iHist = processHistory.begin(); iHist != processHistory.end(); ++iHist ) {
177  if ( processHistory.getConfigurationForProcess( iHist->processName(), processConfiguration ) &&
178  pset::Registry::instance()->getMapped( processConfiguration.parameterSetID(), processPSet ) &&
179  processPSet.exists( tagTriggerEvent_.label() )
180  ) {
181  nameProcess_ = iHist->processName();
182  LogDebug( "autoProcessName" ) << "HLT process name '" << nameProcess_ << "' discovered";
183  }
184  }
185  // terminate, if nothing is found
186  if ( nameProcess_ == "*" ) {
187  LogError( "autoProcessName" ) << "trigger::TriggerEvent product with label '" << tagTriggerEvent_.label() << "' not produced according to process history of input data\n"
188  << "No trigger information produced";
189  return;
190  }
191  LogInfo( "autoProcessName" ) << "HLT process name' " << nameProcess_ << "' used for PAT trigger information";
192  }
193  // adapt configuration of used input tags
194  if ( tagTriggerResults_.process().empty() || tagTriggerResults_.process() == "*" ) {
196  } else if ( tagTriggerEvent_.process() != nameProcess_ ) {
197  LogWarning( "triggerResultsTag" ) << "TriggerResults process name '" << tagTriggerResults_.process() << "' differs from HLT process name '" << nameProcess_ << "'";
198  }
199  if ( tagTriggerEvent_.process().empty() || tagTriggerEvent_.process() == "*" ) {
201  } else if ( tagTriggerEvent_.process() != nameProcess_ ) {
202  LogWarning( "triggerEventTag" ) << "TriggerEvent process name '" << tagTriggerEvent_.process() << "' differs from HLT process name '" << nameProcess_ << "'";
203  }
212 
213  // Initialize HLTConfigProvider
214  bool changed( true );
215  if ( ! hltConfig_.init( iRun, iSetup, nameProcess_, changed ) ) {
216  LogError( "hltConfigExtraction" ) << "HLT config extraction error with process name '" << nameProcess_ << "'";
217  } else if ( hltConfig_.size() <= 0 ) {
218  LogError( "hltConfigSize" ) << "HLT config size error";
219  } else hltConfigInit_ = true;
220 
221  // Extract pre-scales
222  if ( hltConfigInit_ ) {
223  // Start empty
225  // Try run product, if configured
226  if ( ! labelHltPrescaleTable_.empty() ) {
227  Handle< trigger::HLTPrescaleTable > handleHltPrescaleTable;
228  iRun.getByLabel( InputTag( labelHltPrescaleTable_, "Run", nameProcess_ ), handleHltPrescaleTable );
229  if ( handleHltPrescaleTable.isValid() ) {
230  hltPrescaleTableRun_ = trigger::HLTPrescaleTable( handleHltPrescaleTable->set(), handleHltPrescaleTable->labels(), handleHltPrescaleTable->table() );
231  }
232  }
233  }
234 
235 }
236 
237 
238 void PATTriggerProducer::beginLuminosityBlock( LuminosityBlock & iLuminosityBlock, const EventSetup & iSetup )
239 {
240 
241  // Terminate, if auto process name determination failed
242  if ( nameProcess_ == "*" ) return;
243 
244  // Extract pre-scales
245  if ( hltConfigInit_ ) {
246  // Start from run
248  // Try lumi product, if configured and available
249  if ( ! labelHltPrescaleTable_.empty() ) {
250  Handle< trigger::HLTPrescaleTable > handleHltPrescaleTable;
251  iLuminosityBlock.getByLabel( InputTag( labelHltPrescaleTable_, "Lumi", nameProcess_ ), handleHltPrescaleTable );
252  if ( handleHltPrescaleTable.isValid() ) {
253  hltPrescaleTableLumi_ = trigger::HLTPrescaleTable( handleHltPrescaleTable->set(), handleHltPrescaleTable->labels(), handleHltPrescaleTable->table() );
254  }
255  }
256  }
257 
258 }
259 
260 
262 {
263 
264  // Terminate, if auto process name determination failed
265  if ( nameProcess_ == "*" ) return;
266 
267  std::auto_ptr< TriggerObjectCollection > triggerObjects( new TriggerObjectCollection() );
268  if ( onlyStandAlone_ ) triggerObjects->reserve( 0 );
269  std::auto_ptr< TriggerObjectStandAloneCollection > triggerObjectsStandAlone( new TriggerObjectStandAloneCollection() );
270 
271  // HLT
272 
273  // Get and check HLT event data
274  Handle< trigger::TriggerEvent > handleTriggerEvent;
275  iEvent.getByLabel( tagTriggerEvent_, handleTriggerEvent );
276  Handle< TriggerResults > handleTriggerResults;
277  iEvent.getByLabel( tagTriggerResults_, handleTriggerResults );
278  bool goodHlt( hltConfigInit_ );
279  if ( goodHlt ) {
280  if( ! handleTriggerResults.isValid() ) {
281  LogError( "triggerResultsValid" ) << "TriggerResults product with InputTag '" << tagTriggerResults_.encode() << "' not in event\n"
282  << "No HLT information produced";
283  goodHlt = false;
284  } else if ( ! handleTriggerEvent.isValid() ) {
285  LogError( "triggerEventValid" ) << "trigger::TriggerEvent product with InputTag '" << tagTriggerEvent_.encode() << "' not in event\n"
286  << "No HLT information produced";
287  goodHlt = false;
288  }
289  }
290 
291  // Produce HLT paths and determine status of modules
292 
293  if ( goodHlt ) {
294 
295  // Extract pre-scales
296  // Start from lumi
298  // Try event product, if configured and available
299  if ( ! labelHltPrescaleTable_.empty() ) {
300  Handle< trigger::HLTPrescaleTable > handleHltPrescaleTable;
301  iEvent.getByLabel( InputTag( labelHltPrescaleTable_, "Event", nameProcess_ ), handleHltPrescaleTable );
302  if ( handleHltPrescaleTable.isValid() ) {
303  hltPrescaleTable = trigger::HLTPrescaleTable( handleHltPrescaleTable->set(), handleHltPrescaleTable->labels(), handleHltPrescaleTable->table() );
304  }
305  }
306  // Try event setup, if no product
307  if ( hltPrescaleTable.size() == 0 ) {
308  if ( ! labelHltPrescaleTable_.empty() ) {
309  LogWarning( "hltPrescaleInputTag" ) << "HLTPrescaleTable product with label '" << labelHltPrescaleTable_ << "' not found in process" << nameProcess_ << "\n"
310  << "Using default from event setup";
311  }
312  if ( hltConfig_.prescaleSize() > 0 ) {
313  if ( hltConfig_.prescaleSet( iEvent, iSetup ) != -1 ) {
315  LogDebug( "hltPrescaleTable" ) << "HLT prescale table found in event setup";
316  } else {
317  LogWarning( "hltPrescaleSet" ) << "HLTPrescaleTable from event setup has error";
318  }
319  }
320  }
321  unsigned set( hltPrescaleTable.set() );
322  if ( hltPrescaleTable.size() > 0 ) {
323  if ( hltPrescaleLabel_.size() > 0 ) {
324  bool foundPrescaleLabel( false );
325  for ( unsigned iLabel = 0; iLabel < hltPrescaleTable.labels().size(); ++iLabel ) {
326  if ( hltPrescaleTable.labels().at( iLabel ) == hltPrescaleLabel_ ) {
327  set = iLabel;
328  foundPrescaleLabel = true;
329  break;
330  }
331  }
332  if ( ! foundPrescaleLabel ) {
333  LogWarning( "hltPrescaleLabel" ) << "HLT prescale label '" << hltPrescaleLabel_ << "' not in prescale table\n"
334  << "Using default";
335  }
336  }
337  } else if ( iEvent.isRealData() ) {
338  LogWarning( "hltPrescaleTable" ) << "No HLT prescale table found\n"
339  << "Using default empty table with all prescales 1";
340  }
341 
342  const unsigned sizePaths( hltConfig_.size() );
343  const unsigned sizeFilters( handleTriggerEvent->sizeFilters() );
344  const unsigned sizeObjects( handleTriggerEvent->sizeObjects() );
345 
346  std::auto_ptr< TriggerPathCollection > triggerPaths( new TriggerPathCollection() );
347  triggerPaths->reserve( onlyStandAlone_ ? 0 : sizePaths );
348  std::map< std::string, int > moduleStates;
349  std::multimap< std::string, std::pair< std::string, std::pair< bool, bool > > > filterPaths;
350 
351  for ( size_t iP = 0; iP < sizePaths; ++iP ) {
352  const std::string namePath( hltConfig_.triggerName( iP ) );
353  const unsigned indexPath( hltConfig_.triggerIndex( namePath ) );
354  const unsigned sizeModulesPath( hltConfig_.size( namePath ) );
355  unsigned indexLastFilterPathModules( handleTriggerResults->index( indexPath ) + 1 );
356  unsigned indexLastFilterFilters( sizeFilters );
357  while ( indexLastFilterPathModules > 0 ) {
358  --indexLastFilterPathModules;
359  const std::string labelLastFilterPathModules( hltConfig_.moduleLabel( indexPath, indexLastFilterPathModules ) );
360  indexLastFilterFilters = handleTriggerEvent->filterIndex( InputTag( labelLastFilterPathModules, "", nameProcess_ ) );
361  if ( indexLastFilterFilters < sizeFilters ) {
362  if ( hltConfig_.moduleType( labelLastFilterPathModules ) == "HLTBool" ) continue;
363  break;
364  }
365  }
366  for ( size_t iM = 0; iM < sizeModulesPath; ++iM ) {
367  const std::string nameFilter( hltConfig_.moduleLabel( indexPath, iM ) );
368  const unsigned indexFilter( handleTriggerEvent->filterIndex( InputTag( nameFilter, "", nameProcess_ ) ) );
369  if ( indexFilter < sizeFilters ) {
370  bool pathLastFilterAccepted( handleTriggerResults->wasrun( indexPath ) && handleTriggerResults->accept( indexPath ) && indexFilter == indexLastFilterFilters );
371  bool pathL3FilterAccepted( handleTriggerResults->wasrun( indexPath ) && handleTriggerResults->accept( indexPath ) && hltConfig_.saveTags( nameFilter ) );
372  std::pair< bool, bool > pathStatusValues( pathLastFilterAccepted, pathL3FilterAccepted );
373  std::pair< std::string, std::pair< bool, bool > > pathAndStatus( namePath, pathStatusValues );
374  filterPaths.insert( std::pair< std::string, std::pair< std::string, std::pair< bool, bool > > >( nameFilter, pathAndStatus ) );
375  }
376  }
377  if ( ! onlyStandAlone_ ) {
378  TriggerPath triggerPath( namePath, indexPath, hltConfig_.prescaleValue( set, namePath ), handleTriggerResults->wasrun( indexPath ), handleTriggerResults->accept( indexPath ), handleTriggerResults->error( indexPath ), indexLastFilterPathModules, hltConfig_.saveTagsModules( namePath ).size() );
379  // add module names to path and states' map
380  assert( indexLastFilterPathModules < sizeModulesPath );
381  std::map< unsigned, std::string > indicesModules;
382  for ( size_t iM = 0; iM < sizeModulesPath; ++iM ) {
383  const std::string nameModule( hltConfig_.moduleLabel( indexPath, iM ) );
384  if ( addPathModuleLabels_ ) {
385  triggerPath.addModule( nameModule );
386  }
387  const unsigned indexFilter( handleTriggerEvent->filterIndex( InputTag( nameModule, "", nameProcess_ ) ) );
388  if ( indexFilter < sizeFilters ) {
389  triggerPath.addFilterIndex( indexFilter );
390  }
391  const unsigned slotModule( hltConfig_.moduleIndex( indexPath, nameModule ) );
392  indicesModules.insert( std::pair< unsigned, std::string >( slotModule, nameModule ) );
393  }
394  // add L1 seeds
395  const L1SeedCollection l1Seeds( hltConfig_.hltL1GTSeeds( namePath ) );
396  for ( L1SeedCollection::const_iterator iSeed = l1Seeds.begin(); iSeed != l1Seeds.end(); ++iSeed ) {
397  triggerPath.addL1Seed( *iSeed );
398  }
399  // store path
400  triggerPaths->push_back( triggerPath );
401  // cache module states to be used for the filters
402  for ( std::map< unsigned, std::string >::const_iterator iM = indicesModules.begin(); iM != indicesModules.end(); ++iM ) {
403  if ( iM->first < indexLastFilterPathModules ) {
404  moduleStates[ iM->second ] = 1;
405  } else if ( iM->first == indexLastFilterPathModules ) {
406  moduleStates[ iM->second ] = handleTriggerResults->accept( indexPath );
407  } else if ( moduleStates.find( iM->second ) == moduleStates.end() ) {
408  moduleStates[ iM->second ] = -1;
409  }
410  }
411  }
412  }
413 
414  // Put HLT paths to event
415  if ( ! onlyStandAlone_ ) iEvent.put( triggerPaths );
416 
417  // Store used trigger objects and their types for HLT filters
418  // (only last active filter(s) available from trigger::TriggerEvent)
419 
420  std::auto_ptr< TriggerFilterCollection > triggerFilters( new TriggerFilterCollection() );
421  triggerFilters->reserve( onlyStandAlone_ ? 0 : sizeFilters );
422  std::multimap< trigger::size_type, int > objectTypes;
423  std::multimap< trigger::size_type, std::string > filterLabels;
424 
425  for ( size_t iF = 0; iF < sizeFilters; ++iF ) {
426  const std::string nameFilter( handleTriggerEvent->filterTag( iF ).label() );
427  const trigger::Keys & keys = handleTriggerEvent->filterKeys( iF );
428  const trigger::Vids & types = handleTriggerEvent->filterIds( iF );
429  assert( types.size() == keys.size() );
430  for ( size_t iK = 0; iK < keys.size(); ++iK ) {
431  filterLabels.insert( std::pair< trigger::size_type, std::string >( keys[ iK ], nameFilter ) );
432  objectTypes.insert( std::pair< trigger::size_type, int >( keys[ iK ], types[ iK ] ) );
433  }
434  }
435 
436  // HLT objects
437 
438  const trigger::Keys & collectionKeys( handleTriggerEvent->collectionKeys() );
439  std::map< trigger::size_type, trigger::size_type > newObjectKeys;
440  for ( size_t iO = 0, iC = 0; iO < sizeObjects && iC < handleTriggerEvent->sizeCollections(); ++iO ) {
441 
442  TriggerObject triggerObject( handleTriggerEvent->getObjects().at( iO ) );
443  // set collection
444  while ( iO >= collectionKeys[ iC ] ) ++iC; // relies on well ordering of trigger objects with respect to the collections
445  triggerObject.setCollection( handleTriggerEvent->collectionTag( iC ) );
446  // set filter ID
447  for ( std::multimap< trigger::size_type, int >::iterator iM = objectTypes.begin(); iM != objectTypes.end(); ++iM ) {
448  if ( iM->first == iO ) {
449  triggerObject.addTriggerObjectType( iM->second );
450  }
451  }
452 
453  // stand-alone trigger object
454  TriggerObjectStandAlone triggerObjectStandAlone( triggerObject );
455  // check for excluded collections
456  bool excluded( false );
457  for ( size_t iE = 0; iE < exludeCollections_.size(); ++iE ) {
458  if ( triggerObjectStandAlone.hasCollection( exludeCollections_.at( iE ) ) ) {
459  newObjectKeys[ iO ] = trigger::size_type( sizeObjects );
460  excluded = true;
461  break;
462  }
463  }
464  if ( excluded ) continue;
465  for ( std::multimap< trigger::size_type, std::string >::iterator iM = filterLabels.begin(); iM != filterLabels.end(); ++iM ) {
466  if ( iM->first == iO ) {
467  triggerObjectStandAlone.addFilterLabel( iM->second );
468  for ( std::multimap< std::string, std::pair< std::string, std::pair< bool, bool > > >::iterator iP = filterPaths.begin(); iP != filterPaths.end(); ++iP ) {
469  if ( iP->first == iM->second ) {
470  triggerObjectStandAlone.addPathName( iP->second.first, iP->second.second.first, iP->second.second.second );
471  }
472  }
473  }
474  }
475 
476  if ( ! onlyStandAlone_ ) triggerObjects->push_back( triggerObject );
477  triggerObjectsStandAlone->push_back( triggerObjectStandAlone );
478  newObjectKeys[ iO ] = trigger::size_type( triggerObjectsStandAlone->size() - 1 );
479  }
480 
481  // Re-iterate HLT filters and finally produce them
482  // in ordert to account for optionally skipped objects
483 
484  if ( ! onlyStandAlone_ ) {
485  for ( size_t iF = 0; iF < sizeFilters; ++iF ) {
486  const std::string nameFilter( handleTriggerEvent->filterTag( iF ).label() );
487  const trigger::Keys & keys = handleTriggerEvent->filterKeys( iF ); // not cached
488  const trigger::Vids & types = handleTriggerEvent->filterIds( iF ); // not cached
489  TriggerFilter triggerFilter( nameFilter );
490  // set filter type
491  const std::string typeFilter( hltConfig_.moduleType( nameFilter ) );
492  triggerFilter.setType( typeFilter );
493  triggerFilter.setSaveTags( hltConfig_.saveTags( nameFilter ) );
494  // set keys and trigger object types of used objects
495  for ( size_t iK = 0; iK < keys.size(); ++iK ) { // identical to types.size()
496  // check, if current object is excluded
497  if ( newObjectKeys.find( keys.at( iK ) ) != newObjectKeys.end() ) {
498  if ( newObjectKeys[ keys.at( iK ) ] == sizeObjects ) continue;
499  triggerFilter.addObjectKey( keys.at( iK ) );
500  triggerFilter.addTriggerObjectType( types.at( iK ) );
501  } else {
502  LogWarning( "triggerObjectKey" ) << "TriggerFilter '" << nameFilter << "' requests non-existing TriggerObject key " << keys.at( iK ) << "\n"
503  << "Skipping object assignment";
504  }
505  }
506  // set status from path info
507  std::map< std::string, int >::iterator iS( moduleStates.find( nameFilter ) );
508  if ( iS != moduleStates.end() ) {
509  if ( ! triggerFilter.setStatus( iS->second ) ) {
510  triggerFilter.setStatus( -1 ); // FIXME different code for "unvalid status determined" needed?
511  }
512  } else {
513  triggerFilter.setStatus( -1 ); // FIXME different code for "unknown" needed?
514  }
515  // store filter
516  triggerFilters->push_back( triggerFilter );
517  }
518  // put HLT filters to event
519  iEvent.put( triggerFilters );
520  }
521 
522  } // if ( goodHlt )
523 
524  // L1 objects
525  // (needs to be done after HLT objects, since their x-links with filters rely on their collection keys)
526 
527  // map for assignments of objects to conditions
528  std::map< L1GtObject, std::vector< unsigned > > l1ObjectTypeMap;
529 
530  if ( ! tagL1ExtraMu_.label().empty() ) {
532  iEvent.getByLabel( tagL1ExtraMu_, handleL1ExtraMu );
533  if ( handleL1ExtraMu.isValid() ) {
534  std::vector< unsigned > muKeys;
535  for ( size_t l1Mu = 0; l1Mu < handleL1ExtraMu->size(); ++l1Mu ) {
536  if ( mainBxOnly_ && handleL1ExtraMu->at( l1Mu ).bx() != 0 ) continue;
537  TriggerObject triggerObject;
538  if ( saveL1Refs_ ) {
539  const reco::CandidateBaseRef leafCandRef( l1extra::L1MuonParticleRef( handleL1ExtraMu, l1Mu ) );
540  triggerObject = TriggerObject( leafCandRef );
541  } else {
542  const reco::LeafCandidate * leafCandidate( handleL1ExtraMu->at( l1Mu ).reco::LeafCandidate::clone() );
543  triggerObject = TriggerObject( *leafCandidate );
544  }
545  triggerObject.setCollection( tagL1ExtraMu_ );
547  if ( ! onlyStandAlone_ ) triggerObjects->push_back( triggerObject );
548  TriggerObjectStandAlone triggerObjectStandAlone( triggerObject );
549  triggerObjectsStandAlone->push_back( triggerObjectStandAlone );
550  if ( handleL1ExtraMu->at( l1Mu ).bx() == 0 ) muKeys.push_back( triggerObjectsStandAlone->size() - 1 );
551  }
552  l1ObjectTypeMap.insert( std::make_pair( Mu, muKeys ) );
553  } else LogError( "l1ExtraValid" ) << "l1extra::L1MuonParticleCollection product with InputTag '" << tagL1ExtraMu_.encode() << "' not in event";
554  }
555  if ( ! tagL1ExtraNoIsoEG_.label().empty() ) {
556  Handle< l1extra::L1EmParticleCollection > handleL1ExtraNoIsoEG;
557  iEvent.getByLabel( tagL1ExtraNoIsoEG_, handleL1ExtraNoIsoEG );
558  if ( handleL1ExtraNoIsoEG.isValid() ) {
559  std::vector< unsigned > noIsoEGKeys;
560  for ( size_t l1NoIsoEG = 0; l1NoIsoEG < handleL1ExtraNoIsoEG->size(); ++l1NoIsoEG ) {
561  if ( mainBxOnly_ && handleL1ExtraNoIsoEG->at( l1NoIsoEG ).bx() != 0 ) continue;
562  TriggerObject triggerObject;
563  if ( saveL1Refs_ ) {
564  const reco::CandidateBaseRef leafCandRef( l1extra::L1EmParticleRef( handleL1ExtraNoIsoEG, l1NoIsoEG ) );
565  triggerObject = TriggerObject( leafCandRef );
566  } else {
567  const reco::LeafCandidate * leafCandidate( handleL1ExtraNoIsoEG->at( l1NoIsoEG ).reco::LeafCandidate::clone() );
568  triggerObject = TriggerObject( *leafCandidate );
569  }
570  triggerObject.setCollection( tagL1ExtraNoIsoEG_ );
572  if ( ! onlyStandAlone_ ) triggerObjects->push_back( triggerObject );
573  TriggerObjectStandAlone triggerObjectStandAlone( triggerObject );
574  triggerObjectsStandAlone->push_back( triggerObjectStandAlone );
575  if ( handleL1ExtraNoIsoEG->at( l1NoIsoEG ).bx() == 0 ) noIsoEGKeys.push_back( triggerObjectsStandAlone->size() - 1 );
576  }
577  l1ObjectTypeMap.insert( std::make_pair( NoIsoEG, noIsoEGKeys ) );
578  } else LogError( "l1ExtraValid" ) << "l1extra::L1EmParticleCollection product with InputTag '" << tagL1ExtraNoIsoEG_.encode() << "' not in event";
579  }
580  if ( ! tagL1ExtraIsoEG_.label().empty() ) {
582  iEvent.getByLabel( tagL1ExtraIsoEG_, handleL1ExtraIsoEG );
583  if ( handleL1ExtraIsoEG.isValid() ) {
584  std::vector< unsigned > isoEGKeys;
585  for ( size_t l1IsoEG = 0; l1IsoEG < handleL1ExtraIsoEG->size(); ++l1IsoEG ) {
586  if ( mainBxOnly_ && handleL1ExtraIsoEG->at( l1IsoEG ).bx() != 0 ) continue;
587  TriggerObject triggerObject;
588  if ( saveL1Refs_ ) {
589  const reco::CandidateBaseRef leafCandRef( l1extra::L1EmParticleRef( handleL1ExtraIsoEG, l1IsoEG ) );
590  triggerObject = TriggerObject( leafCandRef );
591  } else {
592  const reco::LeafCandidate * leafCandidate( handleL1ExtraIsoEG->at( l1IsoEG ).reco::LeafCandidate::clone() );
593  triggerObject = TriggerObject( *leafCandidate );
594  }
595  triggerObject.setCollection( tagL1ExtraIsoEG_ );
597  if ( ! onlyStandAlone_ ) triggerObjects->push_back( triggerObject );
598  TriggerObjectStandAlone triggerObjectStandAlone( triggerObject );
599  triggerObjectsStandAlone->push_back( triggerObjectStandAlone );
600  if ( handleL1ExtraIsoEG->at( l1IsoEG ).bx() == 0 ) isoEGKeys.push_back( triggerObjectsStandAlone->size() - 1 );
601  }
602  l1ObjectTypeMap.insert( std::make_pair( IsoEG, isoEGKeys ) );
603  } else LogError( "l1ExtraValid" ) << "l1extra::L1EmParticleCollection product with InputTag '" << tagL1ExtraIsoEG_.encode() << "' not in event";
604  }
605  if ( ! tagL1ExtraCenJet_.label().empty() ) {
606  Handle< l1extra::L1JetParticleCollection > handleL1ExtraCenJet;
607  iEvent.getByLabel( tagL1ExtraCenJet_, handleL1ExtraCenJet );
608  if ( handleL1ExtraCenJet.isValid() ) {
609  std::vector< unsigned > cenJetKeys;
610  for ( size_t l1CenJet = 0; l1CenJet < handleL1ExtraCenJet->size(); ++l1CenJet ) {
611  if ( mainBxOnly_ && handleL1ExtraCenJet->at( l1CenJet ).bx() != 0 ) continue;
612  TriggerObject triggerObject;
613  if ( saveL1Refs_ ) {
614  const reco::CandidateBaseRef leafCandRef( l1extra::L1JetParticleRef( handleL1ExtraCenJet, l1CenJet ) );
615  triggerObject = TriggerObject( leafCandRef );
616  } else {
617  const reco::LeafCandidate * leafCandidate( handleL1ExtraCenJet->at( l1CenJet ).reco::LeafCandidate::clone() );
618  triggerObject = TriggerObject( *leafCandidate );
619  }
620  triggerObject.setCollection( tagL1ExtraCenJet_ );
622  if ( ! onlyStandAlone_ ) triggerObjects->push_back( triggerObject );
623  TriggerObjectStandAlone triggerObjectStandAlone( triggerObject );
624  triggerObjectsStandAlone->push_back( triggerObjectStandAlone );
625  if ( handleL1ExtraCenJet->at( l1CenJet ).bx() == 0 ) cenJetKeys.push_back( triggerObjectsStandAlone->size() - 1 );
626  }
627  l1ObjectTypeMap.insert( std::make_pair( CenJet, cenJetKeys ) );
628  } else LogError( "l1ExtraValid" ) << "l1extra::L1JetParticleCollection product with InputTag '" << tagL1ExtraCenJet_.encode() << "' not in event";
629  }
630  if ( ! tagL1ExtraForJet_.label().empty() ) {
631  Handle< l1extra::L1JetParticleCollection > handleL1ExtraForJet;
632  iEvent.getByLabel( tagL1ExtraForJet_, handleL1ExtraForJet );
633  if ( handleL1ExtraForJet.isValid() ) {
634  std::vector< unsigned > forJetKeys;
635  for ( size_t l1ForJet = 0; l1ForJet < handleL1ExtraForJet->size(); ++l1ForJet ) {
636  if ( mainBxOnly_ && handleL1ExtraForJet->at( l1ForJet ).bx() != 0 ) continue;
637  TriggerObject triggerObject;
638  if ( saveL1Refs_ ) {
639  const reco::CandidateBaseRef leafCandRef( l1extra::L1JetParticleRef( handleL1ExtraForJet, l1ForJet ) );
640  triggerObject = TriggerObject( leafCandRef );
641  } else {
642  const reco::LeafCandidate * leafCandidate( handleL1ExtraForJet->at( l1ForJet ).reco::LeafCandidate::clone() );
643  triggerObject = TriggerObject( *leafCandidate );
644  }
645  triggerObject.setCollection( tagL1ExtraForJet_ );
647  if ( ! onlyStandAlone_ ) triggerObjects->push_back( triggerObject );
648  TriggerObjectStandAlone triggerObjectStandAlone( triggerObject );
649  triggerObjectsStandAlone->push_back( triggerObjectStandAlone );
650  if ( handleL1ExtraForJet->at( l1ForJet ).bx() == 0 ) forJetKeys.push_back( triggerObjectsStandAlone->size() - 1 );
651  }
652  l1ObjectTypeMap.insert( std::make_pair( ForJet, forJetKeys ) );
653  } else LogError( "l1ExtraValid" ) << "l1extra::L1JetParticleCollection product with InputTag '" << tagL1ExtraForJet_.encode() << "' not in event";
654  }
655  if ( ! tagL1ExtraTauJet_.label().empty() ) {
656  Handle< l1extra::L1JetParticleCollection > handleL1ExtraTauJet;
657  iEvent.getByLabel( tagL1ExtraTauJet_, handleL1ExtraTauJet );
658  if ( handleL1ExtraTauJet.isValid() ) {
659  std::vector< unsigned > tauJetKeys;
660  for ( size_t l1TauJet = 0; l1TauJet < handleL1ExtraTauJet->size(); ++l1TauJet ) {
661  if ( mainBxOnly_ && handleL1ExtraTauJet->at( l1TauJet ).bx() != 0 ) continue;
662  TriggerObject triggerObject;
663  if ( saveL1Refs_ ) {
664  const reco::CandidateBaseRef leafCandRef( l1extra::L1JetParticleRef( handleL1ExtraTauJet, l1TauJet ) );
665  triggerObject = TriggerObject( leafCandRef );
666  } else {
667  const reco::LeafCandidate * leafCandidate( handleL1ExtraTauJet->at( l1TauJet ).reco::LeafCandidate::clone() );
668  triggerObject = TriggerObject( *leafCandidate );
669  }
670  triggerObject.setCollection( tagL1ExtraTauJet_ );
672  if ( ! onlyStandAlone_ ) triggerObjects->push_back( triggerObject );
673  TriggerObjectStandAlone triggerObjectStandAlone( triggerObject );
674  triggerObjectsStandAlone->push_back( triggerObjectStandAlone );
675  if ( handleL1ExtraTauJet->at( l1TauJet ).bx() == 0 ) tauJetKeys.push_back( triggerObjectsStandAlone->size() - 1 );
676  }
677  l1ObjectTypeMap.insert( std::make_pair( TauJet, tauJetKeys ) );
678  } else LogError( "l1ExtraValid" ) << "l1extra::L1JetParticleCollection product with InputTag '" << tagL1ExtraTauJet_.encode() << "' not in event";
679  }
680  if ( ! tagL1ExtraETM_ .label().empty()) {
682  iEvent.getByLabel( tagL1ExtraETM_, handleL1ExtraETM );
683  if ( handleL1ExtraETM.isValid() ) {
684  std::vector< unsigned > etmKeys;
685  for ( size_t l1ETM = 0; l1ETM < handleL1ExtraETM->size(); ++l1ETM ) {
686  if ( mainBxOnly_ && handleL1ExtraETM->at( l1ETM ).bx() != 0 ) continue;
687  TriggerObject triggerObject;
688  if ( saveL1Refs_ ) {
689  const reco::CandidateBaseRef leafCandRef( l1extra::L1EtMissParticleRef( handleL1ExtraETM, l1ETM ) );
690  triggerObject = TriggerObject( leafCandRef );
691  } else {
692  const reco::LeafCandidate * leafCandidate( handleL1ExtraETM->at( l1ETM ).reco::LeafCandidate::clone() );
693  triggerObject = TriggerObject( *leafCandidate );
694  }
695  triggerObject.setCollection( tagL1ExtraETM_ );
697  if ( ! onlyStandAlone_ ) triggerObjects->push_back( triggerObject );
698  TriggerObjectStandAlone triggerObjectStandAlone( triggerObject );
699  triggerObjectsStandAlone->push_back( triggerObjectStandAlone );
700  if ( handleL1ExtraETM->at( l1ETM ).bx() == 0 ) etmKeys.push_back( triggerObjectsStandAlone->size() - 1 );
701  }
702  l1ObjectTypeMap.insert( std::make_pair( ETM, etmKeys ) );
703  } else LogError( "l1ExtraValid" ) << "l1extra::L1EtMissParticleCollection product with InputTag '" << tagL1ExtraETM_.encode() << "' not in event";
704  }
705  if ( ! tagL1ExtraHTM_.label().empty() ) {
707  iEvent.getByLabel( tagL1ExtraHTM_, handleL1ExtraHTM );
708  if ( handleL1ExtraHTM.isValid() ) {
709  std::vector< unsigned > htmKeys;
710  for ( size_t l1HTM = 0; l1HTM < handleL1ExtraHTM->size(); ++l1HTM ) {
711  if ( mainBxOnly_ && handleL1ExtraHTM->at( l1HTM ).bx() != 0 ) continue;
712  TriggerObject triggerObject;
713  if ( saveL1Refs_ ) {
714  const reco::CandidateBaseRef leafCandRef( l1extra::L1EtMissParticleRef( handleL1ExtraHTM, l1HTM ) );
715  triggerObject = TriggerObject( leafCandRef );
716  } else {
717  const reco::LeafCandidate * leafCandidate( handleL1ExtraHTM->at( l1HTM ).reco::LeafCandidate::clone() );
718  triggerObject = TriggerObject( *leafCandidate );
719  }
720  triggerObject.setCollection( tagL1ExtraHTM_ );
722  if ( ! onlyStandAlone_ ) triggerObjects->push_back( triggerObject );
723  TriggerObjectStandAlone triggerObjectStandAlone( triggerObject );
724  triggerObjectsStandAlone->push_back( triggerObjectStandAlone );
725  if ( handleL1ExtraHTM->at( l1HTM ).bx() == 0 ) htmKeys.push_back( triggerObjectsStandAlone->size() - 1 );
726  }
727  l1ObjectTypeMap.insert( std::make_pair( HTM, htmKeys ) );
728  } else LogError( "l1ExtraValid" ) << "l1extra::L1EtMissParticleCollection product with InputTag '" << tagL1ExtraHTM_.encode() << "' not in event";
729  }
730 
731  // Put trigger objects to event
732  if ( ! onlyStandAlone_ ) iEvent.put( triggerObjects );
733 
734  // L1 algorithms
735  if ( ! onlyStandAlone_ ) {
736  std::auto_ptr< TriggerAlgorithmCollection > triggerAlgos( new TriggerAlgorithmCollection() );
737  std::auto_ptr< TriggerConditionCollection > triggerConditions( new TriggerConditionCollection() );
738  if ( addL1Algos_ ) {
739  // create trigger object types transalation map (yes, it's ugly!)
740  std::map< L1GtObject, trigger::TriggerObjectType > mapObjectTypes;
741  mapObjectTypes.insert( std::make_pair( Mu , trigger::TriggerL1Mu ) );
742  mapObjectTypes.insert( std::make_pair( NoIsoEG, trigger::TriggerL1NoIsoEG ) );
743  mapObjectTypes.insert( std::make_pair( IsoEG , trigger::TriggerL1IsoEG ) );
744  mapObjectTypes.insert( std::make_pair( CenJet , trigger::TriggerL1CenJet ) );
745  mapObjectTypes.insert( std::make_pair( ForJet , trigger::TriggerL1ForJet ) );
746  mapObjectTypes.insert( std::make_pair( TauJet , trigger::TriggerL1TauJet ) );
747  mapObjectTypes.insert( std::make_pair( ETM , trigger::TriggerL1ETM ) );
748  mapObjectTypes.insert( std::make_pair( HTM , trigger::TriggerL1HTM ) );
749  // get and cache L1 menu
751  ESHandle< L1GtTriggerMenu > handleL1GtTriggerMenu;
752  iSetup.get< L1GtTriggerMenuRcd >().get( handleL1GtTriggerMenu );
753  L1GtTriggerMenu l1GtTriggerMenu( *handleL1GtTriggerMenu );
754  const AlgorithmMap l1GtAlgorithms( l1GtTriggerMenu.gtAlgorithmMap() );
755  const AlgorithmMap l1GtTechTriggers( l1GtTriggerMenu.gtTechnicalTriggerMap() );
756  l1GtTriggerMenu.buildGtConditionMap();
757  const std::vector< ConditionMap > l1GtConditionsVector( l1GtTriggerMenu.gtConditionMap() );
758  // cache conditions in one single condition map
759  ConditionMap l1GtConditions;
760  for ( size_t iCv = 0; iCv < l1GtConditionsVector.size(); ++iCv ) {
761  l1GtConditions.insert( l1GtConditionsVector.at( iCv ).begin(), l1GtConditionsVector.at( iCv ).end() );
762  }
763  triggerAlgos->reserve( l1GtAlgorithms.size() + l1GtTechTriggers.size() );
764  Handle< L1GlobalTriggerObjectMapRecord > handleL1GlobalTriggerObjectMapRecord;
765  iEvent.getByLabel( tagL1GlobalTriggerObjectMapRecord_, handleL1GlobalTriggerObjectMapRecord );
766  if( ! handleL1GlobalTriggerObjectMapRecord.isValid() ) {
767  LogWarning( "l1ObjectMap" ) << "L1GlobalTriggerObjectMapRecord product with InputTag '" << tagL1GlobalTriggerObjectMapRecord_.encode() << "' not in event\n"
768  << "No L1 objects and GTL results available for physics algorithms";
769  }
770  // physics algorithms
771  for ( CItAlgo iAlgo = l1GtAlgorithms.begin(); iAlgo != l1GtAlgorithms.end(); ++iAlgo ) {
772  const std::string & algoName( iAlgo->second.algoName() );
773  if ( ! ( iAlgo->second.algoBitNumber() < int( L1GlobalTriggerReadoutSetup::NumberPhysTriggers ) ) ) {
774  LogError( "l1Algo" ) << "L1 physics algorithm '" << algoName << "' has bit number " << iAlgo->second.algoBitNumber() << " >= " << L1GlobalTriggerReadoutSetup::NumberPhysTriggers << "\n"
775  << "Skipping";
776  continue;
777  }
779  int bit;
780  if ( ! l1GtUtils_.l1AlgoTechTrigBitNumber( algoName, category, bit ) ) {
781  LogError( "l1Algo" ) << "L1 physics algorithm '" << algoName << "' not found in the L1 menu\n"
782  << "Skipping";
783  continue;
784  }
785  if ( category != L1GtUtils::AlgorithmTrigger ) {
786  LogError( "l1Algo" ) << "L1 physics algorithm '" << algoName << "' does not have category 'AlgorithmTrigger' from 'L1GtUtils'\n"
787  << "Skipping";
788  continue;
789  }
790  bool decisionBeforeMask;
791  bool decisionAfterMask;
792  int prescale;
793  int mask;
794  int error( l1GtUtils_.l1Results( iEvent, algoName, decisionBeforeMask, decisionAfterMask, prescale, mask ) );
795  if ( error ) {
796  LogError( "l1Algo" ) << "L1 physics algorithm '" << algoName << "' decision has error code " << error << " from 'L1GtUtils'\n"
797  << "Skipping";
798  continue;
799  }
800  TriggerAlgorithm triggerAlgo( algoName, iAlgo->second.algoAlias(), category == L1GtUtils::TechnicalTrigger, (unsigned)bit, (unsigned)prescale, (bool)mask, decisionBeforeMask, decisionAfterMask );
801  triggerAlgo.setLogicalExpression( iAlgo->second.algoLogicalExpression() );
802  // GTL result and used conditions in physics algorithm
803  if( ! handleL1GlobalTriggerObjectMapRecord.isValid() ) {
804  triggerAlgos->push_back( triggerAlgo );
805  continue; // LogWarning already earlier (before loop)
806  }
807  const L1GlobalTriggerObjectMap * l1ObjectMap( handleL1GlobalTriggerObjectMapRecord->getObjectMap( algoName ) );
808  if ( ! l1ObjectMap ) {
809  LogError( "l1ObjectMap" ) << "L1 physics algorithm '" << algoName << "' is missing in L1GlobalTriggerObjectMapRecord\n"
810  << "Skipping conditions and GTL result";
811  triggerAlgos->push_back( triggerAlgo );
812  continue;
813  }
814 // if ( ( l1ObjectMap->algoGtlResult() != decisionBeforeMask ) && ( decisionBeforeMask == true || prescale == 1 ) ) {
815  if ( ( l1ObjectMap->algoGtlResult() != decisionBeforeMask ) && ( decisionBeforeMask == true ) ) { // FIXME: understand the difference for un-prescaled algos 118, 119, 123
816  LogInfo( "l1ObjectMap" ) << "L1 physics algorithm '" << algoName << "' with different decisions in\n"
817  << "L1GlobalTriggerObjectMapRecord (GTL result) : " << l1ObjectMap->algoGtlResult() << "\n"
818  << "L1GlobalTriggerReadoutRecord (decision before mask): " << decisionBeforeMask;
819  }
820  triggerAlgo.setGtlResult( l1ObjectMap->algoGtlResult() );
821  // conditions in algorithm
822  const std::vector< L1GtLogicParser::OperandToken > & tokens( l1ObjectMap->operandTokenVector() );
823  for ( size_t iT = 0; iT < tokens.size(); ++iT ) {
824  const L1GtLogicParser::OperandToken & token( tokens.at( iT ) );
825  size_t key( triggerConditions->size() );
826  for ( size_t iC = 0; iC < triggerConditions->size(); ++iC ) {
827  if ( token.tokenName == triggerConditions->at( iC ).name() ) {
828  key = iC;
829  break;
830  }
831  }
832  if ( key == triggerConditions->size() ) {
833  TriggerCondition triggerCond( token.tokenName, token.tokenResult );
834  if ( l1GtConditions.find( triggerCond.name() ) != l1GtConditions.end() ) {
835  triggerCond.setCategory( l1GtConditions[ triggerCond.name() ]->condCategory() );
836  triggerCond.setType( l1GtConditions[ triggerCond.name() ]->condType() );
837  const std::vector< L1GtObject > l1ObjectTypes( l1GtConditions[ triggerCond.name() ]->objectType() );
838  for ( size_t iT = 0 ; iT < l1ObjectTypes.size(); ++iT ) {
839  triggerCond.addTriggerObjectType( mapObjectTypes[ l1ObjectTypes.at( iT ) ] );
840  }
841  // objects in condition
842  CombinationsInCond combis( l1ObjectMap->combinationVector().at( token.tokenNumber ) );
843  for ( size_t iVV = 0; iVV < combis.size(); ++iVV ) {
844  SingleCombInCond combi( combis.at( iVV ) );
845  for ( size_t iV = 0; iV < combi.size(); ++iV ) {
846  if ( iV >= l1ObjectTypes.size() ) {
847  LogError( "l1CondMap" ) << "Index " << iV << " in combinations vector overshoots size " << l1ObjectTypes.size() << " of types vector in conditions map\n"
848  << "Skipping object key in condition " << triggerCond.name();
849  } else if ( l1ObjectTypeMap.find( l1ObjectTypes.at( iV ) ) != l1ObjectTypeMap.end() ) {
850  if ( combi.at( iV ) >= int( l1ObjectTypeMap[ l1ObjectTypes.at( iV ) ].size() ) ) {
851  LogError( "l1CondMap" ) << "Index " << combi.at( iV ) << " in combination overshoots number " << l1ObjectTypeMap[ l1ObjectTypes.at( iV ) ].size() << "of according trigger objects\n"
852  << "Skipping object key in condition " << triggerCond.name();
853  }
854  const unsigned objectKey( l1ObjectTypeMap[ l1ObjectTypes.at( iV ) ].at( combi.at( iV ) ) );
855  triggerCond.addObjectKey( objectKey );
856  // add current condition and algorithm also to the according stand-alone trigger object
857  triggerObjectsStandAlone->at( objectKey ).addAlgorithmName( triggerAlgo.name(), ( triggerAlgo.decision() && triggerCond.wasAccept() ) );
858  triggerObjectsStandAlone->at( objectKey ).addConditionName( triggerCond.name() );
859  }
860  }
861  }
862  } else {
863  LogWarning( "l1CondMap" ) << "L1 conditions '" << triggerCond.name() << "' not found in the L1 menu\n"
864  << "Remains incomplete";
865  }
866  triggerConditions->push_back( triggerCond );
867  }
868  triggerAlgo.addConditionKey( key );
869  }
870  triggerAlgos->push_back( triggerAlgo );
871  }
872  // technical triggers
873  for ( CItAlgo iAlgo = l1GtTechTriggers.begin(); iAlgo != l1GtTechTriggers.end(); ++iAlgo ) {
874  const std::string & algoName( iAlgo->second.algoName() );
875  if ( ! ( iAlgo->second.algoBitNumber() < int( L1GlobalTriggerReadoutSetup::NumberTechnicalTriggers ) ) ) {
876  LogError( "l1Algo" ) << "L1 technical trigger '" << algoName << "' has bit number " << iAlgo->second.algoBitNumber() << " >= " << L1GlobalTriggerReadoutSetup::NumberTechnicalTriggers << "\n"
877  << "Skipping";
878  continue;
879  }
881  int bit;
882  if ( ! l1GtUtils_.l1AlgoTechTrigBitNumber( algoName, category, bit ) ) {
883  LogError( "l1Algo" ) << "L1 technical trigger '" << algoName << "' not found in the L1 menu\n"
884  << "Skipping";
885  continue;
886  }
887  if ( category != L1GtUtils::TechnicalTrigger ) {
888  LogError( "l1Algo" ) << "L1 technical trigger '" << algoName << "' does not have category 'TechnicalTrigger' from 'L1GtUtils'\n"
889  << "Skipping";
890  continue;
891  }
892  bool decisionBeforeMask;
893  bool decisionAfterMask;
894  int prescale;
895  int mask;
896  int error( l1GtUtils_.l1Results( iEvent, algoName, decisionBeforeMask, decisionAfterMask, prescale, mask ) );
897  if ( error ) {
898  LogError( "l1Algo" ) << "L1 technical trigger '" << algoName << "' decision has error code " << error << " from 'L1GtUtils'\n"
899  << "Skipping";
900  continue;
901  }
902  TriggerAlgorithm triggerAlgo( algoName, iAlgo->second.algoAlias(), category == L1GtUtils::TechnicalTrigger, (unsigned)bit, (unsigned)prescale, (bool)mask, decisionBeforeMask, decisionAfterMask );
903  triggerAlgo.setLogicalExpression( iAlgo->second.algoLogicalExpression() );
904  triggerAlgos->push_back( triggerAlgo );
905  }
906  }
907 
908  // Put L1 algorithms and conditions to event
909  iEvent.put( triggerAlgos );
910  iEvent.put( triggerConditions );
911  }
912 
913  // Put (finally) stand-alone trigger objects to event
914  iEvent.put( triggerObjectsStandAlone );
915 
916 }
917 
918 
#define LogDebug(id)
unsigned int set() const
low-level const accessors for data members
unsigned int size() const
number of trigger paths in trigger table
collection_type::const_iterator const_iterator
T getParameter(std::string const &) const
bool getByLabel(std::string const &label, Handle< PROD > &result) const
Definition: Run.h:175
std::string name() const
Get the filter label.
Analysis-level L1 trigger algorithm class.
const int l1Results(const edm::Event &iEvent, const edm::InputTag &l1GtRecordInputTag, const edm::InputTag &l1GtReadoutRecordInputTag, const std::string &nameAlgoTechTrig, bool &decisionBeforeMask, bool &decisionAfterMask, int &prescaleFactor, int &triggerMask) const
Definition: L1GtUtils.cc:614
virtual void produce(edm::Event &iEvent, const edm::EventSetup &iSetup)
const std::string moduleType(const std::string &module) const
C++ class name of module.
virtual void beginLuminosityBlock(edm::LuminosityBlock &iLuminosityBlock, const edm::EventSetup &iSetup)
const std::string & label
Definition: MVAComputer.cc:186
const std::string & triggerName(unsigned int triggerIndex) const
PATTriggerProducer(const edm::ParameterSet &iConfig)
HLTConfigProvider hltConfig_
bool setStatus(int status)
enum start value shifted to 81 so as to avoid clashes with PDG codes
std::map< std::string, L1GtCondition * > ConditionMap
map containing the conditions
virtual bool hasCollection(const std::string &collName) const
Checks, if a certain label of original collection is assigned (method overrides)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
edm::InputTag tagTriggerResults_
tuple triggerConditions
std::map< std::string, L1GtAlgorithm > AlgorithmMap
map containing the algorithms
const bool l1AlgoTechTrigBitNumber(const std::string &nameAlgoTechTrig, TriggerCategory &trigCategory, int &bitNumber) const
Definition: L1GtUtils.cc:470
static const unsigned int NumberTechnicalTriggers
TriggerCategory
Definition: L1GtUtils.h:59
bool wasAccept() const
Get the success flag.
std::string name() const
Get L1 algorithm name.
const std::vector< std::vector< std::pair< bool, std::string > > > & hltL1GTSeeds() const
The single EDProduct containing the HLT Prescale Table.
void setGtlResult(bool gtlResult)
Set L1 algorithm GTL result.
void addTriggerObjectType(trigger::TriggerObjectType triggerObjectType)
Add a new trigger object type.
bool exists(std::string const &parameterName) const
checks if a parameter exists
std::vector< int > SingleCombInCond
typedefs
void addTriggerObjectType(trigger::TriggerObjectType triggerObjectType)
Add a new trigger object type identifier.
Definition: TriggerFilter.h:81
std::vector< TriggerObjectStandAlone > TriggerObjectStandAloneCollection
Collection of TriggerObjectStandAlone.
void addObjectKey(unsigned objectKey)
Add a new trigger object collection index.
Definition: TriggerFilter.h:79
const std::vector< ConditionMap > & gtConditionMap() const
get / set / build the condition maps
bool getByLabel(std::string const &label, Handle< PROD > &result) const
const std::map< std::string, std::vector< unsigned int > > & prescaleTable() const
Analysis-level trigger object class.
Definition: TriggerObject.h:49
uint16_t size_type
bool isRealData() const
Definition: EventBase.h:60
const std::map< std::string, std::vector< unsigned int > > & table() const
std::string encode() const
Definition: InputTag.cc:72
void addFilterLabel(const std::string &filterLabel)
Methods.
const std::string & moduleLabel(unsigned int trigger, unsigned int module) const
AlgorithmMap::const_iterator CItAlgo
iterators through map containing the algorithms
const std::vector< std::string > & saveTagsModules(unsigned int trigger) const
unsigned int triggerIndex(const std::string &triggerName) const
slot position of trigger path in trigger table (0 to size-1)
std::vector< TriggerAlgorithm > TriggerAlgorithmCollection
Collection of TriggerAlgorithm.
void addPathName(const std::string &pathName, bool pathLastFilterAccepted=true, bool pathL3FilterAccepted=true)
Adds a new HLT path name.
Analysis-level HLTrigger filter class.
Definition: TriggerFilter.h:37
Produces the full or stand-alone PAT trigger information collections.
unsigned int prescaleValue(unsigned int set, const std::string &trigger) const
HLT prescale value in specific prescale set for a specific trigger path.
int iEvent
Definition: GenABIO.cc:243
unsigned int moduleIndex(unsigned int trigger, const std::string &module) const
slot position of module on trigger path (0 to size-1)
void setCollection(const std::string &collName)
Methods.
Definition: TriggerObject.h:86
Analysis-level L1 trigger condition class.
Analysis-level HLTrigger path class.
Definition: TriggerPath.h:41
static const unsigned int NumberPhysTriggersExtended
edm::InputTag tagL1GlobalTriggerObjectMapRecord_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:84
const std::vector< std::string > & labels() const
trigger::HLTPrescaleTable hltPrescaleTableLumi_
ProcessHistory const & processHistory() const
Definition: Run.cc:100
static const unsigned int NumberPhysTriggers
void retrieveL1EventSetup(const edm::EventSetup &)
retrieve all the relevant L1 trigger event setup records and cache them to improve the speed ...
Definition: L1GtUtils.cc:107
void setSaveTags(bool saveTags)
Set the L3 status.
Definition: TriggerFilter.h:89
void setLogicalExpression(const std::string &expression)
Set L1 algorithm logical expression.
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:355
const bool saveTags(const std::string &module) const
Is module an L3 filter (ie, tracked saveTags=true)
virtual void beginRun(edm::Run &iRun, const edm::EventSetup &iSetup)
std::vector< TriggerFilter > TriggerFilterCollection
Collection of TriggerFilter.
void setCategory(L1GtConditionCategory category)
Set the condition category.
int prescaleSet(const edm::Event &iEvent, const edm::EventSetup &iSetup) const
std::vector< size_type > Keys
void addObjectKey(unsigned objectKey)
Add a new trigger object collection index.
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
const T & get() const
Definition: EventSetup.h:55
const std::vector< std::string > & prescaleLabels() const
low-level data member access
void addConditionKey(unsigned conditionKey)
Add a new trigger condition collection index.
std::string const & label() const
Definition: InputTag.h:25
std::string const & process() const
Definition: InputTag.h:29
void setType(const std::string &type)
Set the filter module type.
Definition: TriggerFilter.h:77
list key
Definition: combine.py:13
static const std::string category("Muon|RecoMuon|L3MuonCandidateProducerFromMuons")
std::vector< TriggerObject > TriggerObjectCollection
Collection of TriggerObject.
const AlgorithmMap & gtAlgorithmMap() const
get / set the algorithm map (by name)
unsigned int prescaleSize() const
trigger::HLTPrescaleTable hltPrescaleTableRun_
std::vector< TriggerCondition > TriggerConditionCollection
Collection of TriggerCondition.
const AlgorithmMap & gtTechnicalTriggerMap() const
get / set the technical trigger map
std::vector< std::string > exludeCollections_
std::vector< L1Seed > L1SeedCollection
Collection of L1Seed.
Definition: TriggerPath.h:39
void addTriggerObjectType(trigger::TriggerObjectType triggerObjectType)
Add a new trigger object type identifier.
Definition: TriggerObject.h:89
std::vector< SingleCombInCond > CombinationsInCond
all the object combinations evaluated to true in the condition
std::vector< TriggerPath > TriggerPathCollection
Collection of TriggerPath.
Definition: TriggerPath.h:155
std::string const & instance() const
Definition: InputTag.h:26
edm::InputTag tagL1ExtraNoIsoEG_
std::vector< int > Vids
void setType(L1GtConditionType type)
Set the condition type.
Definition: Run.h:32
Analysis-level trigger object class (stand-alone)