BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
Analysis/VertexFit/include/VertexFit/KalmanKinematicFit.h
Go to the documentation of this file.
1#ifndef VertexFit_KalmanKinematicFit_H
2#define VertexFit_KalmanKinematicFit_H
3
4#include "TGraph2D.h"
5#include "VertexFit/GammaShape.h"
6#include "VertexFit/KinematicConstraints.h"
7#include "VertexFit/TrackPool.h"
8#include "VertexFit/WTrackParameter.h"
9#include <vector>
10
11class KalmanKinematicFit : public TrackPool {
12
13public:
14 // constructor & destructor
15
16 static KalmanKinematicFit* instance();
18 //
19 // Resonance Constraints
20 //
21 void AddResonance( int number, double mres, std::vector<int> tlis );
22 void AddResonance( int number, double mres, int n1 );
23 void AddResonance( int number, double mres, int n1, int n2 );
24 void AddResonance( int number, double mres, int n1, int n2, int n3 );
25 void AddResonance( int number, double mres, int n1, int n2, int n3, int n4 );
26 void AddResonance( int number, double mres, int n1, int n2, int n3, int n4, int n5 );
27 void AddResonance( int number, double mres, int n1, int n2, int n3, int n4, int n5, int n6 );
28 void AddResonance( int number, double mres, int n1, int n2, int n3, int n4, int n5, int n6,
29 int n7 );
30 void AddResonance( int number, double mres, int n1, int n2, int n3, int n4, int n5, int n6,
31 int n7, int n8 );
32 void AddResonance( int number, double mres, int n1, int n2, int n3, int n4, int n5, int n6,
33 int n7, int n8, int n9 );
34 void AddResonance( int number, double mres, int n1, int n2, int n3, int n4, int n5, int n6,
35 int n7, int n8, int n9, int n10 );
36 void AddResonance( int number, double mres, int n1, int n2, int n3, int n4, int n5, int n6,
37 int n7, int n8, int n9, int n10, int n11 );
38 void AddResonance( int number, double mres, int n1, int n2, int n3, int n4, int n5, int n6,
39 int n7, int n8, int n9, int n10, int n11, int n12 );
40 //
41 // Total Energy Constraints
42 //
43 void AddTotalEnergy( int number, double etot, std::vector<int> lis );
44 void AddTotalEnergy( int number, double etot, int n1 );
45 void AddTotalEnergy( int number, double etot, int n1, int n2 );
46 void AddTotalEnergy( int number, double etot, int n1, int n2, int n3 );
47 void AddTotalEnergy( int number, double etot, int n1, int n2, int n3, int n4 );
48 void AddTotalEnergy( int number, double etot, int n1, int n2, int n3, int n4, int n5 );
49 void AddTotalEnergy( int number, double etot, int n1, int n2, int n3, int n4, int n5,
50 int n6 );
51 void AddTotalEnergy( int number, double etot, int n1, int n2, int n3, int n4, int n5, int n6,
52 int n7 );
53 void AddTotalEnergy( int number, double etot, int n1, int n2, int n3, int n4, int n5, int n6,
54 int n7, int n8 );
55 void AddTotalEnergy( int number, double etot, int n1, int n2, int n3, int n4, int n5, int n6,
56 int n7, int n8, int n9 );
57 void AddTotalEnergy( int number, double etot, int n1, int n2, int n3, int n4, int n5, int n6,
58 int n7, int n8, int n9, int n10 );
59 void AddTotalEnergy( int number, double etot, int n1, int n2, int n3, int n4, int n5, int n6,
60 int n7, int n8, int n9, int n10, int n11 );
61 void AddTotalEnergy( int number, double etot, int n1, int n2, int n3, int n4, int n5, int n6,
62 int n7, int n8, int n9, int n10, int n11, int n12 );
63
64 //
65 // Total Momentum Constraints
66 //
67 void AddTotalMomentum( int number, double ptot, std::vector<int> lis );
68 void AddTotalMomentum( int number, double ptot, int n1 );
69 void AddTotalMomentum( int number, double ptot, int n1, int n2 );
70 void AddTotalMomentum( int number, double ptot, int n1, int n2, int n3 );
71 void AddTotalMomentum( int number, double ptot, int n1, int n2, int n3, int n4 );
72 void AddTotalMomentum( int number, double ptot, int n1, int n2, int n3, int n4, int n5 );
73 void AddTotalMomentum( int number, double ptot, int n1, int n2, int n3, int n4, int n5,
74 int n6 );
75 void AddTotalMomentum( int number, double ptot, int n1, int n2, int n3, int n4, int n5,
76 int n6, int n7 );
77 void AddTotalMomentum( int number, double ptot, int n1, int n2, int n3, int n4, int n5,
78 int n6, int n7, int n8 );
79 void AddTotalMomentum( int number, double ptot, int n1, int n2, int n3, int n4, int n5,
80 int n6, int n7, int n8, int n9 );
81 void AddTotalMomentum( int number, double ptot, int n1, int n2, int n3, int n4, int n5,
82 int n6, int n7, int n8, int n9, int n10 );
83 void AddTotalMomentum( int number, double ptot, int n1, int n2, int n3, int n4, int n5,
84 int n6, int n7, int n8, int n9, int n10, int n11 );
85 void AddTotalMomentum( int number, double ptot, int n1, int n2, int n3, int n4, int n5,
86 int n6, int n7, int n8, int n9, int n10, int n11, int n12 );
87 //
88 // Three Momentum Constraints
89 //
90 void AddThreeMomentum( int number, Hep3Vector p3 );
91 //
92 // Four Momentum Constraints
93 //
94 void AddFourMomentum( int number, HepLorentzVector p4 );
95 void AddFourMomentum( int number, double etot );
96
97 //
98 // Equal Mass Constraints
99 //
100
101 void AddEqualMass( int number, std::vector<int> tlis1, std::vector<int> tlis2 );
102
103 //
104 // Position Constraints
105 //
106 // void AddPosition(int number, HepPoint3D Xbeam, HepSymMatrix Vbeam,std::vector<int>
107 // tlis_V);
108
109 //
110 // Build Virtual Particle
111 //
112 void BuildVirtualParticle( int number );
113
114 // initialization called before fit
115
116 void init();
117 //
118 // set iteration number and chisq cut
119 //
120 void setFlag( const bool flag = 1 ) { m_flag = flag; }
121 void setIterNumber( const int niter = 5 ) { m_niter = niter; }
122 void setChisqCut( const double chicut = 200, const double chiter = 0.05 ) {
123 m_chicut = chicut;
124 m_chiter = chiter;
125 }
126 //
127 // set error matrix parameters
128 //
129 void setEspread( const double espread = 0.0009 ) { m_espread = espread; }
130 void setCollideangle( const double collideangle = 11e-3 ) { m_collideangle = collideangle; }
131 void setDynamicerror( const bool dynamicerror = 1 ) { m_dynamicerror = dynamicerror; }
132 void setTgraph( TGraph2D* graph2d ) { m_graph2d = graph2d; }
133 //
134 // fit function
135 //
136 bool Fit();
137 bool Fit( int n );
138 //
139 // Fit Results
140 //
141 // chisq of fit
142 //
143 double chisq() const { return m_chi; }
144 double chisq( int n ) const { return m_chisq[n]; }
145 // updated WTrack parameter after kinematic fit
146 // HepLorentzVector pfit(int n) const {return wTrackInfit(n).p();}
147 HepLorentzVector pfit( int n ) const { return p4Infit( n ); }
148 // added by yanl 05.10.07
149 // HepLorentzVector pfit1(int n) const {return wTrackOrigin(n).p();}
150 HepLorentzVector pfit1( int n ) { return p4Origin( n ); }
151 HepVector xfit() { return m_q.sub( 1, 3 ); }
152
153 WTrackParameter origin( int n ) const { return wTrackOrigin( n ); }
154 WTrackParameter infit( int n ) const { return wTrackInfit( n ); }
155
156 HepVector pull( int n );
157 // WTrackParameter wVirtualTrack(int n) const {return m_virtual_wtrk[n];}
158 // error Matrix parameters
159 double espread() const { return m_espread; }
160 double collideangle() const { return m_collideangle; }
161 bool dynamicerror() const { return m_dynamicerror; }
162 // cpu time
163 HepVector cpu() const { return m_cpu; }
164 HepSymMatrix getCOrigin( int i ) const;
165 HepSymMatrix getCInfit( int i ) const;
166
167 WTrackParameter wVirtualTrack( int n ) const { return m_virtual_wtrk[n]; }
168
169private:
170 // bulid virtual particle
171 std::vector<WTrackParameter> m_virtual_wtrk;
172
173private:
174 void updateConstraints( KinematicConstraints kc );
175 void fit();
176 // void covMatrix();
177 void upCovmtx();
178 void upTrkpar();
179 void clearDDT();
180 void fit( int n );
181 void covMatrix( int n );
182 void gda();
183
184private:
185 std::vector<KinematicConstraints> m_kc;
186 std::vector<double> m_chisq;
187 double m_chi;
188 HepSymMatrix m_Vm;
189 HepMatrix m_A;
190 void setA( int ic, int itk, const HepMatrix& p ) { m_A.sub( ic + 1, itk, p ); }
191 HepMatrix m_AT;
192 void setAT( int itk, int ic, const HepMatrix& p ) { m_AT.sub( itk, ic + 1, p ); }
193 HepVector m_G;
194 HepSymMatrix m_W;
195 HepMatrix m_KP;
196
197 // virtual particle
198 HepMatrix m_B;
199 void setB( int ic, int itk, const HepMatrix& p ) { m_B.sub( ic + 1, itk, p ); }
200 HepMatrix m_BT;
201 void setBT( int itk, int ic, const HepMatrix& p ) { m_BT.sub( itk, ic + 1, p ); }
202
203 HepMatrix m_KQ;
204 int m_nc;
205 int m_nktrk;
206
207 HepVector m_p0;
208 HepVector m_p;
209 HepSymMatrix m_C0;
210 HepSymMatrix m_C;
211 HepVector pOrigin( int i ) const;
212 HepLorentzVector p4Origin( int i ) const {
213 HepVector p( 4, 0 );
214 p = pOrigin( i );
215 return HepLorentzVector( p[0], p[1], p[2], p[3] );
216 }
217 HepVector pInfit( int i ) const;
218 HepLorentzVector p4Infit( int i ) const {
219 HepVector p( 4, 0 );
220 p = pInfit( i );
221 return HepLorentzVector( p[0], p[1], p[2], p[3] );
222 }
223
224 void setPOrigin( int i, const HepVector& p ) { m_p0.sub( i, p ); }
225 void setPInfit( int i, const HepVector& p ) { m_p.sub( i, p ); }
226 void setCOrigin( int i, const HepSymMatrix& D ) { m_C0.sub( i, D ); }
227 void setCInfit( int i, const HepSymMatrix& D ) { m_C.sub( i, D ); }
228
229 HepVector m_q0;
230 HepVector m_q;
231 HepSymMatrix m_D0;
232 HepSymMatrix m_D;
233 HepSymMatrix m_D0inv;
234 HepSymMatrix m_Dinv;
235
236 void setQOrigin( int i, const HepVector& q ) { m_q0.sub( i, q ); }
237 void setQInfit( int i, const HepVector& q ) { m_q.sub( i, q ); }
238 void setDOrigin( int i, const HepSymMatrix& D ) { m_D0.sub( i, D ); }
239 void setDInfit( int i, const HepSymMatrix& D ) { m_D.sub( i, D ); }
240 void setDOriginInv( int i, const HepSymMatrix& Dinv ) { m_D0inv.sub( i, Dinv ); }
241
242private:
243 KalmanKinematicFit();
244 static KalmanKinematicFit* m_pointer;
245
246private:
247 int m_niter;
248 bool m_flag;
249 double m_chicut;
250 double m_chiter;
251
252private:
253 double m_espread;
254 double m_collideangle;
255
256private:
257 HepVector m_cpu;
258
259private:
260 bool m_dynamicerror;
261
262private:
263 static const int NTRKPAR;
264 static const int NKFPAR;
265 static const int Resonance;
266 static const int TotalEnergy;
267 static const int TotalMomentum;
268 static const int ThreeMomentum;
269 static const int FourMomentum;
270 static const int EqualMass;
271 static const int Position;
272
273private:
274 TGraph2D* m_graph2d;
275};
276#endif
const Int_t n
Double_t etot
****INTEGER imax DOUBLE PRECISION m_pi *DOUBLE PRECISION m_amfin DOUBLE PRECISION m_Chfin DOUBLE PRECISION m_Xenph DOUBLE PRECISION m_sinw2 DOUBLE PRECISION m_GFermi DOUBLE PRECISION m_MfinMin DOUBLE PRECISION m_ta2 INTEGER m_out INTEGER m_KeyFSR INTEGER m_KeyQCD *COMMON c_Semalib $ !copy of input $ !CMS energy $ !beam mass $ !final mass $ !beam charge $ !final charge $ !smallest final mass $ !Z mass $ !Z width $ !EW mixing angle $ !Gmu Fermi $ alphaQED at q
Definition KKsem.h:33
int n2
Definition SD0Tag.cxx:59
int n1
Definition SD0Tag.cxx:58
void AddTotalEnergy(int number, double etot, std::vector< int > lis)
void AddFourMomentum(int number, HepLorentzVector p4)
void setChisqCut(const double chicut=200, const double chiter=0.05)
void AddThreeMomentum(int number, Hep3Vector p3)
void setCollideangle(const double collideangle=11e-3)
void BuildVirtualParticle(int number)
HepSymMatrix getCInfit(int i) const
void AddResonance(int number, double mres, std::vector< int > tlis)
void AddTotalMomentum(int number, double ptot, std::vector< int > lis)
HepSymMatrix getCOrigin(int i) const
static KalmanKinematicFit * instance()
void AddEqualMass(int number, std::vector< int > tlis1, std::vector< int > tlis2)
std::vector< WTrackParameter > wTrackInfit() const
std::vector< WTrackParameter > wTrackOrigin() const