test
CMS 3D CMS Logo

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

#include <LossFunctions.h>

Inheritance diagram for PercentErrorSquared:
LossFunction

Public Member Functions

Double_t fit (std::vector< Event * > &v)
 
int id ()
 
std::string name ()
 
 PercentErrorSquared ()
 
Double_t target (Event *e)
 
 ~PercentErrorSquared ()
 

Detailed Description

Definition at line 191 of file LossFunctions.h.

Constructor & Destructor Documentation

PercentErrorSquared::PercentErrorSquared ( )
inline

Definition at line 194 of file LossFunctions.h.

194 {}
PercentErrorSquared::~PercentErrorSquared ( )
inline

Definition at line 195 of file LossFunctions.h.

195 {}

Member Function Documentation

Double_t PercentErrorSquared::fit ( std::vector< Event * > &  v)
inlinevirtual

Implements LossFunction.

Definition at line 203 of file LossFunctions.h.

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

Referenced by trackingPlots.Iteration::modules().

204  {
205  // The average of the weighted residuals minimizes the squared percent error.
206  // Weight(i) = 1/true(i)^2.
207 
208  Double_t SUMtop = 0;
209  Double_t SUMbottom = 0;
210 
211  for(unsigned int i=0; i<v.size(); i++)
212  {
213  Event* e = v[i];
214  SUMtop += (e->trueValue - e->predictedValue)/(e->trueValue*e->trueValue);
215  SUMbottom += 1/(e->trueValue*e->trueValue);
216  }
217 
218  return SUMtop/SUMbottom;
219  }
Double_t predictedValue
Definition: Event.h:20
int i
Definition: DBlmapReader.cc:9
Definition: Event.h:16
Double_t trueValue
Definition: Event.h:19
int PercentErrorSquared::id ( void  )
inlinevirtual

Implements LossFunction.

Definition at line 221 of file LossFunctions.h.

221 { return 4; }
std::string PercentErrorSquared::name ( void  )
inlinevirtual
Double_t PercentErrorSquared::target ( Event e)
inlinevirtual

Implements LossFunction.

Definition at line 197 of file LossFunctions.h.

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

198  {
199  // The gradient of the squared percent error.
200  return (e->trueValue - e->predictedValue)/(e->trueValue * e->trueValue);
201  }
Double_t predictedValue
Definition: Event.h:20
Double_t trueValue
Definition: Event.h:19