CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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) return cone_dr[i]; else return 0.; }
11 
13 {
14  for(int i=DIM; i>=1; i--) if (cone_dr[i-1] < dr) return i;
15  return 0;
16 }
17 
19 { 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};
20 
22  const vector<string> & ceff, const vector<double>& weights) : theWeights(weights){
24  coneForEfficiency = cones(ceff);
25  theDepThresholds = std::vector<double>(weights.size(), -1e12);
26 }
27 
29 IsolatorByNominalEfficiency(const string & thrFile, const vector<string> & ceff,
30  const vector<double>& weights, const vector<double>& thresh
31  ) : theWeights(weights), theDepThresholds(thresh){
33  coneForEfficiency = cones(ceff);
34 }
35 
37 {
38  delete thresholds;
39 }
40 
42  IsolatorByNominalEfficiency::cones(const vector<string>& usrVec) {
44  for (vector<string>::const_iterator is = usrVec.begin();
45  is != usrVec.end(); is++) {
46  char * evp = 0;
47  int cone = strtol( (*is).c_str(), &evp, 10);
48  float effic = strtod(evp+1, &evp);
49  result.insert(make_pair(effic,cone));
50  }
51  return result;
52 }
53 
55 {
56  // FIXME
57  edm::FileInPath f(fileName);
58  return f.fullPath();
59 }
60 
63 
64  if (deposits.size()==0) {
65  cout << "IsolatorByNominalEfficiency: no deposit" << endl;
66  return Result(resultType()); //FIXME
67  }
68 
69  // To determine the threshold, the direction of the cone of the first
70  // set of deposits is used.
71  // For algorithms where different cone axis definitions are used
72  // for different types deposits (eg. HCAL and ECAL deposits for
73  // calorimeter isolation), the first one is used to determine the threshold
74  // value!
75  float theEta = deposits.back().dep->eta();
76 
77  // Try descending efficiency values to find the point where the candidate
78  // becomes non isolated
79 
80  float nominalEfficiency = 1.;
81  const float deltaeff=0.005;
82  const float mineff=deltaeff;
83  for (float eff=.995; eff>mineff; eff-=deltaeff) {
84  int cone = bestConeForEfficiencyIndex(eff);
85  float coneSize = theConesInfo.size(cone);
86  NominalEfficiencyThresholds::ThresholdLocation location = {theEta,cone};
87  float thres = thresholds->thresholdValueForEfficiency(location, eff);
88  float sumDep = weightedSum(deposits,coneSize);
89 // cout << " Eff=" << eff
90 // << " eta=" << theEta
91 // << " cone=" << cone
92 // << " dR=" << coneSize
93 // << " thres=" << thres
94 // << " deposit=" << sumDep
95 // << " isolated=" << (sumDep < thres)
96 // << endl;
97  if (sumDep > thres) break;
98  nominalEfficiency = eff;
99  }
100  Result res(resultType());
101  res.valFloat = nominalEfficiency;
102  return res;
103 }
104 
106 {
107 
108  //FIXME use upper_bound
109  int best_cone;
110  if (coneForEfficiency.size() != 0) {
111  best_cone = (--(coneForEfficiency.end()))->second;
112  } else return 0;
113 
114  mapNomEff_Cone::const_reverse_iterator it;
115  for (it = coneForEfficiency.rbegin();
116  it != coneForEfficiency.rend(); it++) {
117  if (eff_thr <= (*it).first) best_cone = (*it).second;
118  }
119  return best_cone;
120 }
121 
122 
124  float dRcone) const {
125  double sumDep=0;
126 
127  assert(deposits.size()==theWeights.size());
128 
129  vector<double>::const_iterator w = theWeights.begin();
130  vector<double>::const_iterator dThresh = theDepThresholds.begin();
131  for (DepositContainer::const_iterator dep = deposits.begin();
132  dep != deposits.end(); dep++) {
133  if (dep->vetos != 0){
134  sumDep += dep->dep->depositAndCountWithin(dRcone, *dep->vetos, *dThresh).first * (*w);
135  } else {
136  sumDep += dep->dep->depositAndCountWithin(dRcone, Vetos(), *dThresh).first * (*w);
137  }
138  if (sumDep <0.) sumDep = 0.;
139  w++;
140  dThresh++;
141  }
142  return sumDep;
143 }
144 
145 Cuts IsolatorByNominalEfficiency::cuts(float nominalEfficiency) const
146 {
147  vector<double> etaBounds = thresholds->bins();
148  vector<double> coneSizes;
149  vector<double> cutvalues;
150  for (vector<double>::const_iterator it=etaBounds.begin(),itEnd=etaBounds.end();it < itEnd;++it){
151  float eta = (*it);
152  int icone = bestConeForEfficiencyIndex(nominalEfficiency);
153  coneSizes.push_back( theConesInfo.size(icone));
154  NominalEfficiencyThresholds::ThresholdLocation location = {eta-1.e-3f, icone};
155  cutvalues.push_back( thresholds->thresholdValueForEfficiency(location, nominalEfficiency));
156  }
157  return Cuts(etaBounds,coneSizes,cutvalues);
158 }
int i
Definition: DBlmapReader.cc:9
const double w
Definition: UKUtility.cc:23
assert(m_qm.get())
MuIsoBaseIsolator::DepositContainer DepositContainer
reco::IsoDeposit::Vetos Vetos
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)
virtual Result result(const DepositContainer &deposits, const edm::Event *=0) const
Compute the deposit within the cone and return the isolation result.
double f[11][100]
virtual double weightedSum(const DepositContainer &deposits, float dRcone) const
#define DIM
float thresholdValueForEfficiency(ThresholdLocation location, float eff_thr) const
tuple cout
Definition: gather_cfg.py:145
std::string fullPath() const
Definition: FileInPath.cc:184
std::string findPath(const std::string &fileName)