 |
Belle II Software
release-05-01-25
|
1 #ifndef FITTER3DUTILITY_H
2 #define FITTER3DUTILITY_H
5 #include <TLorentzVector.h>
17 class TRGCDCJSignalData;
32 static void rPhiFit(
double* rr,
double* phi2,
double* phierror,
double& rho,
double& myphi0);
35 static void rPhiFitter(
double* rr,
double* phi2,
double* invphierror,
double& rho,
double& myphi0);
38 static void rPhiFitter(
double* rr,
double* phi2,
double* invphierror,
double& rho,
double& myphi0,
double& chi2);
41 static void chargeFinder(
double* nTSs,
double* tsIds,
double* tsHitmap,
double phi0,
double inCharge,
double& outCharge);
44 static void rPhiFit2(
double* rr,
double* phi2,
double* phierror,
double& rho,
double& myphi0,
int nTS);
50 static double calPhi(
double wirePhi,
double driftLength,
double rr,
int lr);
53 static double calPhi(
double wirePhi,
double driftTime,
double eventTime,
double rr,
int lr);
56 static double calPhi(
int localId,
int nWires,
double driftTime,
double eventTime,
double rr,
int lr);
59 static void calPhi(std::map<std::string, double>
const& mConstD, std::map<std::string, std::vector<double> >
const& mConstV,
60 std::map<std::string, Belle2::TRGCDCJSignal>& mSignalStorage, std::map<std::string, Belle2::TRGCDCJLUT* >& mLutStorage);
63 static void saveStereoXt(std::vector<std::vector<double> >& stXts, std::string
const& filePrefix);
66 static void loadStereoXt(std::string
const& filePrefix,
int nFiles, std::vector<std::vector<double> >& stXts);
69 static double stereoIdToPhi(std::vector<double>& stNWires,
int iSt,
int id);
72 static void calPhiFast(std::map<std::string, std::vector<double> >& stGeometry, std::vector<std::vector<double> >
const& stXts,
73 int eventTimeValid,
int eventTime, std::vector<std::vector<int> >
const& rawStTSs, std::vector<double>& stTSs);
76 static double rotatePhi(
double value,
double refPhi);
79 static double rotatePhi(
double value,
int refId,
int nTSs);
82 static int rotateTsId(
int value,
int refId,
int nTSs);
88 static void setErrorFast(std::vector<std::vector<int> >
const& rawStTSs,
int eventTimeValid, std::vector<double>& invZError2);
91 static void setError(std::map<std::string, double>
const& mConstD, std::map<std::string, std::vector<double> >
const& mConstV,
92 std::map<std::string, Belle2::TRGCDCJSignal>& mSignalStorage);
95 static double calStAxPhi(
int charge,
double anglest,
double ztostraw,
double rr,
double rho,
double phi0);
98 static double calDeltaPhi(
int charge,
double anglest,
double ztostraw,
double rr,
double phi,
double rho,
double phi0);
101 static void constrainRPerStSl(std::map<std::string, std::vector<double> >
const& mConstV,
102 std::map<std::string, Belle2::TRGCDCJSignal>& mSignalStorage);
105 static double calZ(
int charge,
double anglest,
double ztostraw,
double rr,
double phi,
double rho,
double phi0);
108 static void calZ(std::map<std::string, double>
const& mConstD, std::map<std::string, std::vector<double> >
const& mConstV,
109 std::map<std::string, Belle2::TRGCDCJSignal>& mSignalStorage, std::map<std::string, Belle2::TRGCDCJLUT* >& mLutStorage);
112 static double calS(
double rho,
double rr);
115 static void calS(std::map<std::string, double>
const& mConstD, std::map<std::string, std::vector<double> >
const& mConstV,
116 std::map<std::string, Belle2::TRGCDCJSignal>& mSignalStorage, std::map<std::string, Belle2::TRGCDCJLUT* >& mLutStorage);
119 static double calIZError2(
int lr,
double driftZError,
double wireZError);
122 static double calDen(
double* arcS,
double* zError);
129 static void rSFit(
double* iezz2,
double* arcS,
double* zz,
double& z0,
double& cot,
double& zchi2);
132 static void rSFit2(
double* iezz21,
double* iezz22,
double* arcS,
double* zz,
int* lutv,
double& z0,
double& cot,
double& zchi2);
135 static void rSFit(std::map<std::string, double>
const& mConstD, std::map<std::string, std::vector<double> >
const& mConstV,
136 std::map<std::string, Belle2::TRGCDCJSignal>& mSignalStorage, std::map<std::string, Belle2::TRGCDCJLUT* >& mLutStorage);
139 static void fitter3D(std::map<std::string, std::vector<double> >& stGeometry, std::vector<std::vector<double> >
const& stXts,
140 int eventTimeValid,
int eventTime,
141 std::vector<std::vector<int> >
const& rawStTSs,
142 int charge,
double radius,
double phi_c,
double& z0,
double& cot,
double& chi2);
144 static void fitter3D(std::map<std::string, std::vector<double> >& stGeometry, std::vector<std::vector<double> >
const& stXts,
145 int eventTimeValid,
int eventTime,
146 std::vector<std::vector<int> >
const& rawStTSs,
147 int charge,
double radius,
double phi_c,
double& z0,
double& cot,
double& chi2,
148 std::vector<double>& arcS, std::vector<double>& zz, std::vector<double>& invZError2);
151 static void fitter3DFirm(std::map<std::string, double>& mConstD, std::map<std::string, std::vector<double> >& mConstV,
152 int eventTimeValid,
int eventTime,
153 std::vector<std::vector<int> >
const& rawStTSs,
154 int charge,
double radius,
double phi_c,
156 std::map<std::string, Belle2::TRGCDCJLUT*>& mLutStorage);
161 static void findImpactPosition(TVector3* mcPosition, TLorentzVector* mcMomentum,
int charge, TVector2& helixCenter,
162 TVector3& impactPosition);
166 static void calHelixParameters(TVector3 position, TVector3 momentum,
int charge, TVectorD& helixParameters);
169 static void calVectorsAtR(TVectorD& helixParameters,
int charge,
double radius, TVector3& position, TVector3& momentum);
175 static int bitSize(
int numberBits,
int mode);
178 static void changeInteger(
int& integer,
double real,
double minValue,
double maxValue,
int bitSize);
181 static void changeReal(
double& real,
int integer,
double minValue,
double maxValue,
int bitSize);
184 static void findExtreme(
double& m_max,
double& m_min,
double value);
static void fitter3DFirm(std::map< std::string, double > &mConstD, 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 findImpactPosition(TVector3 *mcPosition, TLorentzVector *mcMomentum, int charge, TVector2 &helixCenter, TVector3 &impactPosition)
MC calculation functions Calculates the impact position of track.
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 unsigned toUnsignedTdc(int tdc, int nBits)
Changes tdc and event time to unsigned value that has # bits.
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 void calVectorsAtR(TVectorD &helixParameters, int charge, double radius, TVector3 &position, TVector3 &momentum)
Calculates position and momentum at a certain radius.
static void changeInteger(int &integer, double real, double minValue, double maxValue, int bitSize)
Changes float to integer value.
static void findExtreme(double &m_max, double &m_min, double value)
Finds maximum and minium values.
static double calDen(double *arcS, double *zError)
Calculates the denominator for fitting z and arc s.
A class that holds functions for 3D tracking.
static void rPhiFit2(double *rr, double *phi2, double *phierror, double &rho, double &myphi0, int nTS)
A circle fitter.
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 double calZ(int charge, double anglest, double ztostraw, double rr, double phi, double rho, double phi0)
Calculates z.
A class to hold common data for JSignals.
static int rotateTsId(int value, int refId, int nTSs)
Rotates to range [0, nTSs-1].
static void rPhiFitter(double *rr, double *phi2, double *invphierror, double &rho, double &myphi0)
A circle fitter with invPhiError without fit chi2 output.
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 int bitSize(int numberBits, int mode)
Firmware convert functions.
static double calS(double rho, double rr)
Calculates arc length.
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.
Abstract base class for different kinds of events.
static double calDenWithIZError(double *arcS, double *iZError)
Calculates the denominator for fitting z and arc s.
static double stereoIdToPhi(std::vector< double > &stNWires, int iSt, int id)
Converts stereo ts id to phi.
static void changeReal(double &real, int integer, double minValue, double maxValue, int bitSize)
Changes integer to float value.
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 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 int findQuadrant(double value)
Finds quadrant of angle. Angle is in rad.
static void rPhiFit(double *rr, double *phi2, double *phierror, double &rho, double &myphi0)
A circle fitter.
static void saveStereoXt(std::vector< std::vector< double > > &stXts, std::string const &filePrefix)
Saves stereo Xt to file.
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 void rSFit(double *iezz2, double *arcS, double *zz, double &z0, double &cot, double &zchi2)
3D fitter functions Fits z and arc S.
static void calHelixParameters(TVector3 position, TVector3 momentum, int charge, TVectorD &helixParameters)
HelixParameters: dR, phi0, keppa, dz, tanLambda Calculates the helix parameters of track.
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 double calIZError2(int lr, double driftZError, double wireZError)
Chooses and calculates inverse z error.
static int findSign(double *phi2)
2D fitter functions
static void loadStereoXt(std::string const &filePrefix, int nFiles, std::vector< std::vector< double > > &stXts)
Load stereo Xt file.
static double rotatePhi(double value, double refPhi)
Rotates to range [-pi, pi].