CMS 3D CMS Logo

TriggerHelper.cc
Go to the documentation of this file.
1 //
2 //
3 
4 
6 
8 
9 
10 using namespace pat;
11 using namespace pat::helper;
12 
13 
14 
15 // Methods
16 
17 
18 // Get a reference to the trigger objects matched to a certain physics object given by a reference for a certain matcher module
19 
20 // ... by resulting association
21 TriggerObjectRef TriggerMatchHelper::triggerMatchObject( const reco::CandidateBaseRef & candRef, const TriggerObjectMatch * matchResult, const edm::Event & event, const TriggerEvent & triggerEvent ) const
22 {
23  if ( matchResult ) {
24  auto it = edm::makeAssociativeIterator< reco::CandidateBaseRef>( *matchResult, event );
25  auto itEnd = it.end() ;
26  while ( it != itEnd ) {
27  if ( it->first.isNonnull() && it->second.isNonnull() && it->second.isAvailable() ) {
28  if ( it->first.id() == candRef.id() && it->first.key() == candRef.key() ) {
29  return TriggerObjectRef( it->second );
30  }
31  }
32  ++it;
33  }
34  }
35  return TriggerObjectRef();
36 }
37 
38 // ... by matcher module label
39 TriggerObjectRef TriggerMatchHelper::triggerMatchObject( const reco::CandidateBaseRef & candRef, const std::string & labelMatcher, const edm::Event & event, const TriggerEvent & triggerEvent ) const
40 {
41  return triggerMatchObject( candRef, triggerEvent.triggerObjectMatchResult( labelMatcher ), event, triggerEvent );
42 }
43 
44 
45 // Get a table of references to all trigger objects matched to a certain physics object given by a reference
47 {
48  TriggerObjectMatchMap theContainer;
49  const std::vector< std::string > matchers( triggerEvent.triggerMatchers() );
50  for ( size_t iMatch = 0; iMatch < matchers.size(); ++iMatch ) {
51  theContainer[ matchers.at( iMatch ) ] = triggerMatchObject( candRef, matchers.at( iMatch ), event, triggerEvent );
52  }
53  return theContainer;
54 }
55 
56 
57 // Get a vector of references to the phyics objects matched to a certain trigger object given by a reference for a certain matcher module
58 
59 // ... by resulting association
61 {
63  if ( matchResult ) {
64  auto it = edm::makeAssociativeIterator< reco::CandidateBaseRef>( *matchResult, event );
65  auto itEnd = it.end() ;
66  while ( it != itEnd ) {
67  if ( it->first.isNonnull() && it->second.isNonnull() && it->second.isAvailable() ) {
68  if ( it->second == objectRef ) {
69  theCands.push_back( it->first );
70  }
71  }
72  ++it;
73  }
74  }
75  return theCands;
76 }
77 
78 // ... by matcher module label
79 reco::CandidateBaseRefVector TriggerMatchHelper::triggerMatchCandidates( const TriggerObjectRef & objectRef, const std::string & labelMatcher, const edm::Event & event, const TriggerEvent & triggerEvent ) const
80 {
81  return triggerMatchCandidates( objectRef, triggerEvent.triggerObjectMatchResult( labelMatcher ), event, triggerEvent );
82 }
83 
84 
85 // Get a vector of references to the phyics objects matched to a certain trigger object given by a collection and index for a certain matcher module
86 
87 // ... by resulting association
88 reco::CandidateBaseRefVector TriggerMatchHelper::triggerMatchCandidates( const edm::Handle< TriggerObjectCollection > & trigCollHandle, const size_t iTrig, const TriggerObjectMatch * matchResult, const edm::Event & event, const TriggerEvent & triggerEvent ) const
89 {
90  return triggerMatchCandidates( TriggerObjectRef( trigCollHandle, iTrig ), matchResult, event, triggerEvent );
91 }
92 
93 // ... by matcher module label
94 reco::CandidateBaseRefVector TriggerMatchHelper::triggerMatchCandidates( const edm::Handle< TriggerObjectCollection > & trigCollHandle, const size_t iTrig, const std::string & labelMatcher, const edm::Event & event, const TriggerEvent & triggerEvent ) const
95 {
96  return triggerMatchCandidates( TriggerObjectRef( trigCollHandle, iTrig ), triggerEvent.triggerObjectMatchResult( labelMatcher ), event, triggerEvent );
97 }
TriggerObjectRef triggerMatchObject(const reco::CandidateBaseRef &candRef, const TriggerObjectMatch *matchResult, const edm::Event &event, const TriggerEvent &triggerEvent) const
Methods.
std::vector< std::string > triggerMatchers() const
Get a list of all linked trigger matches.
TriggerObjectMatchMap triggerMatchObjects(const reco::CandidateBaseRef &candRef, const edm::Event &event, const TriggerEvent &triggerEvent) const
Get a table of references to all trigger objects matched to a certain physics object given by a refer...
const_iterator end() const
std::map< std::string, TriggerObjectRef > TriggerObjectMatchMap
Container to store match references from different producers (for one PAT object) ...
ProductID id() const
Definition: RefToBase.h:242
Definition: HeavyIon.h:7
size_t key() const
Definition: RefToBase.h:250
edm::Ref< TriggerObjectCollection > TriggerObjectRef
Persistent reference to an item in a TriggerObjectCollection.
const TriggerObjectMatch * triggerObjectMatchResult(const std::string &labelMatcher) const
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
Analysis-level trigger event class.
Definition: TriggerEvent.h:42
void push_back(const RefToBase< T > &)
reco::CandidateBaseRefVector triggerMatchCandidates(const pat::TriggerObjectRef &objectRef, const TriggerObjectMatch *matchResult, const edm::Event &event, const TriggerEvent &triggerEvent) const
Definition: event.py:1