CMS 3D CMS Logo

VertexWeighter.cc
Go to the documentation of this file.
2 #include <vector>
3 #include <cmath>
5 
7  : m_sigma_init(1.), m_mean_init(0.), m_sigma_final(1.), m_usemain(false), m_dummy(true) {}
8 
9 VertexWeighter::VertexWeighter(const double& sigma_init,
10  const double& mean_init,
11  const double& sigma_final,
12  const bool& usemainvtx)
13  : m_sigma_init(sigma_init),
14  m_mean_init(mean_init),
15  m_sigma_final(sigma_final),
16  m_usemain(usemainvtx),
17  m_dummy(false) {}
18 
20  : m_sigma_init(iConfig.getParameter<double>("initSigma")),
21  m_mean_init(iConfig.getParameter<double>("initMean")),
22  m_sigma_final(iConfig.getParameter<double>("finalSigma")),
23  m_usemain(iConfig.getParameter<bool>("useMainVertex")),
24  m_dummy(false) {}
25 
26 const double VertexWeighter::weight(const std::vector<float>& zpositions, const float& zmain) const {
27  double final_weight = 1.;
28 
29  if (!m_dummy) {
30  for (std::vector<float>::const_iterator zpos = zpositions.begin(); zpos != zpositions.end(); ++zpos) {
31  final_weight *= (m_sigma_init / m_sigma_final) * exp(-pow((*zpos - m_mean_init), 2) / 2. *
32  (1. / pow(m_sigma_final, 2) - 1. / pow(m_sigma_init, 2)));
33  }
34 
35  if (m_usemain) {
36  final_weight *= (m_sigma_init / m_sigma_final) * exp(-pow((zmain - m_mean_init), 2) / 2. *
37  (1. / pow(m_sigma_final, 2) - 1. / pow(m_sigma_init, 2)));
38  }
39  }
40 
41  return final_weight;
42 }
const double weight(const std::vector< float > &zpositions, const float &zmain) const
const bool m_dummy
constexpr int pow(int x)
Definition: conifer.h:24
const bool m_usemain
const double m_sigma_init
const double m_mean_init
const double m_sigma_final