CMS 3D CMS Logo

List of all members | Public Member Functions
PercentErrorSquared Class Reference

#include <LossFunctions.h>

Inheritance diagram for PercentErrorSquared:
L1TLossFunction

Public Member Functions

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

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< emtf::Event * > &  v)
inlinevirtual

Implements L1TLossFunction.

Definition at line 203 of file LossFunctions.h.

References MillePedeFileConverter_cfg::e, mps_fire::i, emtf::Event::predictedValue, and emtf::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  emtf::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 trueValue
Definition: Event.h:19
Double_t predictedValue
Definition: Event.h:20
int PercentErrorSquared::id ( void  )
inlinevirtual

Implements L1TLossFunction.

Definition at line 221 of file LossFunctions.h.

221 { return 4; }
std::string PercentErrorSquared::name ( void  )
inlinevirtual

Implements L1TLossFunction.

Definition at line 220 of file LossFunctions.h.

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

220 { return "Percent_Error"; }
Double_t PercentErrorSquared::target ( emtf::Event e)
inlinevirtual

Implements L1TLossFunction.

Definition at line 197 of file LossFunctions.h.

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

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