CbmRoot
Loading...
Searching...
No Matches
CbmLitFieldFitter.h
Go to the documentation of this file.
1/* Copyright (C) 2009-2012 GSI/JINR-LIT, Darmstadt/Dubna
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Andrey Lebedev [committer] */
4
12#ifndef CBMLITFIELDFITTER_H_
13#define CBMLITFIELDFITTER_H_
14
15#include "LitFieldSlice.h"
16
17#include <vector>
18class FairField;
19
27 public:
32
36 virtual ~CbmLitPolynom() {}
37
45 virtual double Calculate(double x, double y, double c[]) const = 0;
46
51 virtual unsigned int GetNofCoefficients() const = 0;
52};
53
66 public:
71 CbmLitFieldFitter(unsigned int polynomDegree);
72
76 virtual ~CbmLitFieldFitter();
77
83 template<class T>
85 {
86 std::vector<double> aparBx, aparBy, aparBz;
87 FitSlice(Z, aparBx, aparBy, aparBz);
88
89 std::vector<T> aparBxT, aparByT, aparBzT;
90 aparBxT.assign(aparBx.begin(), aparBx.end());
91 aparByT.assign(aparBy.begin(), aparBy.end());
92 aparBzT.assign(aparBz.begin(), aparBz.end());
93
94 slice.SetZ(Z);
95 slice.SetCoefficients(aparBxT, aparByT, aparBzT);
96 }
97
102
107
108 /* Setters */
109 void SetXangle(double xangle) { fXangle = xangle; }
110 void SetYangle(double yangle) { fYangle = yangle; }
111 void SetNofBinsX(int nofBinsX) { fNofBinsX = nofBinsX; }
112 void SetNofBinsY(int nofBinsY) { fNofBinsY = nofBinsY; }
113 void SetUseEllipseAcc(bool useEllipseAcc) { fUseEllipseAcc = useEllipseAcc; }
114
115 private:
123 void FitSlice(double Z, std::vector<double>& parBx, std::vector<double>& parBy, std::vector<double>& parBz);
124
132 void FitSlice(const std::vector<double>& x, const std::vector<double>& y, const std::vector<double>& z,
133 std::vector<double>& par);
134
142 void FitSliceMy(double Z, std::vector<double>& parBx, std::vector<double>& parBy, std::vector<double>& parBz);
143
148 const CbmLitPolynom* GetPolynom() const { return fPolynom; }
149
150 private:
151 FairField* fField; // Magnetic field
152
153 double fXangle; // Acceptance angle for X [grad]
154 double fYangle; // Acceptance angle for Y [grad]
155
156 int fNofBinsX; // Number of bins for X [cm]
157 int fNofBinsY; // Number of bins for Y [cm]
158
159 bool fUseEllipseAcc; // If true than only values inside an ellipse will be fitted
160
161 unsigned int fPolynomDegree; // Degree of the polynomial to be used for the field approximation
162 CbmLitPolynom* fPolynom; // Polynomial to be used for field approximation
163};
164
165#endif /* CBMLITFIELDFITTER_H_ */
Approximated magnetic field slice in XY plane perpendicular to Z.
Implementation of the polynomial field approximation.
const CbmLitPolynom * GetPolynom() const
Return polynomial which is used for approximation.
void FitSlice(float Z, lit::parallel::LitFieldSlice< T > &slice)
Fits (X, Y) slice of the magnetic field at Z position.
CbmLitPolynom * fPolynom
void SetNofBinsX(int nofBinsX)
void FitSliceVec(float Z, lit::parallel::LitFieldSlice< fvec > &slice)
FitSlice implementation using fvec data type.
void SetXangle(double xangle)
void FitSliceMy(double Z, std::vector< double > &parBx, std::vector< double > &parBy, std::vector< double > &parBz)
Fit (X, Y) slice of the magnetic field at Z position.
void SetUseEllipseAcc(bool useEllipseAcc)
virtual ~CbmLitFieldFitter()
Destructor.
void FitSliceScal(float Z, lit::parallel::LitFieldSlice< fscal > &slice)
FitSlice implementation using fscal data type.
void SetNofBinsY(int nofBinsY)
CbmLitFieldFitter(unsigned int polynomDegree)
Constructor.
unsigned int fPolynomDegree
void SetYangle(double yangle)
Abstract class for polynomial function.
CbmLitPolynom()
Constructor.
virtual unsigned int GetNofCoefficients() const =0
Return number of coefficients for this polynomial function.
virtual ~CbmLitPolynom()
Destructor.
virtual double Calculate(double x, double y, double c[]) const =0
Returns calculated value.
Approximated magnetic field slice in XY plane perpendicular to Z.
void SetZ(const T &Z)
Sets Z position of the slice.
void SetCoefficients(const std::vector< T > &x, const std::vector< T > &y, const std::vector< T > &z)
Sets polynom coefficients.