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 firstjet_phi = atan2(py[0], px[0]);
26 
27  double apcjet(0.), apcmet(0.), apcjetmet(0.);
28  double apcjetmetmin(0.);
29 
30  for (size_t i = 0; i < et.size(); i++) {
31  double jet_phi = atan2(py[i], px[i]);
32  double met_phi = atan2(mety, metx);
33 
34  double dphisignaljet = fabs(deltaPhi(jet_phi, firstjet_phi));
35  double dphimet = fabs(deltaPhi(jet_phi, met_phi));
36 
37  apcjet += et[i] * cos(dphisignaljet / 2.0);
38  apcmet += et[i] * sin(dphimet / 2.0);
39  apcjetmet += et[i] * cos(dphisignaljet / 2.0) * sin(dphimet / 2.0);
40  }
41 
42  std::vector<double> apcjetvector;
43  std::vector<double> apcjetmetvector;
44  for (size_t j = 0; j < et.size(); j++) {
45  apcjetvector.push_back(0.);
46  apcjetmetvector.push_back(0.);
47  double jet_phi_j = atan2(py[j], px[j]);
48  for (size_t i = 0; i < et.size(); i++) {
49  double jet_phi_i = atan2(py[i], px[i]);
50  double dphi_jet = fabs(deltaPhi(jet_phi_i, jet_phi_j));
51  double met_phi = atan2(mety, metx);
52  double dphimet = fabs(deltaPhi(jet_phi_i, met_phi));
53 
54  apcjetvector.back() += et[i] * cos(dphi_jet / 2.0);
55  apcjetmetvector.back() += et[i] * cos(dphi_jet / 2.0) * sin(dphimet / 2.0);
56  }
57  }
58  if (!apcjetvector.empty() && !apcjetmetvector.empty()) {
59  apcjetmetmin = *min_element(apcjetmetvector.begin(), apcjetmetvector.end());
60  }
61 
62  if (ht != 0)
63  return apcjetmetmin / ht;
64  else
65  return -1.;
66  }
67 } // 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