CLHEP VERSION Reference Documentation
CLHEP Home Page CLHEP Documentation CLHEP Bug Reports |
00001 // -*- C++ -*- 00002 // $Id: 00003 #include "CLHEP/GenericFunctions/EfficiencyFunctional.hh" 00004 #include "CLHEP/GenericFunctions/Argument.hh" 00005 #include "CLHEP/GenericFunctions/AbsFunction.hh" 00006 #include <iostream> 00007 #include <cmath> // for log() 00008 00009 namespace Genfun { 00010 EfficiencyFunctional::EfficiencyFunctional(const ArgumentList & aList): 00011 _aList(aList) 00012 {} 00013 00014 EfficiencyFunctional::~EfficiencyFunctional() { 00015 } 00016 00017 double EfficiencyFunctional::operator [] (const AbsFunction & function) const { 00018 double logEfficiency(0); 00019 for (unsigned int i=0; i<_aList.size()-1;i++) { 00020 Argument a = _aList[i]; 00021 Argument b(a.dimension()-1); 00022 for (unsigned int j=0;j<b.dimension();j++) b[j]=a[j]; 00023 double f = function(b); 00024 if (f<0 || f>1) { 00025 std::cerr 00026 << "Warning.. negative likelihood arg[" << i << "]=" << a << "f=" << f << std::endl; 00027 } 00028 logEfficiency -= (a[a.dimension()-1]>0.5) ? log(f):log(1-f); 00029 } 00030 return 2.0*logEfficiency; 00031 } 00032 } // namespace Genfun