File indexing completed on 2024-04-06 12:18:27
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include "HLTFiltCand.h"
0011 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0012
0013 #include "DataFormats/Common/interface/Handle.h"
0014
0015 #include "DataFormats/RecoCandidate/interface/RecoEcalCandidate.h"
0016 #include "DataFormats/RecoCandidate/interface/RecoEcalCandidateFwd.h"
0017 #include "DataFormats/EgammaCandidates/interface/Electron.h"
0018 #include "DataFormats/EgammaCandidates/interface/ElectronFwd.h"
0019 #include "DataFormats/RecoCandidate/interface/RecoChargedCandidate.h"
0020 #include "DataFormats/RecoCandidate/interface/RecoChargedCandidateFwd.h"
0021 #include "DataFormats/JetReco/interface/CaloJet.h"
0022 #include "DataFormats/JetReco/interface/CaloJetCollection.h"
0023 #include "DataFormats/Candidate/interface/CompositeCandidate.h"
0024 #include "DataFormats/Candidate/interface/CompositeCandidateFwd.h"
0025 #include "DataFormats/METReco/interface/CaloMET.h"
0026 #include "DataFormats/METReco/interface/CaloMETFwd.h"
0027 #include "DataFormats/METReco/interface/MET.h"
0028 #include "DataFormats/METReco/interface/METFwd.h"
0029
0030 #include "DataFormats/JetReco/interface/GenJet.h"
0031 #include "DataFormats/JetReco/interface/GenJetCollection.h"
0032 #include "DataFormats/METReco/interface/GenMET.h"
0033 #include "DataFormats/METReco/interface/GenMETCollection.h"
0034
0035 #include "DataFormats/Common/interface/Ref.h"
0036 #include "DataFormats/HLTReco/interface/TriggerFilterObjectWithRefs.h"
0037
0038 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0039
0040
0041
0042
0043
0044 HLTFiltCand::HLTFiltCand(const edm::ParameterSet& iConfig)
0045 : HLTFilter(iConfig),
0046 photTag_(iConfig.getParameter<edm::InputTag>("photTag")),
0047 elecTag_(iConfig.getParameter<edm::InputTag>("elecTag")),
0048 muonTag_(iConfig.getParameter<edm::InputTag>("muonTag")),
0049 tausTag_(iConfig.getParameter<edm::InputTag>("tausTag")),
0050 jetsTag_(iConfig.getParameter<edm::InputTag>("jetsTag")),
0051 metsTag_(iConfig.getParameter<edm::InputTag>("metsTag")),
0052 mhtsTag_(iConfig.getParameter<edm::InputTag>("mhtsTag")),
0053 trckTag_(iConfig.getParameter<edm::InputTag>("trckTag")),
0054 ecalTag_(iConfig.getParameter<edm::InputTag>("ecalTag")),
0055 photToken_(consumes<reco::RecoEcalCandidateCollection>(photTag_)),
0056 elecToken_(consumes<reco::ElectronCollection>(elecTag_)),
0057 muonToken_(consumes<reco::RecoChargedCandidateCollection>(muonTag_)),
0058 tausToken_(consumes<reco::CaloJetCollection>(tausTag_)),
0059 jetsToken_(consumes<reco::CaloJetCollection>(jetsTag_)),
0060 metsToken_(consumes<reco::CaloMETCollection>(metsTag_)),
0061 mhtsToken_(consumes<reco::METCollection>(mhtsTag_)),
0062 trckToken_(consumes<reco::RecoChargedCandidateCollection>(trckTag_)),
0063 ecalToken_(consumes<reco::RecoEcalCandidateCollection>(ecalTag_)),
0064 min_Pt_(iConfig.getParameter<double>("MinPt")) {
0065 LogDebug("") << "MinPt cut " << min_Pt_ << " g: " << photTag_.encode() << " e: " << elecTag_.encode()
0066 << " m: " << muonTag_.encode() << " t: " << tausTag_.encode() << " j: " << jetsTag_.encode()
0067 << " M: " << metsTag_.encode() << " H: " << mhtsTag_.encode() << " TR: " << trckTag_.encode()
0068 << " SC: " << ecalTag_.encode();
0069 }
0070
0071 HLTFiltCand::~HLTFiltCand() = default;
0072
0073
0074
0075
0076
0077 void HLTFiltCand::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0078 edm::ParameterSetDescription desc;
0079 makeHLTFilterDescription(desc);
0080 desc.add<edm::InputTag>("photTag", edm::InputTag("photCollection"));
0081 desc.add<edm::InputTag>("elecTag", edm::InputTag("elecCollection"));
0082 desc.add<edm::InputTag>("muonTag", edm::InputTag("muonCollection"));
0083 desc.add<edm::InputTag>("tausTag", edm::InputTag("tausCollection"));
0084 desc.add<edm::InputTag>("jetsTag", edm::InputTag("jetsCollection"));
0085 desc.add<edm::InputTag>("metsTag", edm::InputTag("metsCollection"));
0086 desc.add<edm::InputTag>("mhtsTag", edm::InputTag("mhtsCollection"));
0087 desc.add<edm::InputTag>("trckTag", edm::InputTag("trckCollection"));
0088 desc.add<edm::InputTag>("ecalTag", edm::InputTag("ecalCollection"));
0089 desc.add<double>("MinPt", -1.0);
0090 descriptions.add("hltFiltCand", desc);
0091 }
0092
0093
0094 bool HLTFiltCand::hltFilter(edm::Event& iEvent,
0095 const edm::EventSetup& iSetup,
0096 trigger::TriggerFilterObjectWithRefs& filterproduct) const {
0097 using namespace std;
0098 using namespace edm;
0099 using namespace reco;
0100 using namespace trigger;
0101
0102
0103
0104
0105
0106
0107 if (saveTags()) {
0108 filterproduct.addCollectionTag(photTag_);
0109 filterproduct.addCollectionTag(elecTag_);
0110 filterproduct.addCollectionTag(muonTag_);
0111 filterproduct.addCollectionTag(tausTag_);
0112 filterproduct.addCollectionTag(jetsTag_);
0113 filterproduct.addCollectionTag(metsTag_);
0114 filterproduct.addCollectionTag(mhtsTag_);
0115 filterproduct.addCollectionTag(trckTag_);
0116 filterproduct.addCollectionTag(ecalTag_);
0117 }
0118
0119
0120
0121
0122
0123 Handle<RecoEcalCandidateCollection> photons;
0124 Handle<ElectronCollection> electrons;
0125 Handle<RecoChargedCandidateCollection> muons;
0126 Handle<CaloJetCollection> taus;
0127 Handle<CaloJetCollection> jets;
0128 Handle<CaloMETCollection> mets;
0129 Handle<METCollection> mhts;
0130 Handle<RecoChargedCandidateCollection> trcks;
0131 Handle<RecoEcalCandidateCollection> ecals;
0132
0133 iEvent.getByToken(photToken_, photons);
0134 iEvent.getByToken(elecToken_, electrons);
0135 iEvent.getByToken(muonToken_, muons);
0136 iEvent.getByToken(tausToken_, taus);
0137 iEvent.getByToken(jetsToken_, jets);
0138 iEvent.getByToken(metsToken_, mets);
0139 iEvent.getByToken(mhtsToken_, mhts);
0140 iEvent.getByToken(trckToken_, trcks);
0141 iEvent.getByToken(ecalToken_, ecals);
0142
0143
0144
0145
0146 int nphot(0);
0147 auto aphot(photons->begin());
0148 auto ophot(photons->end());
0149 RecoEcalCandidateCollection::const_iterator iphot;
0150 for (iphot = aphot; iphot != ophot; iphot++) {
0151 if (iphot->pt() >= min_Pt_) {
0152 nphot++;
0153 RecoEcalCandidateRef ref(RecoEcalCandidateRef(photons, distance(aphot, iphot)));
0154 filterproduct.addObject(TriggerPhoton, ref);
0155 }
0156 }
0157
0158
0159 int nelec(0);
0160 auto aelec(electrons->begin());
0161 auto oelec(electrons->end());
0162 ElectronCollection::const_iterator ielec;
0163 for (ielec = aelec; ielec != oelec; ielec++) {
0164 if (ielec->pt() >= min_Pt_) {
0165 nelec++;
0166 ElectronRef ref(ElectronRef(electrons, distance(aelec, ielec)));
0167 filterproduct.addObject(-TriggerElectron, ref);
0168 }
0169 }
0170
0171
0172 int nmuon(0);
0173 auto amuon(muons->begin());
0174 auto omuon(muons->end());
0175 RecoChargedCandidateCollection::const_iterator imuon;
0176 for (imuon = amuon; imuon != omuon; imuon++) {
0177 if (imuon->pt() >= min_Pt_) {
0178 nmuon++;
0179 RecoChargedCandidateRef ref(RecoChargedCandidateRef(muons, distance(amuon, imuon)));
0180 filterproduct.addObject(TriggerMuon, ref);
0181 }
0182 }
0183
0184
0185 int ntaus(0);
0186 auto ataus(taus->begin());
0187 auto otaus(taus->end());
0188 CaloJetCollection::const_iterator itaus;
0189 for (itaus = ataus; itaus != otaus; itaus++) {
0190 if (itaus->pt() >= min_Pt_) {
0191 ntaus++;
0192 CaloJetRef ref(CaloJetRef(taus, distance(ataus, itaus)));
0193 filterproduct.addObject(-TriggerTau, ref);
0194 }
0195 }
0196
0197
0198 int njets(0);
0199 auto ajets(jets->begin());
0200 auto ojets(jets->end());
0201 CaloJetCollection::const_iterator ijets;
0202 for (ijets = ajets; ijets != ojets; ijets++) {
0203 if (ijets->pt() >= min_Pt_) {
0204 njets++;
0205 CaloJetRef ref(CaloJetRef(jets, distance(ajets, ijets)));
0206 filterproduct.addObject(TriggerJet, ref);
0207 }
0208 }
0209
0210
0211 int nmets(0);
0212 auto amets(mets->begin());
0213 auto omets(mets->end());
0214 CaloMETCollection::const_iterator imets;
0215 for (imets = amets; imets != omets; imets++) {
0216 if (imets->pt() >= min_Pt_) {
0217 nmets++;
0218 CaloMETRef ref(CaloMETRef(mets, distance(amets, imets)));
0219 filterproduct.addObject(TriggerMET, ref);
0220 }
0221 }
0222
0223
0224 int nmhts(0);
0225 auto amhts(mhts->begin());
0226 auto omhts(mhts->end());
0227 METCollection::const_iterator imhts;
0228 for (imhts = amhts; imhts != omhts; imhts++) {
0229 if (imhts->pt() >= min_Pt_) {
0230 nmhts++;
0231 METRef ref(METRef(mhts, distance(amhts, imhts)));
0232 filterproduct.addObject(TriggerMHT, ref);
0233 }
0234 }
0235
0236
0237 int ntrck(0);
0238 auto atrcks(trcks->begin());
0239 auto otrcks(trcks->end());
0240 RecoChargedCandidateCollection::const_iterator itrcks;
0241 for (itrcks = atrcks; itrcks != otrcks; itrcks++) {
0242 if (itrcks->pt() >= min_Pt_) {
0243 ntrck++;
0244 RecoChargedCandidateRef ref(RecoChargedCandidateRef(trcks, distance(atrcks, itrcks)));
0245 filterproduct.addObject(TriggerTrack, ref);
0246 }
0247 }
0248
0249
0250 int necal(0);
0251 auto aecals(ecals->begin());
0252 auto oecals(ecals->end());
0253 RecoEcalCandidateCollection::const_iterator iecals;
0254 for (iecals = aecals; iecals != oecals; iecals++) {
0255 if (iecals->pt() >= min_Pt_) {
0256 necal++;
0257 RecoEcalCandidateRef ref(RecoEcalCandidateRef(ecals, distance(aecals, iecals)));
0258 filterproduct.addObject(TriggerCluster, ref);
0259 }
0260 }
0261
0262
0263
0264
0265
0266 const bool accept((nphot > 0) && (nelec > 0) && (nmuon > 0) && (ntaus > 0) &&
0267
0268 (njets > 0) && (nmets > 0) && (ntrck > 0) && (necal > 0));
0269
0270 LogDebug("") << "Number of g/e/m/t/j/M/H/TR/SC objects accepted:"
0271 << " " << nphot << " " << nelec << " " << nmuon << " " << ntaus << " " << njets << " " << nmets << " "
0272 << nmhts << " " << ntrck << " " << necal;
0273
0274
0275 return accept;
0276 }