CMS 3D CMS Logo

Cuts.cc
Go to the documentation of this file.
3 
4 #include <cmath>
5 #include <sstream>
6 
7 using namespace std;
8 using namespace muonisolation;
9 
10 Cuts::Cuts(const edm::ParameterSet & pset)
11 {
12  vector<double> etaBounds = pset.getParameter<std::vector<double> >("EtaBounds");
13  vector<double> coneSizes = pset.getParameter<std::vector<double> >("ConeSizes");
14  vector<double> thresholds = pset.getParameter<std::vector<double> >("Thresholds");
15  init(etaBounds,coneSizes,thresholds);
16 }
17 
18 Cuts::Cuts(const vector<double> & etaBounds, const vector<double> & coneSizes,
19  const vector<double> & thresholds)
20 {
21  init(etaBounds,coneSizes,thresholds);
22 }
23 
24 
25 void Cuts::init(const vector<double> & etaBounds, const vector<double> & coneSizes,
26  const vector<double> & thresholds)
27 {
28  double minEta = 0.;
29  double coneSize = 0;
30  double threshold = 0;
31  unsigned int nEta = etaBounds.size();
32  for (unsigned int i=0; i< nEta; i++) {
33  if (i>0) minEta = etaBounds[i-1];
34  double maxEta = etaBounds[i];
35  if (i < coneSizes.size()) coneSize = coneSizes[i];
36  if (i < thresholds.size()) threshold = thresholds[i];
37 
38  CutSpec cut = {muonisolation::Range<double>(minEta,maxEta), coneSize, threshold };
39 
40  theCuts.push_back( cut );
41  }
42 }
43 
44 const Cuts::CutSpec & Cuts::operator()(double eta) const
45 {
46  double absEta = fabs(eta);
47  unsigned int nCuts = theCuts.size();
48  unsigned int idx_eta = nCuts-1;
49  for (unsigned int i = 0; i < nCuts; i++) {
50  if (absEta < theCuts[i].etaRange.max() ) { idx_eta = i; break; }
51  }
52  return theCuts[idx_eta];
53 }
54 
56 {
57  std::ostringstream result;
58  typedef std::vector<CutSpec>::const_iterator IT;
59  result << "Cuts : " << std::endl;
60  for (IT it = theCuts.begin(), itEnd = theCuts.end(); it < itEnd; ++it) {
61  result << "eta: "<<(*it).etaRange
62  <<", cone: "<< (*it).conesize
63  <<", cut: "<<(*it).threshold
64  <<std::endl;
65  }
66  return result.str();
67 }
T getParameter(std::string const &) const
std::string print(const Track &, edm::Verbosity=edm::Concise)
Track print utility.
Definition: print.cc:10
int init
Definition: HydjetWrapper.h:67
double maxEta
std::vector< LinkConnSpec >::const_iterator IT