CMS 3D CMS Logo

Apc.cc
Go to the documentation of this file.
4 
5 #include <cmath>
6 #include <numeric>
7 #include <vector>
8 #include <algorithm>
9 #include <cstdlib>
10 
11 namespace heppy {
12 
13  double Apc::getApcJetMetMin(const std::vector<double>& et,
14  const std::vector<double>& px,
15  const std::vector<double>& py,
16  const double metx,
17  const double mety) {
18  if (et.empty())
19  return -1.;
20 
21  // Momentum sums in transverse plane
22  const double ht = accumulate(et.begin(), et.end(), 0.);
23 
24  // jets are pt-sorted
25  double apcjetmetmin(0.);
26 
27  std::vector<double> apcjetvector;
28  std::vector<double> apcjetmetvector;
29  for (size_t j = 0; j < et.size(); j++) {
30  apcjetvector.push_back(0.);
31  apcjetmetvector.push_back(0.);
32  double jet_phi_j = atan2(py[j], px[j]);
33  for (size_t i = 0; i < et.size(); i++) {
34  double jet_phi_i = atan2(py[i], px[i]);
35  double dphi_jet = fabs(deltaPhi(jet_phi_i, jet_phi_j));
36  double met_phi = atan2(mety, metx);
37  double dphimet = fabs(deltaPhi(jet_phi_i, met_phi));
38 
39  apcjetvector.back() += et[i] * cos(dphi_jet / 2.0);
40  apcjetmetvector.back() += et[i] * cos(dphi_jet / 2.0) * sin(dphimet / 2.0);
41  }
42  }
43  if (!apcjetvector.empty() && !apcjetmetvector.empty()) {
44  apcjetmetmin = *min_element(apcjetmetvector.begin(), apcjetmetvector.end());
45  }
46 
47  if (ht != 0)
48  return apcjetmetmin / ht;
49  else
50  return -1.;
51  }
52 } // namespace heppy
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
TAKEN FROM http://cmssw.cvs.cern.ch/cgi-bin/cmssw.cgi/CMSSW/ElectroWeakAnalysis/Utilities/src/PdfWeig...
Definition: AlphaT.h:16
static double getApcJetMetMin(const std::vector< double > &et, const std::vector< double > &px, const std::vector< double > &py, const double metx, const double mety)
Definition: Apc.cc:13