Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a module to do eta filtering for Egamma HLT candidates #39764

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions HLTrigger/Egamma/plugins/HLTEgammaEtaFilter.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/** \class HLTEgammaEtaFilter
*
*
* \author Abanti Ranadhir Sahasransu (VUB, Belgium)
*
*/

#include "HLTEgammaEtaFilter.h"

#include "DataFormats/Common/interface/Handle.h"

#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

#include "DataFormats/RecoCandidate/interface/RecoEcalCandidate.h"

//
// constructors and destructor
//
HLTEgammaEtaFilter::HLTEgammaEtaFilter(const edm::ParameterSet& iConfig) : HLTFilter(iConfig) {
inputTag_ = iConfig.getParameter<edm::InputTag>("inputTag");
minEtacut_ = iConfig.getParameter<double>("minEtaCut");
maxEtacut_ = iConfig.getParameter<double>("maxEtaCut");
ncandcut_ = iConfig.getParameter<int>("ncandcut");
l1EGTag_ = iConfig.getParameter<edm::InputTag>("l1EGCand");
inputToken_ = consumes<trigger::TriggerFilterObjectWithRefs>(inputTag_);
}

void HLTEgammaEtaFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
makeHLTFilterDescription(desc);
desc.add<edm::InputTag>("inputTag", edm::InputTag("HLTEgammaL1MatchFilter"));
desc.add<edm::InputTag>("l1EGCand", edm::InputTag("hltL1IsoRecoEcalCandidate"));
desc.add<double>("minEtaCut", -2.65);
desc.add<double>("maxEtaCut", 2.65);
desc.add<int>("ncandcut", 1);
descriptions.add("hltEgammaEtaFilter", desc);
}

HLTEgammaEtaFilter::~HLTEgammaEtaFilter() = default;

// ------------ method called to produce the data ------------
bool HLTEgammaEtaFilter::hltFilter(edm::Event& iEvent,
const edm::EventSetup& iSetup,
trigger::TriggerFilterObjectWithRefs& filterproduct) const {
using namespace trigger;

// The filter object
if (saveTags()) {
filterproduct.addCollectionTag(l1EGTag_);
;
}

// Ref to Candidate object to be recorded in filter object
edm::Ref<reco::RecoEcalCandidateCollection> ref;

// get hold of filtered candidates
//edm::Handle<reco::HLTFilterObjectWithRefs> recoecalcands;
edm::Handle<trigger::TriggerFilterObjectWithRefs> PrevFilterOutput;
iEvent.getByToken(inputToken_, PrevFilterOutput);

std::vector<edm::Ref<reco::RecoEcalCandidateCollection> > recoecalcands; // vref with your specific C++ collection type
PrevFilterOutput->getObjects(TriggerCluster, recoecalcands);
if (recoecalcands.empty())
PrevFilterOutput->getObjects(TriggerPhoton,
recoecalcands); //we dont know if its type trigger cluster or trigger photon

// look at all candidates, check cuts and add to filter object
int n(0);

for (auto& recoecalcand : recoecalcands) {
ref = recoecalcand;

if (ref->eta() > minEtacut_ && ref->eta() < maxEtacut_) {
n++;
filterproduct.addObject(TriggerCluster, ref);
}
}

// filter decision
bool accept(n >= ncandcut_);

return accept;
}

// declare this class as a framework plugin
#include "FWCore/Framework/interface/MakerMacros.h"
DEFINE_FWK_MODULE(HLTEgammaEtaFilter);
41 changes: 41 additions & 0 deletions HLTrigger/Egamma/plugins/HLTEgammaEtaFilter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#ifndef HLTEgammaEtaFilter_h
#define HLTEgammaEtaFilter_h

/** \class HLTEgammaEtaFilter
*
* \author Abanti Ranadhir Sahasransu (VUB, Belgium)
*
*/

#include "HLTrigger/HLTcore/interface/HLTFilter.h"

#include "DataFormats/HLTReco/interface/TriggerFilterObjectWithRefs.h"

namespace edm {
class ConfigurationDescriptions;
}

//
// class declaration
//

class HLTEgammaEtaFilter : public HLTFilter {
public:
explicit HLTEgammaEtaFilter(const edm::ParameterSet&);
~HLTEgammaEtaFilter() override;
bool hltFilter(edm::Event&,
const edm::EventSetup&,
trigger::TriggerFilterObjectWithRefs& filterproduct) const override;
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);

private:
edm::InputTag inputTag_; // input tag identifying product contains egammas
edm::EDGetTokenT<trigger::TriggerFilterObjectWithRefs> inputToken_;
double minEtacut_; // Min Eta threshold
double maxEtacut_; // Max Eta threshold
int ncandcut_; // number of egammas required

edm::InputTag l1EGTag_;
};

#endif //HLTEgammaEtaFilter_h