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 // $Id: TriggerHelper.cc,v 1.5 2011/04/05 19:41:33 vadler Exp $
3 //
4 
5 
7 
9 
10 
11 using namespace pat;
12 using namespace pat::helper;
13 
14 
15 
16 // Methods
17 
18 
19 // Get a reference to the trigger objects matched to a certain physics object given by a reference for a certain matcher module
20 
21 // ... by resulting association
22 TriggerObjectRef TriggerMatchHelper::triggerMatchObject( const reco::CandidateBaseRef & candRef, const TriggerObjectMatch * matchResult, const edm::Event & event, const TriggerEvent & triggerEvent ) const
23 {
24  if ( matchResult ) {
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
46 TriggerObjectMatchMap TriggerMatchHelper::triggerMatchObjects( const reco::CandidateBaseRef & candRef, const edm::Event & event, const TriggerEvent & triggerEvent ) const
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
60 reco::CandidateBaseRefVector TriggerMatchHelper::triggerMatchCandidates( const TriggerObjectRef & objectRef, const TriggerObjectMatch * matchResult, const edm::Event & event, const TriggerEvent & triggerEvent ) const
61 {
63  if ( matchResult ) {
65  while ( it != itEnd ) {
66  if ( it->first.isNonnull() && it->second.isNonnull() && it->second.isAvailable() ) {
67  if ( it->second == objectRef ) {
68  theCands.push_back( it->first );
69  }
70  }
71  ++it;
72  }
73  }
74  return theCands;
75 }
76 
77 // ... by matcher module label
78 reco::CandidateBaseRefVector TriggerMatchHelper::triggerMatchCandidates( const TriggerObjectRef & objectRef, const std::string & labelMatcher, const edm::Event & event, const TriggerEvent & triggerEvent ) const
79 {
80  return triggerMatchCandidates( objectRef, triggerEvent.triggerObjectMatchResult( labelMatcher ), event, triggerEvent );
81 }
82 
83 
84 // 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
85 
86 // ... by resulting association
87 reco::CandidateBaseRefVector TriggerMatchHelper::triggerMatchCandidates( const edm::Handle< TriggerObjectCollection > & trigCollHandle, const size_t iTrig, const TriggerObjectMatch * matchResult, const edm::Event & event, const TriggerEvent & triggerEvent ) const
88 {
89  return triggerMatchCandidates( TriggerObjectRef( trigCollHandle, iTrig ), matchResult, event, triggerEvent );
90 }
91 
92 // ... by matcher module label
93 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
94 {
95  return triggerMatchCandidates( TriggerObjectRef( trigCollHandle, iTrig ), triggerEvent.triggerObjectMatchResult( labelMatcher ), event, triggerEvent );
96 }
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:220
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
size_t key() const
Definition: RefToBase.h:228
Analysis-level trigger event class.
Definition: TriggerEvent.h:44
void push_back(const RefToBase< T > &)