CMS 3D CMS Logo

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

#include <LossFunctions.h>

Inheritance diagram for Huber:
L1TLossFunction

Public Member Functions

double calculateQuantile (std::vector< emtf::Event * > &v, double whichQuantile)
 
Double_t fit (std::vector< emtf::Event * > &v)
 
 Huber ()
 
int id ()
 
std::string name ()
 
Double_t target (emtf::Event *e)
 
 ~Huber ()
 

Public Attributes

double quantile
 
double residual_median
 

Detailed Description

Definition at line 127 of file LossFunctions.h.

Constructor & Destructor Documentation

Huber::Huber ( )
inline

Definition at line 130 of file LossFunctions.h.

130 {}
Huber::~Huber ( )
inline

Definition at line 131 of file LossFunctions.h.

131 {}

Member Function Documentation

double Huber::calculateQuantile ( std::vector< emtf::Event * > &  v,
double  whichQuantile 
)
inline

Definition at line 169 of file LossFunctions.h.

References Abs(), alignCSCRings::e, i, emtf::Event::predictedValue, and emtf::Event::trueValue.

Referenced by fit().

170  {
171  // Container for the residuals.
172  std::vector<Double_t> residuals(v.size());
173 
174  // Load the residuals into a vector.
175  for(unsigned int i=0; i<v.size(); i++)
176  {
177  emtf::Event* e = v[i];
178  residuals[i] = TMath::Abs(e->trueValue - e->predictedValue);
179  }
180 
181  std::sort(residuals.begin(), residuals.end());
182  unsigned int quantile_location = whichQuantile*(residuals.size()-1);
183  return residuals[quantile_location];
184  }
int i
Definition: DBlmapReader.cc:9
Double_t trueValue
Definition: Event.h:19
T Abs(T a)
Definition: MathUtil.h:49
Double_t predictedValue
Definition: Event.h:20
Double_t Huber::fit ( std::vector< emtf::Event * > &  v)
inlinevirtual

Implements L1TLossFunction.

Definition at line 146 of file LossFunctions.h.

References Abs(), calculateQuantile(), mps_update::diff, alignCSCRings::e, i, min(), emtf::Event::predictedValue, quantile, residual_median, emtf::Event::trueValue, and x.

Referenced by trackingPlots.Iteration::modules().

147  {
148  // The constant fit that minimizes Huber in a region.
149 
150  quantile = calculateQuantile(v, 0.7);
152 
153  double x = 0;
154  for(unsigned int i=0; i<v.size(); i++)
155  {
156  emtf::Event* e = v[i];
157  double residual = e->trueValue - e->predictedValue;
158  double diff = residual - residual_median;
159  x += ((diff > 0)?1.0:-1.0)*std::min(quantile, TMath::Abs(diff));
160  }
161 
162  return (residual_median + x/v.size());
163 
164  }
int i
Definition: DBlmapReader.cc:9
double residual_median
list diff
Definition: mps_update.py:85
double calculateQuantile(std::vector< emtf::Event * > &v, double whichQuantile)
Double_t trueValue
Definition: Event.h:19
T Abs(T a)
Definition: MathUtil.h:49
T min(T a, T b)
Definition: MathUtil.h:58
double quantile
Double_t predictedValue
Definition: Event.h:20
int Huber::id ( void  )
inlinevirtual

Implements L1TLossFunction.

Definition at line 167 of file LossFunctions.h.

167 { return 3; }
std::string Huber::name ( void  )
inlinevirtual
Double_t Huber::target ( emtf::Event e)
inlinevirtual

Implements L1TLossFunction.

Definition at line 136 of file LossFunctions.h.

References Abs(), emtf::Event::predictedValue, quantile, and emtf::Event::trueValue.

137  {
138  // The gradient of the loss function.
139 
141  return (e->trueValue - e->predictedValue);
142  else
143  return quantile*(((e->trueValue - e->predictedValue) > 0)?1.0:-1.0);
144  }
Double_t trueValue
Definition: Event.h:19
T Abs(T a)
Definition: MathUtil.h:49
double quantile
Double_t predictedValue
Definition: Event.h:20

Member Data Documentation

double Huber::quantile

Definition at line 133 of file LossFunctions.h.

Referenced by fit(), and target().

double Huber::residual_median

Definition at line 134 of file LossFunctions.h.

Referenced by fit().