CMS 3D CMS Logo

IsolatorByNominalEfficiency.cc
Go to the documentation of this file.
5 
6 using namespace muonisolation;
7 using namespace std;
8 
10  if (i >= 0 && i < DIM)
11  return cone_dr[i];
12  else
13  return 0.;
14 }
15 
17  for (int i = DIM; i >= 1; i--)
18  if (cone_dr[i - 1] < dr)
19  return i;
20  return 0;
21 }
22 
24  0.001, 0.02, 0.045, 0.09, 0.13, 0.17, 0.20, 0.24, 0.28, 0.32, 0.38, 0.45, 0.5, 0.6, 0.7};
25 
27  const vector<string>& ceff,
28  const vector<double>& weights)
29  : theWeights(weights) {
31  coneForEfficiency = cones(ceff);
32  theDepThresholds = std::vector<double>(weights.size(), -1e12);
33 }
34 
36  const vector<string>& ceff,
37  const vector<double>& weights,
38  const vector<double>& thresh)
41  coneForEfficiency = cones(ceff);
42 }
43 
45 
48  for (vector<string>::const_iterator is = usrVec.begin(); is != usrVec.end(); is++) {
49  char* evp = nullptr;
50  int cone = strtol((*is).c_str(), &evp, 10);
51  float effic = strtod(evp + 1, &evp);
52  result.insert(make_pair(effic, cone));
53  }
54  return result;
55 }
56 
58  // FIXME
60  return f.fullPath();
61 }
62 
64  const edm::Event*) const {
65  if (deposits.empty()) {
66  cout << "IsolatorByNominalEfficiency: no deposit" << endl;
67  return Result(resultType()); //FIXME
68  }
69 
70  // To determine the threshold, the direction of the cone of the first
71  // set of deposits is used.
72  // For algorithms where different cone axis definitions are used
73  // for different types deposits (eg. HCAL and ECAL deposits for
74  // calorimeter isolation), the first one is used to determine the threshold
75  // value!
76  float theEta = deposits.back().dep->eta();
77 
78  // Try descending efficiency values to find the point where the candidate
79  // becomes non isolated
80 
81  float nominalEfficiency = 1.;
82  const float deltaeff = 0.005;
83  const float mineff = deltaeff;
84  for (float eff = .995; eff > mineff; eff -= deltaeff) {
86  float coneSize = theConesInfo.size(cone);
88  float thres = thresholds->thresholdValueForEfficiency(location, eff);
89  float sumDep = weightedSum(deposits, coneSize);
90  // cout << " Eff=" << eff
91  // << " eta=" << theEta
92  // << " cone=" << cone
93  // << " dR=" << coneSize
94  // << " thres=" << thres
95  // << " deposit=" << sumDep
96  // << " isolated=" << (sumDep < thres)
97  // << endl;
98  if (sumDep > thres)
99  break;
100  nominalEfficiency = eff;
101  }
102  Result res(resultType());
103  res.valFloat = nominalEfficiency;
104  return res;
105 }
106 
108  //FIXME use upper_bound
109  int best_cone;
110  if (!coneForEfficiency.empty()) {
111  best_cone = (--(coneForEfficiency.end()))->second;
112  } else
113  return 0;
114 
115  mapNomEff_Cone::const_reverse_iterator it;
116  for (it = coneForEfficiency.rbegin(); it != coneForEfficiency.rend(); it++) {
117  if (eff_thr <= (*it).first)
118  best_cone = (*it).second;
119  }
120  return best_cone;
121 }
122 
124  double sumDep = 0;
125 
126  assert(deposits.size() == theWeights.size());
127 
128  vector<double>::const_iterator w = theWeights.begin();
129  vector<double>::const_iterator dThresh = theDepThresholds.begin();
130  for (DepositContainer::const_iterator dep = deposits.begin(); dep != deposits.end(); dep++) {
131  if (dep->vetos != nullptr) {
132  sumDep += dep->dep->depositAndCountWithin(dRcone, *dep->vetos, *dThresh).first * (*w);
133  } else {
134  sumDep += dep->dep->depositAndCountWithin(dRcone, Vetos(), *dThresh).first * (*w);
135  }
136  if (sumDep < 0.)
137  sumDep = 0.;
138  w++;
139  dThresh++;
140  }
141  return sumDep;
142 }
143 
144 Cuts IsolatorByNominalEfficiency::cuts(float nominalEfficiency) const {
145  vector<double> etaBounds = thresholds->bins();
146  vector<double> coneSizes;
147  vector<double> cutvalues;
148  for (vector<double>::const_iterator it = etaBounds.begin(), itEnd = etaBounds.end(); it < itEnd; ++it) {
149  float eta = (*it);
150  int icone = bestConeForEfficiencyIndex(nominalEfficiency);
151  coneSizes.push_back(theConesInfo.size(icone));
153  cutvalues.push_back(thresholds->thresholdValueForEfficiency(location, nominalEfficiency));
154  }
155  return Cuts(etaBounds, coneSizes, cutvalues);
156 }
T w() const
Result result(const DepositContainer &deposits, const edm::Event *=nullptr) const override
Compute the deposit within the cone and return the isolation result.
#define DIM(a)
MuIsoBaseIsolator::DepositContainer DepositContainer
reco::IsoDeposit::Vetos Vetos
assert(be >=bs)
Definition: Electron.h:6
float thresholdValueForEfficiency(ThresholdLocation location, float eff_thr) const
virtual double weightedSum(const DepositContainer &deposits, float dRcone) const
IsolatorByNominalEfficiency(const std::string &thrFile, const std::vector< std::string > &ceff, const std::vector< double > &weights)
Constructor.
mapNomEff_Cone cones(const std::vector< std::string > &names)
double f[11][100]
std::string findPath(const std::string &fileName)