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) {
85  int cone = bestConeForEfficiencyIndex(eff);
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 }
HLT_2018_cff.weights
weights
Definition: HLT_2018_cff.py:87167
mps_fire.i
i
Definition: mps_fire.py:355
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
gather_cfg.cout
cout
Definition: gather_cfg.py:144
muonisolation::MuIsoBaseIsolator::Result
Definition: MuIsoBaseIsolator.h:27
cms::cuda::assert
assert(be >=bs)
muonisolation::IsolatorByNominalEfficiency::ConeSizes::cone_dr
static const float cone_dr[DIM]
Definition: IsolatorByNominalEfficiency.h:47
MillePedeFileConverter_cfg.fileName
fileName
Definition: MillePedeFileConverter_cfg.py:32
muonisolation::IsolatorByNominalEfficiency::cuts
Cuts cuts(float nominalEfficiency) const
Definition: IsolatorByNominalEfficiency.cc:144
muonisolation::IsolatorByNominalEfficiency::theDepThresholds
std::vector< double > theDepThresholds
Definition: IsolatorByNominalEfficiency.h:72
muonisolation::IsolatorByNominalEfficiency::DepositContainer
MuIsoBaseIsolator::DepositContainer DepositContainer
Definition: IsolatorByNominalEfficiency.h:24
FileInPath.h
edm::FileInPath
Definition: FileInPath.h:64
DIM
#define DIM(a)
Definition: LogEleMapdb.h:14738
HLT_2018_cff.coneSize
coneSize
Definition: HLT_2018_cff.py:49353
muonisolation::IsolatorByNominalEfficiency::theConesInfo
ConeSizes theConesInfo
Definition: IsolatorByNominalEfficiency.h:73
muonisolation::IsolatorByNominalEfficiency::ConeSizes::size
double size(int i) const
Definition: IsolatorByNominalEfficiency.cc:9
PVValHelper::eta
Definition: PVValidationHelpers.h:69
w
const double w
Definition: UKUtility.cc:23
muonisolation::MuIsoBaseIsolator::Vetos
reco::IsoDeposit::Vetos Vetos
Definition: MuIsoBaseIsolator.h:15
muonisolation::IsolatorByNominalEfficiency::coneForEfficiency
mapNomEff_Cone coneForEfficiency
Definition: IsolatorByNominalEfficiency.h:69
muonisolation::IsolatorByNominalEfficiency::bestConeForEfficiencyIndex
int bestConeForEfficiencyIndex(float eff_thr) const
Definition: IsolatorByNominalEfficiency.cc:107
muonisolation::Cuts
Definition: Cuts.h:14
muonisolation::NominalEfficiencyThresholds
Definition: NominalEfficiencyThresholds.h:10
IsoDeposit.h
muonisolation::IsolatorByNominalEfficiency::result
Result result(const DepositContainer &deposits, const edm::Event *=nullptr) const override
Compute the deposit within the cone and return the isolation result.
Definition: IsolatorByNominalEfficiency.cc:63
muonisolation::IsolatorByNominalEfficiency::weightedSum
virtual double weightedSum(const DepositContainer &deposits, float dRcone) const
Definition: IsolatorByNominalEfficiency.cc:123
muonisolation::IsolatorByNominalEfficiency::findPath
std::string findPath(const std::string &fileName)
Definition: IsolatorByNominalEfficiency.cc:57
IsolatorByNominalEfficiency.h
muonisolation::IsolatorByNominalEfficiency::theWeights
std::vector< double > theWeights
Definition: IsolatorByNominalEfficiency.h:71
muonisolation::IsolatorByNominalEfficiency::ConeSizes::index
int index(float dr) const
Definition: IsolatorByNominalEfficiency.cc:16
muonisolation::NominalEfficiencyThresholds::thresholdValueForEfficiency
float thresholdValueForEfficiency(ThresholdLocation location, float eff_thr) const
Definition: NominalEfficiencyThresholds.cc:124
res
Definition: Electron.h:6
muonisolation
Definition: CandViewExtractor.h:16
GOODCOLL_filter_cfg.thresh
thresh
Definition: GOODCOLL_filter_cfg.py:74
std
Definition: JetResolutionObject.h:76
muonisolation::NominalEfficiencyThresholds::bins
std::vector< double > bins() const
Definition: NominalEfficiencyThresholds.cc:44
NominalEfficiencyThresholds.h
muonisolation::IsolatorByNominalEfficiency::thresholds
NominalEfficiencyThresholds * thresholds
Definition: IsolatorByNominalEfficiency.h:70
flavorHistoryFilter_cfi.dr
dr
Definition: flavorHistoryFilter_cfi.py:37
muonisolation::IsolatorByNominalEfficiency::cones
mapNomEff_Cone cones(const std::vector< std::string > &names)
Definition: IsolatorByNominalEfficiency.cc:46
EcalCondDBWriter_cfi.location
location
Definition: EcalCondDBWriter_cfi.py:63
PFRecoTauChargedHadronBuilderPlugins_cfi.dRcone
dRcone
Definition: PFRecoTauChargedHadronBuilderPlugins_cfi.py:46
muonisolation::IsolatorByNominalEfficiency::IsolatorByNominalEfficiency
IsolatorByNominalEfficiency(const std::string &thrFile, const std::vector< std::string > &ceff, const std::vector< double > &weights)
Constructor.
muonisolation::IsolatorByNominalEfficiency::resultType
ResultType resultType() const override
Definition: IsolatorByNominalEfficiency.h:66
edm::Event
Definition: Event.h:73
CandIsolatorFromDeposits_cfi.deposits
deposits
Definition: CandIsolatorFromDeposits_cfi.py:4
muonisolation::NominalEfficiencyThresholds::ThresholdLocation
threshold location
Definition: NominalEfficiencyThresholds.h:17
muonisolation::IsolatorByNominalEfficiency::mapNomEff_Cone
std::multimap< float, int > mapNomEff_Cone
Definition: IsolatorByNominalEfficiency.h:61
muonisolation::IsolatorByNominalEfficiency::~IsolatorByNominalEfficiency
~IsolatorByNominalEfficiency() override
Definition: IsolatorByNominalEfficiency.cc:44