LOGO

RestFrames  v1.0.1
RestFrames HEP Event Analysis Software Library
MinMassChi2CombJigsaw.cc
Go to the documentation of this file.
1 // RestFrames: particle physics event analysis library
3 // --------------------------------------------------------------------
4 // Copyright (c) 2014-2016, Christopher Rogan
14 // This file is part of RestFrames.
15 //
16 // RestFrames is free software; you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation; either version 2 of the License, or
19 // (at your option) any later version.
20 //
21 // RestFrames is distributed in the hope that it will be useful,
22 // but WITHOUT ANY WARRANTY; without even the implied warranty of
23 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 // GNU General Public License for more details.
25 //
26 // You should have received a copy of the GNU General Public License
27 // along with RestFrames. If not, see <http://www.gnu.org/licenses/>.
29 
30 #include "RestFrames/RestFrame.hh"
32 
33 namespace RestFrames {
34 
35  MinMassChi2CombJigsaw::MinMassChi2CombJigsaw(const std::string& sname,
36  const std::string& stitle,
37  int N_comb, int N_mass)
38  : CombinatoricJigsaw(sname, stitle, N_comb, N_mass),
39  m_Ncomb(N_comb), m_Nmass(N_mass)
40  {
41  for(int i = 0; i < m_Nmass; i++){
42  m_Mass.push_back(0.);
43  m_Sigma.push_back(1.);
44  }
45  }
46 
47  MinMassChi2CombJigsaw::~MinMassChi2CombJigsaw() {}
48 
49  void MinMassChi2CombJigsaw::SetMass(double mass, int i){
50  if(i < 0 || i >= m_Nmass)
51  return;
52 
53  m_Mass[i] = std::max(mass, 0.);
54  }
55 
56  void MinMassChi2CombJigsaw::SetSigma(double sigma, int i){
57  if(i < 0 || i >= m_Nmass)
58  return;
59  if(sigma <= 0.)
60  return;
61 
62  m_Sigma[i] = sigma;
63  }
64 
65  bool MinMassChi2CombJigsaw::EvaluateMetric(double& metric) const {
66  double mass;
67  double chi2 = 0.;
68 
69  for(int i = 0; i < m_Nmass; i++){
70  mass = GetDependancyStates(i).GetFourVector().M();
71  chi2 += (mass-m_Mass[i])*(mass-m_Mass[i])/m_Sigma[i]/m_Sigma[i];
72  }
73 
74  metric = chi2;
75  return true;
76  }
77 
78 }
79