CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TriggerObject.cc
Go to the documentation of this file.
1 //
2 // $Id: TriggerObject.cc,v 1.12 2010/12/20 20:05:52 vadler Exp $
3 //
4 
6 
8 
9 
10 using namespace pat;
11 
12 
13 // Constructors and Destructor
14 
15 
16 // Default constructor
18  reco::LeafCandidate()
19 {
20  triggerObjectTypes_.clear();
21 }
22 
23 
24 // Constructor from trigger::TriggerObject
26  reco::LeafCandidate( 0, trigObj.particle().p4(), reco::Particle::Point( 0., 0., 0. ), trigObj.id() ),
27  refToOrig_()
28 {
29  triggerObjectTypes_.clear();
30 }
31 
32 
33 // Constructors from base class object
35  reco::LeafCandidate( leafCand ),
36  refToOrig_()
37 {
38  triggerObjectTypes_.clear();
39 }
40 
41 
42 // Constructors from base candidate reference (for 'l1extra' particles)
44  reco::LeafCandidate( *candRef ),
45  refToOrig_( candRef )
46 {
47  triggerObjectTypes_.clear();
48 }
49 
50 
51 // Constructors from Lorentz-vectors and (optional) PDG ID
53  reco::LeafCandidate( 0, vec, reco::Particle::Point( 0., 0., 0. ), id ),
54  refToOrig_()
55 {
56  triggerObjectTypes_.clear();
57 }
59  reco::LeafCandidate( 0, vec, reco::Particle::Point( 0., 0., 0. ), id ),
60  refToOrig_()
61 {
62  triggerObjectTypes_.clear();
63 }
64 
65 
66 // Methods
67 
68 
69 // Get all trigger object type identifiers
70 std::vector< int > TriggerObject::triggerObjectTypes() const
71 {
72  std::vector< int > triggerObjectTypes;
73  for ( size_t iTo = 0; iTo < triggerObjectTypes_.size(); ++iTo ) {
74  triggerObjectTypes.push_back( triggerObjectTypes_.at( iTo ) );
75  }
76  return triggerObjectTypes;
77 }
78 
79 
80 // Checks, if a certain label of original collection is assigned
81 bool TriggerObject::hasCollection( const std::string & collName ) const
82 {
83  // True, if collection name is simply fine
84  if ( collName == collection_ ) return true;
85  // Check, if collection name possibly fits in an edm::InputTag approach
86  const edm::InputTag collectionTag( collection_ );
87  const edm::InputTag collTag( collName );
88  // If evaluated collection tag contains a process name, it must have been found already by identity check
89  if ( collTag.process().empty() ) {
90  // Check instance ...
91  if ( ( collTag.instance().empty() && collectionTag.instance().empty() ) || collTag.instance() == collectionTag.instance() ) {
92  // ... and label
93  return ( collTag.label() == collectionTag.label() );
94  }
95  }
96  return false;
97 }
98 
99 
100 // Checks, if a certain trigger object type identifier is assigned
102 {
103  for ( size_t iF = 0; iF < triggerObjectTypes_.size(); ++iF ) {
104  if ( triggerObjectType == triggerObjectTypes_.at( iF ) ) return true;
105  }
106  return false;
107 }
108 
109 
110 // Special methods for 'l1extra' particles
111 
112 
113 // Getters specific to the 'l1extra' particle types
114 // Exceptions of type 'edm::errors::InvalidReference' are thrown,
115 // if wrong particle type is requested
116 
117 // EM
119 {
121  try {
123  } catch ( edm::Exception X ) {
124  if ( X.categoryCode() != edm::errors::InvalidReference ) throw X;
125  }
126  return l1Ref;
127 }
128 
129 // EtMiss
131 {
133  try {
135  } catch ( edm::Exception X ) {
136  if ( X.categoryCode() != edm::errors::InvalidReference ) throw X;
137  }
138  return l1Ref;
139 }
140 
141 // Jet
143 {
145  try {
147  } catch ( edm::Exception X ) {
148  if ( X.categoryCode() != edm::errors::InvalidReference ) throw X;
149  }
150  return l1Ref;
151 }
152 
153 // Muon
155 {
157  try {
159  } catch ( edm::Exception X ) {
160  if ( X.categoryCode() != edm::errors::InvalidReference ) throw X;
161  }
162  return l1Ref;
163 }
Code categoryCode() const
Definition: EDMException.h:94
std::string collection_
Data Members.
Definition: TriggerObject.h:54
std::vector< trigger::TriggerObjectType > triggerObjectTypes_
Definition: TriggerObject.h:58
const l1extra::L1MuonParticleRef origL1MuonRef() const
bool hasTriggerObjectType(trigger::TriggerObjectType triggerObjectType) const
Checks, if a certain trigger object type identifier is assigned.
const l1extra::L1EtMissParticleRef origL1EtMissRef() const
#define X(str)
Definition: MuonsGrabber.cc:49
const l1extra::L1EmParticleRef origL1EmRef() const
Single trigger physics object (e.g., an isolated muon)
Definition: TriggerObject.h:24
TriggerObject()
Constructors and Destructor.
double p4[4]
Definition: TauolaWrapper.h:92
virtual bool hasCollection(const std::string &collName) const
Checks, if a certain label of original collection is assigned.
Analysis-level particle class.
Definition: Particle.h:34
REF castTo() const
cast to a concrete type
Definition: RefToBase.h:241
const l1extra::L1JetParticleRef origL1JetRef() const
std::string const & label() const
Definition: InputTag.h:42
std::string const & process() const
Definition: InputTag.h:46
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition: Particle.h:27
const reco::CandidateBaseRef & origObjRef() const
Special methods for &#39;l1extra&#39; particles.
std::vector< int > triggerObjectTypes() const
Get all trigger object type identifiers.
math::XYZPoint Point
point in the space
Definition: Candidate.h:45
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:25
std::string const & instance() const
Definition: InputTag.h:43