CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/src/RecoMuon/MuonIsolation/src/Cuts.cc

Go to the documentation of this file.
00001 #include "RecoMuon/MuonIsolation/interface/Cuts.h"
00002 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00003 
00004 #include <math.h>
00005 #include <sstream>
00006 
00007 using namespace std;
00008 using namespace muonisolation;
00009 
00010 Cuts::Cuts(const edm::ParameterSet & pset)
00011 {
00012   vector<double> etaBounds  = pset.getParameter<std::vector<double> >("EtaBounds");
00013   vector<double> coneSizes  = pset.getParameter<std::vector<double> >("ConeSizes");
00014   vector<double> thresholds = pset.getParameter<std::vector<double> >("Thresholds");
00015   init(etaBounds,coneSizes,thresholds);
00016 }
00017 
00018 Cuts::Cuts(const vector<double> & etaBounds, const vector<double> & coneSizes,
00019       const vector<double> & thresholds) 
00020 {
00021   init(etaBounds,coneSizes,thresholds);
00022 }
00023 
00024 
00025 void Cuts::init(const vector<double> & etaBounds, const vector<double> & coneSizes,
00026       const vector<double> & thresholds)
00027 {
00028   double minEta = 0.;
00029   double coneSize = 0;
00030   double threshold = 0;
00031   unsigned int nEta = etaBounds.size();
00032   for (unsigned int i=0; i< nEta; i++) {
00033     if (i>0) minEta = etaBounds[i-1];
00034     double maxEta = etaBounds[i];
00035     if (i < coneSizes.size()) coneSize = coneSizes[i]; 
00036     if (i < thresholds.size()) threshold = thresholds[i]; 
00037 
00038     CutSpec cut = {muonisolation::Range<double>(minEta,maxEta), coneSize, threshold };
00039     
00040     theCuts.push_back( cut ); 
00041   } 
00042 }
00043 
00044 const Cuts::CutSpec & Cuts::operator()(double eta) const
00045 {
00046   double absEta = fabs(eta);
00047   unsigned int nCuts = theCuts.size();
00048   unsigned int idx_eta = nCuts-1;
00049   for (unsigned int i = 0; i < nCuts; i++) {
00050     if (absEta < theCuts[i].etaRange.max() ) { idx_eta = i; break; }
00051   }
00052   return theCuts[idx_eta];
00053 }
00054 
00055 std::string Cuts::print() const
00056 {
00057   std::ostringstream result;
00058   typedef std::vector<CutSpec>::const_iterator IT;
00059   result << "Cuts : " << std::endl;
00060   for (IT it = theCuts.begin(), itEnd = theCuts.end(); it < itEnd; ++it) {
00061     result << "eta: "<<(*it).etaRange
00062            <<", cone: "<< (*it).conesize
00063            <<", cut: "<<(*it).threshold
00064            <<std::endl;
00065   }  
00066   return result.str();
00067 }