5 #ifndef L1Trigger_L1TMuonEndCap_emtf_LossFunctions
6 #define L1Trigger_L1TMuonEndCap_emtf_LossFunctions
29 virtual double fit(std::vector<Event*>&
v) = 0;
49 double fit(std::vector<Event*>&
v)
override {
53 for (
unsigned int i = 0;
i < v.size();
i++) {
58 return SUM / v.size();
61 int id()
override {
return 1; }
81 double fit(std::vector<Event*>&
v)
override {
85 std::vector<double> residuals(v.size());
88 for (
unsigned int i = 0;
i < v.size();
i++) {
94 int median_loc = (residuals.size() - 1) / 2;
97 if (residuals.size() % 2 != 0) {
98 std::nth_element(residuals.begin(), residuals.begin() + median_loc, residuals.end());
99 return residuals[median_loc];
104 std::nth_element(residuals.begin(), residuals.begin() + median_loc, residuals.end());
105 double low = residuals[median_loc];
106 std::nth_element(residuals.begin() + median_loc + 1, residuals.begin() + median_loc + 1, residuals.end());
107 double high = residuals[median_loc + 1];
108 return (high + low) / 2;
112 int id()
override {
return 2; }
136 double fit(std::vector<Event*>&
v)
override {
143 for (
unsigned int i = 0;
i < v.size();
i++) {
154 int id()
override {
return 3; }
158 std::vector<double> residuals(v.size());
161 for (
unsigned int i = 0;
i < v.size();
i++) {
166 std::sort(residuals.begin(), residuals.end());
167 unsigned int quantile_location = whichQuantile * (residuals.size() - 1);
168 return residuals[quantile_location];
186 double fit(std::vector<Event*>&
v)
override {
191 double SUMbottom = 0;
193 for (
unsigned int i = 0;
i < v.size();
i++) {
199 return SUMtop / SUMbottom;
202 int id()
override {
return 4; }
double fit(std::vector< Event * > &v) override
std::string name() override
std::string name() override
double target(Event *e) override
virtual double fit(std::vector< Event * > &v)=0
double target(Event *e) override
std::string name() override
virtual std::string name()=0
double fit(std::vector< Event * > &v) override
Abs< T >::type abs(const T &t)
double target(Event *e) override
~PercentErrorSquared() override
double fit(std::vector< Event * > &v) override
virtual double target(Event *e)=0
std::string name() override
double fit(std::vector< Event * > &v) override
double target(Event *e) override
~AbsoluteDeviation() override
double calculateQuantile(std::vector< Event * > &v, double whichQuantile)
virtual ~LossFunction()=default