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