Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "RecoMuon/MuonIsolation/interface/Cuts.h"
0002 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0003 
0004 #include <cmath>
0005 #include <sstream>
0006 
0007 using namespace std;
0008 using namespace muonisolation;
0009 
0010 Cuts::Cuts(const edm::ParameterSet& pset) {
0011   vector<double> etaBounds = pset.getParameter<std::vector<double> >("EtaBounds");
0012   vector<double> coneSizes = pset.getParameter<std::vector<double> >("ConeSizes");
0013   vector<double> thresholds = pset.getParameter<std::vector<double> >("Thresholds");
0014   init(etaBounds, coneSizes, thresholds);
0015 }
0016 
0017 Cuts::Cuts(const vector<double>& etaBounds, const vector<double>& coneSizes, const vector<double>& thresholds) {
0018   init(etaBounds, coneSizes, thresholds);
0019 }
0020 
0021 void Cuts::init(const vector<double>& etaBounds, const vector<double>& coneSizes, const vector<double>& thresholds) {
0022   double minEta = 0.;
0023   double coneSize = 0;
0024   double threshold = 0;
0025   unsigned int nEta = etaBounds.size();
0026   for (unsigned int i = 0; i < nEta; i++) {
0027     if (i > 0)
0028       minEta = etaBounds[i - 1];
0029     double maxEta = etaBounds[i];
0030     if (i < coneSizes.size())
0031       coneSize = coneSizes[i];
0032     if (i < thresholds.size())
0033       threshold = thresholds[i];
0034 
0035     CutSpec cut = {muonisolation::Range<double>(minEta, maxEta), coneSize, threshold};
0036 
0037     theCuts.push_back(cut);
0038   }
0039 }
0040 
0041 const Cuts::CutSpec& Cuts::operator()(double eta) const {
0042   double absEta = fabs(eta);
0043   unsigned int nCuts = theCuts.size();
0044   unsigned int idx_eta = nCuts - 1;
0045   for (unsigned int i = 0; i < nCuts; i++) {
0046     if (absEta < theCuts[i].etaRange.max()) {
0047       idx_eta = i;
0048       break;
0049     }
0050   }
0051   return theCuts[idx_eta];
0052 }
0053 
0054 std::string Cuts::print() const {
0055   std::ostringstream result;
0056   typedef std::vector<CutSpec>::const_iterator IT;
0057   result << "Cuts : " << std::endl;
0058   for (IT it = theCuts.begin(), itEnd = theCuts.end(); it < itEnd; ++it) {
0059     result << "eta: " << (*it).etaRange << ", cone: " << (*it).conesize << ", cut: " << (*it).threshold << std::endl;
0060   }
0061   return result.str();
0062 }