CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
VertexWeighter.cc
Go to the documentation of this file.
2 #include <vector>
3 #include <math.h>
5 
6 
8  m_sigma_init(1.), m_mean_init(0.), m_sigma_final(1.), m_usemain(false), m_dummy(true) { }
9 
10 VertexWeighter::VertexWeighter(const double& sigma_init, const double& mean_init, const double& sigma_final, const bool& usemainvtx):
11  m_sigma_init(sigma_init), m_mean_init(mean_init), m_sigma_final(sigma_final), m_usemain(usemainvtx), m_dummy(false) { }
12 
14  m_sigma_init(iConfig.getParameter<double>("initSigma")),
15  m_mean_init(iConfig.getParameter<double>("initMean")),
16  m_sigma_final(iConfig.getParameter<double>("finalSigma")),
17  m_usemain(iConfig.getParameter<bool>("useMainVertex")),
18  m_dummy(false) { }
19 
20 const double VertexWeighter::weight(const std::vector<float>& zpositions, const float& zmain) const {
21 
22  double final_weight = 1.;
23 
24  if(!m_dummy) {
25 
26  for(std::vector<float>::const_iterator zpos = zpositions.begin() ; zpos != zpositions.end() ; ++zpos) {
27 
28  final_weight *= (m_sigma_init/m_sigma_final) * exp(-pow((*zpos-m_mean_init),2)/2.*(1./pow(m_sigma_final,2)-1./pow(m_sigma_init,2)));
29 
30  }
31 
32  if(m_usemain) {
33  final_weight *= (m_sigma_init/m_sigma_final) * exp(-pow((zmain-m_mean_init),2)/2.*(1./pow(m_sigma_final,2)-1./pow(m_sigma_init,2)));
34  }
35 
36  }
37 
38  return final_weight;
39 
40 
41 }
const bool m_dummy
const bool m_usemain
const double m_sigma_init
const double m_mean_init
const double m_sigma_final
volatile std::atomic< bool > shutdown_flag false
const double weight(const std::vector< float > &zpositions, const float &zmain) const
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40