BOSS 7.0.3
BESIII Offline Software System
Loading...
Searching...
No Matches
InstallArea/include/VertexFit/VertexFit/KinematicFit.h
Go to the documentation of this file.
1#ifndef VertexFit_KinematicFit_H
2#define VertexFit_KinematicFit_H
3
4#include <vector>
5#include "VertexFit/WTrackParameter.h"
6#include "VertexFit/KinematicConstraints.h"
7#include "VertexFit/TrackPool.h"
8#include "VertexFit/GammaShape.h"
9
10class KinematicFit : public TrackPool{
11
12 public:
13
14 // constructor & destructor
15
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,
27 int n5);
28 void AddResonance(int number, double mres, int n1, int n2, int n3, int n4,
29 int n5, int n6);
30 void AddResonance(int number, double mres, int n1, int n2, int n3, int n4,
31 int n5, int n6, int n7);
32 void AddResonance(int number, double mres, int n1, int n2, int n3, int n4,
33 int n5, int n6, int n7, int n8);
34 void AddResonance(int number, double mres, int n1, int n2, int n3, int n4,
35 int n5, int n6, int n7, int n8, int n9);
36 void AddResonance(int number, double mres, int n1, int n2, int n3, int n4,
37 int n5, int n6, int n7, int n8, int n9,
38 int n10);
39 void AddResonance(int number, double mres, int n1, int n2, int n3, int n4,
40 int n5, int n6, int n7, int n8, int n9,
41 int n10, int n11);
42 void AddResonance(int number, double mres, int n1, int n2, int n3, int n4,
43 int n5, int n6, int n7, int n8, int n9,
44 int n10, int n11, int n12);
45 //
46 // Total Energy Constraints
47 //
48 void AddTotalEnergy(int number, double etot, std::vector<int> lis);
49 void AddTotalEnergy(int number, double etot, int n1);
50 void AddTotalEnergy(int number, double etot, int n1, int n2);
51 void AddTotalEnergy(int number, double etot, int n1, int n2, int n3);
52 void AddTotalEnergy(int number, double etot, int n1, int n2, int n3, int n4);
53 void AddTotalEnergy(int number, double etot, int n1, int n2, int n3, int n4,
54 int n5);
55 void AddTotalEnergy(int number, double etot, int n1, int n2, int n3, int n4,
56 int n5, int n6);
57 void AddTotalEnergy(int number, double etot, int n1, int n2, int n3, int n4,
58 int n5, int n6, int n7);
59 void AddTotalEnergy(int number, double etot, int n1, int n2, int n3, int n4,
60 int n5, int n6, int n7, int n8);
61 void AddTotalEnergy(int number, double etot, int n1, int n2, int n3, int n4,
62 int n5, int n6, int n7, int n8, int n9);
63 void AddTotalEnergy(int number, double etot, int n1, int n2, int n3, int n4,
64 int n5, int n6, int n7, int n8, int n9, int n10);
65 void AddTotalEnergy(int number, double etot, int n1, int n2, int n3, int n4,
66 int n5, int n6, int n7, int n8, int n9, int n10, int n11);
67 void AddTotalEnergy(int number, double etot, int n1, int n2, int n3, int n4,
68 int n5, int n6, int n7, int n8, int n9,
69 int n10, int n11, int n12);
70
71 //
72 // Total Momentum Constraints
73 //
74 void AddTotalMomentum(int number, double ptot, std::vector<int> lis);
75 void AddTotalMomentum(int number, double ptot, int n1);
76 void AddTotalMomentum(int number, double ptot, int n1, int n2);
77 void AddTotalMomentum(int number, double ptot, int n1, int n2, int n3);
78 void AddTotalMomentum(int number, double ptot, int n1, int n2, int n3, int n4);
79 void AddTotalMomentum(int number, double ptot, int n1, int n2, int n3, int n4,
80 int n5);
81 void AddTotalMomentum(int number, double ptot, int n1, int n2, int n3, int n4,
82 int n5, int n6);
83 void AddTotalMomentum(int number, double ptot, int n1, int n2, int n3, int n4,
84 int n5, int n6, int n7);
85 void AddTotalMomentum(int number, double ptot, int n1, int n2, int n3, int n4,
86 int n5, int n6, int n7, int n8);
87 void AddTotalMomentum(int number, double ptot, int n1, int n2, int n3, int n4,
88 int n5, int n6, int n7, int n8, int n9);
89 void AddTotalMomentum(int number, double ptot, int n1, int n2, int n3, int n4,
90 int n5, int n6, int n7, int n8, int n9,
91 int n10);
92 void AddTotalMomentum(int number, double ptot, int n1, int n2, int n3, int n4,
93 int n5, int n6, int n7, int n8, int n9,
94 int n10, int n11);
95 void AddTotalMomentum(int number, double ptot, int n1, int n2, int n3, int n4,
96 int n5, int n6, int n7, int n8, int n9,
97 int n10, int n11, int n12);
98 //
99 // Three Momentum Constraints
100 //
101 void AddThreeMomentum(int number, Hep3Vector p3);
102 //
103 // Four Momentum Constraints
104 //
105 void AddFourMomentum(int number, HepLorentzVector p4);
106 void AddFourMomentum(int number, double etot);
107
108 //
109 // Equal Mass Constraints
110 //
111
112 void AddEqualMass(int number, std::vector<int> tlis1, std::vector<int> tlis2);
113
114 //
115 // Position Constraints
116 //
117// void AddPosition(int number, HepPoint3D xorigin, std::vector<int> tlis_V);
118
119 //
120 // Build Virtual Particle
121 //
122 void BuildVirtualParticle(int number);
123
124 // initialization called before fit
125
126 void init();
127 //
128 // set iteration number and chisq cut
129 //
130 void setFlag(const bool flag = 1) {m_flag = flag;}
131 void setIterNumber(const int niter = 5) {m_niter = niter;}
132 void setChisqCut(const double chicut = 200, const double chiter=0.05) {m_chicut = chicut;m_chiter=chiter;}
133 //
134 // set error matrix parameters
135 //
136 void setKalman (const int kalman) {m_kalman = kalman;}
137 void setEspread (const double espread = 0.0009) {m_espread = espread;}
138 void setCollideangle (const double collideangle = 11e-3) {m_collideangle = collideangle;}
139 void setDynamicerror (const bool dynamicerror = 1) {m_dynamicerror = dynamicerror;}
140 //
141 // fit function
142 //
143 bool Fit();
144 bool Fit(int n);
145 //
146 // Fit Results
147 //
148 // chisq of fit
149 //
150 double chisq() const {return m_chi;}
151 double chisq(int n) const {return m_chisq[n];}
152 // updated WTrack parameter after kinematic fit
153 // HepLorentzVector pfit(int n) const {return wTrackInfit(n).p();}
154 HepLorentzVector pfit(int n) const {return p4Infit(n);}
155 // added by yanl 05.10.07
156 // HepLorentzVector pfit1(int n) const {return wTrackOrigin(n).p();}
157 HepLorentzVector pfit1(int n) const {return p4Origin(n);}
158
159
160 WTrackParameter origin(int n) const {return wTrackOrigin(n);}
161 WTrackParameter infit(int n) const {return wTrackInfit(n);}
162
163 HepVector pull(int n) ;
164 // error Matrix parameters
165 double espread() const {return m_espread;}
166 double collideangle() const {return m_collideangle;}
167 bool dynamicerror() const {return m_dynamicerror;}
168 // cpu time
169 HepVector cpu() const {return m_cpu;}
170
171 WTrackParameter wVirtualTrack(int n) const {return m_virtual_wtrk[n];}
172 private:
173 //bulid virtual particle
174 std::vector<WTrackParameter> m_virtual_wtrk;
175
176
177 void updateConstraints(KinematicConstraints kc);
178 void fits();
179 void fit();
180 // void covMatrix();
181 void upCovmtx();
182 void fit(int n);
183 void covMatrix(int n);
184 void gda();
185 private:
186 std::vector<KinematicConstraints> m_kc;
187 std::vector<double> m_chisq;
188 double m_chi;
189 // std::vector<HepMatrix> m_D;
190 // std::vector<HepMatrix> m_DT;
191 HepMatrix m_D;
192 HepMatrix D(int ic, int itk) const {return m_D.sub(ic+1, ic+1, itk*NTRKPAR+1, (itk+1)*NTRKPAR);}
193 void setD(int ic, int itk, const HepMatrix &p) {m_D.sub(ic+1, itk*NTRKPAR+1, p);}
194 HepMatrix m_DT;
195 HepMatrix DT(int itk, int ic) const {return m_DT.sub(itk*NTRKPAR+1, (itk+1)*NTRKPAR, ic+1, ic+1);}
196 void setDT(int itk, int ic, const HepMatrix &p) { m_DT.sub(itk*NTRKPAR+1, ic+1, p);}
197 HepVector m_d;
198 HepSymMatrix m_VD;
199 HepMatrix m_KP;
200 // HepVector m_lambda;
201 int m_nc;
202 int m_nktrk;
203 HepVector m_pOrigin;
204 HepVector m_pInfit;
205 HepSymMatrix m_covOrigin;
206 HepSymMatrix m_covInfit;
207 HepVector m_massvector; //add to save the mass of each particle
208 HepVector pOrigin(int i) const {return m_pOrigin.sub(i*NTRKPAR+1, (i+1)*NTRKPAR);}
209 HepLorentzVector p4Origin(int i) const { HepVector p(3, 0); p = pOrigin(i); double E = sqrt(p[0]*p[0] + p[1]*p[1] + p[2]*p[2] + origin(i).mass() * origin(i).mass());return HepLorentzVector(p[0], p[1], p[2], E);} //modified by yanl 2010.7.26 for changing the wtrackparameters
210 HepVector pInfit(int i) const {return m_pInfit.sub(i*NTRKPAR+1, (i+1)*NTRKPAR);}
211 HepLorentzVector p4Infit(int i) const { HepVector p(3, 0); p = pInfit(i); double E = sqrt(p[0]*p[0] + p[1]*p[1] + p[2]*p[2] + origin(i).mass() * origin(i).mass()); return HepLorentzVector(p[0], p[1], p[2], E); } //modified by yanl 2010.7.26 for changing the wtrackparameters
212 void setPOrigin(int i, const HepVector &p) { m_pOrigin.sub(i*NTRKPAR+1, p);}
213 void setPInfit(int i, const HepVector &p) {m_pInfit.sub(i*NTRKPAR+1, p);}
214 HepSymMatrix covOrigin(int i) const {return m_covOrigin.sub(i*NTRKPAR+1, (i+1)*NTRKPAR);}
215 HepSymMatrix covInfit(int i) const {return m_covInfit.sub(i*NTRKPAR+1, (i+1)*NTRKPAR);}
216 void setCovOrigin(int i, const HepSymMatrix &c) {m_covOrigin.sub(i*NTRKPAR+1, c);}
217 void setCovInfit(int i, const HepSymMatrix &c) {m_covInfit.sub(i*NTRKPAR+1,c);}
218 void setMassvector(int i, const double mass) {m_massvector[i] = mass;}
219 private:
220 KinematicFit();
221 static KinematicFit * m_pointer;
222 private:
223 int m_niter;
224 bool m_flag;
225 double m_chicut;
226 double m_chiter;
227 private:
228 int m_kalman;
229 double m_espread;
230 double m_collideangle;
231 private:
232 HepVector m_cpu;
233 private:
234 bool m_dynamicerror;
235 private:
236 static const int NTRKPAR;
237
238 static const int Resonance;
239 static const int TotalEnergy;
240 static const int TotalMomentum;
241 static const int ThreeMomentum;
242 static const int FourMomentum;
243 static const int EqualMass;
244 static const int Position;
245
246
247};
248#endif
double mass
const Int_t n
Double_t etot
const DifPoint origin
int n2
Definition: SD0Tag.cxx:55
int n1
Definition: SD0Tag.cxx:54
void BuildVirtualParticle(int number)
void AddTotalMomentum(int number, double ptot, int n1, int n2, int n3, int n4, int n5, int n6)
void AddTotalEnergy(int number, double etot, int n1)
void AddTotalMomentum(int number, double ptot, int n1, int n2, int n3, int n4, int n5, int n6, int n7, int n8)
void AddResonance(int number, double mres, std::vector< int > tlis)
void AddTotalMomentum(int number, double ptot, int n1, int n2)
void AddTotalEnergy(int number, double etot, int n1, int n2, int n3, int n4, int n5, int n6, int n7, int n8, int n9, int n10)
void AddTotalMomentum(int number, double ptot, int n1, int n2, int n3, int n4)
void AddTotalMomentum(int number, double ptot, int n1, int n2, int n3, int n4, int n5, int n6, int n7, int n8, int n9, int n10)
void setEspread(const double espread=0.0009)
void AddTotalEnergy(int number, double etot, int n1, int n2, int n3)
void AddEqualMass(int number, std::vector< int > tlis1, std::vector< int > tlis2)
void AddTotalMomentum(int number, double ptot, int n1, int n2, int n3, int n4, int n5, int n6, int n7, int n8, int n9, int n10, int n11)
void AddResonance(int number, double mres, int n1, int n2, int n3, int n4, int n5)
void AddTotalEnergy(int number, double etot, int n1, int n2, int n3, int n4, int n5, int n6, int n7, int n8, int n9, int n10, int n11)
void setChisqCut(const double chicut=200, const double chiter=0.05)
void AddResonance(int number, double mres, int n1, int n2, int n3, int n4, int n5, int n6, int n7)
void AddTotalEnergy(int number, double etot, int n1, int n2, int n3, int n4, int n5, int n6, int n7, int n8, int n9)
void AddTotalEnergy(int number, double etot, int n1, int n2, int n3, int n4)
void AddResonance(int number, double mres, int n1, int n2, int n3, int n4, int n5, int n6)
void setDynamicerror(const bool dynamicerror=1)
void AddTotalMomentum(int number, double ptot, int n1, int n2, int n3, int n4, int n5, int n6, int n7, int n8, int n9)
void AddTotalMomentum(int number, double ptot, int n1, int n2, int n3, int n4, int n5)
void AddTotalMomentum(int number, double ptot, int n1, int n2, int n3)
void AddTotalMomentum(int number, double ptot, int n1, int n2, int n3, int n4, int n5, int n6, int n7)
void AddTotalEnergy(int number, double etot, int n1, int n2, int n3, int n4, int n5, int n6)
static KinematicFit * instance()
void AddTotalMomentum(int number, double ptot, int n1, int n2, int n3, int n4, int n5, int n6, int n7, int n8, int n9, int n10, int n11, int n12)
void AddTotalMomentum(int number, double ptot, int n1)
void AddThreeMomentum(int number, Hep3Vector p3)
void AddResonance(int number, double mres, int n1, int n2, int n3, int n4, int n5, int n6, int n7, int n8, int n9, int n10)
void AddResonance(int number, double mres, int n1, int n2, int n3, int n4, int n5, int n6, int n7, int n8, int n9, int n10, int n11, int n12)
void AddResonance(int number, double mres, int n1, int n2, int n3, int n4, int n5, int n6, int n7, int n8)
void AddResonance(int number, double mres, int n1)
void AddFourMomentum(int number, HepLorentzVector p4)
void AddResonance(int number, double mres, int n1, int n2)
HepVector pull(int n)
bool Fit(int n)
void AddFourMomentum(int number, double etot)
void AddTotalEnergy(int number, double etot, int n1, int n2, int n3, int n4, int n5, int n6, int n7, int n8, int n9, int n10, int n11, int n12)
void AddResonance(int number, double mres, int n1, int n2, int n3)
void AddResonance(int number, double mres, int n1, int n2, int n3, int n4, int n5, int n6, int n7, int n8, int n9)
void setCollideangle(const double collideangle=11e-3)
void AddTotalEnergy(int number, double etot, int n1, int n2, int n3, int n4, int n5)
void AddResonance(int number, double mres, int n1, int n2, int n3, int n4, int n5, int n6, int n7, int n8, int n9, int n10, int n11)
void AddTotalEnergy(int number, double etot, int n1, int n2, int n3, int n4, int n5, int n6, int n7, int n8)
void AddResonance(int number, double mres, int n1, int n2, int n3, int n4)
void AddTotalEnergy(int number, double etot, std::vector< int > lis)
void AddTotalEnergy(int number, double etot, int n1, int n2)
void AddTotalMomentum(int number, double ptot, std::vector< int > lis)
void AddTotalEnergy(int number, double etot, int n1, int n2, int n3, int n4, int n5, int n6, int n7)
std::vector< WTrackParameter > wTrackInfit() const
std::vector< WTrackParameter > wTrackOrigin() const