CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 ) {
25  while ( it != itEnd ) {
26  if ( it->first.isNonnull() && it->second.isNonnull() && it->second.isAvailable() ) {
27  if ( it->first.id() == candRef.id() && it->first.key() == candRef.key() ) {
28  return TriggerObjectRef( it->second );
29  }
30  }
31  ++it;
32  }
33  }
34  return TriggerObjectRef();
35 }
36 
37 // ... by matcher module label
38 TriggerObjectRef TriggerMatchHelper::triggerMatchObject( const reco::CandidateBaseRef & candRef, const std::string & labelMatcher, const edm::Event & event, const TriggerEvent & triggerEvent ) const
39 {
40  return triggerMatchObject( candRef, triggerEvent.triggerObjectMatchResult( labelMatcher ), event, triggerEvent );
41 }
42 
43 
44 // Get a table of references to all trigger objects matched to a certain physics object given by a reference
45 TriggerObjectMatchMap TriggerMatchHelper::triggerMatchObjects( const reco::CandidateBaseRef & candRef, const edm::Event & event, const TriggerEvent & triggerEvent ) const
46 {
47  TriggerObjectMatchMap theContainer;
48  const std::vector< std::string > matchers( triggerEvent.triggerMatchers() );
49  for ( size_t iMatch = 0; iMatch < matchers.size(); ++iMatch ) {
50  theContainer[ matchers.at( iMatch ) ] = triggerMatchObject( candRef, matchers.at( iMatch ), event, triggerEvent );
51  }
52  return theContainer;
53 }
54 
55 
56 // Get a vector of references to the phyics objects matched to a certain trigger object given by a reference for a certain matcher module
57 
58 // ... by resulting association
59 reco::CandidateBaseRefVector TriggerMatchHelper::triggerMatchCandidates( const TriggerObjectRef & objectRef, const TriggerObjectMatch * matchResult, const edm::Event & event, const TriggerEvent & triggerEvent ) const
60 {
62  if ( matchResult ) {
64  while ( it != itEnd ) {
65  if ( it->first.isNonnull() && it->second.isNonnull() && it->second.isAvailable() ) {
66  if ( it->second == objectRef ) {
67  theCands.push_back( it->first );
68  }
69  }
70  ++it;
71  }
72  }
73  return theCands;
74 }
75 
76 // ... by matcher module label
77 reco::CandidateBaseRefVector TriggerMatchHelper::triggerMatchCandidates( const TriggerObjectRef & objectRef, const std::string & labelMatcher, const edm::Event & event, const TriggerEvent & triggerEvent ) const
78 {
79  return triggerMatchCandidates( objectRef, triggerEvent.triggerObjectMatchResult( labelMatcher ), event, triggerEvent );
80 }
81 
82 
83 // 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
84 
85 // ... by resulting association
86 reco::CandidateBaseRefVector TriggerMatchHelper::triggerMatchCandidates( const edm::Handle< TriggerObjectCollection > & trigCollHandle, const size_t iTrig, const TriggerObjectMatch * matchResult, const edm::Event & event, const TriggerEvent & triggerEvent ) const
87 {
88  return triggerMatchCandidates( TriggerObjectRef( trigCollHandle, iTrig ), matchResult, event, triggerEvent );
89 }
90 
91 // ... by matcher module label
92 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
93 {
94  return triggerMatchCandidates( TriggerObjectRef( trigCollHandle, iTrig ), triggerEvent.triggerObjectMatchResult( labelMatcher ), event, triggerEvent );
95 }
std::vector< std::string > triggerMatchers() const
Get a list of all linked trigger matches.
std::map< std::string, TriggerObjectRef > TriggerObjectMatchMap
Container to store match references from different producers (for one PAT object) ...
ProductID id() const
Definition: RefToBase.h:233
size_t key() const
Definition: RefToBase.h:241
Helper class that fetches some type of Ref given ProductID and index, using the edm::Event.
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 > &)