CMS 3D CMS Logo

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 194 of file LossFunctions.h.

Constructor & Destructor Documentation

emtf::PercentErrorSquared::PercentErrorSquared ( )
inline

Definition at line 197 of file LossFunctions.h.

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

Definition at line 198 of file LossFunctions.h.

198 {}

Member Function Documentation

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

Implements emtf::LossFunction.

Definition at line 206 of file LossFunctions.h.

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

Referenced by trackingPlots.Iteration::modules().

207  {
208  // The average of the weighted residuals minimizes the squared percent error.
209  // Weight(i) = 1/true(i)^2.
210 
211  double SUMtop = 0;
212  double SUMbottom = 0;
213 
214  for(unsigned int i=0; i<v.size(); i++)
215  {
216  Event* e = v[i];
217  SUMtop += (e->trueValue - e->predictedValue)/(e->trueValue*e->trueValue);
218  SUMbottom += 1/(e->trueValue*e->trueValue);
219  }
220 
221  return SUMtop/SUMbottom;
222  }
int emtf::PercentErrorSquared::id ( void  )
inlineoverridevirtual

Implements emtf::LossFunction.

Definition at line 224 of file LossFunctions.h.

224 { return 4; }
std::string emtf::PercentErrorSquared::name ( void  )
inlineoverridevirtual

Implements emtf::LossFunction.

Definition at line 223 of file LossFunctions.h.

Referenced by config.CFG::__str__(), validation.Sample::digest(), and VIDSelectorBase.VIDSelectorBase::initialize().

223 { return "Percent_Error"; }
double emtf::PercentErrorSquared::target ( Event e)
inlineoverridevirtual

Implements emtf::LossFunction.

Definition at line 200 of file LossFunctions.h.

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

201  {
202  // The gradient of the squared percent error.
203  return (e->trueValue - e->predictedValue)/(e->trueValue * e->trueValue);
204  }