Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:18:40

0001 #include "HLTEcalIsolationFilter.h"
0002 
0003 #include "DataFormats/Common/interface/Handle.h"
0004 
0005 #include "DataFormats/Common/interface/RefToBase.h"
0006 
0007 #include "DataFormats/HLTReco/interface/TriggerFilterObjectWithRefs.h"
0008 
0009 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0010 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0011 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0012 
0013 HLTEcalIsolationFilter::HLTEcalIsolationFilter(const edm::ParameterSet& iConfig) : HLTFilter(iConfig) {
0014   candTag_ = iConfig.getParameter<edm::InputTag>("EcalIsolatedParticleSource");
0015   maxhitout = iConfig.getParameter<int>("MaxNhitOuterCone");
0016   maxhitin = iConfig.getParameter<int>("MaxNhitInnerCone");
0017   maxenin = iConfig.getParameter<double>("MaxEnergyInnerCone");
0018   maxenout = iConfig.getParameter<double>("MaxEnergyOuterCone");
0019   maxetacand = iConfig.getParameter<double>("MaxEtaCandidate");
0020   candToken_ = consumes<reco::IsolatedPixelTrackCandidateCollection>(candTag_);
0021 }
0022 
0023 HLTEcalIsolationFilter::~HLTEcalIsolationFilter() = default;
0024 
0025 void HLTEcalIsolationFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0026   edm::ParameterSetDescription desc;
0027   makeHLTFilterDescription(desc);
0028   desc.add<edm::InputTag>("EcalIsolatedParticleSource", edm::InputTag("ecalIsolPartProd"));
0029   desc.add<int>("MaxNhitInnerCone", 1000);
0030   desc.add<int>("MaxNhitOuterCone", 0);
0031   desc.add<double>("MaxEnergyOuterCone", 10000.);
0032   desc.add<double>("MaxEnergyInnerCone", 10000.);
0033   desc.add<double>("MaxEtaCandidate", 1.3);
0034   descriptions.add("hltEcalIsolationFilter", desc);
0035 }
0036 
0037 bool HLTEcalIsolationFilter::hltFilter(edm::Event& iEvent,
0038                                        const edm::EventSetup& iSetup,
0039                                        trigger::TriggerFilterObjectWithRefs& filterproduct) const {
0040   // Ref to Candidate object to be recorded in filter object
0041   edm::Ref<reco::IsolatedPixelTrackCandidateCollection> candref;
0042 
0043   // get hold of filtered candidates
0044   edm::Handle<reco::IsolatedPixelTrackCandidateCollection> ecIsolCands;
0045   iEvent.getByToken(candToken_, ecIsolCands);
0046 
0047   //Filtering
0048 
0049   unsigned int n = 0;
0050   for (unsigned int i = 0; i < ecIsolCands->size(); i++) {
0051     candref = edm::Ref<reco::IsolatedPixelTrackCandidateCollection>(ecIsolCands, i);
0052 
0053     if ((candref->nHitIn() <= maxhitin) && (candref->nHitOut() <= maxhitout) && (candref->energyOut() < maxenout) &&
0054         (candref->energyIn() < maxenin) && fabs(candref->eta()) < maxetacand) {
0055       filterproduct.addObject(trigger::TriggerTrack, candref);
0056       n++;
0057     }
0058   }
0059 
0060   bool accept(n > 0);
0061 
0062   return accept;
0063 }
0064 
0065 // declare this class as a framework plugin
0066 #include "FWCore/Framework/interface/MakerMacros.h"
0067 DEFINE_FWK_MODULE(HLTEcalIsolationFilter);