CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/Validation/RecoVertex/src/VertexWeighter.cc

Go to the documentation of this file.
00001 #include "Validation/RecoVertex/interface/VertexWeighter.h"
00002 #include <vector>
00003 #include <math.h>
00004 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00005 
00006 
00007 VertexWeighter::VertexWeighter():
00008   m_sigma_init(1.), m_mean_init(0.), m_sigma_final(1.), m_usemain(false), m_dummy(true) { }
00009 
00010 VertexWeighter::VertexWeighter(const double& sigma_init, const double& mean_init, const double& sigma_final, const bool& usemainvtx):
00011   m_sigma_init(sigma_init), m_mean_init(mean_init), m_sigma_final(sigma_final), m_usemain(usemainvtx), m_dummy(false) { }
00012 
00013 VertexWeighter::VertexWeighter(const edm::ParameterSet& iConfig):
00014   m_sigma_init(iConfig.getParameter<double>("initSigma")), 
00015   m_mean_init(iConfig.getParameter<double>("initMean")), 
00016   m_sigma_final(iConfig.getParameter<double>("finalSigma")), 
00017   m_usemain(iConfig.getParameter<bool>("useMainVertex")), 
00018   m_dummy(false) { }
00019 
00020 const double VertexWeighter::weight(const std::vector<float>& zpositions, const float& zmain) const {
00021 
00022   double final_weight = 1.;
00023 
00024   if(!m_dummy) {
00025 
00026     for(std::vector<float>::const_iterator zpos = zpositions.begin() ; zpos != zpositions.end() ; ++zpos) {
00027       
00028       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)));
00029 
00030     }
00031 
00032     if(m_usemain) {
00033       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)));
00034     }
00035 
00036   }
00037 
00038   return final_weight;
00039 
00040 
00041 }