test
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 //
3 
5 
7 
8 
9 using namespace pat;
10 
11 
12 // Constructors and Destructor
13 
14 
15 // Default constructor
17  reco::LeafCandidate()
18 {
19  triggerObjectTypes_.clear();
20 }
21 
22 
23 // Constructor from trigger::TriggerObject
25  reco::LeafCandidate( 0, trigObj.particle().p4(), reco::Particle::Point( 0., 0., 0. ), trigObj.id() ),
26  refToOrig_()
27 {
28  triggerObjectTypes_.clear();
29 }
30 
31 
32 // Constructors from base class object
34  reco::LeafCandidate( leafCand ),
35  refToOrig_()
36 {
37  triggerObjectTypes_.clear();
38 }
39 
40 
41 // Constructors from base candidate reference (for 'l1extra' particles)
43  reco::LeafCandidate( *candRef ),
44  refToOrig_( candRef )
45 {
46  triggerObjectTypes_.clear();
47 }
48 
49 
50 // Constructors from Lorentz-vectors and (optional) PDG ID
52  reco::LeafCandidate( 0, vec, reco::Particle::Point( 0., 0., 0. ), id ),
53  refToOrig_()
54 {
55  triggerObjectTypes_.clear();
56 }
58  reco::LeafCandidate( 0, vec, reco::Particle::Point( 0., 0., 0. ), id ),
59  refToOrig_()
60 {
61  triggerObjectTypes_.clear();
62 }
63 
64 
65 // Methods
66 
67 
68 // Get all trigger object type identifiers
69 std::vector< int > TriggerObject::triggerObjectTypes() const
70 {
71  std::vector< int > triggerObjectTypes;
72  for ( size_t iTo = 0; iTo < triggerObjectTypes_.size(); ++iTo ) {
73  triggerObjectTypes.push_back( triggerObjectTypes_.at( iTo ) );
74  }
75  return triggerObjectTypes;
76 }
77 
78 
79 // Checks, if a certain label of original collection is assigned
80 bool TriggerObject::hasCollection( const std::string & collName ) const
81 {
82  // True, if collection name is simply fine
83  if ( collName == collection_ ) return true;
84  // Check, if collection name possibly fits in an edm::InputTag approach
85  const edm::InputTag collectionTag( collection_ );
86  const edm::InputTag collTag( collName );
87  // If evaluated collection tag contains a process name, it must have been found already by identity check
88  if ( collTag.process().empty() ) {
89  // Check instance ...
90  if ( ( collTag.instance().empty() && collectionTag.instance().empty() ) || collTag.instance() == collectionTag.instance() ) {
91  // ... and label
92  return ( collTag.label() == collectionTag.label() );
93  }
94  }
95  return false;
96 }
97 
98 
99 // Checks, if a certain trigger object type identifier is assigned
101 {
102  for ( size_t iF = 0; iF < triggerObjectTypes_.size(); ++iF ) {
103  if ( triggerObjectType == triggerObjectTypes_.at( iF ) ) return true;
104  }
105  return false;
106 }
107 
108 
109 // Special methods for 'l1extra' particles
110 
111 
112 // Getters specific to the 'l1extra' particle types
113 // Exceptions of type 'edm::errors::InvalidReference' are thrown,
114 // if wrong particle type is requested
115 
116 // EM
118 {
120  try {
122  } catch ( edm::Exception X ) {
123  if ( X.categoryCode() != edm::errors::InvalidReference ) throw X;
124  }
125  return l1Ref;
126 }
127 
128 // EtMiss
130 {
132  try {
134  } catch ( edm::Exception X ) {
135  if ( X.categoryCode() != edm::errors::InvalidReference ) throw X;
136  }
137  return l1Ref;
138 }
139 
140 // Jet
142 {
144  try {
146  } catch ( edm::Exception X ) {
147  if ( X.categoryCode() != edm::errors::InvalidReference ) throw X;
148  }
149  return l1Ref;
150 }
151 
152 // Muon
154 {
156  try {
158  } catch ( edm::Exception X ) {
159  if ( X.categoryCode() != edm::errors::InvalidReference ) throw X;
160  }
161  return l1Ref;
162 }
Code categoryCode() const
Definition: EDMException.h:96
std::string collection_
Data Members.
Definition: TriggerObject.h:52
std::vector< trigger::TriggerObjectType > triggerObjectTypes_
Definition: TriggerObject.h:56
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:48
const l1extra::L1EmParticleRef origL1EmRef() const
Single trigger physics object (e.g., an isolated muon)
Definition: TriggerObject.h:22
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:32
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:29
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:27
std::string const & instance() const
Definition: InputTag.h:43