File indexing completed on 2024-04-06 12:18:20
0001
0002
0003
0004
0005
0006
0007
0008 #include "HLTEgammaDoubleEtFilter.h"
0009
0010 #include "DataFormats/Common/interface/Handle.h"
0011
0012 #include "DataFormats/HLTReco/interface/TriggerFilterObjectWithRefs.h"
0013
0014 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0015 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0016 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0017
0018 #include "DataFormats/RecoCandidate/interface/RecoEcalCandidate.h"
0019
0020 class EgammaHLTEtSortCriterium {
0021 public:
0022 bool operator()(edm::Ref<reco::RecoEcalCandidateCollection> lhs, edm::Ref<reco::RecoEcalCandidateCollection> rhs) {
0023 return lhs->et() > rhs->et();
0024 }
0025 };
0026
0027
0028
0029
0030 HLTEgammaDoubleEtFilter::HLTEgammaDoubleEtFilter(const edm::ParameterSet& iConfig) : HLTFilter(iConfig) {
0031 candTag_ = iConfig.getParameter<edm::InputTag>("candTag");
0032 etcut1_ = iConfig.getParameter<double>("etcut1");
0033 etcut2_ = iConfig.getParameter<double>("etcut2");
0034 npaircut_ = iConfig.getParameter<int>("npaircut");
0035 l1EGTag_ = iConfig.getParameter<edm::InputTag>("l1EGCand");
0036 candToken_ = consumes<trigger::TriggerFilterObjectWithRefs>(candTag_);
0037 }
0038
0039 HLTEgammaDoubleEtFilter::~HLTEgammaDoubleEtFilter() = default;
0040
0041 void HLTEgammaDoubleEtFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0042 edm::ParameterSetDescription desc;
0043 makeHLTFilterDescription(desc);
0044 desc.add<edm::InputTag>("candTag", edm::InputTag("hltTrackIsolFilter"));
0045 desc.add<edm::InputTag>("l1EGCand", edm::InputTag("hltL1IsoRecoEcalCandidate"));
0046 desc.add<double>("etcut1", 30.0);
0047 desc.add<double>("etcut2", 20.0);
0048 desc.add<int>("npaircut", 1);
0049 descriptions.add("hltEgammaDoubleEtFilter", desc);
0050 }
0051
0052
0053 bool HLTEgammaDoubleEtFilter::hltFilter(edm::Event& iEvent,
0054 const edm::EventSetup& iSetup,
0055 trigger::TriggerFilterObjectWithRefs& filterproduct) const {
0056 using namespace trigger;
0057
0058
0059 if (saveTags()) {
0060 filterproduct.addCollectionTag(l1EGTag_);
0061 }
0062
0063 edm::Handle<trigger::TriggerFilterObjectWithRefs> PrevFilterOutput;
0064 iEvent.getByToken(candToken_, PrevFilterOutput);
0065
0066 std::vector<edm::Ref<reco::RecoEcalCandidateCollection> > mysortedrecoecalcands;
0067 PrevFilterOutput->getObjects(TriggerPhoton, mysortedrecoecalcands);
0068 if (mysortedrecoecalcands.empty())
0069 PrevFilterOutput->getObjects(TriggerCluster,
0070 mysortedrecoecalcands);
0071
0072
0073 int n(0);
0074
0075
0076 std::sort(mysortedrecoecalcands.begin(), mysortedrecoecalcands.end(), EgammaHLTEtSortCriterium());
0077 edm::Ref<reco::RecoEcalCandidateCollection> ref1, ref2;
0078 for (unsigned int i = 0; i < mysortedrecoecalcands.size(); i++) {
0079 ref1 = mysortedrecoecalcands[i];
0080 if (ref1->et() >= etcut1_) {
0081 for (unsigned int j = i + 1; j < mysortedrecoecalcands.size(); j++) {
0082 ref2 = mysortedrecoecalcands[j];
0083 if (ref2->et() >= etcut2_) {
0084 filterproduct.addObject(TriggerPhoton, ref1);
0085 filterproduct.addObject(TriggerPhoton, ref2);
0086 n++;
0087 }
0088 }
0089 }
0090 }
0091
0092
0093 bool accept(n >= npaircut_);
0094
0095 return accept;
0096 }
0097
0098
0099 #include "FWCore/Framework/interface/MakerMacros.h"
0100 DEFINE_FWK_MODULE(HLTEgammaDoubleEtFilter);