Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:27:05

0001 #include "RecoMuon/MuonIsolation/interface/MuIsoByTrackPt.h"
0002 
0003 #include "PhysicsTools/IsolationAlgos/interface/IsoDepositExtractor.h"
0004 #include "PhysicsTools/IsolationAlgos/interface/IsoDepositExtractorFactory.h"
0005 #include "RecoMuon/MuonIsolation/interface/IsolatorByDeposit.h"
0006 
0007 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0008 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0009 
0010 #include "DataFormats/TrackReco/interface/Track.h"
0011 #include "DataFormats/TrackReco/interface/TrackFwd.h"
0012 
0013 #include <vector>
0014 #include <iostream>
0015 
0016 using reco::IsoDeposit;
0017 using std::string;
0018 using std::vector;
0019 using namespace muonisolation;
0020 
0021 MuIsoByTrackPt::MuIsoByTrackPt(const edm::ParameterSet& conf, edm::ConsumesCollector&& iC) {
0022   edm::ParameterSet extractorPSet = conf.getParameter<edm::ParameterSet>("ExtractorPSet");
0023   string extractorName = extractorPSet.getParameter<string>("ComponentName");
0024   theExtractor = IsoDepositExtractorFactoryFromHelper::get()->create(extractorName, extractorPSet, iC);
0025 
0026   theCut = conf.getUntrackedParameter<double>("Threshold", 0.);
0027   float coneSize = conf.getUntrackedParameter<double>("ConeSize", 0.);
0028   vector<double> weights(1, 1.);
0029   theIsolator = std::make_unique<IsolatorByDeposit>(coneSize, weights);
0030 }
0031 
0032 MuIsoByTrackPt::~MuIsoByTrackPt() = default;
0033 
0034 void MuIsoByTrackPt::setConeSize(float dr) { theIsolator->setConeSize(dr); }
0035 
0036 float MuIsoByTrackPt::isolation(const edm::Event& ev, const edm::EventSetup& es, const reco::Track& muon) {
0037   IsoDeposit dep = extractor()->deposit(ev, es, muon);
0038   MuIsoBaseIsolator::DepositContainer deposits;
0039   deposits.push_back(&dep);
0040   if (isolator()->resultType() == MuIsoBaseIsolator::ISOL_FLOAT_TYPE) {
0041     return isolator()->result(deposits).valFloat;
0042   }
0043 
0044   return -999.;
0045 }
0046 
0047 bool MuIsoByTrackPt::isIsolated(const edm::Event& ev, const edm::EventSetup& es, const reco::Track& muon) {
0048   return (isolation(ev, es, muon) > theCut);
0049 }