Belle II Software development
Fitter3DUtility.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#ifndef FITTER3DUTILITY_H
10#define FITTER3DUTILITY_H
11
12#include <TVectorD.h>
13#include <Math/Vector4D.h>
14#include <Math/Vector3D.h>
15#include <Math/Vector2D.h>
16#include <map>
17#include <string>
18
19namespace Belle2 {
24 class TRGCDCJSignal;
25 class TRGCDCJSignalData;
26 class TRGCDCJLUT;
28};
29
30
33
34public:
35
37 static int findSign(double* phi2);
38
40 static void rPhiFit(double* rr, double* phi2, double* phierror, double& rho, double& myphi0);
41
43 static void rPhiFitter(double* rr, double* phi2, double* invphierror, double& rho, double& myphi0);
44
46 static void rPhiFitter(double* rr, double* phi2, double* invphierror, double& rho, double& myphi0, double& chi2);
47
49 static void chargeFinder(double* nTSs, double* tsIds, double* tsHitmap, double phi0, double inCharge, double& outCharge);
50
52 static void rPhiFit2(double* rr, double* phi2, double* phierror, double& rho, double& myphi0, int nTS);
53
55 static unsigned toUnsignedTdc(int tdc, int nBits);
56
58 static double calPhi(double wirePhi, double driftLength, double rr, int lr);
59
61 static double calPhi(double wirePhi, double driftTime, double eventTime, double rr, int lr);
62
64 static double calPhi(int localId, int nWires, double driftTime, double eventTime, double rr, int lr);
65
67 static void calPhi(std::map<std::string, double> const& mConstD, std::map<std::string, std::vector<double> > const& mConstV,
68 std::map<std::string, Belle2::TRGCDCJSignal>& mSignalStorage, std::map<std::string, Belle2::TRGCDCJLUT* >& mLutStorage);
69
71 static void saveStereoXt(std::vector<std::vector<double> >& stXts, std::string const& filePrefix);
72
74 static void loadStereoXt(std::string const& filePrefix, int nFiles, std::vector<std::vector<double> >& stXts);
75
77 static double stereoIdToPhi(std::vector<double>& stNWires, int iSt, int id);
78
80 static void calPhiFast(std::map<std::string, std::vector<double> >& stGeometry, std::vector<std::vector<double> > const& stXts,
81 int eventTimeValid, int eventTime, std::vector<std::vector<int> > const& rawStTSs, std::vector<double>& stTSs);
82
84 static double rotatePhi(double value, double refPhi);
85
87 static double rotatePhi(double value, int refId, int nTSs);
88
90 static int rotateTsId(int value, int refId, int nTSs);
91
93 static int findQuadrant(double value);
94
96 static void setErrorFast(std::vector<std::vector<int> > const& rawStTSs, int eventTimeValid, std::vector<double>& invZError2);
97
99 static void setError(std::map<std::string, double> const& mConstD, std::map<std::string, std::vector<double> > const& mConstV,
100 std::map<std::string, Belle2::TRGCDCJSignal>& mSignalStorage);
101
103 static double calStAxPhi(int charge, double anglest, double ztostraw, double rr, double rho, double phi0);
104
106 static double calDeltaPhi(int charge, double anglest, double ztostraw, double rr, double phi, double rho, double phi0);
107
109 static void constrainRPerStSl(std::map<std::string, std::vector<double> > const& mConstV,
110 std::map<std::string, Belle2::TRGCDCJSignal>& mSignalStorage);
111
113 static double calZ(int charge, double anglest, double ztostraw, double rr, double phi, double rho, double phi0);
114
116 static void calZ(std::map<std::string, double> const& mConstD, std::map<std::string, std::vector<double> > const& mConstV,
117 std::map<std::string, Belle2::TRGCDCJSignal>& mSignalStorage, std::map<std::string, Belle2::TRGCDCJLUT* >& mLutStorage);
118
120 static double calS(double rho, double rr);
121
123 static void calS(std::map<std::string, double> const& mConstD, std::map<std::string, std::vector<double> > const& mConstV,
124 std::map<std::string, Belle2::TRGCDCJSignal>& mSignalStorage, std::map<std::string, Belle2::TRGCDCJLUT* >& mLutStorage);
125
127 static double calIZError2(int lr, double driftZError, double wireZError);
128
130 static double calDen(double* arcS, double* zError);
131
133 static double calDenWithIZError(double* arcS, double* iZError);
134
137 static void rSFit(double* iezz2, double* arcS, double* zz, double& z0, double& cot, double& zchi2);
138
140 static void rSFit2(double* iezz21, double* iezz22, double* arcS, double* zz, int* lutv, double& z0, double& cot, double& zchi2);
141
143 static void rSFit(std::map<std::string, double> const& mConstD, std::map<std::string, std::vector<double> > const& mConstV,
144 std::map<std::string, Belle2::TRGCDCJSignal>& mSignalStorage, std::map<std::string, Belle2::TRGCDCJLUT* >& mLutStorage);
145
147 static void fitter3D(std::map<std::string, std::vector<double> >& stGeometry, std::vector<std::vector<double> > const& stXts,
148 int eventTimeValid, int eventTime,
149 std::vector<std::vector<int> > const& rawStTSs,
150 int charge, double radius, double phi_c, double& z0, double& cot, double& chi2);
152 static void fitter3D(std::map<std::string, std::vector<double> >& stGeometry, std::vector<std::vector<double> > const& stXts,
153 int eventTimeValid, int eventTime,
154 std::vector<std::vector<int> > const& rawStTSs,
155 int charge, double radius, double phi_c, double& z0, double& cot, double& chi2,
156 std::vector<double>& arcS, std::vector<double>& zz, std::vector<double>& invZError2);
157
159 static void fitter3DFirm(std::map<std::string, double>& mConstD, const std::map<std::string, std::vector<double> >& mConstV,
160 int eventTimeValid, int eventTime,
161 std::vector<std::vector<int> > const& rawStTSs,
162 int charge, double radius, double phi_c,
163 Belle2::TRGCDCJSignalData* commonData, std::map<std::string, Belle2::TRGCDCJSignal>& mSignalStorage,
164 std::map<std::string, Belle2::TRGCDCJLUT*>& mLutStorage);
165
166
169 static void findImpactPosition(ROOT::Math::XYZVector* mcPosition, ROOT::Math::PxPyPzEVector* mcMomentum, int charge,
170 ROOT::Math::XYVector& helixCenter,
171 ROOT::Math::XYZVector& impactPosition);
172
175 static void calHelixParameters(ROOT::Math::XYZVector position, ROOT::Math::XYZVector momentum, int charge,
176 TVectorD& helixParameters);
177
179 static void calVectorsAtR(const TVectorD& helixParameters, int charge, double radius, ROOT::Math::XYZVector& position,
180 ROOT::Math::XYZVector& momentum);
181
183
186 static int bitSize(int numberBits, int mode);
187
189 static void changeInteger(int& integer, double real, double minValue, double maxValue, int bitSize);
190
192 static void changeReal(double& real, int integer, double minValue, double maxValue, int bitSize);
193
195 static void findExtreme(double& m_max, double& m_min, double value);
196};
197
198#endif
A class to hold common data for JSignals.
Definition: JSignalData.h:33
A class that holds functions for 3D tracking.
static void calVectorsAtR(const TVectorD &helixParameters, int charge, double radius, ROOT::Math::XYZVector &position, ROOT::Math::XYZVector &momentum)
Calculates position and momentum at a certain radius.
static void loadStereoXt(std::string const &filePrefix, int nFiles, std::vector< std::vector< double > > &stXts)
Load stereo Xt file.
static double calIZError2(int lr, double driftZError, double wireZError)
Chooses and calculates inverse z error.
static double rotatePhi(double value, double refPhi)
Rotates to range [-pi, pi].
static double calStAxPhi(int charge, double anglest, double ztostraw, double rr, double rho, double phi0)
Calculates the fitted axial phi for the stereo super layer.
static void changeReal(double &real, int integer, double minValue, double maxValue, int bitSize)
Changes integer to float value.
static void calHelixParameters(ROOT::Math::XYZVector position, ROOT::Math::XYZVector momentum, int charge, TVectorD &helixParameters)
HelixParameters: dR, phi0, keppa, dz, tanLambda Calculates the helix parameters of track.
static int findQuadrant(double value)
Finds quadrant of angle. Angle is in rad.
static int bitSize(int numberBits, int mode)
Firmware convert functions.
static void fitter3DFirm(std::map< std::string, double > &mConstD, const std::map< std::string, std::vector< double > > &mConstV, int eventTimeValid, int eventTime, std::vector< std::vector< int > > const &rawStTSs, int charge, double radius, double phi_c, Belle2::TRGCDCJSignalData *commonData, std::map< std::string, Belle2::TRGCDCJSignal > &mSignalStorage, std::map< std::string, Belle2::TRGCDCJLUT * > &mLutStorage)
Combines several functions for fitter3D firmware.
static void rPhiFitter(double *rr, double *phi2, double *invphierror, double &rho, double &myphi0)
A circle fitter with invPhiError without fit chi2 output.
static void changeInteger(int &integer, double real, double minValue, double maxValue, int bitSize)
Changes float to integer value.
static double calZ(int charge, double anglest, double ztostraw, double rr, double phi, double rho, double phi0)
Calculates z.
static double calDenWithIZError(double *arcS, double *iZError)
Calculates the denominator for fitting z and arc s.
static void setError(std::map< std::string, double > const &mConstD, std::map< std::string, std::vector< double > > const &mConstV, std::map< std::string, Belle2::TRGCDCJSignal > &mSignalStorage)
Sets error using JSignal class.
static void setErrorFast(std::vector< std::vector< int > > const &rawStTSs, int eventTimeValid, std::vector< double > &invZError2)
Sets error for fitting.
static void calPhiFast(std::map< std::string, std::vector< double > > &stGeometry, std::vector< std::vector< double > > const &stXts, int eventTimeValid, int eventTime, std::vector< std::vector< int > > const &rawStTSs, std::vector< double > &stTSs)
Calculates phi with fast simulation.
static double calDeltaPhi(int charge, double anglest, double ztostraw, double rr, double phi, double rho, double phi0)
Calculates the phi difference between fitted axial phi and stereo phi.
static double calS(double rho, double rr)
Calculates arc length.
static double stereoIdToPhi(std::vector< double > &stNWires, int iSt, int id)
Converts stereo ts id to phi.
static void fitter3D(std::map< std::string, std::vector< double > > &stGeometry, std::vector< std::vector< double > > const &stXts, int eventTimeValid, int eventTime, std::vector< std::vector< int > > const &rawStTSs, int charge, double radius, double phi_c, double &z0, double &cot, double &chi2)
Combines several functions for fitter3D.
static int findSign(double *phi2)
2D fitter functions
static double calPhi(double wirePhi, double driftLength, double rr, int lr)
Pre 3D fitter functions. rr is in cm scale. driftLength is in cm scale.
static void chargeFinder(double *nTSs, double *tsIds, double *tsHitmap, double phi0, double inCharge, double &outCharge)
Charge finder using circle fitter output and axial TSs.
static int rotateTsId(int value, int refId, int nTSs)
Rotates to range [0, nTSs-1].
static void saveStereoXt(std::vector< std::vector< double > > &stXts, std::string const &filePrefix)
Saves stereo Xt to file.
static void rPhiFit(double *rr, double *phi2, double *phierror, double &rho, double &myphi0)
A circle fitter.
static void rSFit2(double *iezz21, double *iezz22, double *arcS, double *zz, int *lutv, double &z0, double &cot, double &zchi2)
Fits z and arc S. (Will be deprecated.)
static unsigned toUnsignedTdc(int tdc, int nBits)
Changes tdc and event time to unsigned value that has # bits.
static void rSFit(double *iezz2, double *arcS, double *zz, double &z0, double &cot, double &zchi2)
3D fitter functions Fits z and arc S.
static double calDen(double *arcS, double *zError)
Calculates the denominator for fitting z and arc s.
static void rPhiFit2(double *rr, double *phi2, double *phierror, double &rho, double &myphi0, int nTS)
A circle fitter.
static void findExtreme(double &m_max, double &m_min, double value)
Finds maximum and minium values.
static void constrainRPerStSl(std::map< std::string, std::vector< double > > const &mConstV, std::map< std::string, Belle2::TRGCDCJSignal > &mSignalStorage)
Constrains R for each SL differently using JSignal and multiple constants.
static void findImpactPosition(ROOT::Math::XYZVector *mcPosition, ROOT::Math::PxPyPzEVector *mcMomentum, int charge, ROOT::Math::XYVector &helixCenter, ROOT::Math::XYZVector &impactPosition)
MC calculation functions Calculates the impact position of track.
Abstract base class for different kinds of events.