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

Constructor & Destructor Documentation

emtf::LeastSquares::LeastSquares ( )
inline

Definition at line 44 of file LossFunctions.h.

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

Definition at line 45 of file LossFunctions.h.

45 {}

Member Function Documentation

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

Implements emtf::LossFunction.

Definition at line 53 of file LossFunctions.h.

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

Referenced by trackingPlots.Iteration::modules().

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

Implements emtf::LossFunction.

Definition at line 67 of file LossFunctions.h.

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

Implements emtf::LossFunction.

Definition at line 66 of file LossFunctions.h.

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

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

Implements emtf::LossFunction.

Definition at line 47 of file LossFunctions.h.

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

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