Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:49:42

0001 /** \class HLTElectronMuonInvMassFilter
0002  *
0003  *  Original Author: Massimiliano Chiorboli
0004  *  Institution: INFN, Italy
0005  *  Contact: Massimiliano.Chiorboli@cern.ch
0006  *  Date: July 6, 2011
0007  */
0008 
0009 #include "HLTElectronMuonInvMassFilter.h"
0010 #include "DataFormats/RecoCandidate/interface/RecoEcalCandidate.h"
0011 #include "DataFormats/EgammaReco/interface/SuperCluster.h"
0012 #include "DataFormats/EgammaReco/interface/SuperClusterFwd.h"
0013 
0014 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0015 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0016 //
0017 // constructors and destructor
0018 //
0019 HLTElectronMuonInvMassFilter::HLTElectronMuonInvMassFilter(const edm::ParameterSet& iConfig) : HLTFilter(iConfig) {
0020   eleCandTag_ = iConfig.getParameter<edm::InputTag>("elePrevCandTag");
0021   muonCandTag_ = iConfig.getParameter<edm::InputTag>("muonPrevCandTag");
0022   lowerMassCut_ = iConfig.getParameter<double>("lowerMassCut");
0023   upperMassCut_ = iConfig.getParameter<double>("upperMassCut");
0024   ncandcut_ = iConfig.getParameter<int>("ncandcut");
0025   relaxed_ = iConfig.getUntrackedParameter<bool>("electronRelaxed", true);
0026   L1IsoCollTag_ = iConfig.getParameter<edm::InputTag>("ElectronL1IsoCand");
0027   L1NonIsoCollTag_ = iConfig.getParameter<edm::InputTag>("ElectronL1NonIsoCand");
0028   MuonCollTag_ = iConfig.getParameter<edm::InputTag>("MuonCand");
0029   eleCandToken_ = consumes<trigger::TriggerFilterObjectWithRefs>(eleCandTag_);
0030   muonCandToken_ = consumes<trigger::TriggerFilterObjectWithRefs>(muonCandTag_);
0031 }
0032 
0033 HLTElectronMuonInvMassFilter::~HLTElectronMuonInvMassFilter() = default;
0034 
0035 void HLTElectronMuonInvMassFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0036   edm::ParameterSetDescription desc;
0037   makeHLTFilterDescription(desc);
0038   desc.add<edm::InputTag>("elePrevCandTag",
0039                           edm::InputTag("hltL1NonIsoHLTCaloIdTTrkIdVLSingleElectronEt8NoCandDphiFilter"));
0040   desc.add<edm::InputTag>("muonPrevCandTag", edm::InputTag("hltL1Mu0HTT50L3Filtered3"));
0041   desc.add<double>("lowerMassCut", 4.0);
0042   desc.add<double>("upperMassCut", 999999.0);
0043   desc.add<int>("ncandcut", 1);
0044   desc.addUntracked<bool>("electronRelaxed", true);
0045   desc.add<edm::InputTag>("ElectronL1IsoCand", edm::InputTag("hltPixelMatchElectronsActivity"));
0046   desc.add<edm::InputTag>("ElectronL1NonIsoCand", edm::InputTag("hltPixelMatchElectronsActivity"));
0047   desc.add<edm::InputTag>("MuonCand", edm::InputTag("hltL3MuonCandidates"));
0048   descriptions.add("hltElectronMuonInvMassFilter", desc);
0049 }
0050 
0051 // ------------ method called to produce the data  ------------
0052 bool HLTElectronMuonInvMassFilter::hltFilter(edm::Event& iEvent,
0053                                              const edm::EventSetup& iSetup,
0054                                              trigger::TriggerFilterObjectWithRefs& filterproduct) const {
0055   using namespace std;
0056   using namespace math;
0057   using namespace edm;
0058   using namespace reco;
0059   // The filter object
0060   using namespace trigger;
0061 
0062   if (saveTags()) {
0063     filterproduct.addCollectionTag(L1IsoCollTag_);
0064     if (relaxed_)
0065       filterproduct.addCollectionTag(L1NonIsoCollTag_);
0066     filterproduct.addCollectionTag(MuonCollTag_);
0067   }
0068 
0069   edm::Handle<trigger::TriggerFilterObjectWithRefs> EleFromPrevFilter;
0070   iEvent.getByToken(eleCandToken_, EleFromPrevFilter);
0071 
0072   edm::Handle<trigger::TriggerFilterObjectWithRefs> MuonFromPrevFilter;
0073   iEvent.getByToken(muonCandToken_, MuonFromPrevFilter);
0074 
0075   vector<Ref<ElectronCollection>> electrons;
0076   EleFromPrevFilter->getObjects(TriggerElectron, electrons);
0077 
0078   vector<RecoChargedCandidateRef> l3muons;
0079   MuonFromPrevFilter->getObjects(TriggerMuon, l3muons);
0080 
0081   std::vector<edm::Ref<reco::RecoEcalCandidateCollection>> clusCands;
0082   if (electrons.empty()) {
0083     EleFromPrevFilter->getObjects(TriggerCluster, clusCands);
0084   }
0085 
0086   if (clusCands.empty()) {
0087     EleFromPrevFilter->getObjects(TriggerPhoton, clusCands);
0088   }
0089 
0090   int nEleMuPairs = 0;
0091 
0092   for (auto& electron : electrons) {
0093     for (auto& l3muon : l3muons) {
0094       double mass = (electron->p4() + l3muon->p4()).mass();
0095       if (mass >= lowerMassCut_ && mass <= upperMassCut_) {
0096         nEleMuPairs++;
0097         filterproduct.addObject(TriggerElectron, electron);
0098         filterproduct.addObject(TriggerMuon, l3muon);
0099       }
0100     }
0101   }
0102 
0103   for (auto& clusCand : clusCands) {
0104     for (auto& l3muon : l3muons) {
0105       double mass = (clusCand->p4() + l3muon->p4()).mass();
0106       if (mass >= lowerMassCut_ && mass <= upperMassCut_) {
0107         nEleMuPairs++;
0108         filterproduct.addObject(TriggerElectron, clusCand);
0109         filterproduct.addObject(TriggerMuon, l3muon);
0110       }
0111     }
0112   }
0113 
0114   // filter decision
0115   bool accept(nEleMuPairs >= ncandcut_);
0116   return accept;
0117 }
0118 
0119 // declare this class as a framework plugin
0120 #include "FWCore/Framework/interface/MakerMacros.h"
0121 DEFINE_FWK_MODULE(HLTElectronMuonInvMassFilter);