File indexing completed on 2024-09-07 04:35:56
0001 #ifndef DataFormats_PatCandidates_TriggerObject_h
0002 #define DataFormats_PatCandidates_TriggerObject_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 #include "DataFormats/Candidate/interface/LeafCandidate.h"
0022
0023 #include <map>
0024 #include <string>
0025 #include <vector>
0026 #include <algorithm>
0027
0028 #include "DataFormats/L1Trigger/interface/L1EmParticle.h"
0029 #include "DataFormats/L1Trigger/interface/L1EmParticleFwd.h"
0030 #include "DataFormats/L1Trigger/interface/L1EtMissParticle.h"
0031 #include "DataFormats/L1Trigger/interface/L1EtMissParticleFwd.h"
0032 #include "DataFormats/L1Trigger/interface/L1JetParticle.h"
0033 #include "DataFormats/L1Trigger/interface/L1JetParticleFwd.h"
0034 #include "DataFormats/L1Trigger/interface/L1MuonParticle.h"
0035 #include "DataFormats/L1Trigger/interface/L1MuonParticleFwd.h"
0036 #include "DataFormats/HLTReco/interface/TriggerTypeDefs.h"
0037 #include "DataFormats/HLTReco/interface/TriggerObject.h"
0038 #include "DataFormats/Common/interface/RefVectorIterator.h"
0039 #include "DataFormats/Common/interface/Association.h"
0040 #include "FWCore/Utilities/interface/InputTag.h"
0041
0042 namespace pat {
0043
0044 class TriggerObject : public reco::LeafCandidate {
0045
0046
0047
0048 std::string collection_;
0049
0050
0051
0052 std::vector<trigger::TriggerObjectType> triggerObjectTypes_;
0053
0054
0055
0056 reco::CandidateBaseRef refToOrig_;
0057
0058 public:
0059
0060
0061
0062 TriggerObject();
0063
0064 TriggerObject(const trigger::TriggerObject& trigObj);
0065
0066 TriggerObject(const reco::LeafCandidate& leafCand);
0067
0068 TriggerObject(const reco::CandidateBaseRef& candRef);
0069
0070 TriggerObject(const reco::Particle::LorentzVector& vec, int id = 0);
0071 TriggerObject(const reco::Particle::PolarLorentzVector& vec, int id = 0);
0072
0073
0074 ~TriggerObject() override {}
0075
0076
0077
0078
0079 void setCollection(const std::string& collName) { collection_ = collName; };
0080 void setCollection(const edm::InputTag& collName) { collection_ = collName.encode(); };
0081
0082 void addTriggerObjectType(trigger::TriggerObjectType triggerObjectType) {
0083 if (!hasTriggerObjectType(triggerObjectType))
0084 triggerObjectTypes_.push_back(triggerObjectType);
0085 };
0086 void addTriggerObjectType(int triggerObjectType) {
0087 addTriggerObjectType(trigger::TriggerObjectType(triggerObjectType));
0088 };
0089 void addFilterId(trigger::TriggerObjectType triggerObjectType) {
0090 addTriggerObjectType(triggerObjectType);
0091 };
0092 void addFilterId(int triggerObjectType) {
0093 addTriggerObjectType(trigger::TriggerObjectType(triggerObjectType));
0094 };
0095
0096 const std::string& collection() const { return collection_; };
0097
0098
0099
0100 std::vector<int> triggerObjectTypes() const;
0101 std::vector<int> filterIds() const { return triggerObjectTypes(); };
0102
0103 virtual bool hasCollection(const std::string& collName) const;
0104 virtual bool hasCollection(const edm::InputTag& collName) const { return hasCollection(collName.encode()); };
0105
0106 bool hasTriggerObjectType(trigger::TriggerObjectType triggerObjectType) const;
0107 bool hasTriggerObjectType(int triggerObjectType) const {
0108 return hasTriggerObjectType(trigger::TriggerObjectType(triggerObjectType));
0109 };
0110 bool hasFilterId(trigger::TriggerObjectType triggerObjectType) const {
0111 return hasTriggerObjectType(triggerObjectType);
0112 };
0113 bool hasFilterId(int triggerObjectType) const {
0114 return hasTriggerObjectType(trigger::TriggerObjectType(triggerObjectType));
0115 };
0116
0117
0118
0119
0120 const reco::CandidateBaseRef& origObjRef() const { return refToOrig_; };
0121 const reco::Candidate* origObjCand() const { return refToOrig_.get(); };
0122
0123
0124 const l1extra::L1EmParticleRef origL1EmRef() const;
0125 const L1GctEmCand* origL1GctEmCand() const {
0126 return origL1EmRef().isNonnull() ? origL1EmRef()->gctEmCand() : nullptr;
0127 };
0128
0129 const l1extra::L1EtMissParticleRef origL1EtMissRef() const;
0130 const L1GctEtMiss* origL1GctEtMiss() const {
0131 return origL1EtMissRef().isNonnull() ? origL1EtMissRef()->gctEtMiss() : nullptr;
0132 };
0133 const L1GctEtTotal* origL1GctEtTotal() const {
0134 return origL1EtMissRef().isNonnull() ? origL1EtMissRef()->gctEtTotal() : nullptr;
0135 };
0136 const L1GctHtMiss* origL1GctHtMiss() const {
0137 return origL1EtMissRef().isNonnull() ? origL1EtMissRef()->gctHtMiss() : nullptr;
0138 };
0139 const L1GctEtHad* origL1GctEtHad() const {
0140 return origL1EtMissRef().isNonnull() ? origL1EtMissRef()->gctEtHad() : nullptr;
0141 };
0142
0143 const l1extra::L1JetParticleRef origL1JetRef() const;
0144 const L1GctJetCand* origL1GctJetCand() const {
0145 return origL1JetRef().isNonnull() ? origL1JetRef()->gctJetCand() : nullptr;
0146 };
0147
0148 const l1extra::L1MuonParticleRef origL1MuonRef() const;
0149 const L1MuGMTExtendedCand* origL1GmtMuonCand() const {
0150 return origL1MuonRef().isNonnull() ? &(origL1MuonRef()->gmtMuonCand()) : nullptr;
0151 };
0152
0153
0154
0155
0156
0157
0158 virtual bool coll(const std::string& collName) const { return hasCollection(collName); };
0159
0160 bool type(trigger::TriggerObjectType triggerObjectType) const { return hasTriggerObjectType(triggerObjectType); };
0161 bool type(int triggerObjectType) const {
0162 return hasTriggerObjectType(trigger::TriggerObjectType(triggerObjectType));
0163 };
0164 bool id(trigger::TriggerObjectType triggerObjectType) const {
0165 return hasTriggerObjectType(triggerObjectType);
0166 };
0167 bool id(int triggerObjectType) const {
0168 return hasTriggerObjectType(trigger::TriggerObjectType(triggerObjectType));
0169 };
0170 };
0171
0172
0173 typedef std::vector<TriggerObject> TriggerObjectCollection;
0174
0175 typedef edm::Ref<TriggerObjectCollection> TriggerObjectRef;
0176
0177 typedef std::map<std::string, TriggerObjectRef> TriggerObjectMatchMap;
0178
0179 typedef edm::RefProd<TriggerObjectCollection> TriggerObjectRefProd;
0180
0181 typedef edm::RefVector<TriggerObjectCollection> TriggerObjectRefVector;
0182
0183 typedef edm::RefVectorIterator<TriggerObjectCollection> TriggerObjectRefVectorIterator;
0184
0185 typedef edm::Association<TriggerObjectCollection> TriggerObjectMatch;
0186
0187 typedef edm::RefProd<TriggerObjectMatch> TriggerObjectMatchRefProd;
0188
0189 typedef std::map<std::string, TriggerObjectMatchRefProd> TriggerObjectMatchContainer;
0190
0191 }
0192
0193 #endif