Belle II Software development
SVDMCFudgeFactorFunction.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#pragma once
10
11#include <framework/logging/Logger.h>
12#include <TObject.h>
13#include <TF1.h>
14#include <TString.h>
15#include <TROOT.h>
16#include <TGraph.h>
17
18#include <cmath>
19#include <vector>
20
21namespace Belle2 {
28 class SVDMCFudgeFactorFunction : public TObject {
29
30 public:
31
33 typedef double (SVDMCFudgeFactorFunction::*fudgeFactorFunction)(double) const;
34
36 double getFudgeFactor(double trkAngle) const
37 {
39 return (this->*f)(trkAngle) ;
40 }
41
44 {
45 // The m_implementations vector is static.
46 // We have to initialize it just once.
47 if (m_implementations.size() == 0) {
50 }
51
52 m_current = m_implementations.size() - 1;
53
54 };
55
57 void set_current(int current)
58 {
59 m_current = current;
60 }
61
62 //SETTERS FOR function ID = 0 (cheby_v0)
68 void set_chebyCoeffs(std::vector<double> c)
69 {
70 m_chebyCoeffs = c;
71 }
72
73 //SETTERS FOR function ID = 1 (tgraph_v0)
80 void set_graphPoints(std::vector<double> x, std::vector<double> y)
81 {
82 m_x = x;
83 m_y = y;
84 }
85
88
91
92 private:
99 std::vector<double> m_chebyCoeffs;
100
105 double cheby_v0(double trkAngle) const
106 {
107 TF1* f = (TF1*) gROOT->GetFunction(TString::Format("chebyshev%lu", m_chebyCoeffs.size() - 1));
108 f->SetParameters(&m_chebyCoeffs[0]);
109
110 return f->Eval(trkAngle);
111 };
112
117 std::vector<double> m_x;
119 std::vector<double> m_y;
120
125 double tgraph_v0(double trkAngle) const
126 {
127 TGraph* g = new TGraph(m_x.size(), &m_x[0], &m_y[0]);
128 double returnvalue = g->Eval(trkAngle);
129 delete g;
130
131 return returnvalue;
132 };
133
136
138 static std::vector < fudgeFactorFunction > m_implementations;
139
141 };
142
144}
class to contain the MC fudge factor formulae
std::vector< double > m_chebyCoeffs
function parameters & implementations
void set_graphPoints(std::vector< double > x, std::vector< double > y)
Set vectors of TGraph points (x for angles, y for sigmas) Input:
SVDMCFudgeFactorFunction & operator=(const Belle2::SVDMCFudgeFactorFunction &a)
operator =
double tgraph_v0(double trkAngle) const
tgraph_v0 implementation
double cheby_v0(double trkAngle) const
cheby_v0 implementation
ClassDef(SVDMCFudgeFactorFunction, 2)
Do not stream this, please throw it in the WC.
void set_chebyCoeffs(std::vector< double > c)
Set the vector of Chebyshev coefficients Input:
double getFudgeFactor(double trkAngle) const
returns the fudge factor, depending on the track's angle
double(SVDMCFudgeFactorFunction::* fudgeFactorFunction)(double) const
typedef of the return value of the fudge factor function
std::vector< double > m_y
Vectors of TGraph points for the sigmas.
void set_current(int current)
allows to choose the function version
std::vector< double > m_x
ID = {1}, rel07: fudge factor parametrized with linear interpolation between graph points.
static std::vector< fudgeFactorFunction > m_implementations
vector of functions for fudge factor computation, we use the m_current
Abstract base class for different kinds of events.