CMS 3D CMS Logo

List of all members | Public Member Functions
emtf::LeastSquares Class Reference

#include <LossFunctions.h>

Inheritance diagram for emtf::LeastSquares:
emtf::LossFunction

Public Member Functions

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

Detailed Description

Definition at line 40 of file LossFunctions.h.

Constructor & Destructor Documentation

emtf::LeastSquares::LeastSquares ( )
inline

Definition at line 43 of file LossFunctions.h.

43 {}
emtf::LeastSquares::~LeastSquares ( )
inlineoverride

Definition at line 44 of file LossFunctions.h.

44 {}

Member Function Documentation

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

Implements emtf::LossFunction.

Definition at line 52 of file LossFunctions.h.

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

Referenced by trackingPlots.Iteration::modules().

53  {
54  // The average of the residuals minmizes the Loss Function for LS.
55 
56  double SUM = 0;
57  for(unsigned int i=0; i<v.size(); i++)
58  {
59  Event* e = v[i];
60  SUM += e->trueValue - e->predictedValue;
61  }
62 
63  return SUM/v.size();
64  }
#define SUM(A, B)
int emtf::LeastSquares::id ( void  )
inlineoverridevirtual

Implements emtf::LossFunction.

Definition at line 66 of file LossFunctions.h.

66 { return 1; }
std::string emtf::LeastSquares::name ( void  )
inlineoverridevirtual

Implements emtf::LossFunction.

Definition at line 65 of file LossFunctions.h.

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

65 { return "Least_Squares"; }
double emtf::LeastSquares::target ( Event e)
inlineoverridevirtual

Implements emtf::LossFunction.

Definition at line 46 of file LossFunctions.h.

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

47  {
48  // Each tree fits the residuals when using LeastSquares.
49  return e->trueValue - e->predictedValue;
50  }