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:
LossFunction

Public Member Functions

double calculateQuantile (std::vector< Event * > &v, double whichQuantile)
 
Double_t fit (std::vector< Event * > &v)
 
 Huber ()
 
int id ()
 
std::string name ()
 
Double_t target (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< Event * > &  v,
double  whichQuantile 
)
inline

Definition at line 169 of file LossFunctions.h.

References Abs(), alignCSCRings::e, i, Event::predictedValue, and 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  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  }
Double_t predictedValue
Definition: Event.h:20
int i
Definition: DBlmapReader.cc:9
Definition: Event.h:16
T Abs(T a)
Definition: MathUtil.h:49
Double_t trueValue
Definition: Event.h:19
Double_t Huber::fit ( std::vector< Event * > &  v)
inlinevirtual

Implements LossFunction.

Definition at line 146 of file LossFunctions.h.

References Abs(), calculateQuantile(), diffTreeTool::diff, alignCSCRings::e, i, min(), Event::predictedValue, quantile, residual_median, 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  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  }
Double_t predictedValue
Definition: Event.h:20
int i
Definition: DBlmapReader.cc:9
double residual_median
double calculateQuantile(std::vector< Event * > &v, double whichQuantile)
Definition: Event.h:16
T Abs(T a)
Definition: MathUtil.h:49
T min(T a, T b)
Definition: MathUtil.h:58
double quantile
Double_t trueValue
Definition: Event.h:19
int Huber::id ( void  )
inlinevirtual

Implements LossFunction.

Definition at line 167 of file LossFunctions.h.

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

Implements LossFunction.

Definition at line 136 of file LossFunctions.h.

References Abs(), Event::predictedValue, quantile, and 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 predictedValue
Definition: Event.h:20
T Abs(T a)
Definition: MathUtil.h:49
double quantile
Double_t trueValue
Definition: Event.h:19

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().