File indexing completed on 2024-04-06 12:18:19
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "HLTEgammaAllCombMassFilter.h"
0010
0011 #include "DataFormats/Common/interface/Handle.h"
0012
0013 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0014 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0015 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0016
0017 #include "DataFormats/RecoCandidate/interface/RecoEcalCandidate.h"
0018 #include "DataFormats/EgammaCandidates/interface/Electron.h"
0019
0020
0021
0022
0023 HLTEgammaAllCombMassFilter::HLTEgammaAllCombMassFilter(const edm::ParameterSet& iConfig) : HLTFilter(iConfig) {
0024 firstLegLastFilterTag_ = iConfig.getParameter<edm::InputTag>("firstLegLastFilter");
0025 secondLegLastFilterTag_ = iConfig.getParameter<edm::InputTag>("secondLegLastFilter");
0026 minMass_ = iConfig.getParameter<double>("minMass");
0027 firstLegLastFilterToken_ = consumes<trigger::TriggerFilterObjectWithRefs>(firstLegLastFilterTag_);
0028 secondLegLastFilterToken_ = consumes<trigger::TriggerFilterObjectWithRefs>(secondLegLastFilterTag_);
0029 }
0030
0031 HLTEgammaAllCombMassFilter::~HLTEgammaAllCombMassFilter() = default;
0032
0033 void HLTEgammaAllCombMassFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0034 edm::ParameterSetDescription desc;
0035 makeHLTFilterDescription(desc);
0036 desc.add<edm::InputTag>("firstLegLastFilter", edm::InputTag("firstFilter"));
0037 desc.add<edm::InputTag>("secondLegLastFilter", edm::InputTag("secondFilter"));
0038 desc.add<double>("minMass", -1.0);
0039 descriptions.add("hltEgammaAllCombMassFilter", desc);
0040 }
0041
0042
0043
0044 bool HLTEgammaAllCombMassFilter::hltFilter(edm::Event& iEvent,
0045 const edm::EventSetup& iSetup,
0046 trigger::TriggerFilterObjectWithRefs& filterproduct) const {
0047
0048
0049
0050 std::vector<math::XYZTLorentzVector> firstLegP4s;
0051
0052
0053 std::vector<math::XYZTLorentzVector> secondLegP4s;
0054
0055 math::XYZTLorentzVector pairP4;
0056
0057 getP4OfLegCands(iEvent, firstLegLastFilterToken_, firstLegP4s);
0058 getP4OfLegCands(iEvent, secondLegLastFilterToken_, secondLegP4s);
0059
0060 bool accept = false;
0061 for (auto& firstLegP4 : firstLegP4s) {
0062 for (auto& secondLegP4 : secondLegP4s) {
0063 math::XYZTLorentzVector pairP4 = firstLegP4 + secondLegP4;
0064 double mass = pairP4.M();
0065 if (mass >= minMass_)
0066 accept = true;
0067 }
0068 }
0069 for (size_t firstLegNr = 0; firstLegNr < firstLegP4s.size(); firstLegNr++) {
0070 for (size_t secondLegNr = 0; secondLegNr < firstLegP4s.size(); secondLegNr++) {
0071 math::XYZTLorentzVector pairP4 = firstLegP4s[firstLegNr] + firstLegP4s[secondLegNr];
0072 double mass = pairP4.M();
0073 if (mass >= minMass_)
0074 accept = true;
0075 }
0076 }
0077 for (size_t firstLegNr = 0; firstLegNr < secondLegP4s.size(); firstLegNr++) {
0078 for (size_t secondLegNr = 0; secondLegNr < secondLegP4s.size(); secondLegNr++) {
0079 math::XYZTLorentzVector pairP4 = secondLegP4s[firstLegNr] + secondLegP4s[secondLegNr];
0080 double mass = pairP4.M();
0081 if (mass >= minMass_)
0082 accept = true;
0083 }
0084 }
0085
0086 return accept;
0087 }
0088
0089 void HLTEgammaAllCombMassFilter::getP4OfLegCands(
0090 const edm::Event& iEvent,
0091 const edm::EDGetTokenT<trigger::TriggerFilterObjectWithRefs>& filterToken,
0092 std::vector<math::XYZTLorentzVector>& p4s) {
0093 edm::Handle<trigger::TriggerFilterObjectWithRefs> filterOutput;
0094 iEvent.getByToken(filterToken, filterOutput);
0095
0096
0097 std::vector<edm::Ref<reco::RecoEcalCandidateCollection> > phoCands;
0098 filterOutput->getObjects(trigger::TriggerPhoton, phoCands);
0099 std::vector<edm::Ref<reco::RecoEcalCandidateCollection> > clusCands;
0100 filterOutput->getObjects(trigger::TriggerCluster, clusCands);
0101 std::vector<edm::Ref<reco::ElectronCollection> > eleCands;
0102 filterOutput->getObjects(trigger::TriggerElectron, eleCands);
0103
0104 if (!phoCands.empty()) {
0105 for (auto& phoCand : phoCands) {
0106 p4s.push_back(phoCand->p4());
0107 }
0108 } else if (!clusCands.empty()) {
0109
0110 for (auto& clusCand : clusCands) {
0111 p4s.push_back(clusCand->p4());
0112 }
0113 } else if (!eleCands.empty()) {
0114 for (auto& eleCand : eleCands) {
0115 p4s.push_back(eleCand->p4());
0116 }
0117 }
0118 }
0119
0120
0121 #include "FWCore/Framework/interface/MakerMacros.h"
0122 DEFINE_FWK_MODULE(HLTEgammaAllCombMassFilter);