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

Constructor & Destructor Documentation

emtf::PercentErrorSquared::PercentErrorSquared ( )
inline

Definition at line 198 of file LossFunctions.h.

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

Definition at line 199 of file LossFunctions.h.

199 {}

Member Function Documentation

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

Implements emtf::LossFunction.

Definition at line 207 of file LossFunctions.h.

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

Referenced by trackingPlots.Iteration::modules().

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

Implements emtf::LossFunction.

Definition at line 225 of file LossFunctions.h.

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

Implements emtf::LossFunction.

Definition at line 224 of file LossFunctions.h.

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

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

Implements emtf::LossFunction.

Definition at line 201 of file LossFunctions.h.

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

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