[127644a] | 1 | //
|
---|
| 2 | #ifndef G__VERTEXFIT_H
|
---|
| 3 | #define G__VERTEXFIT_H
|
---|
| 4 | //
|
---|
| 5 | #include <TMath.h>
|
---|
| 6 | #include <TVectorD.h>
|
---|
| 7 | #include <TMatrixDSym.h>
|
---|
| 8 | #include "ObsTrk.h"
|
---|
[82db145] | 9 | #include <vector>
|
---|
[127644a] | 10 | #include <iostream>
|
---|
| 11 | //
|
---|
| 12 | // Class for vertex fitting
|
---|
| 13 |
|
---|
| 14 | class VertexFit {
|
---|
| 15 | //
|
---|
| 16 | // Vertex fitting with track parameters steering
|
---|
| 17 | // Author: F. Bedeschi, INFN-Pisa, Italy
|
---|
| 18 | // February 10, 2021
|
---|
| 19 | //
|
---|
| 20 | private:
|
---|
| 21 | //
|
---|
| 22 | // Inputs
|
---|
| 23 | Int_t fNtr; // Number of tracks
|
---|
[82db145] | 24 | std::vector<TVectorD*> fPar; // Input parameter array
|
---|
[53f4746] | 25 | std::vector<TVectorD*> fParNew; // Updated parameter array
|
---|
| 26 | std::vector<TMatrixDSym*> fCov; // Input parameter covariances
|
---|
| 27 | std::vector<TMatrixDSym*> fCovNew; // Updated parameter covariances
|
---|
[127644a] | 28 | // Constraints
|
---|
| 29 | Bool_t fVtxCst; // Vertex constraint flag
|
---|
| 30 | TVectorD fxCst; // Constraint value
|
---|
[53f4746] | 31 | TMatrixDSym fCovCst; // Constraint
|
---|
| 32 | TMatrixDSym fCovCstInv; // Inverse of constraint covariance
|
---|
[127644a] | 33 | //
|
---|
| 34 | // Results
|
---|
[82db145] | 35 | Bool_t fVtxDone; // Flag vertex fit completed
|
---|
| 36 | Double_t fRold; // Current value of vertex radius
|
---|
[127644a] | 37 | TVectorD fXv; // Found vertex
|
---|
| 38 | TMatrixDSym fcovXv; // Vertex covariance
|
---|
| 39 | Double_t fChi2; // Vertex fit Chi2
|
---|
| 40 | TVectorD fChi2List; // List of Chi2 contributions
|
---|
| 41 | //
|
---|
[82db145] | 42 | // Work arrays
|
---|
| 43 | std::vector<Double_t> ffi; // Fit phases
|
---|
[53f4746] | 44 | std::vector<TVectorD*> fx0i; // Track expansion points
|
---|
[82db145] | 45 | std::vector<TVectorD*> fai; // dx/dphi
|
---|
[53f4746] | 46 | std::vector<TVectorD*> fdi; // x-shift
|
---|
[82db145] | 47 | std::vector<Double_t> fa2i; // a'Wa
|
---|
[53f4746] | 48 | std::vector<TMatrixD*> fAti; // A transposed
|
---|
[82db145] | 49 | std::vector<TMatrixDSym*> fDi; // W-WBW
|
---|
| 50 | std::vector<TMatrixDSym*> fWi; // (ACA')^-1
|
---|
| 51 | std::vector<TMatrixDSym*> fWinvi; // ACA'
|
---|
[127644a] | 52 | //
|
---|
| 53 | // Service routines
|
---|
[82db145] | 54 | //void InitWrkArrays(); // Initializations
|
---|
| 55 | void ResetWrkArrays(); // Clear work arrays
|
---|
| 56 | Double_t StartRadius(); // Starting vertex radius determination
|
---|
[127644a] | 57 | Double_t FastRv(TVectorD p1, TVectorD p2); // Fast vertex radius determination
|
---|
[82db145] | 58 | TMatrixDSym RegInv(TMatrixDSym& Smat0); // Regularized 3D matrix inversion
|
---|
| 59 | TMatrixD Fill_A(TVectorD par, Double_t phi); // Derivative of track position wrt track parameters
|
---|
| 60 | TVectorD Fill_a(TVectorD par, Double_t phi); // Derivative of track position wrt track phase
|
---|
[127644a] | 61 | TVectorD Fill_x0(TVectorD par); // Track position at dma to z-axis
|
---|
[82db145] | 62 | TVectorD Fill_x(TVectorD par, Double_t phi); // Track position at given phase
|
---|
| 63 | void UpdateTrkArrays(Int_t i); // Fill track realted arrays
|
---|
| 64 | void VertexFitter(); // Vertex finder routine
|
---|
[127644a] | 65 | public:
|
---|
| 66 | //
|
---|
| 67 | // Constructors
|
---|
| 68 | VertexFit(); // Initialize waiting for tracks
|
---|
[82db145] | 69 | VertexFit(Int_t Ntr, ObsTrk** tracks); // Initialize with ObsTrk tracks
|
---|
[127644a] | 70 | VertexFit(Int_t Ntr, TVectorD** trkPar, TMatrixDSym** trkCov); // Initialize with parameters and covariances
|
---|
| 71 | // Destructor
|
---|
| 72 | ~VertexFit();
|
---|
| 73 | //
|
---|
| 74 | // Accessors also trigger calculations when needed
|
---|
| 75 | Int_t GetNtrk() { return fNtr; };
|
---|
| 76 | TVectorD GetVtx();
|
---|
| 77 | TMatrixDSym GetVtxCov();
|
---|
| 78 | Double_t GetVtxChi2();
|
---|
| 79 | TVectorD GetVtxChi2List();
|
---|
| 80 | //
|
---|
| 81 | // Handle tracks/constraints
|
---|
| 82 | void AddVtxConstraint(TVectorD xv, TMatrixDSym cov); // Add gaussian vertex constraint
|
---|
[82db145] | 83 | void AddTrk(TVectorD *par, TMatrixDSym *Cov); // Add track to input list
|
---|
| 84 | void RemoveTrk(Int_t iTrk); // Remove iTrk track
|
---|
[127644a] | 85 | //
|
---|
| 86 | };
|
---|
| 87 |
|
---|
| 88 | #endif
|
---|