CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions
emtf::PercentErrorSquared Class Reference

#include <LossFunctions.h>

Inheritance diagram for emtf::PercentErrorSquared:
emtf::LossFunction

Public Member Functions

double fit (std::vector< Event * > &v) override
 
int id () override
 
std::string name () override
 
 PercentErrorSquared ()
 
double target (Event *e) override
 
 ~PercentErrorSquared () override
 
- Public Member Functions inherited from emtf::LossFunction
virtual ~LossFunction ()=default
 

Detailed Description

Definition at line 176 of file LossFunctions.h.

Constructor & Destructor Documentation

emtf::PercentErrorSquared::PercentErrorSquared ( )
inline

Definition at line 178 of file LossFunctions.h.

178 {}
emtf::PercentErrorSquared::~PercentErrorSquared ( )
inlineoverride

Definition at line 179 of file LossFunctions.h.

179 {}

Member Function Documentation

double emtf::PercentErrorSquared::fit ( std::vector< Event * > &  v)
inlineoverridevirtual

Implements emtf::LossFunction.

Definition at line 186 of file LossFunctions.h.

References alignCSCRings::e, mps_fire::i, emtf::Event::predictedValue, and emtf::Event::trueValue.

Referenced by trackingPlots.Iteration::modules().

186  {
187  // The average of the weighted residuals minimizes the squared percent error.
188  // Weight(i) = 1/true(i)^2.
189 
190  double SUMtop = 0;
191  double SUMbottom = 0;
192 
193  for (unsigned int i = 0; i < v.size(); i++) {
194  Event* e = v[i];
195  SUMtop += (e->trueValue - e->predictedValue) / (e->trueValue * e->trueValue);
196  SUMbottom += 1 / (e->trueValue * e->trueValue);
197  }
198 
199  return SUMtop / SUMbottom;
200  }
int emtf::PercentErrorSquared::id ( void  )
inlineoverridevirtual

Implements emtf::LossFunction.

Definition at line 202 of file LossFunctions.h.

202 { return 4; }
std::string emtf::PercentErrorSquared::name ( void  )
inlineoverridevirtual
double emtf::PercentErrorSquared::target ( Event e)
inlineoverridevirtual

Implements emtf::LossFunction.

Definition at line 181 of file LossFunctions.h.

References emtf::Event::predictedValue, and emtf::Event::trueValue.

181  {
182  // The gradient of the squared percent error.
183  return (e->trueValue - e->predictedValue) / (e->trueValue * e->trueValue);
184  }